Esempio n. 1
0
static void
gpioled_identify(driver_t *driver, device_t bus)
{
	phandle_t child, leds, root;

	root = OF_finddevice("/");
	if (root == 0)
		return;
	leds = fdt_find_compatible(root, "gpio-leds", 1);
	if (leds == 0)
		return;

	/* Traverse the 'gpio-leds' node and add its children. */
	for (child = OF_child(leds); child != 0; child = OF_peer(child))
		if (ofw_gpiobus_add_fdt_child(bus, child) == NULL)
			continue;
}
Esempio n. 2
0
static int
ofw_gpiobus_attach(device_t dev)
{
	int err;
	phandle_t child;

	err = gpiobus_init_softc(dev);
	if (err != 0)
		return (err);
	bus_generic_probe(dev);
	bus_enumerate_hinted_children(dev);
	/*
	 * Attach the children represented in the device tree.
	 */
	for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
	    child = OF_peer(child)) {
		if (!OF_hasprop(child, "gpios"))
			continue;
		if (ofw_gpiobus_add_fdt_child(dev, NULL, child) == NULL)
			continue;
	}

	return (bus_generic_attach(dev));
}