diff options
Diffstat (limited to 'sys/dev/hme/if_hme_sbus.c')
-rw-r--r-- | sys/dev/hme/if_hme_sbus.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sys/dev/hme/if_hme_sbus.c b/sys/dev/hme/if_hme_sbus.c index 46eaa45..66456fe 100644 --- a/sys/dev/hme/if_hme_sbus.c +++ b/sys/dev/hme/if_hme_sbus.c @@ -92,11 +92,19 @@ struct hme_sbus_softc { static int hme_sbus_probe(device_t); static int hme_sbus_attach(device_t); +static int hme_sbus_detach(device_t); +static int hme_sbus_suspend(device_t); +static int hme_sbus_resume(device_t); static device_method_t hme_sbus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, hme_sbus_probe), DEVMETHOD(device_attach, hme_sbus_attach), + DEVMETHOD(device_detach, hme_sbus_detach), + DEVMETHOD(device_suspend, hme_sbus_suspend), + DEVMETHOD(device_resume, hme_sbus_resume), + /* Can just use the suspend method here. */ + DEVMETHOD(device_shutdown, hme_sbus_suspend), /* bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), @@ -249,6 +257,7 @@ hme_sbus_attach(device_t dev) if ((error = bus_setup_intr(dev, hsc->hsc_ires, INTR_TYPE_NET, hme_intr, sc, &hsc->hsc_ih)) != 0) { device_printf(dev, "couldn't establish interrupt\n"); + hme_detach(sc); goto fail_ires; } return (0); @@ -274,3 +283,47 @@ fail_seb_res: hsc->hsc_seb_res); return (ENXIO); } + +static int +hme_sbus_detach(device_t dev) +{ + struct hme_sbus_softc *hsc = device_get_softc(dev); + struct hme_softc *sc = &hsc->hsc_hme; + + hme_detach(sc); + + bus_teardown_intr(dev, hsc->hsc_ires, hsc->hsc_ih); + if (hsc->hsc_mif_res != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mif_rid, + hsc->hsc_mif_res); + } + bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_mac_rid, + hsc->hsc_mac_res); + bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_erx_rid, + hsc->hsc_erx_res); + bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_etx_rid, + hsc->hsc_etx_res); + bus_release_resource(dev, SYS_RES_MEMORY, hsc->hsc_seb_rid, + hsc->hsc_seb_res); + return (0); +} + +static int +hme_sbus_suspend(device_t dev) +{ + struct hme_sbus_softc *hsc = device_get_softc(dev); + struct hme_softc *sc = &hsc->hsc_hme; + + hme_suspend(sc); + return (0); +} + +static int +hme_sbus_resume(device_t dev) +{ + struct hme_sbus_softc *hsc = device_get_softc(dev); + struct hme_softc *sc = &hsc->hsc_hme; + + hme_resume(sc); + return (0); +} |