Deleted Added
sdiff udiff text old ( 57481 ) new ( 58271 )
full compact
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/atkbdc_isa.c 57481 2000-02-25 11:40:31Z 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>
35#include <sys/malloc.h>
36#include <machine/bus.h>
37#include <machine/resource.h>
38#include <sys/rman.h>
39
40#include <dev/kbd/atkbdcreg.h>
41
42#include <isa/isareg.h>
43#include <isa/isavar.h>

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

82};
83
84static driver_t atkbdc_driver = {
85 ATKBDC_DRIVER_NAME,
86 atkbdc_methods,
87 sizeof(atkbdc_softc_t *),
88};
89
90static int
91atkbdc_probe(device_t dev)
92{
93 int error;
94 int rid;
95 struct resource *port;
96
97 /* Check isapnp ids */
98 if (isa_get_vendorid(dev))
99 return (ENXIO);
100
101 device_set_desc(dev, "keyboard controller (i8042)");
102 rid = 0;
103 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
104 0, ~0, IO_KBDSIZE, RF_ACTIVE);
105 if (!port)
106 return ENXIO;
107 error = atkbdc_probe_unit(device_get_unit(dev), rman_get_start(port));
108 bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
109 return error;
110}
111
112static void
113atkbdc_add_device(device_t dev, const char *name, int unit)
114{
115 atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
116 atkbdc_device_t *kdev;
117 device_t child;
118 int t;
119
120 if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0)
121 return;
122
123 kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
124 if (!kdev)
125 return;
126 bzero(kdev, sizeof *kdev);
127
128 kdev->port = sc->port;
129
130 if (resource_int_value(name, unit, "irq", &t) == 0)
131 kdev->irq = t;
132 else
133 kdev->irq = -1;
134
135 if (resource_int_value(name, unit, "flags", &t) == 0)
136 kdev->flags = t;
137 else
138 kdev->flags = 0;
139
140 child = device_add_child(dev, name, unit);
141 device_set_ivars(child, kdev);
142}
143
144static int
145atkbdc_attach(device_t dev)
146{
147 atkbdc_softc_t *sc;
148 struct resource *port;
149 int unit;
150 int error;
151 int rid;
152 int i;
153
154 unit = device_get_unit(dev);
155 sc = *(atkbdc_softc_t **)device_get_softc(dev);
156 if (sc == NULL) {

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

161 * kbdc_soft[] contains the default entry for that purpose.
162 * See atkbdc.c. XXX
163 */
164 sc = atkbdc_get_softc(unit);
165 if (sc == NULL)
166 return ENOMEM;
167 }
168
169 /* XXX should track resource in softc */
170 rid = 0;
171 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
172 0, ~0, IO_KBDSIZE, RF_ACTIVE);
173 if (!port)
174 return ENXIO;
175 error = atkbdc_attach_unit(unit, sc, rman_get_start(port));
176 if (error)
177 return error;
178 *(atkbdc_softc_t **)device_get_softc(dev) = sc;
179
180 /*
181 * Add all devices configured to be attached to atkbdc0.
182 */
183 for (i = resource_query_string(-1, "at", "atkbdc0");
184 i != -1;
185 i = resource_query_string(i, "at", "atkbdc0")) {

--- 82 unchanged lines hidden ---