Rev 4055 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4055 | Rev 4156 | ||
---|---|---|---|
Line 44... | Line 44... | ||
44 | #ifdef CONFIG_NS16550 |
44 | #ifdef CONFIG_NS16550 |
45 | #include <genarch/drivers/ns16550/ns16550.h> |
45 | #include <genarch/drivers/ns16550/ns16550.h> |
46 | #endif |
46 | #endif |
47 | 47 | ||
48 | #include <console/console.h> |
48 | #include <console/console.h> |
49 | #include <ddi/device.h> |
- | |
50 | #include <ddi/irq.h> |
49 | #include <ddi/irq.h> |
51 | #include <arch/mm/page.h> |
50 | #include <arch/mm/page.h> |
52 | #include <arch/types.h> |
51 | #include <arch/types.h> |
53 | #include <align.h> |
52 | #include <align.h> |
54 | #include <string.h> |
53 | #include <string.h> |
55 | #include <print.h> |
54 | #include <print.h> |
56 | #include <sysinfo/sysinfo.h> |
55 | #include <sysinfo/sysinfo.h> |
57 | 56 | ||
58 | kbd_type_t kbd_type = KBD_UNKNOWN; |
57 | kbd_type_t kbd_type = KBD_UNKNOWN; |
59 | 58 | ||
- | 59 | #ifdef CONFIG_SUN_KBD |
|
- | 60 | ||
60 | /** Initialize keyboard. |
61 | /** Initialize keyboard. |
61 | * |
62 | * |
62 | * Traverse OpenFirmware device tree in order to find necessary |
63 | * Traverse OpenFirmware device tree in order to find necessary |
63 | * info about the keyboard device. |
64 | * info about the keyboard device. |
64 | * |
65 | * |
Line 111... | Line 112... | ||
111 | if ((!prop) || (!prop->value)) |
112 | if ((!prop) || (!prop->value)) |
112 | panic("Cannot find 'reg' property."); |
113 | panic("Cannot find 'reg' property."); |
113 | 114 | ||
114 | uintptr_t pa; |
115 | uintptr_t pa; |
115 | size_t size; |
116 | size_t size; |
116 | devno_t devno; |
- | |
117 | inr_t inr; |
117 | inr_t inr; |
118 | 118 | ||
119 | switch (kbd_type) { |
119 | switch (kbd_type) { |
120 | case KBD_Z8530: |
120 | case KBD_Z8530: |
121 | size = ((ofw_fhc_reg_t *) prop->value)->size; |
121 | size = ((ofw_fhc_reg_t *) prop->value)->size; |
Line 160... | Line 160... | ||
160 | offset = pa - aligned_addr; |
160 | offset = pa - aligned_addr; |
161 | 161 | ||
162 | switch (kbd_type) { |
162 | switch (kbd_type) { |
163 | #ifdef CONFIG_Z8530 |
163 | #ifdef CONFIG_Z8530 |
164 | case KBD_Z8530: |
164 | case KBD_Z8530: |
165 | devno = device_assign_devno(); |
- | |
166 | z8530 = (z8530_t *) hw_map(aligned_addr, offset + size) + |
165 | z8530 = (z8530_t *) hw_map(aligned_addr, offset + size) + |
167 | offset; |
166 | offset; |
- | 167 | ||
- | 168 | indev_t *kbrdin_z8530 = z8530_init(z8530, inr, cir, cir_arg); |
|
168 | kbrd_init(stdin); |
169 | if (kbrdin_z8530) |
169 | (void) z8530_init(z8530, devno, inr, cir, cir_arg, &kbrdin); |
170 | kbrd_init(kbrdin_z8530); |
170 | 171 | ||
171 | /* |
172 | /* |
172 | * This is the necessary evil until the userspace drivers are |
173 | * This is the necessary evil until the userspace drivers are |
173 | * entirely self-sufficient. |
174 | * entirely self-sufficient. |
174 | */ |
175 | */ |
175 | sysinfo_set_item_val("kbd", NULL, true); |
176 | sysinfo_set_item_val("kbd", NULL, true); |
176 | sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530); |
177 | sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530); |
177 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
- | |
178 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
178 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
179 | sysinfo_set_item_val("kbd.address.kernel", NULL, |
179 | sysinfo_set_item_val("kbd.address.kernel", NULL, |
180 | (uintptr_t) z8530); |
180 | (uintptr_t) z8530); |
181 | sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
181 | sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
182 | break; |
182 | break; |
183 | #endif |
183 | #endif |
184 | #ifdef CONFIG_NS16550 |
184 | #ifdef CONFIG_NS16550 |
185 | case KBD_NS16550: |
185 | case KBD_NS16550: |
186 | devno = device_assign_devno(); |
- | |
187 | ns16550 = (ns16550_t *) hw_map(aligned_addr, offset + size) + |
186 | ns16550 = (ns16550_t *) hw_map(aligned_addr, offset + size) + |
188 | offset; |
187 | offset; |
- | 188 | ||
- | 189 | indev_t *kbrdin_ns16550 = ns16550_init(ns16550, inr, cir, cir_arg); |
|
189 | kbrd_init(stdin); |
190 | if (kbrdin_ns16550) |
190 | (void) ns16550_init(ns16550, devno, inr, cir, cir_arg, &kbrdin); |
191 | kbrd_init(kbrdin_ns16550); |
191 | 192 | ||
192 | /* |
193 | /* |
193 | * This is the necessary evil until the userspace driver is |
194 | * This is the necessary evil until the userspace driver is |
194 | * entirely self-sufficient. |
195 | * entirely self-sufficient. |
195 | */ |
196 | */ |
196 | sysinfo_set_item_val("kbd", NULL, true); |
197 | sysinfo_set_item_val("kbd", NULL, true); |
197 | sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); |
198 | sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550); |
198 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
- | |
199 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
199 | sysinfo_set_item_val("kbd.inr", NULL, inr); |
200 | sysinfo_set_item_val("kbd.address.kernel", NULL, |
200 | sysinfo_set_item_val("kbd.address.kernel", NULL, |
201 | (uintptr_t) ns16550); |
201 | (uintptr_t) ns16550); |
202 | sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
202 | sysinfo_set_item_val("kbd.address.physical", NULL, pa); |
203 | break; |
203 | break; |
Line 206... | Line 206... | ||
206 | printf("Kernel is not compiled with the necessary keyboard " |
206 | printf("Kernel is not compiled with the necessary keyboard " |
207 | "driver this machine requires.\n"); |
207 | "driver this machine requires.\n"); |
208 | } |
208 | } |
209 | } |
209 | } |
210 | 210 | ||
- | 211 | #endif |
|
- | 212 | ||
211 | /** @} |
213 | /** @} |
212 | */ |
214 | */ |