diff options
Diffstat (limited to 'sys/powerpc/psim/openpic_iobus.c')
-rw-r--r-- | sys/powerpc/psim/openpic_iobus.c | 142 |
1 files changed, 14 insertions, 128 deletions
diff --git a/sys/powerpc/psim/openpic_iobus.c b/sys/powerpc/psim/openpic_iobus.c index 9be65a8..a3a69d3 100644 --- a/sys/powerpc/psim/openpic_iobus.c +++ b/sys/powerpc/psim/openpic_iobus.c @@ -60,117 +60,33 @@ __FBSDID("$FreeBSD$"); #include "pic_if.h" -struct openpic_iobus_softc { - struct openpic_softc osc; - struct resource *sc_memr; /* iobus mem resource */ - device_t sc_ndev; /* nexus device */ -}; - -static struct openpic_iobus_softc *ppicsoftc; - /* - * MacIO interface + * PSIM IOBus interface */ -static void openpic_psim_identify(driver_t *, device_t); -static int openpic_psim_probe(device_t); -static int openpic_psim_attach(device_t); static int openpic_iobus_probe(device_t); -static int openpic_iobus_attach(device_t); -/* - * Nexus attachment - */ -static device_method_t openpic_psim_methods[] = { +static device_method_t openpic_iobus_methods[] = { /* Device interface */ - DEVMETHOD(device_identify, openpic_psim_identify), - DEVMETHOD(device_probe, openpic_psim_probe), - DEVMETHOD(device_attach, openpic_psim_attach), + DEVMETHOD(device_probe, openpic_iobus_probe), + DEVMETHOD(device_attach, openpic_attach), /* PIC interface */ - DEVMETHOD(pic_allocate_intr, openpic_allocate_intr), - DEVMETHOD(pic_setup_intr, openpic_setup_intr), - DEVMETHOD(pic_teardown_intr, openpic_teardown_intr), - DEVMETHOD(pic_release_intr, openpic_release_intr), + DEVMETHOD(pic_dispatch, openpic_dispatch), + DEVMETHOD(pic_enable, openpic_enable), + DEVMETHOD(pic_eoi, openpic_eoi), + DEVMETHOD(pic_mask, openpic_mask), + DEVMETHOD(pic_unmask, openpic_unmask), { 0, 0 } }; -static driver_t openpic_psim_driver = { - "openpic", - openpic_psim_methods, - sizeof(struct openpic_iobus_softc) -}; - -static devclass_t openpic_psim_devclass; - -DRIVER_MODULE(openpic_psim, nexus, openpic_psim_driver, openpic_psim_devclass, - 0, 0); - -static void -openpic_psim_identify(driver_t *driver, device_t parent) -{ - device_t child; - phandle_t pic; - - pic = OF_finddevice("/iobus/opic"); - if (pic == -1) - return; - - child = BUS_ADD_CHILD(parent, 0, "openpic", 0); - if (child != NULL) - nexus_set_device_type(child, "psim"); -} - -static int -openpic_psim_probe(device_t dev) -{ - char *name; - char *type; - - name = nexus_get_name(dev); - type = nexus_get_device_type(dev); - - if (strcmp(name, "openpic") != 0 || - strcmp(type, "psim") != 0) - return (ENXIO); - - device_set_desc(dev, OPENPIC_DEVSTR); - return (0); -} - -static int -openpic_psim_attach(device_t dev) -{ - KASSERT(ppicsoftc == NULL, ("iobus openpic: already probed")); - ppicsoftc = device_get_softc(dev); - ppicsoftc->sc_ndev = dev; - - nexus_install_intcntlr(dev); - openpic_early_attach(dev); - return (0); -} - -/* - * PSIM IOBus attachment - */ -static device_method_t openpic_iobus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, openpic_iobus_probe), - DEVMETHOD(device_attach, openpic_iobus_attach), - - { 0, 0 }, -}; - static driver_t openpic_iobus_driver = { - "openpiciobus", + "openpic", openpic_iobus_methods, - 0 + sizeof(struct openpic_softc) }; -static devclass_t openpic_iobus_devclass; - -DRIVER_MODULE(openpiciobus, iobus, openpic_iobus_driver, - openpic_iobus_devclass, 0, 0); +DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, openpic_devclass, 0, 0); static int openpic_iobus_probe(device_t dev) @@ -179,42 +95,12 @@ openpic_iobus_probe(device_t dev) name = iobus_get_name(dev); if (strcmp(name, "interrupt-controller") != 0) - return (ENXIO); + return (ENXIO); /* * The description was already printed out in the nexus * probe, so don't do it again here */ - device_set_desc(dev, "OpenPIC IOBus interrupt cell"); - if (!bootverbose) - device_quiet(dev); + device_set_desc(dev, OPENPIC_DEVSTR); return (0); } - -static int -openpic_iobus_attach(device_t dev) -{ - struct openpic_iobus_softc *sc; - int rid; - - sc = ppicsoftc; - KASSERT(sc != NULL, ("pic not nexus-probed\n")); - - rid = 0; - sc->sc_memr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, - RF_ACTIVE); - - if (sc->sc_memr == NULL) { - device_printf(dev, "Could not alloc mem resource!\n"); - return (ENXIO); - } - - sc->osc.sc_psim = 1; - sc->osc.sc_bt = rman_get_bustag(sc->sc_memr); - sc->osc.sc_bh = rman_get_bushandle(sc->sc_memr); - sc->osc.sc_altdev = dev; - - return (openpic_attach(sc->sc_ndev)); -} - - |