[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4a18d6b6-a8a4-a2e6-6841-fa78951792e7@gmail.com>
Date: Thu, 23 Feb 2023 20:46:47 +0100
From: Johan Jonker <jbx6244@...il.com>
To: linus.walleij@...aro.org, brgl@...ev.pl
Cc: robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
heiko@...ech.de, linux-gpio@...r.kernel.org,
devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: [PATCH v4 3/7] gpio: gpio-rockchip: parse rockchip,gpio-controller
property for bank id
Parse the rockchip,gpio-controller property in Rockchip gpio nodes to be
independent from aliases and probe order for our bank id.
Signed-off-by: Johan Jonker <jbx6244@...il.com>
---
drivers/gpio/gpio-rockchip.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index e5de15a2a..47e45299f 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -702,24 +702,38 @@ static int rockchip_gpio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
- struct device_node *pctlnp = of_get_parent(np);
+ struct device_node *pctlnp;
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;
- if (!np || !pctlnp)
+ if (!np)
return -ENODEV;
+ ret = of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, 0, &args);
+ if (!ret)
+ pctlnp = args.np;
+ else
+ pctlnp = of_get_parent(np);
+
+ if (!pctlnp)
+ return -ENODEV;
+
+ ret = of_property_read_u32(np, "rockchip,gpio-controller", &id);
+ if (ret) {
+ id = of_alias_get_id(np, "gpio");
+ if (id < 0)
+ id = gpio++;
+ }
+
pctldev = of_pinctrl_get(pctlnp);
+ of_node_put(pctlnp);
if (!pctldev)
return -EPROBE_DEFER;
- id = of_alias_get_id(np, "gpio");
- if (id < 0)
- id = gpio++;
-
bank = rockchip_gpio_find_bank(pctldev, id);
if (!bank)
return -EINVAL;
--
2.20.1
Powered by blists - more mailing lists