Commit ba9c4745 authored by Horatiu Vultur's avatar Horatiu Vultur Committed by Linus Walleij

pinctrl: ocelot: Fix pincfg

The blamed commit changed to use regmaps instead of __iomem. But it
didn't update the register offsets to be at word offset, so it uses byte
offset.
Another issue with the same commit is that it has a limit of 32 registers
which is incorrect. The sparx5 has 64 while lan966x has 77.

Fixes: 076d9e71 ("pinctrl: ocelot: convert pinctrl to regmap")
Acked-by: default avatarColin Foster <colin.foster@in-advantage.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20220713193750.4079621-3-horatiu.vultur@microchip.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent dc62db71
...@@ -1334,7 +1334,9 @@ static int ocelot_hw_get_value(struct ocelot_pinctrl *info, ...@@ -1334,7 +1334,9 @@ static int ocelot_hw_get_value(struct ocelot_pinctrl *info,
const struct ocelot_pincfg_data *opd = info->pincfg_data; const struct ocelot_pincfg_data *opd = info->pincfg_data;
u32 regcfg; u32 regcfg;
ret = regmap_read(info->pincfg, pin, &regcfg); ret = regmap_read(info->pincfg,
pin * regmap_get_reg_stride(info->pincfg),
&regcfg);
if (ret) if (ret)
return ret; return ret;
...@@ -1366,14 +1368,18 @@ static int ocelot_pincfg_clrsetbits(struct ocelot_pinctrl *info, u32 regaddr, ...@@ -1366,14 +1368,18 @@ static int ocelot_pincfg_clrsetbits(struct ocelot_pinctrl *info, u32 regaddr,
u32 val; u32 val;
int ret; int ret;
ret = regmap_read(info->pincfg, regaddr, &val); ret = regmap_read(info->pincfg,
regaddr * regmap_get_reg_stride(info->pincfg),
&val);
if (ret) if (ret)
return ret; return ret;
val &= ~clrbits; val &= ~clrbits;
val |= setbits; val |= setbits;
ret = regmap_write(info->pincfg, regaddr, val); ret = regmap_write(info->pincfg,
regaddr * regmap_get_reg_stride(info->pincfg),
val);
return ret; return ret;
} }
...@@ -1933,7 +1939,8 @@ static const struct of_device_id ocelot_pinctrl_of_match[] = { ...@@ -1933,7 +1939,8 @@ static const struct of_device_id ocelot_pinctrl_of_match[] = {
{}, {},
}; };
static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev) static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev,
const struct ocelot_pinctrl *info)
{ {
void __iomem *base; void __iomem *base;
...@@ -1941,7 +1948,7 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev) ...@@ -1941,7 +1948,7 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev)
.reg_bits = 32, .reg_bits = 32,
.val_bits = 32, .val_bits = 32,
.reg_stride = 4, .reg_stride = 4,
.max_register = 32, .max_register = info->desc->npins * 4,
.name = "pincfg", .name = "pincfg",
}; };
...@@ -2009,7 +2016,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev) ...@@ -2009,7 +2016,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
/* Pinconf registers */ /* Pinconf registers */
if (info->desc->confops) { if (info->desc->confops) {
pincfg = ocelot_pinctrl_create_pincfg(pdev); pincfg = ocelot_pinctrl_create_pincfg(pdev, info);
if (IS_ERR(pincfg)) if (IS_ERR(pincfg))
dev_dbg(dev, "Failed to create pincfg regmap\n"); dev_dbg(dev, "Failed to create pincfg regmap\n");
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment