git: e5624479d191 - stable/13 - arm64: rockchip: pinctrl: Do not rely on the node name
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Feb 2023 06:46:55 UTC
The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=e5624479d191780a4a49e2d391b79570b4bc0bac commit e5624479d191780a4a49e2d391b79570b4bc0bac Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2022-08-10 13:47:22 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2023-02-02 06:38:06 +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 (cherry picked from commit 8d6b3a85701062ee795a5aeabb0771c93a8f6f72) --- 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 24ad7798eef0..5b62f67201d0 100644 --- a/sys/arm64/rockchip/rk_pinctrl.c +++ b/sys/arm64/rockchip/rk_pinctrl.c @@ -1191,21 +1191,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) { @@ -1226,8 +1211,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; @@ -1264,51 +1248,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);