2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer as
10 * the first lines of this file unmodified.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
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.
26 * $Id: atkbd_isa.c,v 1.3 1999/04/16 21:22:34 peter Exp $
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
40 #include <machine/bus.h>
43 #include <machine/resource.h>
45 #include <dev/kbd/kbdreg.h>
46 #include <dev/kbd/atkbdreg.h>
47 #include <dev/kbd/atkbdcreg.h>
49 #include <isa/isareg.h>
50 #include <isa/isavar.h>
52 devclass_t atkbd_devclass;
54 static int atkbdprobe(device_t dev);
55 static int atkbdattach(device_t dev);
56 static void atkbd_isa_intr(void *arg);
58 static device_method_t atkbd_methods[] = {
59 DEVMETHOD(device_probe, atkbdprobe),
60 DEVMETHOD(device_attach, atkbdattach),
64 static driver_t atkbd_driver = {
67 sizeof(atkbd_softc_t),
71 atkbdprobe(device_t dev)
77 device_set_desc(dev, "AT Keyboard");
79 /* obtain parameters */
80 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
81 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
82 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
84 /* probe the device */
85 return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
89 atkbdattach(device_t dev)
100 sc = (atkbd_softc_t *)device_get_softc(dev);
102 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
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);
106 error = atkbd_attach_unit(device_get_unit(dev), sc, port, irq, flags);
110 /* declare our interrupt handler */
111 res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
112 RF_SHAREABLE | RF_ACTIVE);
113 BUS_SETUP_INTR(device_get_parent(dev), dev, res, INTR_TYPE_TTY,
114 atkbd_isa_intr, sc, &ih);
120 atkbd_isa_intr(void *arg)
124 sc = (atkbd_softc_t *)arg;
125 (*kbdsw[sc->kbd->kb_index]->intr)(sc->kbd, NULL);
128 DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
130 #endif /* NATKBD > 0 */