Skip to content

Commit a49d784

Browse files
Rafał Miłeckilinusw
authored andcommitted
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>
1 parent 2ae8090 commit a49d784

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

drivers/pinctrl/bcm/pinctrl-ns.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55

66
#include <linux/err.h>
77
#include <linux/io.h>
8+
#include <linux/mfd/syscon.h>
89
#include <linux/module.h>
910
#include <linux/of.h>
1011
#include <linux/of_device.h>
1112
#include <linux/pinctrl/pinconf-generic.h>
1213
#include <linux/pinctrl/pinctrl.h>
1314
#include <linux/pinctrl/pinmux.h>
1415
#include <linux/platform_device.h>
16+
#include <linux/regmap.h>
1517
#include <linux/slab.h>
1618

1719
#define FLAG_BCM4708 BIT(1)
@@ -22,7 +24,8 @@ struct ns_pinctrl {
2224
struct device *dev;
2325
unsigned int chipset_flag;
2426
struct pinctrl_dev *pctldev;
25-
void __iomem *base;
27+
struct regmap *regmap;
28+
u32 offset;
2629

2730
struct pinctrl_desc pctldesc;
2831
struct ns_pinctrl_group *groups;
@@ -229,9 +232,9 @@ static int ns_pinctrl_set_mux(struct pinctrl_dev *pctrl_dev,
229232
unset |= BIT(pin_number);
230233
}
231234

232-
tmp = readl(ns_pinctrl->base);
235+
regmap_read(ns_pinctrl->regmap, ns_pinctrl->offset, &tmp);
233236
tmp &= ~unset;
234-
writel(tmp, ns_pinctrl->base);
237+
regmap_write(ns_pinctrl->regmap, ns_pinctrl->offset, tmp);
235238

236239
return 0;
237240
}
@@ -263,13 +266,13 @@ static const struct of_device_id ns_pinctrl_of_match_table[] = {
263266
static int ns_pinctrl_probe(struct platform_device *pdev)
264267
{
265268
struct device *dev = &pdev->dev;
269+
struct device_node *np = dev->of_node;
266270
const struct of_device_id *of_id;
267271
struct ns_pinctrl *ns_pinctrl;
268272
struct pinctrl_desc *pctldesc;
269273
struct pinctrl_pin_desc *pin;
270274
struct ns_pinctrl_group *group;
271275
struct ns_pinctrl_function *function;
272-
struct resource *res;
273276
int i;
274277

275278
ns_pinctrl = devm_kzalloc(dev, sizeof(*ns_pinctrl), GFP_KERNEL);
@@ -287,12 +290,18 @@ static int ns_pinctrl_probe(struct platform_device *pdev)
287290
return -EINVAL;
288291
ns_pinctrl->chipset_flag = (uintptr_t)of_id->data;
289292

290-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
291-
"cru_gpio_control");
292-
ns_pinctrl->base = devm_ioremap_resource(dev, res);
293-
if (IS_ERR(ns_pinctrl->base)) {
294-
dev_err(dev, "Failed to map pinctrl regs\n");
295-
return PTR_ERR(ns_pinctrl->base);
293+
ns_pinctrl->regmap = syscon_node_to_regmap(of_get_parent(np));
294+
if (IS_ERR(ns_pinctrl->regmap)) {
295+
int err = PTR_ERR(ns_pinctrl->regmap);
296+
297+
dev_err(dev, "Failed to map pinctrl regs: %d\n", err);
298+
299+
return err;
300+
}
301+
302+
if (of_property_read_u32(np, "offset", &ns_pinctrl->offset)) {
303+
dev_err(dev, "Failed to get register offset\n");
304+
return -ENOENT;
296305
}
297306

298307
memcpy(pctldesc, &ns_pinctrl_desc, sizeof(*pctldesc));

0 commit comments

Comments
 (0)