mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v1 1/3] gpio: gpio-rockchip: parse gpio-ranges for bank id
@ 2023-01-19 14:00 Johan Jonker
  2023-01-19 14:01 ` [RFC PATCH v1 2/3] ARM: dts: rockchip: add gpio-ranges property to gpio nodes Johan Jonker
  2023-01-19 14:02 ` [RFC PATCH v1 3/3] arm64: " Johan Jonker
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Jonker @ 2023-01-19 14:00 UTC (permalink / raw)
  To: linus.walleij, brgl
  Cc: robh+dt, krzysztof.kozlowski+dt, heiko, linux-gpio, devicetree,
	linux-arm-kernel, linux-rockchip, linux-kernel, kever.yang, sjg,
	philipp.tomsich, john, quentin.schulz

Parse the gpio-ranges property in Rockchip gpio nodes to be
independent from aliases and probe order for our bank id.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/gpio/gpio-rockchip.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index e5de15a2a..3eaa1a5de 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -706,6 +706,7 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
 	struct pinctrl_dev *pctldev = NULL;
 	struct rockchip_pin_bank *bank = NULL;
 	struct rockchip_pin_deferred *cfg;
+	struct of_phandle_args args;
 	static int gpio;
 	int id, ret;

@@ -716,9 +717,14 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
 	if (!pctldev)
 		return -EPROBE_DEFER;

-	id = of_alias_get_id(np, "gpio");
-	if (id < 0)
-		id = gpio++;
+	ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args);
+	if (ret == 0) {
+		id = args.args[1] / 32;
+	} else {
+		id = of_alias_get_id(np, "gpio");
+		if (id < 0)
+			id = gpio++;
+	}

 	bank = rockchip_gpio_find_bank(pctldev, id);
 	if (!bank)
--
2.20.1


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

end of thread, other threads:[~2023-01-19 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-19 14:00 [RFC PATCH v1 1/3] gpio: gpio-rockchip: parse gpio-ranges for bank id Johan Jonker
2023-01-19 14:01 ` [RFC PATCH v1 2/3] ARM: dts: rockchip: add gpio-ranges property to gpio nodes Johan Jonker
2023-01-19 14:02 ` [RFC PATCH v1 3/3] arm64: " Johan Jonker

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

all inboxes | Powered by JetHome®