
Use the gpio alias id as the gpio bank id, same as in the linux driver.
This reverts the recent change to base bank id on the gpio-ranges prop and apply the same logic used when nodes was named gpio0@ to the alias.
With missing gpio aliases added to u-boot.dtsi files this should restore gpio function for SoCs that have synced gpio0@ to gpio@ node name changes from linux.
Fixes: 904b8700f81c ("gpio: gpio-rockchip: parse gpio-ranges for bank id") Signed-off-by: Jonas Karlman jonas@kwiboo.se --- drivers/gpio/rk_gpio.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c index f7ad4d68b452..bc77b28307c0 100644 --- a/drivers/gpio/rk_gpio.c +++ b/drivers/gpio/rk_gpio.c @@ -15,6 +15,7 @@ #include <asm/arch-rockchip/clock.h> #include <asm/arch-rockchip/gpio.h> #include <dm/pinctrl.h> +#include <dm/read.h> #include <dt-bindings/clock/rk3288-cru.h>
enum { @@ -142,7 +143,6 @@ static int rockchip_gpio_probe(struct udevice *dev) { struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); struct rockchip_gpio_priv *priv = dev_get_priv(dev); - struct ofnode_phandle_args args; char *end; int ret;
@@ -151,24 +151,15 @@ static int rockchip_gpio_probe(struct udevice *dev) if (ret) return ret;
- /* - * If "gpio-ranges" is present in the devicetree use it to parse - * the GPIO bank ID, otherwise use the legacy method. - */ - ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), - "gpio-ranges", NULL, 3, - 0, &args); - if (!ret || ret != -ENOENT) { - uc_priv->gpio_count = args.args[2]; - priv->bank = args.args[1] / args.args[2]; - } else { - uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK; + ret = dev_read_alias_seq(dev, &priv->bank); + if (ret) { end = strrchr(dev->name, '@'); priv->bank = trailing_strtoln(dev->name, end); }
priv->name[0] = 'A' + priv->bank; uc_priv->bank_name = priv->name; + uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
return 0; }