Skip to content

Commit 32e67ee

Browse files
Lee JonesLinus Walleij
authored andcommitted
pinctrl: nomadik: Allow prcm_base to be extracted from Device Tree
The Nomadik Pinctrl driver requires access to some PRCMU registers in order to run with full functionality. When Device Tree is disabled the required PRCMU base address is passed in via platform data, so in order for Device Tree booting to be as functional, we need a similar mechanism to fetch it from Device Tree. The new semantics goes like this: Parse the Device Tree and look for the PRCMU node using a provided Phandle. Obtain the ioremaped address from that node. If one was supplied via platform data over-write it with anything found in Device Tree. Fail if either the prcm_base can't be found if we're running on anything other than an STN8815 ASIC. Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 8979cfe commit 32e67ee

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

‎drivers/pinctrl/pinctrl-nomadik.c‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/irqdomain.h>
2626
#include <linux/slab.h>
2727
#include <linux/of_device.h>
28+
#include <linux/of_address.h>
2829
#include <linux/pinctrl/machine.h>
2930
#include <linux/pinctrl/pinctrl.h>
3031
#include <linux/pinctrl/pinmux.h>
@@ -2135,6 +2136,7 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
21352136
{
21362137
const struct platform_device_id *platid = platform_get_device_id(pdev);
21372138
struct device_node *np = pdev->dev.of_node;
2139+
struct device_node *prcm_np;
21382140
struct nmk_pinctrl *npct;
21392141
struct resource *res;
21402142
unsigned int version = 0;
@@ -2163,21 +2165,26 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
21632165
if (version == PINCTRL_NMK_DB8540)
21642166
nmk_pinctrl_db8540_init(&npct->soc);
21652167

2168+
if (np) {
2169+
prcm_np = of_parse_phandle(np, "prcm", 0);
2170+
if (prcm_np)
2171+
npct->prcm_base = of_iomap(prcm_np, 0);
2172+
}
2173+
2174+
/* Allow platform passed information to over-write DT. */
21662175
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2167-
if (res) {
2176+
if (res)
21682177
npct->prcm_base = devm_ioremap(&pdev->dev, res->start,
21692178
resource_size(res));
2170-
if (!npct->prcm_base) {
2171-
dev_err(&pdev->dev,
2172-
"failed to ioremap PRCM registers\n");
2173-
return -ENOMEM;
2179+
if (!npct->prcm_base) {
2180+
if (version == PINCTRL_NMK_STN8815) {
2181+
dev_info(&pdev->dev,
2182+
"No PRCM base, "
2183+
"assuming no ALT-Cx control is available\n");
2184+
} else {
2185+
dev_err(&pdev->dev, "missing PRCM base address\n");
2186+
return -EINVAL;
21742187
}
2175-
} else if (version == PINCTRL_NMK_STN8815) {
2176-
dev_info(&pdev->dev,
2177-
"No PRCM base, assume no ALT-Cx control is available\n");
2178-
} else {
2179-
dev_err(&pdev->dev, "missing PRCM base address\n");
2180-
return -EINVAL;
21812188
}
21822189

21832190
/*

0 commit comments

Comments
 (0)