Changes in kernel/arch/sparc64/src/drivers/kbd.c [336d2f52:d99c1d2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/drivers/kbd.c
r336d2f52 rd99c1d2 35 35 #include <arch/drivers/kbd.h> 36 36 #include <genarch/ofw/ofw_tree.h> 37 #include <genarch/ofw/fhc.h> 37 38 #include <genarch/ofw/ebus.h> 38 39 #include <console/console.h> … … 50 51 #endif 51 52 53 #ifdef CONFIG_Z8530 54 #include <genarch/drivers/z8530/z8530.h> 55 #endif 56 52 57 #ifdef CONFIG_NS16550 53 58 #include <genarch/drivers/ns16550/ns16550.h> … … 55 60 56 61 #ifdef CONFIG_SUN_KBD 62 63 #ifdef CONFIG_Z8530 64 65 static bool kbd_z8530_init(ofw_tree_node_t *node) 66 { 67 const char *name = ofw_tree_node_name(node); 68 69 if (str_cmp(name, "zs") != 0) 70 return false; 71 72 /* 73 * Read 'interrupts' property. 74 */ 75 ofw_tree_property_t *prop = ofw_tree_getprop(node, "interrupts"); 76 if ((!prop) || (!prop->value)) { 77 printf("z8530: Unable to find interrupts property\n"); 78 return false; 79 } 80 81 uint32_t interrupts = *((uint32_t *) prop->value); 82 83 /* 84 * Read 'reg' property. 85 */ 86 prop = ofw_tree_getprop(node, "reg"); 87 if ((!prop) || (!prop->value)) { 88 printf("z8530: Unable to find reg property\n"); 89 return false; 90 } 91 92 size_t size = ((ofw_fhc_reg_t *) prop->value)->size; 93 94 uintptr_t pa; 95 if (!ofw_fhc_apply_ranges(node->parent, 96 ((ofw_fhc_reg_t *) prop->value), &pa)) { 97 printf("z8530: Failed to determine address\n"); 98 return false; 99 } 100 101 inr_t inr; 102 cir_t cir; 103 void *cir_arg; 104 if (!ofw_fhc_map_interrupt(node->parent, 105 ((ofw_fhc_reg_t *) prop->value), interrupts, &inr, &cir, 106 &cir_arg)) { 107 printf("z8530: Failed to determine interrupt\n"); 108 return false; 109 } 110 111 /* 112 * We need to pass aligned address to hw_map(). 113 * However, the physical keyboard address can 114 * be pretty much unaligned, depending on the 115 * underlying controller. 116 */ 117 uintptr_t aligned_addr = ALIGN_DOWN(pa, PAGE_SIZE); 118 size_t offset = pa - aligned_addr; 119 120 z8530_t *z8530 = (z8530_t *) 121 (hw_map(aligned_addr, offset + size) + offset); 122 123 z8530_instance_t *z8530_instance = z8530_init(z8530, inr, cir, cir_arg); 124 if (z8530_instance) { 125 kbrd_instance_t *kbrd_instance = kbrd_init(); 126 if (kbrd_instance) { 127 indev_t *sink = stdin_wire(); 128 indev_t *kbrd = kbrd_wire(kbrd_instance, sink); 129 z8530_wire(z8530_instance, kbrd); 130 } 131 } 132 133 /* 134 * This is the necessary evil until the userspace drivers are 135 * entirely self-sufficient. 136 */ 137 sysinfo_set_item_val("kbd", NULL, true); 138 sysinfo_set_item_val("kbd.inr", NULL, inr); 139 sysinfo_set_item_val("kbd.address.kernel", NULL, 140 (uintptr_t) z8530); 141 sysinfo_set_item_val("kbd.address.physical", NULL, pa); 142 sysinfo_set_item_val("kbd.type.z8530", NULL, true); 143 144 return true; 145 } 146 147 #endif /* CONFIG_Z8530 */ 57 148 58 149 #ifdef CONFIG_NS16550 … … 152 243 void kbd_init(ofw_tree_node_t *node) 153 244 { 245 #ifdef CONFIG_Z8530 246 kbd_z8530_init(node); 247 #endif 248 154 249 #ifdef CONFIG_NS16550 155 250 kbd_ns16550_init(node);
Note:
See TracChangeset
for help on using the changeset viewer.