Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Lee Jones and committed by
Linus Walleij
32e67eee 8979cfef

+18 -11
+18 -11
drivers/pinctrl/pinctrl-nomadik.c
··· 25 25 #include <linux/irqdomain.h> 26 26 #include <linux/slab.h> 27 27 #include <linux/of_device.h> 28 + #include <linux/of_address.h> 28 29 #include <linux/pinctrl/machine.h> 29 30 #include <linux/pinctrl/pinctrl.h> 30 31 #include <linux/pinctrl/pinmux.h> ··· 2136 2135 { 2137 2136 const struct platform_device_id *platid = platform_get_device_id(pdev); 2138 2137 struct device_node *np = pdev->dev.of_node; 2138 + struct device_node *prcm_np; 2139 2139 struct nmk_pinctrl *npct; 2140 2140 struct resource *res; 2141 2141 unsigned int version = 0; ··· 2165 2163 if (version == PINCTRL_NMK_DB8540) 2166 2164 nmk_pinctrl_db8540_init(&npct->soc); 2167 2165 2166 + if (np) { 2167 + prcm_np = of_parse_phandle(np, "prcm", 0); 2168 + if (prcm_np) 2169 + npct->prcm_base = of_iomap(prcm_np, 0); 2170 + } 2171 + 2172 + /* Allow platform passed information to over-write DT. */ 2168 2173 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2169 - if (res) { 2174 + if (res) 2170 2175 npct->prcm_base = devm_ioremap(&pdev->dev, res->start, 2171 2176 resource_size(res)); 2172 - if (!npct->prcm_base) { 2173 - dev_err(&pdev->dev, 2174 - "failed to ioremap PRCM registers\n"); 2175 - return -ENOMEM; 2177 + if (!npct->prcm_base) { 2178 + if (version == PINCTRL_NMK_STN8815) { 2179 + dev_info(&pdev->dev, 2180 + "No PRCM base, " 2181 + "assuming no ALT-Cx control is available\n"); 2182 + } else { 2183 + dev_err(&pdev->dev, "missing PRCM base address\n"); 2184 + return -EINVAL; 2176 2185 } 2177 - } else if (version == PINCTRL_NMK_STN8815) { 2178 - dev_info(&pdev->dev, 2179 - "No PRCM base, assume no ALT-Cx control is available\n"); 2180 - } else { 2181 - dev_err(&pdev->dev, "missing PRCM base address\n"); 2182 - return -EINVAL; 2183 2186 } 2184 2187 2185 2188 /*