Thread (13 messages) flat view 13 messages, 4 authors, 2021-12-13
STALE1692d LANDED

Landed in mainline as 1288cadce4c7 on 2021-12-04.

[PATCH 3/6] pinctrl: spear: plgpio: Introduce regmap phandle

From: Herve Codina <herve.codina@bootlin.com>
Date: 2021-12-02 09:53:40
Also in: linux-arm-kernel, linux-devicetree, lkml
Subsystem: pin control subsystem, spear platform/clock/pinctrl support, the rest · Maintainers: Linus Walleij, Viresh Kumar, Linus Torvalds

Resources need to be shared between pinmux and plgpio.

Introduce regmap phandle in order to retrieve the regmap
from the phandle if the property is present.
This allows to retrieve an external regmap (ie the one
used by pinmux if the phandle references the pinmux node)
from plgpio.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 drivers/pinctrl/spear/pinctrl-plgpio.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c
index 28538ac99eed..b36449724f3f 100644
--- a/drivers/pinctrl/spear/pinctrl-plgpio.c
+++ b/drivers/pinctrl/spear/pinctrl-plgpio.c
@@ -523,6 +523,7 @@ static int plgpio_probe_dt(struct platform_device *pdev, struct plgpio *plgpio)
 
 static int plgpio_probe(struct platform_device *pdev)
 {
+	struct device_node *regmap_np;
 	struct plgpio *plgpio;
 	int ret, irq;
 
@@ -530,11 +531,22 @@ static int plgpio_probe(struct platform_device *pdev)
 	if (!plgpio)
 		return -ENOMEM;
 
-	plgpio->regmap = device_node_to_regmap(pdev->dev.of_node);
-	if (IS_ERR(plgpio->regmap)) {
-		dev_err(&pdev->dev, "Init regmap failed (%pe)\n",
-			plgpio->regmap);
-		return PTR_ERR(plgpio->regmap);
+	regmap_np = of_parse_phandle(pdev->dev.of_node, "regmap", 0);
+	if (regmap_np) {
+		plgpio->regmap = device_node_to_regmap(regmap_np);
+		of_node_put(regmap_np);
+		if (IS_ERR(plgpio->regmap)) {
+			dev_err(&pdev->dev, "Retrieve regmap failed (%pe)\n",
+				plgpio->regmap);
+			return PTR_ERR(plgpio->regmap);
+		}
+	} else {
+		plgpio->regmap = device_node_to_regmap(pdev->dev.of_node);
+		if (IS_ERR(plgpio->regmap)) {
+			dev_err(&pdev->dev, "Init regmap failed (%pe)\n",
+				plgpio->regmap);
+			return PTR_ERR(plgpio->regmap);
+		}
 	}
 
 	ret = plgpio_probe_dt(pdev, plgpio);
-- 
2.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help