public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH/RFC] rockchip: derive GPIO bank from alias if available
@ 2022-07-26 16:25 John Keeping
  2022-07-26 19:53 ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: John Keeping @ 2022-07-26 16:25 UTC (permalink / raw)
  To: u-boot; +Cc: John Keeping, Simon Glass, Philipp Tomsich, Kever Yang

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 <john@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.

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-27 16:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-26 16:25 [PATCH/RFC] rockchip: derive GPIO bank from alias if available John Keeping
2022-07-26 19:53 ` Simon Glass
2022-07-27 16:27   ` John Keeping

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox