rockchip: gpio: rk_gpio: use ROCKCHIP_GPIOS_PER_BANK as divider
authorJohan Jonker <jbx6244@gmail.com>
Sun, 19 Mar 2023 15:02:18 +0000 (16:02 +0100)
committerKever Yang <kever.yang@rock-chips.com>
Fri, 21 Apr 2023 07:16:01 +0000 (15:16 +0800)
The current divider to calculate the bank ID can change.
Given the Rockchip TRM not all gpio-banks have 32 pins per bank.
The "gpio-ranges" syntax allows multiple items with variable number
of pins. Use a constant ROCKCHIP_GPIOS_PER_BANK as fixed divider.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/gpio/rk_gpio.c

index f7ad4d6..0a2acf1 100644 (file)
@@ -160,7 +160,7 @@ static int rockchip_gpio_probe(struct udevice *dev)
                                             0, &args);
        if (!ret || ret != -ENOENT) {
                uc_priv->gpio_count = args.args[2];
-               priv->bank = args.args[1] / args.args[2];
+               priv->bank = args.args[1] / ROCKCHIP_GPIOS_PER_BANK;
        } else {
                uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
                end = strrchr(dev->name, '@');