MCPcopy Create free account
hub / github.com/F-Stack/f-stack / localbus_attach

Function localbus_attach

freebsd/arm/mv/mv_localbus.c:252–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250}
251
252static int
253localbus_attach(device_t dev)
254{
255 device_t dev_child;
256 struct localbus_softc *sc;
257 struct localbus_devinfo *di;
258 phandle_t dt_node, dt_child;
259
260 sc = device_get_softc(dev);
261 sc->sc_dev = dev;
262 sc->sc_banks = localbus_banks;
263
264 /*
265 * Walk localbus and add direct subordinates as our children.
266 */
267 dt_node = ofw_bus_get_node(dev);
268 for (dt_child = OF_child(dt_node); dt_child != 0;
269 dt_child = OF_peer(dt_child)) {
270 /* Check and process 'status' property. */
271 if (!(ofw_bus_node_status_okay(dt_child)))
272 continue;
273
274 if (!(mv_fdt_pm(dt_child)))
275 continue;
276
277 di = malloc(sizeof(*di), M_LOCALBUS, M_WAITOK | M_ZERO);
278 if (ofw_bus_gen_setup_devinfo(&di->di_ofw, dt_child) != 0) {
279 free(di, M_LOCALBUS);
280 device_printf(dev, "could not set up devinfo\n");
281 continue;
282 }
283
284 resource_list_init(&di->di_res);
285 if (fdt_localbus_reg_decode(dt_child, sc, di)) {
286 device_printf(dev, "could not process 'reg' "
287 "property\n");
288 ofw_bus_gen_destroy_devinfo(&di->di_ofw);
289 free(di, M_LOCALBUS);
290 continue;
291 }
292
293 /* Add newbus device for this FDT node */
294 dev_child = device_add_child(dev, NULL, -1);
295 if (dev_child == NULL) {
296 device_printf(dev, "could not add child: %s\n",
297 di->di_ofw.obd_name);
298 resource_list_free(&di->di_res);
299 ofw_bus_gen_destroy_devinfo(&di->di_ofw);
300 free(di, M_LOCALBUS);
301 continue;
302 }
303#ifdef DEBUG
304 device_printf(dev, "added child: %s\n\n", di->di_ofw.obd_name);
305#endif
306 device_set_ivars(dev_child, di);
307 }
308
309 return (bus_generic_attach(dev));

Callers

nothing calls this directly

Calls 11

device_get_softcFunction · 0.85
mv_fdt_pmFunction · 0.85
mallocFunction · 0.85
device_printfFunction · 0.85
resource_list_initFunction · 0.85
fdt_localbus_reg_decodeFunction · 0.85
device_add_childFunction · 0.85
resource_list_freeFunction · 0.85
device_set_ivarsFunction · 0.85
bus_generic_attachFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected