Subversion Repositories HelenOS

Rev

Rev 4346 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4346 Rev 4347
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>
Line 72... Line 71...
72
    uintptr_t aligned_addr;
71
    uintptr_t aligned_addr;
73
    ofw_tree_property_t *prop;
72
    ofw_tree_property_t *prop;
74
    const char *name;
73
    const char *name;
75
    cir_t cir;
74
    cir_t cir;
76
    void *cir_arg;
75
    void *cir_arg;
77
 
76
   
78
#ifdef CONFIG_NS16550
77
#ifdef CONFIG_NS16550
79
    ns16550_t *ns16550;
78
    ns16550_t *ns16550;
80
#endif
79
#endif
81
#ifdef CONFIG_Z8530
80
#ifdef CONFIG_Z8530
82
    z8530_t *z8530;
81
    z8530_t *z8530;
Line 113... Line 112...
113
    if ((!prop) || (!prop->value))
112
    if ((!prop) || (!prop->value))
114
        panic("Cannot find 'reg' property.");
113
        panic("Cannot find 'reg' property.");
115
   
114
   
116
    uintptr_t pa;
115
    uintptr_t pa;
117
    size_t size;
116
    size_t size;
118
    devno_t devno;
-
 
119
    inr_t inr;
117
    inr_t inr;
120
   
118
   
121
    switch (kbd_type) {
119
    switch (kbd_type) {
122
    case KBD_Z8530:
120
    case KBD_Z8530:
123
        size = ((ofw_fhc_reg_t *) prop->value)->size;
121
        size = ((ofw_fhc_reg_t *) prop->value)->size;
Line 162... Line 160...
162
    offset = pa - aligned_addr;
160
    offset = pa - aligned_addr;
163
   
161
   
164
    switch (kbd_type) {
162
    switch (kbd_type) {
165
#ifdef CONFIG_Z8530
163
#ifdef CONFIG_Z8530
166
    case KBD_Z8530:
164
    case KBD_Z8530:
167
        devno = device_assign_devno();
-
 
168
        z8530 = (z8530_t *) hw_map(aligned_addr, offset + size) +
165
        z8530 = (z8530_t *) hw_map(aligned_addr, offset + size) +
169
            offset;
166
            offset;
170
       
167
       
171
        indev_t *kbrdin_z8530 = z8530_init(z8530, devno, inr, cir, cir_arg);
168
        indev_t *kbrdin_z8530 = z8530_init(z8530, inr, cir, cir_arg);
172
        if (kbrdin_z8530)
169
        if (kbrdin_z8530)
173
            kbrd_init(kbrdin_z8530);
170
            kbrd_init(kbrdin_z8530);
174
       
171
       
175
        /*
172
        /*
176
         * This is the necessary evil until the userspace drivers are
173
         * This is the necessary evil until the userspace drivers are
177
         * entirely self-sufficient.
174
         * entirely self-sufficient.
178
         */
175
         */
179
        sysinfo_set_item_val("kbd", NULL, true);
176
        sysinfo_set_item_val("kbd", NULL, true);
180
        sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530);
177
        sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530);
181
        sysinfo_set_item_val("kbd.devno", NULL, devno);
-
 
182
        sysinfo_set_item_val("kbd.inr", NULL, inr);
178
        sysinfo_set_item_val("kbd.inr", NULL, inr);
183
        sysinfo_set_item_val("kbd.address.kernel", NULL,
179
        sysinfo_set_item_val("kbd.address.kernel", NULL,
184
            (uintptr_t) z8530);
180
            (uintptr_t) z8530);
185
        sysinfo_set_item_val("kbd.address.physical", NULL, pa);
181
        sysinfo_set_item_val("kbd.address.physical", NULL, pa);
186
        break;
182
        break;
187
#endif
183
#endif
188
#ifdef CONFIG_NS16550
184
#ifdef CONFIG_NS16550
189
    case KBD_NS16550:
185
    case KBD_NS16550:
190
        devno = device_assign_devno();
-
 
191
        ns16550 = (ns16550_t *) hw_map(aligned_addr, offset + size) +
186
        ns16550 = (ns16550_t *) hw_map(aligned_addr, offset + size) +
192
            offset;
187
            offset;
193
       
188
       
194
        indev_t *kbrdin_ns16550 = ns16550_init(ns16550, devno, inr, cir, cir_arg);
189
        indev_t *kbrdin_ns16550 = ns16550_init(ns16550, inr, cir, cir_arg);
195
        if (kbrdin_ns16550)
190
        if (kbrdin_ns16550)
196
            kbrd_init(kbrdin_ns16550);
191
            kbrd_init(kbrdin_ns16550);
197
       
192
       
198
        /*
193
        /*
199
         * This is the necessary evil until the userspace driver is
194
         * This is the necessary evil until the userspace driver is
200
         * entirely self-sufficient.
195
         * entirely self-sufficient.
201
         */
196
         */
202
        sysinfo_set_item_val("kbd", NULL, true);
197
        sysinfo_set_item_val("kbd", NULL, true);
203
        sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550);
198
        sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550);
204
        sysinfo_set_item_val("kbd.devno", NULL, devno);
-
 
205
        sysinfo_set_item_val("kbd.inr", NULL, inr);
199
        sysinfo_set_item_val("kbd.inr", NULL, inr);
206
        sysinfo_set_item_val("kbd.address.kernel", NULL,
200
        sysinfo_set_item_val("kbd.address.kernel", NULL,
207
            (uintptr_t) ns16550);
201
            (uintptr_t) ns16550);
208
        sysinfo_set_item_val("kbd.address.physical", NULL, pa);
202
        sysinfo_set_item_val("kbd.address.physical", NULL, pa);
209
        break;
203
        break;