From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: <linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <linus.walleij@linaro.org>, <kavyasree.kotagiri@microchip.com>,
<alexandre.belloni@bootlin.com>, <colin.foster@in-advantage.com>,
<UNGLinuxDriver@microchip.com>, <maxime.chevallier@bootlin.com>,
<michael@walle.cc>, <andy.shevchenko@gmail.com>,
Horatiu Vultur <horatiu.vultur@microchip.com>
Subject: [PATCH v3 2/2] pinctrl: ocelot: Fix pincfg
Date: Mon, 11 Jul 2022 21:21:13 +0200 [thread overview]
Message-ID: <20220711192113.3522664-3-horatiu.vultur@microchip.com> (raw)
In-Reply-To: <20220711192113.3522664-1-horatiu.vultur@microchip.com>
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: 076d9e71bcf8 ("pinctrl: ocelot: convert pinctrl to regmap")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
drivers/pinctrl/pinctrl-ocelot.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c
index 4edb36cfa161..b859e5caed09 100644
--- a/drivers/pinctrl/pinctrl-ocelot.c
+++ b/drivers/pinctrl/pinctrl-ocelot.c
@@ -1334,7 +1334,9 @@ static int ocelot_hw_get_value(struct ocelot_pinctrl *info,
if (info->pincfg) {
u32 regcfg;
- ret = regmap_read(info->pincfg, pin, ®cfg);
+ ret = regmap_read(info->pincfg,
+ pin * regmap_get_reg_stride(info->pincfg),
+ ®cfg);
if (ret)
return ret;
@@ -1368,14 +1370,18 @@ static int ocelot_pincfg_clrsetbits(struct ocelot_pinctrl *info, u32 regaddr,
u32 val;
int ret;
- ret = regmap_read(info->pincfg, regaddr, &val);
+ ret = regmap_read(info->pincfg,
+ regaddr * regmap_get_reg_stride(info->pincfg),
+ &val);
if (ret)
return ret;
val &= ~clrbits;
val |= setbits;
- ret = regmap_write(info->pincfg, regaddr, val);
+ ret = regmap_write(info->pincfg,
+ regaddr * regmap_get_reg_stride(info->pincfg),
+ val);
return ret;
}
@@ -1935,7 +1941,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 ocelot_pinctrl *info,
+ struct platform_device *pdev)
{
void __iomem *base;
@@ -1943,7 +1950,7 @@ static struct regmap *ocelot_pinctrl_create_pincfg(struct platform_device *pdev)
.reg_bits = 32,
.val_bits = 32,
.reg_stride = 4,
- .max_register = 32,
+ .max_register = info->desc->npins * 4,
.name = "pincfg",
};
@@ -2010,7 +2017,7 @@ static int ocelot_pinctrl_probe(struct platform_device *pdev)
/* Pinconf registers */
if (info->desc->confops) {
- pincfg = ocelot_pinctrl_create_pincfg(pdev);
+ pincfg = ocelot_pinctrl_create_pincfg(info, pdev);
if (IS_ERR(pincfg))
dev_dbg(dev, "Failed to create pincfg regmap\n");
else
--
2.33.0
next prev parent reply other threads:[~2022-07-11 19:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 19:21 [PATCH v3 0/2] pinctrl: ocelot: Add fixes for ocelot driver Horatiu Vultur
2022-07-11 19:21 ` [PATCH v3 1/2] pinctrl: ocelot: Fix pincfg for lan966x Horatiu Vultur
2022-07-11 19:47 ` Andy Shevchenko
2022-07-11 20:21 ` Horatiu Vultur
2022-07-12 3:53 ` Colin Foster
2022-07-11 19:21 ` Horatiu Vultur [this message]
2022-07-11 19:51 ` [PATCH v3 2/2] pinctrl: ocelot: Fix pincfg Andy Shevchenko
2022-07-11 20:26 ` Horatiu Vultur
2022-07-11 20:29 ` Andy Shevchenko
2022-07-11 20:33 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220711192113.3522664-3-horatiu.vultur@microchip.com \
--to=horatiu.vultur@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andy.shevchenko@gmail.com \
--cc=colin.foster@in-advantage.com \
--cc=kavyasree.kotagiri@microchip.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=michael@walle.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®