1 From a49d784d5a8272d0f63c448fe8dc69e589db006e Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Tue, 18 Dec 2018 16:58:08 +0100
4 Subject: [PATCH] pinctrl: bcm: ns: support updated DT binding as syscon
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Documentation has been recently updated specifying that pinctrl should
11 be subnode of the CRU "syscon". Support that by using parent node for
12 regmap and reading "offset" property from the DT.
14 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
15 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
17 drivers/pinctrl/bcm/pinctrl-ns.c | 29 +++++++++++++++++++----------
18 1 file changed, 19 insertions(+), 10 deletions(-)
20 --- a/drivers/pinctrl/bcm/pinctrl-ns.c
21 +++ b/drivers/pinctrl/bcm/pinctrl-ns.c
24 #include <linux/err.h>
26 +#include <linux/mfd/syscon.h>
27 #include <linux/module.h>
29 #include <linux/of_device.h>
31 #include <linux/pinctrl/pinctrl.h>
32 #include <linux/pinctrl/pinmux.h>
33 #include <linux/platform_device.h>
34 +#include <linux/regmap.h>
35 #include <linux/slab.h>
37 #define FLAG_BCM4708 BIT(1)
38 @@ -22,7 +24,8 @@ struct ns_pinctrl {
40 unsigned int chipset_flag;
41 struct pinctrl_dev *pctldev;
43 + struct regmap *regmap;
46 struct pinctrl_desc pctldesc;
47 struct ns_pinctrl_group *groups;
48 @@ -229,9 +232,9 @@ static int ns_pinctrl_set_mux(struct pin
49 unset |= BIT(pin_number);
52 - tmp = readl(ns_pinctrl->base);
53 + regmap_read(ns_pinctrl->regmap, ns_pinctrl->offset, &tmp);
55 - writel(tmp, ns_pinctrl->base);
56 + regmap_write(ns_pinctrl->regmap, ns_pinctrl->offset, tmp);
60 @@ -263,13 +266,13 @@ static const struct of_device_id ns_pinc
61 static int ns_pinctrl_probe(struct platform_device *pdev)
63 struct device *dev = &pdev->dev;
64 + struct device_node *np = dev->of_node;
65 const struct of_device_id *of_id;
66 struct ns_pinctrl *ns_pinctrl;
67 struct pinctrl_desc *pctldesc;
68 struct pinctrl_pin_desc *pin;
69 struct ns_pinctrl_group *group;
70 struct ns_pinctrl_function *function;
71 - struct resource *res;
74 ns_pinctrl = devm_kzalloc(dev, sizeof(*ns_pinctrl), GFP_KERNEL);
75 @@ -287,12 +290,18 @@ static int ns_pinctrl_probe(struct platf
77 ns_pinctrl->chipset_flag = (uintptr_t)of_id->data;
79 - res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
80 - "cru_gpio_control");
81 - ns_pinctrl->base = devm_ioremap_resource(dev, res);
82 - if (IS_ERR(ns_pinctrl->base)) {
83 - dev_err(dev, "Failed to map pinctrl regs\n");
84 - return PTR_ERR(ns_pinctrl->base);
85 + ns_pinctrl->regmap = syscon_node_to_regmap(of_get_parent(np));
86 + if (IS_ERR(ns_pinctrl->regmap)) {
87 + int err = PTR_ERR(ns_pinctrl->regmap);
89 + dev_err(dev, "Failed to map pinctrl regs: %d\n", err);
94 + if (of_property_read_u32(np, "offset", &ns_pinctrl->offset)) {
95 + dev_err(dev, "Failed to get register offset\n");
99 memcpy(pctldesc, &ns_pinctrl_desc, sizeof(*pctldesc));