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 * 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. 14 * 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. 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 * 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. 14 * 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. 25 *
|
26 * $FreeBSD: head/sys/dev/atkbdc/atkbd_atkbdc.c 56836 2000-01-29 15:08:56Z peter $
| 26 * $FreeBSD: head/sys/dev/atkbdc/atkbd_atkbdc.c 58271 2000-03-19 03:25:13Z yokota $
|
27 */ 28 29#include "opt_kbd.h" 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/kernel.h>
| 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/conf.h> 35#include <sys/tty.h>
| |
36#include <sys/bus.h>
| 34#include <sys/bus.h>
|
| 35
|
37#include <machine/bus.h>
| 36#include <machine/bus.h>
|
| 37#include <machine/resource.h>
|
38#include <sys/rman.h> 39
| 38#include <sys/rman.h> 39
|
40#include <machine/resource.h> 41
| |
42#include <dev/kbd/kbdreg.h> 43#include <dev/kbd/atkbdreg.h> 44#include <dev/kbd/atkbdcreg.h> 45 46#include <isa/isareg.h> 47#include <isa/isavar.h> 48
| 40#include <dev/kbd/kbdreg.h> 41#include <dev/kbd/atkbdreg.h> 42#include <dev/kbd/atkbdcreg.h> 43 44#include <isa/isareg.h> 45#include <isa/isavar.h> 46
|
| 47typedef struct { 48 struct resource *intr; 49 void *ih; 50} atkbd_softc_t; 51
|
49devclass_t atkbd_devclass; 50 51static int atkbdprobe(device_t dev); 52static int atkbdattach(device_t dev); 53static void atkbd_isa_intr(void *arg); 54 55static device_method_t atkbd_methods[] = { 56 DEVMETHOD(device_probe, atkbdprobe), 57 DEVMETHOD(device_attach, atkbdattach), 58 { 0, 0 } 59}; 60 61static driver_t atkbd_driver = { 62 ATKBD_DRIVER_NAME, 63 atkbd_methods,
| 52devclass_t atkbd_devclass; 53 54static int atkbdprobe(device_t dev); 55static int atkbdattach(device_t dev); 56static void atkbd_isa_intr(void *arg); 57 58static device_method_t atkbd_methods[] = { 59 DEVMETHOD(device_probe, atkbdprobe), 60 DEVMETHOD(device_attach, atkbdattach), 61 { 0, 0 } 62}; 63 64static driver_t atkbd_driver = { 65 ATKBD_DRIVER_NAME, 66 atkbd_methods,
|
64 1,
| 67 sizeof(atkbd_softc_t),
|
65}; 66 67static int 68atkbdprobe(device_t dev) 69{
| 68}; 69 70static int 71atkbdprobe(device_t dev) 72{
|
70 uintptr_t port;
| |
71 uintptr_t irq; 72 uintptr_t flags; 73 74 device_set_desc(dev, "AT Keyboard"); 75 76 /* obtain parameters */
| 73 uintptr_t irq; 74 uintptr_t flags; 75 76 device_set_desc(dev, "AT Keyboard"); 77 78 /* obtain parameters */
|
77 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
| |
78 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); 79 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags); 80 81 /* probe the device */
| 79 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); 80 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags); 81 82 /* probe the device */
|
82 return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
| 83 return atkbd_probe_unit(device_get_unit(dev), 84 device_get_unit(device_get_parent(dev)), 85 irq, flags);
|
83} 84 85static int 86atkbdattach(device_t dev) 87{
| 86} 87 88static int 89atkbdattach(device_t dev) 90{
|
| 91 atkbd_softc_t *sc;
|
88 keyboard_t *kbd;
| 92 keyboard_t *kbd;
|
89 uintptr_t port;
| |
90 uintptr_t irq; 91 uintptr_t flags;
| 93 uintptr_t irq; 94 uintptr_t flags;
|
92 struct resource *res; 93 void *ih; 94 int zero = 0;
| 95 int rid;
|
95 int error; 96
| 96 int error; 97
|
97 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
| 98 sc = device_get_softc(dev); 99
|
98 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); 99 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags); 100
| 100 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); 101 BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags); 102
|
101 error = atkbd_attach_unit(device_get_unit(dev), &kbd, port, irq, flags);
| 103 error = atkbd_attach_unit(device_get_unit(dev), &kbd, 104 device_get_unit(device_get_parent(dev)), 105 irq, flags);
|
102 if (error) 103 return error; 104 105 /* declare our interrupt handler */
| 106 if (error) 107 return error; 108 109 /* declare our interrupt handler */
|
106 res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1, 107 RF_SHAREABLE | RF_ACTIVE); 108 BUS_SETUP_INTR(device_get_parent(dev), dev, res, INTR_TYPE_TTY, 109 atkbd_isa_intr, kbd, &ih);
| 110 rid = 0; 111 sc->intr = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq, irq, 1, 112 RF_SHAREABLE | RF_ACTIVE); 113 BUS_SETUP_INTR(device_get_parent(dev), dev, sc->intr, INTR_TYPE_TTY, 114 atkbd_isa_intr, kbd, &sc->ih);
|
110 111 return 0; 112} 113 114static void 115atkbd_isa_intr(void *arg) 116{ 117 keyboard_t *kbd; 118 119 kbd = (keyboard_t *)arg; 120 (*kbdsw[kbd->kb_index]->intr)(kbd, NULL); 121} 122 123DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
| 115 116 return 0; 117} 118 119static void 120atkbd_isa_intr(void *arg) 121{ 122 keyboard_t *kbd; 123 124 kbd = (keyboard_t *)arg; 125 (*kbdsw[kbd->kb_index]->intr)(kbd, NULL); 126} 127 128DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
|