diff options
author | yokota <yokota@FreeBSD.org> | 2000-03-19 03:25:13 +0000 |
---|---|---|
committer | yokota <yokota@FreeBSD.org> | 2000-03-19 03:25:13 +0000 |
commit | 9435f0f0e18180735ef2cdcb77af913b197d332c (patch) | |
tree | 715c8383cbab0ee926f7f79699b82c6ed8bf8e82 /sys/isa/atkbdc_isa.c | |
parent | c778d5b01b612cbc11bb9bf66030443d63e6f1e4 (diff) | |
download | FreeBSD-src-9435f0f0e18180735ef2cdcb77af913b197d332c.zip FreeBSD-src-9435f0f0e18180735ef2cdcb77af913b197d332c.tar.gz |
- Properly keep track of I/O port resources.
- Use bus_space_read/write() to access the ports.
Diffstat (limited to 'sys/isa/atkbdc_isa.c')
-rw-r--r-- | sys/isa/atkbdc_isa.c | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/sys/isa/atkbdc_isa.c b/sys/isa/atkbdc_isa.c index 9549c99..1d64ce2 100644 --- a/sys/isa/atkbdc_isa.c +++ b/sys/isa/atkbdc_isa.c @@ -33,6 +33,7 @@ #include <sys/kernel.h> #include <sys/bus.h> #include <sys/malloc.h> +#include <machine/bus_pio.h> #include <machine/bus.h> #include <machine/resource.h> #include <sys/rman.h> @@ -87,32 +88,54 @@ static driver_t atkbdc_driver = { sizeof(atkbdc_softc_t *), }; +static struct isa_pnp_id atkbdc_ids[] = { + { 0x0303d041, "Keyboard controller (i8042)" }, /* PNP0303 */ + { 0 } +}; + static int atkbdc_probe(device_t dev) { - int error; - int rid; - struct resource *port; + struct resource *port0; + struct resource *port1; + int error; + int rid; - /* Check isapnp ids */ - if (isa_get_vendorid(dev)) - return (ENXIO); + /* check PnP IDs */ + if (ISA_PNP_PROBE(device_get_parent(dev), dev, atkbdc_ids) == ENXIO) + return ENXIO; + + device_set_desc(dev, "Keyboard controller (i8042)"); - device_set_desc(dev, "keyboard controller (i8042)"); rid = 0; - port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, - 0, ~0, IO_KBDSIZE, RF_ACTIVE); - if (!port) + port0 = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, + RF_ACTIVE); + if (port0 == NULL) + return ENXIO; + /* XXX */ + if (bus_get_resource_start(dev, SYS_RES_IOPORT, 1) <= 0) { + bus_set_resource(dev, SYS_RES_IOPORT, 1, + rman_get_start(port0) + KBD_STATUS_PORT, 1); + } + rid = 1; + port1 = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, + RF_ACTIVE); + if (port1 == NULL) { + bus_release_resource(dev, SYS_RES_IOPORT, 0, port0); return ENXIO; - error = atkbdc_probe_unit(device_get_unit(dev), rman_get_start(port)); - bus_release_resource(dev, SYS_RES_IOPORT, rid, port); + } + + error = atkbdc_probe_unit(device_get_unit(dev), port0, port1); + + bus_release_resource(dev, SYS_RES_IOPORT, 0, port0); + bus_release_resource(dev, SYS_RES_IOPORT, 1, port1); + 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; @@ -125,8 +148,6 @@ atkbdc_add_device(device_t dev, const char *name, int unit) return; bzero(kdev, sizeof *kdev); - kdev->port = sc->port; - if (resource_int_value(name, unit, "irq", &t) == 0) kdev->irq = t; else @@ -145,7 +166,6 @@ static int atkbdc_attach(device_t dev) { atkbdc_softc_t *sc; - struct resource *port; int unit; int error; int rid; @@ -166,15 +186,25 @@ atkbdc_attach(device_t dev) return ENOMEM; } - /* XXX should track resource in softc */ rid = 0; - port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, - 0, ~0, IO_KBDSIZE, RF_ACTIVE); - if (!port) + sc->port0 = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, + RF_ACTIVE); + if (sc->port0 == NULL) return ENXIO; - error = atkbdc_attach_unit(unit, sc, rman_get_start(port)); - if (error) + rid = 1; + sc->port1 = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, + RF_ACTIVE); + if (sc->port1 == NULL) { + bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->port0); + return ENXIO; + } + + error = atkbdc_attach_unit(unit, sc, sc->port0, sc->port1); + if (error) { + bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->port0); + bus_release_resource(dev, SYS_RES_IOPORT, 1, sc->port1); return error; + } *(atkbdc_softc_t **)device_get_softc(dev) = sc; /* |