linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c
@ 2023-09-26  9:06 Bartosz Golaszewski
  2023-09-26  9:11 ` Linus Walleij
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2023-09-26  9:06 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Harvey Hunt,
	Paul Cercueil, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra
  Cc: linux-gpio, linux-kernel, linux-mtd, linux-mips,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

We have a special place for OF polarity quirks in gpiolib-of.c. Let's
move this over there so that it doesn't pollute the driver.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
This is an alternative to the previous patch that instead of replacing
one active-low setter with another, just moves the quirk over to
gpiolib-of.c

 drivers/gpio/gpiolib-of.c                       |  9 +++++++++
 drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 12 ------------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 5515f32cf19b..58c0bbe9d569 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -192,6 +192,15 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
 		 */
 		{ "himax,hx8357",	"gpios-reset",	false },
 		{ "himax,hx8369",	"gpios-reset",	false },
+		/*
+		 * The rb-gpios semantics was undocumented and qi,lb60 (along with
+		 * the ingenic driver) got it wrong. The active state encodes the
+		 * NAND ready state, which is high level. Since there's no signal
+		 * inverter on this board, it should be active-high. Let's fix that
+		 * here for older DTs so we can re-use the generic nand_gpio_waitrdy()
+		 * helper, and be consistent with what other drivers do.
+		 */
+		{ "qi,lb60",		"rb-gpios",	true },
 #endif
 	};
 	unsigned int i;
diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
index 6748226b8bd1..c816dc137245 100644
--- a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
+++ b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
@@ -380,18 +380,6 @@ static int ingenic_nand_init_chip(struct platform_device *pdev,
 		return ret;
 	}
 
-	/*
-	 * The rb-gpios semantics was undocumented and qi,lb60 (along with
-	 * the ingenic driver) got it wrong. The active state encodes the
-	 * NAND ready state, which is high level. Since there's no signal
-	 * inverter on this board, it should be active-high. Let's fix that
-	 * here for older DTs so we can re-use the generic nand_gpio_waitrdy()
-	 * helper, and be consistent with what other drivers do.
-	 */
-	if (of_machine_is_compatible("qi,lb60") &&
-	    gpiod_is_active_low(nand->busy_gpio))
-		gpiod_toggle_active_low(nand->busy_gpio);
-
 	nand->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_LOW);
 
 	if (IS_ERR(nand->wp_gpio)) {
-- 
2.39.2


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

* Re: [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c
  2023-09-26  9:06 [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c Bartosz Golaszewski
@ 2023-09-26  9:11 ` Linus Walleij
  2023-09-26  9:16 ` Miquel Raynal
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2023-09-26  9:11 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andy Shevchenko, Harvey Hunt, Paul Cercueil, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, linux-gpio, linux-kernel,
	linux-mtd, linux-mips, Bartosz Golaszewski

On Tue, Sep 26, 2023 at 11:06 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> We have a special place for OF polarity quirks in gpiolib-of.c. Let's
> move this over there so that it doesn't pollute the driver.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

This is nice.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c
  2023-09-26  9:06 [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c Bartosz Golaszewski
  2023-09-26  9:11 ` Linus Walleij
@ 2023-09-26  9:16 ` Miquel Raynal
  2023-09-26  9:26   ` Paul Cercueil
  2023-09-26 11:58 ` Andy Shevchenko
  2023-09-27 11:15 ` Bartosz Golaszewski
  3 siblings, 1 reply; 6+ messages in thread
From: Miquel Raynal @ 2023-09-26  9:16 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Andy Shevchenko, Harvey Hunt, Paul Cercueil,
	Richard Weinberger, Vignesh Raghavendra, linux-gpio, linux-kernel,
	linux-mtd, linux-mips, Bartosz Golaszewski

Hi Bartosz,

brgl@bgdev.pl wrote on Tue, 26 Sep 2023 11:06:23 +0200:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> We have a special place for OF polarity quirks in gpiolib-of.c. Let's
> move this over there so that it doesn't pollute the driver.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> This is an alternative to the previous patch that instead of replacing
> one active-low setter with another, just moves the quirk over to
> gpiolib-of.c
> 
>  drivers/gpio/gpiolib-of.c                       |  9 +++++++++
>  drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 12 ------------
>  2 files changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 5515f32cf19b..58c0bbe9d569 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -192,6 +192,15 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
>  		 */
>  		{ "himax,hx8357",	"gpios-reset",	false },
>  		{ "himax,hx8369",	"gpios-reset",	false },
> +		/*
> +		 * The rb-gpios semantics was undocumented and qi,lb60 (along with
> +		 * the ingenic driver) got it wrong. The active state encodes the
> +		 * NAND ready state, which is high level. Since there's no signal
> +		 * inverter on this board, it should be active-high. Let's fix that
> +		 * here for older DTs so we can re-use the generic nand_gpio_waitrdy()
> +		 * helper, and be consistent with what other drivers do.
> +		 */
> +		{ "qi,lb60",		"rb-gpios",	true },

I didn't know about such a list, interesting. Better be aware when
debugging :)

IIRC Linus was fine, so if Paul also agrees I guess this is better
taking through the gpio tree? I don't have any ingenic related changes
queued right now so feel free to take it.

Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Thanks,
Miquèl

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

* Re: [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c
  2023-09-26  9:16 ` Miquel Raynal
@ 2023-09-26  9:26   ` Paul Cercueil
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Cercueil @ 2023-09-26  9:26 UTC (permalink / raw)
  To: Miquel Raynal, Bartosz Golaszewski
  Cc: Linus Walleij, Andy Shevchenko, Harvey Hunt, Richard Weinberger,
	Vignesh Raghavendra, linux-gpio, linux-kernel, linux-mtd,
	linux-mips, Bartosz Golaszewski

Hi,

Le mardi 26 septembre 2023 à 11:16 +0200, Miquel Raynal a écrit :
> Hi Bartosz,
> 
> brgl@bgdev.pl wrote on Tue, 26 Sep 2023 11:06:23 +0200:
> 
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > 
> > We have a special place for OF polarity quirks in gpiolib-of.c.
> > Let's
> > move this over there so that it doesn't pollute the driver.
> > 
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > ---
> > This is an alternative to the previous patch that instead of
> > replacing
> > one active-low setter with another, just moves the quirk over to
> > gpiolib-of.c
> > 
> >  drivers/gpio/gpiolib-of.c                       |  9 +++++++++
> >  drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 12 ------------
> >  2 files changed, 9 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> > index 5515f32cf19b..58c0bbe9d569 100644
> > --- a/drivers/gpio/gpiolib-of.c
> > +++ b/drivers/gpio/gpiolib-of.c
> > @@ -192,6 +192,15 @@ static void of_gpio_try_fixup_polarity(const
> > struct device_node *np,
> >                  */
> >                 { "himax,hx8357",       "gpios-reset",  false },
> >                 { "himax,hx8369",       "gpios-reset",  false },
> > +               /*
> > +                * The rb-gpios semantics was undocumented and
> > qi,lb60 (along with
> > +                * the ingenic driver) got it wrong. The active
> > state encodes the
> > +                * NAND ready state, which is high level. Since
> > there's no signal
> > +                * inverter on this board, it should be active-
> > high. Let's fix that
> > +                * here for older DTs so we can re-use the generic
> > nand_gpio_waitrdy()
> > +                * helper, and be consistent with what other
> > drivers do.
> > +                */
> > +               { "qi,lb60",            "rb-gpios",     true },
> 
> I didn't know about such a list, interesting. Better be aware when
> debugging :)
> 
> IIRC Linus was fine, so if Paul also agrees I guess this is better
> taking through the gpio tree? I don't have any ingenic related
> changes
> queued right now so feel free to take it.

Works for me.

> 
> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>

Acked-by: Paul Cercueil <paul@crapouillou.net>

> Thanks,
> Miquèl

Cheers,
-Paul

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

* Re: [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c
  2023-09-26  9:06 [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c Bartosz Golaszewski
  2023-09-26  9:11 ` Linus Walleij
  2023-09-26  9:16 ` Miquel Raynal
@ 2023-09-26 11:58 ` Andy Shevchenko
  2023-09-27 11:15 ` Bartosz Golaszewski
  3 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-09-26 11:58 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Harvey Hunt, Paul Cercueil, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, linux-gpio, linux-kernel,
	linux-mtd, linux-mips, Bartosz Golaszewski

On Tue, Sep 26, 2023 at 11:06:23AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> We have a special place for OF polarity quirks in gpiolib-of.c. Let's
> move this over there so that it doesn't pollute the driver.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> This is an alternative to the previous patch that instead of replacing
> one active-low setter with another, just moves the quirk over to
> gpiolib-of.c

Much better than that in my opinion.
Reviewed-by: Andy Shevchenko <andy@kernel.org>

>  drivers/gpio/gpiolib-of.c                       |  9 +++++++++
>  drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 12 ------------
>  2 files changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 5515f32cf19b..58c0bbe9d569 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -192,6 +192,15 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
>  		 */
>  		{ "himax,hx8357",	"gpios-reset",	false },
>  		{ "himax,hx8369",	"gpios-reset",	false },
> +		/*
> +		 * The rb-gpios semantics was undocumented and qi,lb60 (along with
> +		 * the ingenic driver) got it wrong. The active state encodes the
> +		 * NAND ready state, which is high level. Since there's no signal
> +		 * inverter on this board, it should be active-high. Let's fix that
> +		 * here for older DTs so we can re-use the generic nand_gpio_waitrdy()
> +		 * helper, and be consistent with what other drivers do.
> +		 */
> +		{ "qi,lb60",		"rb-gpios",	true },
>  #endif
>  	};
>  	unsigned int i;
> diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
> index 6748226b8bd1..c816dc137245 100644
> --- a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
> +++ b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
> @@ -380,18 +380,6 @@ static int ingenic_nand_init_chip(struct platform_device *pdev,
>  		return ret;
>  	}
>  
> -	/*
> -	 * The rb-gpios semantics was undocumented and qi,lb60 (along with
> -	 * the ingenic driver) got it wrong. The active state encodes the
> -	 * NAND ready state, which is high level. Since there's no signal
> -	 * inverter on this board, it should be active-high. Let's fix that
> -	 * here for older DTs so we can re-use the generic nand_gpio_waitrdy()
> -	 * helper, and be consistent with what other drivers do.
> -	 */
> -	if (of_machine_is_compatible("qi,lb60") &&
> -	    gpiod_is_active_low(nand->busy_gpio))
> -		gpiod_toggle_active_low(nand->busy_gpio);
> -
>  	nand->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_LOW);
>  
>  	if (IS_ERR(nand->wp_gpio)) {
> -- 
> 2.39.2
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c
  2023-09-26  9:06 [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2023-09-26 11:58 ` Andy Shevchenko
@ 2023-09-27 11:15 ` Bartosz Golaszewski
  3 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2023-09-27 11:15 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Harvey Hunt,
	Paul Cercueil, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra
  Cc: linux-gpio, linux-kernel, linux-mtd, linux-mips,
	Bartosz Golaszewski

On Tue, Sep 26, 2023 at 11:06 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> We have a special place for OF polarity quirks in gpiolib-of.c. Let's
> move this over there so that it doesn't pollute the driver.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> This is an alternative to the previous patch that instead of replacing
> one active-low setter with another, just moves the quirk over to
> gpiolib-of.c
>
>  drivers/gpio/gpiolib-of.c                       |  9 +++++++++
>  drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c | 12 ------------
>  2 files changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 5515f32cf19b..58c0bbe9d569 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -192,6 +192,15 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
>                  */
>                 { "himax,hx8357",       "gpios-reset",  false },
>                 { "himax,hx8369",       "gpios-reset",  false },
> +               /*
> +                * The rb-gpios semantics was undocumented and qi,lb60 (along with
> +                * the ingenic driver) got it wrong. The active state encodes the
> +                * NAND ready state, which is high level. Since there's no signal
> +                * inverter on this board, it should be active-high. Let's fix that
> +                * here for older DTs so we can re-use the generic nand_gpio_waitrdy()
> +                * helper, and be consistent with what other drivers do.
> +                */
> +               { "qi,lb60",            "rb-gpios",     true },
>  #endif
>         };
>         unsigned int i;
> diff --git a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
> index 6748226b8bd1..c816dc137245 100644
> --- a/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
> +++ b/drivers/mtd/nand/raw/ingenic/ingenic_nand_drv.c
> @@ -380,18 +380,6 @@ static int ingenic_nand_init_chip(struct platform_device *pdev,
>                 return ret;
>         }
>
> -       /*
> -        * The rb-gpios semantics was undocumented and qi,lb60 (along with
> -        * the ingenic driver) got it wrong. The active state encodes the
> -        * NAND ready state, which is high level. Since there's no signal
> -        * inverter on this board, it should be active-high. Let's fix that
> -        * here for older DTs so we can re-use the generic nand_gpio_waitrdy()
> -        * helper, and be consistent with what other drivers do.
> -        */
> -       if (of_machine_is_compatible("qi,lb60") &&
> -           gpiod_is_active_low(nand->busy_gpio))
> -               gpiod_toggle_active_low(nand->busy_gpio);
> -
>         nand->wp_gpio = devm_gpiod_get_optional(dev, "wp", GPIOD_OUT_LOW);
>
>         if (IS_ERR(nand->wp_gpio)) {
> --
> 2.39.2
>

Queued for v6.7.

Bartosz

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

end of thread, other threads:[~2023-09-27 11:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-26  9:06 [RFT PATCH] mtd: rawnand: ingenic: move the GPIO quirk to gpiolib-of.c Bartosz Golaszewski
2023-09-26  9:11 ` Linus Walleij
2023-09-26  9:16 ` Miquel Raynal
2023-09-26  9:26   ` Paul Cercueil
2023-09-26 11:58 ` Andy Shevchenko
2023-09-27 11:15 ` Bartosz Golaszewski

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).