Skip to content

Commit

Permalink
pinctrl: spear: plgpio: Introduce regmap phandle
Browse files Browse the repository at this point in the history
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>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20211202095255.165797-4-herve.codina@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Herve Codina authored and Linus Walleij committed Dec 4, 2021
1 parent 7151cef commit 1288cad
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions drivers/pinctrl/spear/pinctrl-plgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,18 +523,30 @@ 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;

plgpio = devm_kzalloc(&pdev->dev, sizeof(*plgpio), GFP_KERNEL);
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);
Expand Down

0 comments on commit 1288cad

Please sign in to comment.