Lines Matching +full:a +full:- +full:child +full:- +full:node +full:- +full:property

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
70 rv = ofw_bus_parse_xref_list_alloc(cnode, prop_name, "#gpio-cells",
108 gpio_pin_get_by_ofw_idx(device_t consumer, phandle_t node,
112 return (gpio_pin_get_by_ofw_propidx(consumer, node, "gpios", idx, pin));
116 gpio_pin_get_by_ofw_property(device_t consumer, phandle_t node,
120 return (gpio_pin_get_by_ofw_propidx(consumer, node, name, 0, pin));
124 gpio_pin_get_by_ofw_name(device_t consumer, phandle_t node,
129 KASSERT(consumer != NULL && node > 0,
130 ("both consumer and node required"));
132 rv = ofw_bus_find_string_index(node, "gpio-names", name, &idx);
135 return (gpio_pin_get_by_ofw_idx(consumer, node, idx, pin));
142 ofw_gpiobus_add_fdt_child(device_t bus, const char *drvname, phandle_t child)
150 * Check to see if we already have a child for @p child, and if so
153 childdev = ofw_bus_find_child_device_by_phandle(bus, child);
158 * Set up the GPIO child and OFW bus layer devinfo and add it to bus.
163 dinfo = ofw_gpiobus_setup_devinfo(bus, childdev, child);
173 /* Use the child name as pin name. */
174 devi = &dinfo->opd_dinfo;
175 for (i = 0; i < devi->npins; i++)
176 GPIOBUS_PIN_SETNAME(bus, devi->pins[i],
194 phandle_t node;
196 node = ofw_bus_get_node(provider);
197 if (node != -1)
198 OF_device_register_xref(OF_xref_from_node(node), provider);
204 phandle_t node;
206 node = ofw_bus_get_node(provider);
207 if (node != -1)
208 OF_device_register_xref(OF_xref_from_node(node), NULL);
212 ofw_gpiobus_setup_devinfo(device_t bus, device_t child, phandle_t node)
224 if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, node) != 0) {
228 /* Parse the gpios property for the child. */
229 npins = ofw_gpiobus_parse_gpios_impl(child, node, "gpios", sc, &pins);
231 ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo);
236 resource_list_init(&dinfo->opd_dinfo.rl);
237 /* Allocate the child ivars and copy the parsed pin data. */
238 devi = &dinfo->opd_dinfo;
239 devi->npins = (uint32_t)npins;
245 for (i = 0; i < devi->npins; i++)
246 devi->pins[i] = pins[i].pin;
249 if (ofw_bus_intr_to_rl(bus, node, &dinfo->opd_dinfo.rl, NULL) != 0) {
253 device_set_ivars(child, dinfo);
266 devi = &dinfo->opd_dinfo;
267 for (i = 0; i < devi->npins; i++) {
268 if (devi->pins[i] > sc->sc_npins)
270 sc->sc_pins[devi->pins[i]].mapped = 0;
273 resource_list_free(&dinfo->opd_dinfo.rl);
274 ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo);
288 if (ncells == -1) {
292 return (-1);
295 * The gpio-specifier is controller independent, the first pcell has
297 * Count the number of encoded gpio-specifiers on the first pass.
311 if (ofw_bus_get_node(bussc->sc_dev) != gpio)
314 * Check for gpio-controller property and read the #gpio-cells
317 if (!OF_hasprop(gpio, "gpio-controller") ||
318 OF_getencprop(gpio, "#gpio-cells", &gpiocells,
321 "gpio reference is not a gpio-controller.\n");
323 return (-1);
325 if (ncells - i < gpiocells + 1) {
327 "%s cells doesn't match #gpio-cells.\n", pname);
328 return (-1);
344 return (-1);
357 /* Read gpio-cells property for this GPIO controller. */
358 if (OF_getencprop(gpio, "#gpio-cells", &gpiocells,
361 "gpio does not have the #gpio-cells property.\n");
374 * the child is probed and attached.
393 if (gpiobus_acquire_pin(bussc->sc_busdev, (*pins)[j].pin) != 0)
405 return (-1);
412 if (ofw_bus_get_node(dev) == -1)
423 phandle_t child;
433 for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
434 child = OF_peer(child)) {
435 if (OF_hasprop(child, "gpio-hog"))
437 if (!OF_hasprop(child, "gpios"))
439 if (ofw_gpiobus_add_fdt_child(dev, NULL, child) == NULL)
450 device_t child;
453 child = device_add_child_ordered(dev, order, name, unit);
454 if (child == NULL)
455 return (child);
459 device_delete_child(dev, child);
464 * NULL all the OFW-related parts of the ivars for non-OFW
467 devi->opd_obdinfo.obd_node = -1;
468 devi->opd_obdinfo.obd_name = NULL;
469 devi->opd_obdinfo.obd_compat = NULL;
470 devi->opd_obdinfo.obd_type = NULL;
471 devi->opd_obdinfo.obd_model = NULL;
473 device_set_ivars(child, devi);
475 return (child);
485 return (&dinfo->opd_obdinfo);