diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2008-01-15 22:28:15 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2008-01-15 22:28:15 +0000 |
| commit | dd38cd70540eeaeca5f6d2c2ab1ba7bc5a0711ea (patch) | |
| tree | 97ffe013bc1a0c0f32325fff6ec205166f6ce4dd /sys | |
| parent | b573f27291b2cf989e776d26e6833f4d0e706f65 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/dev/ppbus/ppbconf.c | 37 | ||||
| -rw-r--r-- | sys/dev/ppbus/ppbconf.h | 3 |
2 files changed, 40 insertions, 0 deletions
diff --git a/sys/dev/ppbus/ppbconf.c b/sys/dev/ppbus/ppbconf.c index cb5da93528f5..2ad164c3961d 100644 --- a/sys/dev/ppbus/ppbconf.c +++ b/sys/dev/ppbus/ppbconf.c @@ -36,6 +36,9 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/bus.h> #include <sys/malloc.h> +#include <sys/rman.h> + +#include <machine/resource.h> #include <dev/ppbus/ppbconf.h> #include <dev/ppbus/ppb_1284.h> @@ -380,9 +383,38 @@ end_scan: #endif /* !DONTPROBE_1284 */ +static void +ppbus_dummy_intr(void *arg) +{ +} + static int ppbus_attach(device_t dev) { + struct ppb_data *ppb = (struct ppb_data *)device_get_softc(dev); + uintptr_t irq; + int error, rid; + + /* Attach a dummy interrupt handler to suck up any stray interrupts. */ + BUS_READ_IVAR(device_get_parent(dev), dev, PPC_IVAR_IRQ, &irq); + + if (irq > 0) { + rid = 0; + ppb->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, irq, + irq, 1, RF_SHAREABLE); + if (ppb->irq_res != NULL) { + error = bus_setup_intr(dev, ppb->irq_res, + INTR_TYPE_TTY | INTR_MPSAFE, NULL, ppbus_dummy_intr, + ppb, &ppb->intr_cookie); + if (error) { + device_printf(dev, + "failed to setup interrupt handler\n"); + bus_release_resource(dev, SYS_RES_IRQ, 0, + ppb->irq_res); + return (error); + } + } + } /* Locate our children */ bus_generic_probe(dev); @@ -401,6 +433,7 @@ ppbus_attach(device_t dev) static int ppbus_detach(device_t dev) { + struct ppb_data *ppb = (struct ppb_data *)device_get_softc(dev); device_t *children; int nchildren, i; @@ -412,6 +445,10 @@ ppbus_detach(device_t dev) free(children, M_TEMP); } + if (ppb->irq_res != NULL) { + bus_teardown_intr(dev, ppb->irq_res, ppb->intr_cookie); + bus_release_resource(dev, SYS_RES_IRQ, 0, ppb->irq_res); + } return (0); } diff --git a/sys/dev/ppbus/ppbconf.h b/sys/dev/ppbus/ppbconf.h index eb1f64ec68ae..5f7a20196395 100644 --- a/sys/dev/ppbus/ppbconf.h +++ b/sys/dev/ppbus/ppbconf.h @@ -248,6 +248,9 @@ struct ppb_data { * NIBBLE, PS2, EPP or ECP */ void *ppb_owner; /* device which owns the bus */ + + struct resource *irq_res; + void *intr_cookie; }; #ifdef _KERNEL |
