public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] rockchip: derive GPIO bank from alias if available
@ 2023-01-17 18:15 John Keeping
  2023-01-17 19:52 ` Johan Jonker
  2023-02-22  8:41 ` Kever Yang
  0 siblings, 2 replies; 5+ messages in thread
From: John Keeping @ 2023-01-17 18:15 UTC (permalink / raw)
  To: u-boot
  Cc: John Keeping, Quentin Schulz, Johan Jonker, 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.

Other GPIO drivers already use the sequence number to derive the bank.
This can be set explicitly using an alias in the device tree (which can
be added in a -u-boot.dtsi file) but Rockchip GPIO banks are defined in
order in the device tree anyway so when no aliases are supplied the
indexes should still be correct.

Note that the bank name is only used by the `gpio` command or
potentially by board code via dm_gpio_lookup_name() and related
functions; it is not used by driver code which will lookup GPIOs from
the device tree by phandle.  No Rockchip platforms make any use of
dm_gpio_lookup_name() or `gpio` in the boot scripts.

Cc: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Cc: Johan Jonker <jbx6244@gmail.com>
Signed-off-by: John Keeping <john@metanate.com>
---
 drivers/gpio/rk_gpio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index 68f30157a9..8568f10cd0 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -142,7 +142,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);
-	char *end;
 	int ret;
 
 	priv->regs = dev_read_addr_ptr(dev);
@@ -151,9 +150,8 @@ 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);
-	priv->name[0] = 'A' + priv->bank;
+
+	priv->name[0] = 'A' + dev_seq(dev);
 	uc_priv->bank_name = priv->name;
 
 	return 0;
-- 
2.39.0


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

end of thread, other threads:[~2023-02-22  8:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17 18:15 [PATCH] rockchip: derive GPIO bank from alias if available John Keeping
2023-01-17 19:52 ` Johan Jonker
2023-01-18 16:13   ` John Keeping
2023-01-19 10:17     ` Johan Jonker
2023-02-22  8:41 ` Kever Yang

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