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

pinctrl: bcm: ns: support updated DT binding as syscon subnode

Documentation has been recently updated specifying that pinctrl should
be subnode of the CRU "syscon". Support that by using parent node for
regmap and reading "offset" property from the DT.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Rafał Miłecki and committed by
Linus Walleij
a49d784d 2ae80900

+19 -10
+19 -10
drivers/pinctrl/bcm/pinctrl-ns.c
··· 5 5 6 6 #include <linux/err.h> 7 7 #include <linux/io.h> 8 + #include <linux/mfd/syscon.h> 8 9 #include <linux/module.h> 9 10 #include <linux/of.h> 10 11 #include <linux/of_device.h> ··· 13 12 #include <linux/pinctrl/pinctrl.h> 14 13 #include <linux/pinctrl/pinmux.h> 15 14 #include <linux/platform_device.h> 15 + #include <linux/regmap.h> 16 16 #include <linux/slab.h> 17 17 18 18 #define FLAG_BCM4708 BIT(1) ··· 24 22 struct device *dev; 25 23 unsigned int chipset_flag; 26 24 struct pinctrl_dev *pctldev; 27 - void __iomem *base; 25 + struct regmap *regmap; 26 + u32 offset; 28 27 29 28 struct pinctrl_desc pctldesc; 30 29 struct ns_pinctrl_group *groups; ··· 232 229 unset |= BIT(pin_number); 233 230 } 234 231 235 - tmp = readl(ns_pinctrl->base); 232 + regmap_read(ns_pinctrl->regmap, ns_pinctrl->offset, &tmp); 236 233 tmp &= ~unset; 237 - writel(tmp, ns_pinctrl->base); 234 + regmap_write(ns_pinctrl->regmap, ns_pinctrl->offset, tmp); 238 235 239 236 return 0; 240 237 } ··· 266 263 static int ns_pinctrl_probe(struct platform_device *pdev) 267 264 { 268 265 struct device *dev = &pdev->dev; 266 + struct device_node *np = dev->of_node; 269 267 const struct of_device_id *of_id; 270 268 struct ns_pinctrl *ns_pinctrl; 271 269 struct pinctrl_desc *pctldesc; 272 270 struct pinctrl_pin_desc *pin; 273 271 struct ns_pinctrl_group *group; 274 272 struct ns_pinctrl_function *function; 275 - struct resource *res; 276 273 int i; 277 274 278 275 ns_pinctrl = devm_kzalloc(dev, sizeof(*ns_pinctrl), GFP_KERNEL); ··· 290 287 return -EINVAL; 291 288 ns_pinctrl->chipset_flag = (uintptr_t)of_id->data; 292 289 293 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 294 - "cru_gpio_control"); 295 - ns_pinctrl->base = devm_ioremap_resource(dev, res); 296 - if (IS_ERR(ns_pinctrl->base)) { 297 - dev_err(dev, "Failed to map pinctrl regs\n"); 298 - return PTR_ERR(ns_pinctrl->base); 290 + ns_pinctrl->regmap = syscon_node_to_regmap(of_get_parent(np)); 291 + if (IS_ERR(ns_pinctrl->regmap)) { 292 + int err = PTR_ERR(ns_pinctrl->regmap); 293 + 294 + dev_err(dev, "Failed to map pinctrl regs: %d\n", err); 295 + 296 + return err; 297 + } 298 + 299 + if (of_property_read_u32(np, "offset", &ns_pinctrl->offset)) { 300 + dev_err(dev, "Failed to get register offset\n"); 301 + return -ENOENT; 299 302 } 300 303 301 304 memcpy(pctldesc, &ns_pinctrl_desc, sizeof(*pctldesc));