Hi John,

On Tue, 26 Jul 2022 at 10:25, John Keeping <j...@metanate.com> wrote:
>
> Upstream device trees now use standard node names like "gpio@ff..." but
> the rk_gpio driver expects a name like "gpio0@ff..." (note the index
> before the @).
>
> This is not a change that can be made in a -u-boot.dtsi file, so
> updating to the latest upstream device trees requires updating the
> driver.
>
> When a sequence number is given explicitly via an alias it makes sense
> to use this for the bank number (and aliases can be added via
> -u-boot.dtsi when they are not present upstream), so make this the
> preferred scheme for assigning a bank index, falling back to the current
> method if no alias is defined.
>
> Signed-off-by: John Keeping <j...@metanate.com>
> ---
> I'm not sure if it would be better just to use dev_seq(dev)
> unconditionally here.  If no aliases are defined, then the device tree
> nodes are in the right order for all Rockchip SoCs anyway so the
> sequence numbers will be sensible.

Well dev_seq() should now match the alias numbers if provided, so it
seems better.

>
> But this feels like the change with less risk of unintentionally
> introducing a regression.
>
>  drivers/gpio/rk_gpio.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
> index 68f30157a9..b2f6d0e925 100644
> --- a/drivers/gpio/rk_gpio.c
> +++ b/drivers/gpio/rk_gpio.c
> @@ -151,8 +151,13 @@ static int rockchip_gpio_probe(struct udevice *dev)
>                 return ret;
>
>         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;
>         uc_priv->bank_name = priv->name;
>
> --
> 2.37.1
>

Regards,
Simon

Reply via email to