summaryrefslogtreecommitdiff
path: root/drivers/gpio/rk_gpio.c
diff options
context:
space:
mode:
authorJonas Karlman <jonas@kwiboo.se>2024-02-17 00:22:35 +0000
committerKever Yang <kever.yang@rock-chips.com>2024-03-14 11:40:48 +0800
commitf41738d0f101fc07c79aea6093650ab2ed4bf8c4 (patch)
treeb19c3595d016ea3e236f596a9fb12417ef2711cf /drivers/gpio/rk_gpio.c
parent1e21f569304573759b61ca8ee38087c5509ef070 (diff)
gpio: rockchip: Use gpio alias id as gpio bank id
The U-Boot driver try to base the gpio bank id on the gpio-ranges prop and fall back to base the bank id on the node name. However, the linux driver try to base the bank id on the gpio alias id and fall back on node order. This can cause issues when SoC DT is synced from linux and gpioX@ nodes has been renamed to gpio@ and gpio-ranges or a SoC specific alias has not been assigned. Try to use the gpio alias id as first fallback when a gpio-ranges prop is missing to ease sync of updated SoC DT. Keep the current fallback on node name as a third fallback to not affect any existing unsynced DT. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'drivers/gpio/rk_gpio.c')
-rw-r--r--drivers/gpio/rk_gpio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index c5e096bb1ad..2e901ac5c73 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -200,8 +200,11 @@ static int rockchip_gpio_probe(struct udevice *dev)
priv->bank = args.args[1] / ROCKCHIP_GPIOS_PER_BANK;
} else {
uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
- end = strrchr(dev->name, '@');
- priv->bank = trailing_strtoln(dev->name, end);
+ 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;