git: 8d6b3a857010 - main - arm64: rockchip: pinctrl: Do not rely on the node name
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 10 Aug 2022 13:49:42 UTC
The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=8d6b3a85701062ee795a5aeabb0771c93a8f6f72 commit 8d6b3a85701062ee795a5aeabb0771c93a8f6f72 Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2022-08-10 13:47:22 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2022-08-10 13:47:22 +0000 arm64: rockchip: pinctrl: Do not rely on the node name Node names for gpio bank were made generic in Linux 5.16 so stop using them to map the gpio controller to the pin controller bank unit. Sponsored by: Beckhoff Automation GmbH & Co. KG --- sys/arm64/rockchip/rk_pinctrl.c | 60 +++++++---------------------------------- 1 file changed, 9 insertions(+), 51 deletions(-) diff --git a/sys/arm64/rockchip/rk_pinctrl.c b/sys/arm64/rockchip/rk_pinctrl.c index 6d0d93aee439..c158de40dca5 100644 --- a/sys/arm64/rockchip/rk_pinctrl.c +++ b/sys/arm64/rockchip/rk_pinctrl.c @@ -1437,21 +1437,6 @@ done: return (rv); } -static int -rk_pinctrl_register_gpio(struct rk_pinctrl_softc *sc, char *gpio_name, - device_t gpio_dev) -{ - int i; - - for(i = 0; i < sc->conf->ngpio_bank; i++) { - if (strcmp(gpio_name, sc->conf->gpio_bank[i].gpio_name) != 0) - continue; - sc->conf->gpio_bank[i].gpio_dev = gpio_dev; - return(0); - } - return (ENXIO); -} - static int rk_pinctrl_probe(device_t dev) { @@ -1472,8 +1457,7 @@ rk_pinctrl_attach(device_t dev) struct rk_pinctrl_softc *sc; phandle_t node; device_t cdev; - char *gpio_name, *eptr; - int rv; + int rv, gpio_unit; sc = device_get_softc(dev); sc->dev = dev; @@ -1511,51 +1495,25 @@ rk_pinctrl_attach(device_t dev) bus_generic_probe(dev); /* Attach child devices */ - for (node = OF_child(node); node > 0; node = OF_peer(node)) { + for (node = OF_child(node), gpio_unit = 0; node > 0; + node = OF_peer(node)) { if (!ofw_bus_node_is_compatible(node, "rockchip,gpio-bank")) continue; - - rv = OF_getprop_alloc(node, "name", (void **)&gpio_name); - if (rv <= 0) { - device_printf(sc->dev, "Cannot GPIO subdevice name.\n"); - continue; - } - cdev = simplebus_add_device(dev, node, 0, NULL, -1, NULL); if (cdev == NULL) { - device_printf(dev, " Cannot add GPIO subdevice: %s\n", - gpio_name); - OF_prop_free(gpio_name); + device_printf(dev, " Cannot add GPIO subdevice\n"); + gpio_unit += 1; continue; } - rv = device_probe_and_attach(cdev); if (rv != 0) { device_printf(sc->dev, - "Cannot attach GPIO subdevice: %s\n", gpio_name); - OF_prop_free(gpio_name); - continue; - } - - /* Grep device name from name property */ - eptr = gpio_name; - strsep(&eptr, "@"); - if (gpio_name == eptr) { - device_printf(sc->dev, - "Unrecognized format of GPIO subdevice name: %s\n", - gpio_name); - OF_prop_free(gpio_name); - continue; - } - rv = rk_pinctrl_register_gpio(sc, gpio_name, cdev); - if (rv != 0) { - device_printf(sc->dev, - "Cannot register GPIO subdevice %s: %d\n", - gpio_name, rv); - OF_prop_free(gpio_name); + "Cannot attach GPIO subdevice\n"); + gpio_unit += 1; continue; } - OF_prop_free(gpio_name); + sc->conf->gpio_bank[gpio_unit].gpio_dev = cdev; + gpio_unit += 1; } fdt_pinctrl_configure_tree(dev);