diff options
author | dfr <dfr@FreeBSD.org> | 1999-01-23 16:53:30 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1999-01-23 16:53:30 +0000 |
commit | 126561435c15a39d8ef4a4269cd6203289c0ac1e (patch) | |
tree | 12e378e698803d82b0aceefe2bbd78cbab6a1245 /sys/dev/atkbdc | |
parent | a46648c3bc9b84e02e9017422ad131332206a603 (diff) | |
download | FreeBSD-src-126561435c15a39d8ef4a4269cd6203289c0ac1e.zip FreeBSD-src-126561435c15a39d8ef4a4269cd6203289c0ac1e.tar.gz |
Update the alpha port to use the new syscons.
Submitted by: Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> (partly)
Diffstat (limited to 'sys/dev/atkbdc')
-rw-r--r-- | sys/dev/atkbdc/atkbd_atkbdc.c | 119 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbd_isa.c | 119 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbdc_isa.c | 242 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbdc_subr.c | 242 | ||||
-rw-r--r-- | sys/dev/atkbdc/psm.c | 21 |
5 files changed, 737 insertions, 6 deletions
diff --git a/sys/dev/atkbdc/atkbd_atkbdc.c b/sys/dev/atkbdc/atkbd_atkbdc.c new file mode 100644 index 0000000..4513049 --- /dev/null +++ b/sys/dev/atkbdc/atkbd_atkbdc.c @@ -0,0 +1,119 @@ +/*- + * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id: $ + */ + +#include "atkbd.h" +#include "opt_kbd.h" + +#if NATKBD > 0 + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/conf.h> +#include <sys/tty.h> +#include <sys/bus.h> +#include <sys/rman.h> + +#include <machine/resource.h> + +#include <dev/kbd/kbdreg.h> +#include <dev/kbd/atkbdreg.h> +#include <dev/kbd/atkbdcreg.h> + +#include <isa/isareg.h> +#include <isa/isavar.h> + +devclass_t atkbd_devclass; + +static int atkbdprobe(device_t dev); +static int atkbdattach(device_t dev); + +static device_method_t atkbd_methods[] = { + DEVMETHOD(device_probe, atkbdprobe), + DEVMETHOD(device_attach, atkbdattach), + { 0, 0 } +}; + +static driver_t atkbd_driver = { + ATKBD_DRIVER_NAME, + atkbd_methods, + DRIVER_TYPE_TTY, + sizeof(atkbd_softc_t), +}; + +static int +atkbdprobe(device_t dev) +{ + atkbd_softc_t *sc; + u_long port; + u_long irq; + u_long flags; + + sc = (atkbd_softc_t *)device_get_softc(dev); + + device_set_desc(dev, "AT Keyboard"); + + /* obtain parameters */ + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port); + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags); + + /* probe the device */ + return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags); +} + +static int +atkbdattach(device_t dev) +{ + atkbd_softc_t *sc; + u_long irq; + struct resource *res; + void *ih; + int zero = 0; + int error; + + sc = (atkbd_softc_t *)device_get_softc(dev); + + error = atkbd_attach_unit(device_get_unit(dev), sc); + if (error) + return error; + + /* declare our interrupt handler */ + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); + res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1, + RF_SHAREABLE | RF_ACTIVE); + BUS_SETUP_INTR(device_get_parent(dev), dev, res, + (driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd, + &ih); + + return 0; +} + +DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0); + +#endif /* NATKBD > 0 */ diff --git a/sys/dev/atkbdc/atkbd_isa.c b/sys/dev/atkbdc/atkbd_isa.c new file mode 100644 index 0000000..4513049 --- /dev/null +++ b/sys/dev/atkbdc/atkbd_isa.c @@ -0,0 +1,119 @@ +/*- + * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id: $ + */ + +#include "atkbd.h" +#include "opt_kbd.h" + +#if NATKBD > 0 + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/conf.h> +#include <sys/tty.h> +#include <sys/bus.h> +#include <sys/rman.h> + +#include <machine/resource.h> + +#include <dev/kbd/kbdreg.h> +#include <dev/kbd/atkbdreg.h> +#include <dev/kbd/atkbdcreg.h> + +#include <isa/isareg.h> +#include <isa/isavar.h> + +devclass_t atkbd_devclass; + +static int atkbdprobe(device_t dev); +static int atkbdattach(device_t dev); + +static device_method_t atkbd_methods[] = { + DEVMETHOD(device_probe, atkbdprobe), + DEVMETHOD(device_attach, atkbdattach), + { 0, 0 } +}; + +static driver_t atkbd_driver = { + ATKBD_DRIVER_NAME, + atkbd_methods, + DRIVER_TYPE_TTY, + sizeof(atkbd_softc_t), +}; + +static int +atkbdprobe(device_t dev) +{ + atkbd_softc_t *sc; + u_long port; + u_long irq; + u_long flags; + + sc = (atkbd_softc_t *)device_get_softc(dev); + + device_set_desc(dev, "AT Keyboard"); + + /* obtain parameters */ + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port); + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags); + + /* probe the device */ + return atkbd_probe_unit(device_get_unit(dev), sc, port, irq, flags); +} + +static int +atkbdattach(device_t dev) +{ + atkbd_softc_t *sc; + u_long irq; + struct resource *res; + void *ih; + int zero = 0; + int error; + + sc = (atkbd_softc_t *)device_get_softc(dev); + + error = atkbd_attach_unit(device_get_unit(dev), sc); + if (error) + return error; + + /* declare our interrupt handler */ + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); + res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1, + RF_SHAREABLE | RF_ACTIVE); + BUS_SETUP_INTR(device_get_parent(dev), dev, res, + (driver_intr_t *) kbdsw[sc->kbd->kb_index]->intr, sc->kbd, + &ih); + + return 0; +} + +DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0); + +#endif /* NATKBD > 0 */ diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c new file mode 100644 index 0000000..4435e1e --- /dev/null +++ b/sys/dev/atkbdc/atkbdc_isa.c @@ -0,0 +1,242 @@ +/*- + * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id: $ + */ + +#include "atkbdc.h" +#include "opt_kbd.h" + +#if NATKBDC > 0 + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/bus.h> +#include <sys/malloc.h> + +#include <dev/kbd/atkbdcreg.h> + +#include <isa/isareg.h> +#include <isa/isavar.h> + +MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device"); + +/* children */ +typedef struct atkbdc_device { + int flags; /* configuration flags */ + int port; /* port number (same as the controller's) */ + int irq; /* ISA IRQ mask */ +} atkbdc_device_t; + +/* kbdc */ +devclass_t atkbdc_devclass; + +static int atkbdc_probe(device_t dev); +static int atkbdc_attach(device_t dev); +static void atkbdc_print_child(device_t bus, device_t dev); +static int atkbdc_read_ivar(device_t bus, device_t dev, int index, + u_long *val); +static int atkbdc_write_ivar(device_t bus, device_t dev, int index, + u_long val); + +static device_method_t atkbdc_methods[] = { + DEVMETHOD(device_probe, atkbdc_probe), + DEVMETHOD(device_attach, atkbdc_attach), + + DEVMETHOD(bus_print_child, atkbdc_print_child), + DEVMETHOD(bus_read_ivar, atkbdc_read_ivar), + DEVMETHOD(bus_write_ivar, atkbdc_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t atkbdc_driver = { + ATKBDC_DRIVER_NAME, + atkbdc_methods, + DRIVER_TYPE_MISC, + sizeof(atkbdc_softc_t *), +}; + +static int +atkbdc_probe(device_t dev) +{ + atkbdc_softc_t *sc; + int unit; + int error; + + unit = device_get_unit(dev); + sc = *(atkbdc_softc_t **)device_get_softc(dev); + if (sc == NULL) { + /* + * We have to maintain two copies of the kbdc_softc struct, + * as the low-level console needs to have access to the + * keyboard controller before kbdc is probed and attached. + * kbdc_soft[] contains the default entry for that purpose. + * See atkbdc.c. XXX + */ + sc = atkbdc_get_softc(unit); + if (sc == NULL) + return ENOMEM; + } + + device_set_desc(dev, "keyboard controller (i8042)"); + + error = atkbdc_probe_unit(sc, unit, isa_get_port(dev)); + if (error == 0) + *(atkbdc_softc_t **)device_get_softc(dev) = sc; + + return error; +} + +static void +atkbdc_add_device(device_t dev, const char *name, int unit) +{ + atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev); + atkbdc_device_t *kdev; + device_t child; + int t; + + kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT); + if (!kdev) + return; + bzero(kdev, sizeof *kdev); + + kdev->port = sc->port; + + if (resource_int_value(name, unit, "irq", &t) == 0) + kdev->irq = t; + else + kdev->irq = -1; + + if (resource_int_value(name, unit, "flags", &t) == 0) + kdev->flags = t; + else + kdev->flags = 0; + + child = device_add_child(dev, name, unit, kdev); +} + +static int +atkbdc_attach(device_t dev) +{ + atkbdc_softc_t *sc; + int i; + + sc = *(atkbdc_softc_t **)device_get_softc(dev); + if ((sc == NULL) || (sc->port <= 0)) + return ENXIO; + + /* + * Add all devices configured to be attached to atkbdc0. + */ + for (i = resource_query_string(-1, "at", "atkbdc0"); + i != -1; + i = resource_query_string(i, "at", "atkbdc0")) { + atkbdc_add_device(dev, resource_query_name(i), + resource_query_unit(i)); + } + + /* + * and atkbdc? + */ + for (i = resource_query_string(-1, "at", "atkbdc"); + i != -1; + i = resource_query_string(i, "at", "atkbdc")) { + atkbdc_add_device(dev, resource_query_name(i), + resource_query_unit(i)); + } + + bus_generic_attach(dev); + + return 0; +} + +static void +atkbdc_print_child(device_t bus, device_t dev) +{ + atkbdc_device_t *kbdcdev; + + kbdcdev = (atkbdc_device_t *)device_get_ivars(dev); + + if (kbdcdev->flags != 0) + printf(" flags 0x%x", kbdcdev->flags); + + printf(" on %s%d", device_get_name(bus), device_get_unit(bus)); +} + +static int +atkbdc_read_ivar(device_t bus, device_t dev, int index, u_long *val) +{ + atkbdc_device_t *ivar; + + ivar = (atkbdc_device_t *)device_get_ivars(dev); + switch (index) { + case KBDC_IVAR_PORT: + *val = (u_long)ivar->port; + break; + case KBDC_IVAR_IRQ: + *val = (u_long)ivar->irq; + break; + case KBDC_IVAR_FLAGS: + *val = (u_long)ivar->flags; + break; + default: + return ENOENT; + } + return 0; +} + +static int +atkbdc_write_ivar(device_t bus, device_t dev, int index, u_long val) +{ + atkbdc_device_t *ivar; + + ivar = (atkbdc_device_t *)device_get_ivars(dev); + switch (index) { + case KBDC_IVAR_PORT: + ivar->port = (int)val; + break; + case KBDC_IVAR_IRQ: + ivar->irq = (int)val; + break; + case KBDC_IVAR_FLAGS: + ivar->flags = (int)val; + break; + default: + return ENOENT; + } + return 0; +} + +DRIVER_MODULE(atkbdc, isa, atkbdc_driver, atkbdc_devclass, 0, 0); + +#endif /* NATKBDC > 0 */ diff --git a/sys/dev/atkbdc/atkbdc_subr.c b/sys/dev/atkbdc/atkbdc_subr.c new file mode 100644 index 0000000..4435e1e --- /dev/null +++ b/sys/dev/atkbdc/atkbdc_subr.c @@ -0,0 +1,242 @@ +/*- + * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer as + * the first lines of this file unmodified. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $Id: $ + */ + +#include "atkbdc.h" +#include "opt_kbd.h" + +#if NATKBDC > 0 + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/bus.h> +#include <sys/malloc.h> + +#include <dev/kbd/atkbdcreg.h> + +#include <isa/isareg.h> +#include <isa/isavar.h> + +MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device"); + +/* children */ +typedef struct atkbdc_device { + int flags; /* configuration flags */ + int port; /* port number (same as the controller's) */ + int irq; /* ISA IRQ mask */ +} atkbdc_device_t; + +/* kbdc */ +devclass_t atkbdc_devclass; + +static int atkbdc_probe(device_t dev); +static int atkbdc_attach(device_t dev); +static void atkbdc_print_child(device_t bus, device_t dev); +static int atkbdc_read_ivar(device_t bus, device_t dev, int index, + u_long *val); +static int atkbdc_write_ivar(device_t bus, device_t dev, int index, + u_long val); + +static device_method_t atkbdc_methods[] = { + DEVMETHOD(device_probe, atkbdc_probe), + DEVMETHOD(device_attach, atkbdc_attach), + + DEVMETHOD(bus_print_child, atkbdc_print_child), + DEVMETHOD(bus_read_ivar, atkbdc_read_ivar), + DEVMETHOD(bus_write_ivar, atkbdc_write_ivar), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + + { 0, 0 } +}; + +static driver_t atkbdc_driver = { + ATKBDC_DRIVER_NAME, + atkbdc_methods, + DRIVER_TYPE_MISC, + sizeof(atkbdc_softc_t *), +}; + +static int +atkbdc_probe(device_t dev) +{ + atkbdc_softc_t *sc; + int unit; + int error; + + unit = device_get_unit(dev); + sc = *(atkbdc_softc_t **)device_get_softc(dev); + if (sc == NULL) { + /* + * We have to maintain two copies of the kbdc_softc struct, + * as the low-level console needs to have access to the + * keyboard controller before kbdc is probed and attached. + * kbdc_soft[] contains the default entry for that purpose. + * See atkbdc.c. XXX + */ + sc = atkbdc_get_softc(unit); + if (sc == NULL) + return ENOMEM; + } + + device_set_desc(dev, "keyboard controller (i8042)"); + + error = atkbdc_probe_unit(sc, unit, isa_get_port(dev)); + if (error == 0) + *(atkbdc_softc_t **)device_get_softc(dev) = sc; + + return error; +} + +static void +atkbdc_add_device(device_t dev, const char *name, int unit) +{ + atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev); + atkbdc_device_t *kdev; + device_t child; + int t; + + kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT); + if (!kdev) + return; + bzero(kdev, sizeof *kdev); + + kdev->port = sc->port; + + if (resource_int_value(name, unit, "irq", &t) == 0) + kdev->irq = t; + else + kdev->irq = -1; + + if (resource_int_value(name, unit, "flags", &t) == 0) + kdev->flags = t; + else + kdev->flags = 0; + + child = device_add_child(dev, name, unit, kdev); +} + +static int +atkbdc_attach(device_t dev) +{ + atkbdc_softc_t *sc; + int i; + + sc = *(atkbdc_softc_t **)device_get_softc(dev); + if ((sc == NULL) || (sc->port <= 0)) + return ENXIO; + + /* + * Add all devices configured to be attached to atkbdc0. + */ + for (i = resource_query_string(-1, "at", "atkbdc0"); + i != -1; + i = resource_query_string(i, "at", "atkbdc0")) { + atkbdc_add_device(dev, resource_query_name(i), + resource_query_unit(i)); + } + + /* + * and atkbdc? + */ + for (i = resource_query_string(-1, "at", "atkbdc"); + i != -1; + i = resource_query_string(i, "at", "atkbdc")) { + atkbdc_add_device(dev, resource_query_name(i), + resource_query_unit(i)); + } + + bus_generic_attach(dev); + + return 0; +} + +static void +atkbdc_print_child(device_t bus, device_t dev) +{ + atkbdc_device_t *kbdcdev; + + kbdcdev = (atkbdc_device_t *)device_get_ivars(dev); + + if (kbdcdev->flags != 0) + printf(" flags 0x%x", kbdcdev->flags); + + printf(" on %s%d", device_get_name(bus), device_get_unit(bus)); +} + +static int +atkbdc_read_ivar(device_t bus, device_t dev, int index, u_long *val) +{ + atkbdc_device_t *ivar; + + ivar = (atkbdc_device_t *)device_get_ivars(dev); + switch (index) { + case KBDC_IVAR_PORT: + *val = (u_long)ivar->port; + break; + case KBDC_IVAR_IRQ: + *val = (u_long)ivar->irq; + break; + case KBDC_IVAR_FLAGS: + *val = (u_long)ivar->flags; + break; + default: + return ENOENT; + } + return 0; +} + +static int +atkbdc_write_ivar(device_t bus, device_t dev, int index, u_long val) +{ + atkbdc_device_t *ivar; + + ivar = (atkbdc_device_t *)device_get_ivars(dev); + switch (index) { + case KBDC_IVAR_PORT: + ivar->port = (int)val; + break; + case KBDC_IVAR_IRQ: + ivar->irq = (int)val; + break; + case KBDC_IVAR_FLAGS: + ivar->flags = (int)val; + break; + default: + return ENOENT; + } + return 0; +} + +DRIVER_MODULE(atkbdc, isa, atkbdc_driver, atkbdc_devclass, 0, 0); + +#endif /* NATKBDC > 0 */ diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index 5b999e1..e7eb469 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -20,7 +20,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: psm.c,v 1.1 1998/11/08 18:43:03 dfr Exp $ + * $Id: psm.c,v 1.2 1998/11/15 18:25:17 dfr Exp $ */ /* @@ -90,7 +90,7 @@ #include <isa/isareg.h> #include <isa/isavar.h> -#include <isa/kbdio.h> +#include <dev/kbd/atkbdcreg.h> /* * Driver specific options: the following options may be set by @@ -740,6 +740,8 @@ psmprobe(device_t dev) { int unit = device_get_unit(dev); struct psm_softc *sc = device_get_softc(dev); + u_long port; + u_long flags; int stat[3]; int command_byte; int mask; @@ -748,13 +750,18 @@ psmprobe(device_t dev) #if 0 kbdc_debug(TRUE); #endif - sc->addr = isa_get_port(dev); + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port); + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags); + + sc->addr = port; sc->kbdc = kbdc_open(sc->addr); - sc->config = isa_get_flags(dev) & PSM_CONFIG_FLAGS; + sc->config = flags & PSM_CONFIG_FLAGS; sc->flags = 0; if (bootverbose) ++verbose; + device_set_desc(dev, "PS/2 Mouse"); + if (!kbdc_lock(sc->kbdc, TRUE)) { printf("psm%d: unable to lock the controller.\n", unit); if (bootverbose) @@ -984,6 +991,7 @@ psmattach(device_t dev) struct psm_softc *sc = device_get_softc(dev); void *ih; struct resource *res; + u_long irq; int zero = 0; if (sc == NULL) /* shouldn't happen */ @@ -1027,7 +1035,8 @@ psmattach(device_t dev) if (bootverbose) --verbose; - res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, 0ul, ~0ul, 1, + BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq); + res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1, RF_SHAREABLE | RF_ACTIVE); BUS_SETUP_INTR(device_get_parent(dev), dev, res, psmintr, sc, &ih); @@ -2216,7 +2225,7 @@ psmresume(void *dummy) } #endif /* PSM_HOOKAPM */ -CDEV_DRIVER_MODULE(psm, isa, psm_driver, psm_devclass, +CDEV_DRIVER_MODULE(psm, atkbdc, psm_driver, psm_devclass, CDEV_MAJOR, psm_cdevsw, 0, 0); #endif /* NPSM > 0 */ |