linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: microchip-sgpio: Fix support for regmap
@ 2022-01-25 16:12 Horatiu Vultur
  2022-01-25 16:46 ` Colin Foster
  2022-01-27 12:42 ` Steen.Hegelund
  0 siblings, 2 replies; 6+ messages in thread
From: Horatiu Vultur @ 2022-01-25 16:12 UTC (permalink / raw)
  To: linux-arm-kernel, linux-gpio, linux-kernel
  Cc: lars.povlsen, Steen.Hegelund, UNGLinuxDriver, linus.walleij,
	colin.foster, Horatiu Vultur

Initially the driver accessed the registers using u32 __iomem but then
in the blamed commit it changed it to use regmap. The problem is that now
the offset of the registers is not calculated anymore at word offset but
at byte offset. Therefore make sure to multiply the offset with word size.

Fixes: 2afbbab45c261a ("pinctrl: microchip-sgpio: update to support regmap")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 drivers/pinctrl/pinctrl-microchip-sgpio.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c
index 8e081c90bdb2..2999c98bbdee 100644
--- a/drivers/pinctrl/pinctrl-microchip-sgpio.c
+++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c
@@ -98,6 +98,12 @@ static const struct sgpio_properties properties_sparx5 = {
 	.regoff = { 0x00, 0x06, 0x26, 0x04, 0x05, 0x2a, 0x32, 0x3a, 0x3e, 0x42 },
 };
 
+static const struct regmap_config regmap_config = {
+		.reg_bits = 32,
+		.val_bits = 32,
+		.reg_stride = 4,
+};
+
 static const char * const functions[] = { "gpio" };
 
 struct sgpio_bank {
@@ -137,7 +143,7 @@ static inline int sgpio_addr_to_pin(struct sgpio_priv *priv, int port, int bit)
 
 static inline u32 sgpio_get_addr(struct sgpio_priv *priv, u32 rno, u32 off)
 {
-	return priv->properties->regoff[rno] + off;
+	return (priv->properties->regoff[rno] + off) * regmap_config.reg_stride;
 }
 
 static u32 sgpio_readl(struct sgpio_priv *priv, u32 rno, u32 off)
@@ -821,11 +827,6 @@ static int microchip_sgpio_probe(struct platform_device *pdev)
 	struct clk *clk;
 	u32 __iomem *regs;
 	u32 val;
-	struct regmap_config regmap_config = {
-		.reg_bits = 32,
-		.val_bits = 32,
-		.reg_stride = 4,
-	};
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: Fix support for regmap
  2022-01-25 16:12 [PATCH] pinctrl: microchip-sgpio: Fix support for regmap Horatiu Vultur
@ 2022-01-25 16:46 ` Colin Foster
  2022-01-27 10:40   ` Horatiu Vultur
  2022-01-28 14:19   ` Andy Shevchenko
  2022-01-27 12:42 ` Steen.Hegelund
  1 sibling, 2 replies; 6+ messages in thread
From: Colin Foster @ 2022-01-25 16:46 UTC (permalink / raw)
  To: Horatiu Vultur
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, lars.povlsen,
	Steen.Hegelund, UNGLinuxDriver, linus.walleij

Hi Horatiu,

On Tue, Jan 25, 2022 at 05:12:45PM +0100, Horatiu Vultur wrote:
> Initially the driver accessed the registers using u32 __iomem but then
> in the blamed commit it changed it to use regmap. The problem is that now
> the offset of the registers is not calculated anymore at word offset but
> at byte offset. Therefore make sure to multiply the offset with word size.
> 

Sorry about this one. I see it must have slipped through the cracks
because I had made the same change in my tree. The only difference is I
had copied reg_stride into sgpio_priv instead of making regmap_config
file-scope. For what its worth, with apologies:

Reviewed-by: Colin Foster <colin.foster@in-advantage.com>

> Fixes: 2afbbab45c261a ("pinctrl: microchip-sgpio: update to support regmap")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
>  drivers/pinctrl/pinctrl-microchip-sgpio.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c
> index 8e081c90bdb2..2999c98bbdee 100644
> --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c
> +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c
> @@ -98,6 +98,12 @@ static const struct sgpio_properties properties_sparx5 = {
>  	.regoff = { 0x00, 0x06, 0x26, 0x04, 0x05, 0x2a, 0x32, 0x3a, 0x3e, 0x42 },
>  };
>  
> +static const struct regmap_config regmap_config = {
> +		.reg_bits = 32,
> +		.val_bits = 32,
> +		.reg_stride = 4,
> +};
> +
>  static const char * const functions[] = { "gpio" };
>  
>  struct sgpio_bank {
> @@ -137,7 +143,7 @@ static inline int sgpio_addr_to_pin(struct sgpio_priv *priv, int port, int bit)
>  
>  static inline u32 sgpio_get_addr(struct sgpio_priv *priv, u32 rno, u32 off)
>  {
> -	return priv->properties->regoff[rno] + off;
> +	return (priv->properties->regoff[rno] + off) * regmap_config.reg_stride;
>  }
>  
>  static u32 sgpio_readl(struct sgpio_priv *priv, u32 rno, u32 off)
> @@ -821,11 +827,6 @@ static int microchip_sgpio_probe(struct platform_device *pdev)
>  	struct clk *clk;
>  	u32 __iomem *regs;
>  	u32 val;
> -	struct regmap_config regmap_config = {
> -		.reg_bits = 32,
> -		.val_bits = 32,
> -		.reg_stride = 4,
> -	};
>  
>  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: Fix support for regmap
  2022-01-25 16:46 ` Colin Foster
@ 2022-01-27 10:40   ` Horatiu Vultur
  2022-01-28 14:19   ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Horatiu Vultur @ 2022-01-27 10:40 UTC (permalink / raw)
  To: Colin Foster
  Cc: linux-arm-kernel, linux-gpio, linux-kernel, lars.povlsen,
	Steen.Hegelund, UNGLinuxDriver, linus.walleij

The 01/25/2022 08:46, Colin Foster wrote:
> 
> Hi Horatiu,

Hi Colin,

> 
> On Tue, Jan 25, 2022 at 05:12:45PM +0100, Horatiu Vultur wrote:
> > Initially the driver accessed the registers using u32 __iomem but then
> > in the blamed commit it changed it to use regmap. The problem is that now
> > the offset of the registers is not calculated anymore at word offset but
> > at byte offset. Therefore make sure to multiply the offset with word size.
> >
> 
> Sorry about this one. I see it must have slipped through the cracks
> because I had made the same change in my tree. The only difference is I
> had copied reg_stride into sgpio_priv instead of making regmap_config
> file-scope. For what its worth, with apologies:

No worries, sorry that I missed your patch initially. And thanks for
reviewing this patch.

> 
> Reviewed-by: Colin Foster <colin.foster@in-advantage.com>



> 
> > Fixes: 2afbbab45c261a ("pinctrl: microchip-sgpio: update to support regmap")
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> > ---
> >  drivers/pinctrl/pinctrl-microchip-sgpio.c | 13 +++++++------
> >  1 file changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c
> > index 8e081c90bdb2..2999c98bbdee 100644
> > --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c
> > +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c
> > @@ -98,6 +98,12 @@ static const struct sgpio_properties properties_sparx5 = {
> >       .regoff = { 0x00, 0x06, 0x26, 0x04, 0x05, 0x2a, 0x32, 0x3a, 0x3e, 0x42 },
> >  };
> >
> > +static const struct regmap_config regmap_config = {
> > +             .reg_bits = 32,
> > +             .val_bits = 32,
> > +             .reg_stride = 4,
> > +};
> > +
> >  static const char * const functions[] = { "gpio" };
> >
> >  struct sgpio_bank {
> > @@ -137,7 +143,7 @@ static inline int sgpio_addr_to_pin(struct sgpio_priv *priv, int port, int bit)
> >
> >  static inline u32 sgpio_get_addr(struct sgpio_priv *priv, u32 rno, u32 off)
> >  {
> > -     return priv->properties->regoff[rno] + off;
> > +     return (priv->properties->regoff[rno] + off) * regmap_config.reg_stride;
> >  }
> >
> >  static u32 sgpio_readl(struct sgpio_priv *priv, u32 rno, u32 off)
> > @@ -821,11 +827,6 @@ static int microchip_sgpio_probe(struct platform_device *pdev)
> >       struct clk *clk;
> >       u32 __iomem *regs;
> >       u32 val;
> > -     struct regmap_config regmap_config = {
> > -             .reg_bits = 32,
> > -             .val_bits = 32,
> > -             .reg_stride = 4,
> > -     };
> >
> >       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> >       if (!priv)
> > --
> > 2.33.0
> >

-- 
/Horatiu

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: Fix support for regmap
  2022-01-25 16:12 [PATCH] pinctrl: microchip-sgpio: Fix support for regmap Horatiu Vultur
  2022-01-25 16:46 ` Colin Foster
@ 2022-01-27 12:42 ` Steen.Hegelund
  1 sibling, 0 replies; 6+ messages in thread
From: Steen.Hegelund @ 2022-01-27 12:42 UTC (permalink / raw)
  To: linux-arm-kernel, linux-gpio, linux-kernel, Horatiu.Vultur
  Cc: Lars.Povlsen, UNGLinuxDriver, linus.walleij, colin.foster

Good catch Horatiu.

BR
Steen

Acked-by: Steen Hegelund <Steen.Hegelund@microchip.com>

On Tue, 2022-01-25 at 17:12 +0100, Horatiu Vultur wrote:
> Initially the driver accessed the registers using u32 __iomem but then
> in the blamed commit it changed it to use regmap. The problem is that now
> the offset of the registers is not calculated anymore at word offset but
> at byte offset. Therefore make sure to multiply the offset with word size.
> 
> Fixes: 2afbbab45c261a ("pinctrl: microchip-sgpio: update to support regmap")
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: Fix support for regmap
  2022-01-25 16:46 ` Colin Foster
  2022-01-27 10:40   ` Horatiu Vultur
@ 2022-01-28 14:19   ` Andy Shevchenko
  2022-01-28 21:32     ` Colin Foster
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2022-01-28 14:19 UTC (permalink / raw)
  To: Colin Foster
  Cc: Horatiu Vultur, linux-arm Mailing List, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Lars Povlsen, Steen.Hegelund,
	Microchip Linux Driver Support, Linus Walleij

On Wed, Jan 26, 2022 at 3:19 AM Colin Foster
<colin.foster@in-advantage.com> wrote:
> On Tue, Jan 25, 2022 at 05:12:45PM +0100, Horatiu Vultur wrote:

> The only difference is I
> had copied reg_stride into sgpio_priv instead of making regmap_config
> file-scope.

I'm wondering if we may access config via a pointer to regmap.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: microchip-sgpio: Fix support for regmap
  2022-01-28 14:19   ` Andy Shevchenko
@ 2022-01-28 21:32     ` Colin Foster
  0 siblings, 0 replies; 6+ messages in thread
From: Colin Foster @ 2022-01-28 21:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Horatiu Vultur, linux-arm Mailing List, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List, Lars Povlsen, Steen.Hegelund,
	Microchip Linux Driver Support, Linus Walleij

On Fri, Jan 28, 2022 at 04:19:12PM +0200, Andy Shevchenko wrote:
> On Wed, Jan 26, 2022 at 3:19 AM Colin Foster
> <colin.foster@in-advantage.com> wrote:
> > On Tue, Jan 25, 2022 at 05:12:45PM +0100, Horatiu Vultur wrote:
> 
> > The only difference is I
> > had copied reg_stride into sgpio_priv instead of making regmap_config
> > file-scope.
> 
> I'm wondering if we may access config via a pointer to regmap.

Ooh... regmap_get_reg_stride() exists. I didn't see that before. That
seems like it is the answer.

I don't know the etiquette here. Ask Horatiu to re-submit, or me send
along a v2, or something else.

> 
> -- 
> With Best Regards,
> Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-28 21:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 16:12 [PATCH] pinctrl: microchip-sgpio: Fix support for regmap Horatiu Vultur
2022-01-25 16:46 ` Colin Foster
2022-01-27 10:40   ` Horatiu Vultur
2022-01-28 14:19   ` Andy Shevchenko
2022-01-28 21:32     ` Colin Foster
2022-01-27 12:42 ` Steen.Hegelund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).