[PATCH RFC 03/16] pinctrl: aspeed: g5: Allow use of LPC node instead of LPC host controller

Andrew Jeffery posted 16 patches 1 month, 4 weeks ago
[PATCH RFC 03/16] pinctrl: aspeed: g5: Allow use of LPC node instead of LPC host controller
Posted by Andrew Jeffery 1 month, 4 weeks ago
There's currently a wart where the Aspeed LPC host controller has no
binding specified, but the pinctrl binding depends on referencing its
node.

Allow specification of a phandle to the parent LPC controller instead.
Fall back to testing for a compatible parent node if the provided
phandle doesn't directly resolve to the LPC controller node.

Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
---
 drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
index d4c364d19d64..7d818b4da1e3 100644
--- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
+++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g5.c
@@ -2648,24 +2648,34 @@ static struct regmap *aspeed_g5_acquire_regmap(struct aspeed_pinmux_data *ctx,
 	}
 
 	if (ip == ASPEED_IP_LPC) {
-		struct device_node *np;
+		struct device_node *np, *rnp;
 		struct regmap *map;
 
 		np = of_parse_phandle(ctx->dev->of_node,
 					"aspeed,external-nodes", 1);
-		if (np) {
-			if (!of_device_is_compatible(np->parent, "aspeed,ast2500-lpc-v2"))
-				return ERR_PTR(-ENODEV);
-
-			map = syscon_node_to_regmap(np->parent);
-			of_node_put(np);
-			if (IS_ERR(map))
-				return map;
-		} else
+		if (!np)
 			return ERR_PTR(-ENODEV);
 
+		if (of_device_is_compatible(np, "aspeed,ast2500-lpc-v2")) {
+			rnp = np;
+		} else if (of_device_is_compatible(np->parent, "aspeed,ast2500-lpc-v2")) {
+			/* Maintain compatibility with old aspeed,ast2500-lhc node */
+			rnp = np->parent;
+		} else {
+			map = ERR_PTR(-ENODEV);
+			goto put_external_node;
+		}
+
+		map = syscon_node_to_regmap(rnp);
+		if (IS_ERR(map))
+			goto put_external_node;
+
 		ctx->maps[ASPEED_IP_LPC] = map;
 		dev_dbg(ctx->dev, "Acquired LPC regmap");
+
+put_external_node:
+		of_node_put(np);
+
 		return map;
 	}
 

-- 
2.47.3
Re: [PATCH RFC 03/16] pinctrl: aspeed: g5: Allow use of LPC node instead of LPC host controller
Posted by Linus Walleij 1 month, 1 week ago
On Thu, Dec 11, 2025 at 9:46 AM Andrew Jeffery
<andrew@codeconstruct.com.au> wrote:

> There's currently a wart where the Aspeed LPC host controller has no
> binding specified, but the pinctrl binding depends on referencing its
> node.
>
> Allow specification of a phandle to the parent LPC controller instead.
> Fall back to testing for a compatible parent node if the provided
> phandle doesn't directly resolve to the LPC controller node.
>
> Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>

Reviewed-by: Linus Walleij <linusw@kernel.org>

I guess when this is non-RFC I will just apply these two patches.

Yours,
Linus Walleij
Re: [PATCH RFC 03/16] pinctrl: aspeed: g5: Allow use of LPC node instead of LPC host controller
Posted by Andrew Jeffery 1 month ago
On Wed, 2025-12-31 at 22:38 +0100, Linus Walleij wrote:
> On Thu, Dec 11, 2025 at 9:46 AM Andrew Jeffery
> <andrew@codeconstruct.com.au> wrote:
> 
> > There's currently a wart where the Aspeed LPC host controller has no
> > binding specified, but the pinctrl binding depends on referencing its
> > node.
> > 
> > Allow specification of a phandle to the parent LPC controller instead.
> > Fall back to testing for a compatible parent node if the provided
> > phandle doesn't directly resolve to the LPC controller node.
> > 
> > Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
> 
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> 
> I guess when this is non-RFC I will just apply these two patches.

Yeah, no dramas. I intend to split what remains to be applied into
separate (non-RFC) follow-up series now that many of the changes have
been applied.

Andrew