Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/fdt/simplebus.c
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Driver methods. | * Driver methods. | ||||
*/ | */ | ||||
static device_method_t simplebus_methods[] = { | static device_method_t simplebus_methods[] = { | ||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, simplebus_probe), | DEVMETHOD(device_probe, simplebus_probe), | ||||
DEVMETHOD(device_attach, simplebus_attach), | DEVMETHOD(device_attach, simplebus_attach), | ||||
DEVMETHOD(device_detach, bus_generic_detach), | DEVMETHOD(device_detach, simplebus_detach), | ||||
DEVMETHOD(device_shutdown, bus_generic_shutdown), | DEVMETHOD(device_shutdown, bus_generic_shutdown), | ||||
DEVMETHOD(device_suspend, bus_generic_suspend), | DEVMETHOD(device_suspend, bus_generic_suspend), | ||||
DEVMETHOD(device_resume, bus_generic_resume), | DEVMETHOD(device_resume, bus_generic_resume), | ||||
/* Bus interface */ | /* Bus interface */ | ||||
DEVMETHOD(bus_add_child, simplebus_add_child), | DEVMETHOD(bus_add_child, simplebus_add_child), | ||||
DEVMETHOD(bus_print_child, simplebus_print_child), | DEVMETHOD(bus_print_child, simplebus_print_child), | ||||
DEVMETHOD(bus_probe_nomatch, simplebus_probe_nomatch), | DEVMETHOD(bus_probe_nomatch, simplebus_probe_nomatch), | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | simplebus_attach(device_t dev) | ||||
/* | /* | ||||
* In principle, simplebus could have an interrupt map, but ignore that | * In principle, simplebus could have an interrupt map, but ignore that | ||||
* for now | * for now | ||||
*/ | */ | ||||
for (node = OF_child(sc->node); node > 0; node = OF_peer(node)) | for (node = OF_child(sc->node); node > 0; node = OF_peer(node)) | ||||
simplebus_add_device(dev, node, 0, NULL, -1, NULL); | simplebus_add_device(dev, node, 0, NULL, -1, NULL); | ||||
return (bus_generic_attach(dev)); | return (bus_generic_attach(dev)); | ||||
} | |||||
int | |||||
simplebus_detach(device_t dev) | |||||
{ | |||||
struct simplebus_softc *sc; | |||||
struct simplebus_devinfo *ndi; | |||||
device_t *devlist; | |||||
int index, num; | |||||
sc = device_get_softc(dev); | |||||
/* Free ranges */ | |||||
if (sc->ranges) | |||||
free(sc->ranges, M_DEVBUF); | |||||
/* Free simplebus_devinfo ndi */ | |||||
device_get_children(dev, &devlist, &num); | |||||
for (index = 0; index < num; index++) { | |||||
ndi = device_get_ivars(devlist[index]); | |||||
free(ndi, M_DEVBUF); | |||||
} | |||||
free(devlist, M_TEMP); | |||||
bus_generic_detach(dev); | |||||
return (0); | |||||
} | } | ||||
void | void | ||||
simplebus_init(device_t dev, phandle_t node) | simplebus_init(device_t dev, phandle_t node) | ||||
{ | { | ||||
struct simplebus_softc *sc; | struct simplebus_softc *sc; | ||||
sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
▲ Show 20 Lines • Show All 259 Lines • Show Last 20 Lines |