Deleted Added
full compact
atkbd_atkbdc.c (80040) atkbd_atkbdc.c (83147)
1/*-
2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/atkbdc/atkbd_atkbdc.c 80040 2001-07-20 13:05:57Z yokota $
26 * $FreeBSD: head/sys/dev/atkbdc/atkbd_atkbdc.c 83147 2001-09-06 12:09:26Z yokota $
27 */
28
29#include "opt_kbd.h"
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/kernel.h>
34#include <sys/bus.h>

--- 12 unchanged lines hidden (view full) ---

47
48typedef struct {
49 struct resource *intr;
50 void *ih;
51} atkbd_softc_t;
52
53devclass_t atkbd_devclass;
54
27 */
28
29#include "opt_kbd.h"
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/kernel.h>
34#include <sys/bus.h>

--- 12 unchanged lines hidden (view full) ---

47
48typedef struct {
49 struct resource *intr;
50 void *ih;
51} atkbd_softc_t;
52
53devclass_t atkbd_devclass;
54
55static void atkbdidentify(driver_t *driver, device_t dev);
55static int atkbdprobe(device_t dev);
56static int atkbdattach(device_t dev);
57static int atkbdresume(device_t dev);
58static void atkbd_isa_intr(void *arg);
59
60static device_method_t atkbd_methods[] = {
56static int atkbdprobe(device_t dev);
57static int atkbdattach(device_t dev);
58static int atkbdresume(device_t dev);
59static void atkbd_isa_intr(void *arg);
60
61static device_method_t atkbd_methods[] = {
62 DEVMETHOD(device_identify, atkbdidentify),
61 DEVMETHOD(device_probe, atkbdprobe),
62 DEVMETHOD(device_attach, atkbdattach),
63 DEVMETHOD(device_resume, atkbdresume),
64 { 0, 0 }
65};
66
67static driver_t atkbd_driver = {
68 ATKBD_DRIVER_NAME,
69 atkbd_methods,
70 sizeof(atkbd_softc_t),
71};
72
63 DEVMETHOD(device_probe, atkbdprobe),
64 DEVMETHOD(device_attach, atkbdattach),
65 DEVMETHOD(device_resume, atkbdresume),
66 { 0, 0 }
67};
68
69static driver_t atkbd_driver = {
70 ATKBD_DRIVER_NAME,
71 atkbd_methods,
72 sizeof(atkbd_softc_t),
73};
74
75static void
76atkbdidentify(driver_t *driver, device_t parent)
77{
78
79 /* always add at least one child */
80 BUS_ADD_CHILD(parent, KBDC_RID_KBD, driver->name, 0);
81}
82
73static int
74atkbdprobe(device_t dev)
75{
83static int
84atkbdprobe(device_t dev)
85{
76 uintptr_t irq;
77 uintptr_t flags;
86 struct resource *res;
87 u_long irq;
88 int flags;
89 int rid;
78
79 device_set_desc(dev, "AT Keyboard");
80
81 /* obtain parameters */
90
91 device_set_desc(dev, "AT Keyboard");
92
93 /* obtain parameters */
82 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
83 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
94 flags = device_get_flags(dev);
84
95
96 /* see if IRQ is available */
97 rid = KBDC_RID_KBD;
98 res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
99 RF_SHAREABLE | RF_ACTIVE);
100 if (res == NULL) {
101 if (bootverbose)
102 device_printf(dev, "unable to allocate IRQ\n");
103 return ENXIO;
104 }
105 irq = rman_get_start(res);
106 bus_release_resource(dev, SYS_RES_IRQ, rid, res);
107
85 /* probe the device */
86 return atkbd_probe_unit(device_get_unit(dev),
87 device_get_unit(device_get_parent(dev)),
88 irq, flags);
89}
90
91static int
92atkbdattach(device_t dev)
93{
94 atkbd_softc_t *sc;
95 keyboard_t *kbd;
108 /* probe the device */
109 return atkbd_probe_unit(device_get_unit(dev),
110 device_get_unit(device_get_parent(dev)),
111 irq, flags);
112}
113
114static int
115atkbdattach(device_t dev)
116{
117 atkbd_softc_t *sc;
118 keyboard_t *kbd;
96 uintptr_t irq;
97 uintptr_t flags;
119 u_long irq;
120 int flags;
98 int rid;
99 int error;
100
101 sc = device_get_softc(dev);
102
121 int rid;
122 int error;
123
124 sc = device_get_softc(dev);
125
103 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
104 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
105
126 rid = KBDC_RID_KBD;
127 irq = bus_get_resource_start(dev, SYS_RES_IRQ, rid);
128 flags = device_get_flags(dev);
106 error = atkbd_attach_unit(device_get_unit(dev), &kbd,
107 device_get_unit(device_get_parent(dev)),
108 irq, flags);
109 if (error)
110 return error;
111
112 /* declare our interrupt handler */
129 error = atkbd_attach_unit(device_get_unit(dev), &kbd,
130 device_get_unit(device_get_parent(dev)),
131 irq, flags);
132 if (error)
133 return error;
134
135 /* declare our interrupt handler */
113 rid = 0;
114 sc->intr = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq, irq, 1,
136 sc->intr = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
115 RF_SHAREABLE | RF_ACTIVE);
137 RF_SHAREABLE | RF_ACTIVE);
116 BUS_SETUP_INTR(device_get_parent(dev), dev, sc->intr, INTR_TYPE_TTY,
117 atkbd_isa_intr, kbd, &sc->ih);
138 if (sc->intr == NULL)
139 return ENXIO;
140 error = bus_setup_intr(dev, sc->intr, INTR_TYPE_TTY, atkbd_isa_intr,
141 kbd, &sc->ih);
142 if (error)
143 bus_release_resource(dev, SYS_RES_IRQ, rid, sc->intr);
118
144
119 return 0;
145 return error;
120}
121
122static int
123atkbdresume(device_t dev)
124{
125 keyboard_t *kbd;
126
127 kbd = kbd_get_keyboard(kbd_find_keyboard(ATKBD_DRIVER_NAME,

--- 16 unchanged lines hidden ---
146}
147
148static int
149atkbdresume(device_t dev)
150{
151 keyboard_t *kbd;
152
153 kbd = kbd_get_keyboard(kbd_find_keyboard(ATKBD_DRIVER_NAME,

--- 16 unchanged lines hidden ---