Lines Matching +full:first +full:- +full:data +full:- +full:gpios
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
70 rv = ofw_bus_parse_xref_list_alloc(cnode, prop_name, "#gpio-cells", in gpio_pin_get_by_ofw_propidx()
112 return (gpio_pin_get_by_ofw_propidx(consumer, node, "gpios", idx, pin)); in gpio_pin_get_by_ofw_idx()
132 rv = ofw_bus_find_string_index(node, "gpio-names", name, &idx); in gpio_pin_get_by_ofw_name()
174 devi = &dinfo->opd_dinfo; in ofw_gpiobus_add_fdt_child()
175 for (i = 0; i < devi->npins; i++) in ofw_gpiobus_add_fdt_child()
176 GPIOBUS_PIN_SETNAME(bus, devi->pins[i], in ofw_gpiobus_add_fdt_child()
197 if (node != -1) in ofw_gpiobus_register_provider()
207 if (node != -1) in ofw_gpiobus_unregister_provider()
224 if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, node) != 0) { in ofw_gpiobus_setup_devinfo()
228 /* Parse the gpios property for the child. */ in ofw_gpiobus_setup_devinfo()
229 npins = ofw_gpiobus_parse_gpios_impl(child, node, "gpios", sc, &pins); in ofw_gpiobus_setup_devinfo()
231 ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo); in ofw_gpiobus_setup_devinfo()
236 resource_list_init(&dinfo->opd_dinfo.rl); in ofw_gpiobus_setup_devinfo()
237 /* Allocate the child ivars and copy the parsed pin data. */ in ofw_gpiobus_setup_devinfo()
238 devi = &dinfo->opd_dinfo; in ofw_gpiobus_setup_devinfo()
239 devi->npins = (uint32_t)npins; in ofw_gpiobus_setup_devinfo()
245 for (i = 0; i < devi->npins; i++) in ofw_gpiobus_setup_devinfo()
246 devi->pins[i] = pins[i].pin; in ofw_gpiobus_setup_devinfo()
249 if (ofw_bus_intr_to_rl(bus, node, &dinfo->opd_dinfo.rl, NULL) != 0) { in ofw_gpiobus_setup_devinfo()
266 devi = &dinfo->opd_dinfo; in ofw_gpiobus_destroy_devinfo()
267 for (i = 0; i < devi->npins; i++) { in ofw_gpiobus_destroy_devinfo()
268 if (devi->pins[i] > sc->sc_npins) in ofw_gpiobus_destroy_devinfo()
270 sc->sc_pins[devi->pins[i]].mapped = 0; in ofw_gpiobus_destroy_devinfo()
273 resource_list_free(&dinfo->opd_dinfo.rl); in ofw_gpiobus_destroy_devinfo()
274 ofw_bus_gen_destroy_devinfo(&dinfo->opd_obdinfo); in ofw_gpiobus_destroy_devinfo()
283 pcell_t *gpios; in ofw_gpiobus_parse_gpios_impl() local
286 ncells = OF_getencprop_alloc_multi(cnode, pname, sizeof(*gpios), in ofw_gpiobus_parse_gpios_impl()
287 (void **)&gpios); in ofw_gpiobus_parse_gpios_impl()
288 if (ncells == -1) { in ofw_gpiobus_parse_gpios_impl()
290 "Warning: No %s specified in fdt data; " in ofw_gpiobus_parse_gpios_impl()
292 return (-1); in ofw_gpiobus_parse_gpios_impl()
295 * The gpio-specifier is controller independent, the first pcell has in ofw_gpiobus_parse_gpios_impl()
297 * Count the number of encoded gpio-specifiers on the first pass. in ofw_gpiobus_parse_gpios_impl()
303 if (gpios[i] == 0) { in ofw_gpiobus_parse_gpios_impl()
308 gpio = OF_node_from_xref(gpios[i]); in ofw_gpiobus_parse_gpios_impl()
309 /* If we have bussc, ignore devices from other gpios. */ in ofw_gpiobus_parse_gpios_impl()
311 if (ofw_bus_get_node(bussc->sc_dev) != gpio) in ofw_gpiobus_parse_gpios_impl()
314 * Check for gpio-controller property and read the #gpio-cells in ofw_gpiobus_parse_gpios_impl()
317 if (!OF_hasprop(gpio, "gpio-controller") || in ofw_gpiobus_parse_gpios_impl()
318 OF_getencprop(gpio, "#gpio-cells", &gpiocells, in ofw_gpiobus_parse_gpios_impl()
321 "gpio reference is not a gpio-controller.\n"); in ofw_gpiobus_parse_gpios_impl()
322 OF_prop_free(gpios); in ofw_gpiobus_parse_gpios_impl()
323 return (-1); in ofw_gpiobus_parse_gpios_impl()
325 if (ncells - i < gpiocells + 1) { in ofw_gpiobus_parse_gpios_impl()
327 "%s cells doesn't match #gpio-cells.\n", pname); in ofw_gpiobus_parse_gpios_impl()
328 return (-1); in ofw_gpiobus_parse_gpios_impl()
337 OF_prop_free(gpios); in ofw_gpiobus_parse_gpios_impl()
343 OF_prop_free(gpios); in ofw_gpiobus_parse_gpios_impl()
344 return (-1); in ofw_gpiobus_parse_gpios_impl()
351 if (gpios[i] == 0) { in ofw_gpiobus_parse_gpios_impl()
356 gpio = OF_node_from_xref(gpios[i]); in ofw_gpiobus_parse_gpios_impl()
357 /* Read gpio-cells property for this GPIO controller. */ in ofw_gpiobus_parse_gpios_impl()
358 if (OF_getencprop(gpio, "#gpio-cells", &gpiocells, in ofw_gpiobus_parse_gpios_impl()
361 "gpio does not have the #gpio-cells property.\n"); in ofw_gpiobus_parse_gpios_impl()
365 (*pins)[j].dev = OF_device_from_xref(gpios[i]); in ofw_gpiobus_parse_gpios_impl()
387 &gpios[i + 1], &(*pins)[j].pin, &(*pins)[j].flags) != 0) { in ofw_gpiobus_parse_gpios_impl()
389 "cannot map the gpios specifier.\n"); in ofw_gpiobus_parse_gpios_impl()
393 if (gpiobus_acquire_pin(bussc->sc_busdev, (*pins)[j].pin) != 0) in ofw_gpiobus_parse_gpios_impl()
398 OF_prop_free(gpios); in ofw_gpiobus_parse_gpios_impl()
403 OF_prop_free(gpios); in ofw_gpiobus_parse_gpios_impl()
405 return (-1); in ofw_gpiobus_parse_gpios_impl()
412 if (ofw_bus_get_node(dev) == -1) in ofw_gpiobus_probe()
435 if (OF_hasprop(child, "gpio-hog")) in ofw_gpiobus_attach()
437 if (!OF_hasprop(child, "gpios")) in ofw_gpiobus_attach()
464 * NULL all the OFW-related parts of the ivars for non-OFW in ofw_gpiobus_add_child()
467 devi->opd_obdinfo.obd_node = -1; in ofw_gpiobus_add_child()
468 devi->opd_obdinfo.obd_name = NULL; in ofw_gpiobus_add_child()
469 devi->opd_obdinfo.obd_compat = NULL; in ofw_gpiobus_add_child()
470 devi->opd_obdinfo.obd_type = NULL; in ofw_gpiobus_add_child()
471 devi->opd_obdinfo.obd_model = NULL; in ofw_gpiobus_add_child()
485 return (&dinfo->opd_obdinfo); in ofw_gpiobus_get_devinfo()