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

pinctrl: spear: spear: Convert to regmap

Resources need to be shared between pinmux and plgpio.

Use regmap (syscon) to access resources to allow an
easy way to share resources.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20211202095255.165797-2-herve.codina@bootlin.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Herve Codina and committed by
Linus Walleij
d11db044 896568e5

+15 -7
+7 -3
drivers/pinctrl/spear/pinctrl-spear.c
··· 14 14 */ 15 15 16 16 #include <linux/err.h> 17 + #include <linux/mfd/syscon.h> 17 18 #include <linux/module.h> 18 19 #include <linux/of.h> 19 20 #include <linux/of_address.h> ··· 368 367 if (!pmx) 369 368 return -ENOMEM; 370 369 371 - pmx->vbase = devm_platform_ioremap_resource(pdev, 0); 372 - if (IS_ERR(pmx->vbase)) 373 - return PTR_ERR(pmx->vbase); 370 + pmx->regmap = device_node_to_regmap(np); 371 + if (IS_ERR(pmx->regmap)) { 372 + dev_err(&pdev->dev, "Init regmap failed (%pe).\n", 373 + pmx->regmap); 374 + return PTR_ERR(pmx->regmap); 375 + } 374 376 375 377 pmx->dev = &pdev->dev; 376 378 pmx->machdata = machdata;
+8 -4
drivers/pinctrl/spear/pinctrl-spear.h
··· 15 15 #include <linux/gpio/driver.h> 16 16 #include <linux/io.h> 17 17 #include <linux/pinctrl/pinctrl.h> 18 + #include <linux/regmap.h> 18 19 #include <linux/types.h> 19 20 20 21 struct platform_device; ··· 173 172 * @dev: pointer to struct dev of platform_device registered 174 173 * @pctl: pointer to struct pinctrl_dev 175 174 * @machdata: pointer to SoC or machine specific structure 176 - * @vbase: virtual base address of pinmux controller 175 + * @regmap: regmap of pinmux controller 177 176 */ 178 177 struct spear_pmx { 179 178 struct device *dev; 180 179 struct pinctrl_dev *pctl; 181 180 struct spear_pinctrl_machdata *machdata; 182 - void __iomem *vbase; 181 + struct regmap *regmap; 183 182 }; 184 183 185 184 /* exported routines */ 186 185 static inline u32 pmx_readl(struct spear_pmx *pmx, u32 reg) 187 186 { 188 - return readl_relaxed(pmx->vbase + reg); 187 + u32 val; 188 + 189 + regmap_read(pmx->regmap, reg, &val); 190 + return val; 189 191 } 190 192 191 193 static inline void pmx_writel(struct spear_pmx *pmx, u32 val, u32 reg) 192 194 { 193 - writel_relaxed(val, pmx->vbase + reg); 195 + regmap_write(pmx->regmap, reg, val); 194 196 } 195 197 196 198 void pmx_init_addr(struct spear_pinctrl_machdata *machdata, u16 reg);