From: Herve Codina Date: Thu, 2 Dec 2021 09:52:52 +0000 (+0100) Subject: pinctrl: spear: plgpio: Introduce regmap phandle X-Git-Tag: v6.1-rc5~2249^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1288cadce4c7c2afafd13aeed64305b7fb4e280d;p=platform%2Fkernel%2Flinux-starfive.git pinctrl: spear: plgpio: Introduce regmap phandle 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 Acked-by: Viresh Kumar Link: https://lore.kernel.org/r/20211202095255.165797-4-herve.codina@bootlin.com Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c index 28538ac..b364497 100644 --- a/drivers/pinctrl/spear/pinctrl-plgpio.c +++ b/drivers/pinctrl/spear/pinctrl-plgpio.c @@ -523,6 +523,7 @@ end: 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);