linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpiolib: of: fix lookup quirk for MIPS Lantiq
@ 2024-06-28 18:35 Dmitry Torokhov
  2024-07-01  6:12 ` Martin Schiller
  2024-07-01  8:51 ` Bartosz Golaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2024-06-28 18:35 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Martin Schiller, Hauke Mehrtens, Thomas Bogendoerfer, linux-gpio,
	linux-kernel

As it turns out, there is a large number of out-of-tree DTSes (in
OpenWrt project) that used to specify incorrect (active high) polarity
for the Lantiq reset GPIO, so to keep compatibility while they are
being updated a quirk for force the polarity low is needed. Luckily
these old DTSes used nonstandard name for the property ("gpio-reset" vs
"reset-gpios") so the quirk will not hurt if there are any new devices
that need inverted polarity as they can specify the right polarity in
their DTS when using the standard "reset-gpios" property.

Additionally the condition to enable the translation from standard to
non-standard reset GPIO property name was inverted and the replacement
name for the property was not correct. Fix this as well.

Fixes: fbbbcd177a27 ("gpiolib: of: add quirk for locating reset lines with legacy bindings")
Fixes: 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API")
Reported-by: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 59c7f8a2431a..d21085830632 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -203,6 +203,16 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
 		 */
 		{ "qi,lb60",		"rb-gpios",	true },
 #endif
+#if IS_ENABLED(CONFIG_PCI_LANTIQ)
+		/*
+		 * According to the PCI specification, the RST# pin is an
+		 * active-low signal. However, most of the device trees that
+		 * have been widely used for a long time incorrectly describe
+		 * reset GPIO as active-high, and were also using wrong name
+		 * for the property.
+		 */
+		{ "lantiq,pci-xway",	"gpio-reset",	false },
+#endif
 #if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2005)
 		/*
 		 * DTS for Nokia N900 incorrectly specified "active high"
@@ -512,9 +522,9 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 		{ "reset",	"reset-n-io",	"marvell,nfc-uart" },
 		{ "reset",	"reset-n-io",	"mrvl,nfc-uart" },
 #endif
-#if !IS_ENABLED(CONFIG_PCI_LANTIQ)
+#if IS_ENABLED(CONFIG_PCI_LANTIQ)
 		/* MIPS Lantiq PCI */
-		{ "reset",	"gpios-reset",	"lantiq,pci-xway" },
+		{ "reset",	"gpio-reset",	"lantiq,pci-xway" },
 #endif
 
 		/*
-- 
2.45.2.803.g4e1b14247a-goog


-- 
Dmitry

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

* Re: [PATCH] gpiolib: of: fix lookup quirk for MIPS Lantiq
  2024-06-28 18:35 [PATCH] gpiolib: of: fix lookup quirk for MIPS Lantiq Dmitry Torokhov
@ 2024-07-01  6:12 ` Martin Schiller
  2024-07-01  8:51 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Martin Schiller @ 2024-07-01  6:12 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Bartosz Golaszewski, Hauke Mehrtens,
	Thomas Bogendoerfer, linux-gpio, linux-kernel

On 2024-06-28 20:35, Dmitry Torokhov wrote:
> As it turns out, there is a large number of out-of-tree DTSes (in
> OpenWrt project) that used to specify incorrect (active high) polarity
> for the Lantiq reset GPIO, so to keep compatibility while they are
> being updated a quirk for force the polarity low is needed. Luckily
> these old DTSes used nonstandard name for the property ("gpio-reset" vs
> "reset-gpios") so the quirk will not hurt if there are any new devices
> that need inverted polarity as they can specify the right polarity in
> their DTS when using the standard "reset-gpios" property.
> 
> Additionally the condition to enable the translation from standard to
> non-standard reset GPIO property name was inverted and the replacement
> name for the property was not correct. Fix this as well.
> 
> Fixes: fbbbcd177a27 ("gpiolib: of: add quirk for locating reset lines
> with legacy bindings")
> Fixes: 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API")
> Reported-by: Martin Schiller <ms@dev.tdt.de>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 59c7f8a2431a..d21085830632 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -203,6 +203,16 @@ static void of_gpio_try_fixup_polarity(const
> struct device_node *np,
>  		 */
>  		{ "qi,lb60",		"rb-gpios",	true },
>  #endif
> +#if IS_ENABLED(CONFIG_PCI_LANTIQ)
> +		/*
> +		 * According to the PCI specification, the RST# pin is an
> +		 * active-low signal. However, most of the device trees that
> +		 * have been widely used for a long time incorrectly describe
> +		 * reset GPIO as active-high, and were also using wrong name
> +		 * for the property.
> +		 */
> +		{ "lantiq,pci-xway",	"gpio-reset",	false },
> +#endif
>  #if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2005)
>  		/*
>  		 * DTS for Nokia N900 incorrectly specified "active high"
> @@ -512,9 +522,9 @@ static struct gpio_desc
> *of_find_gpio_rename(struct device_node *np,
>  		{ "reset",	"reset-n-io",	"marvell,nfc-uart" },
>  		{ "reset",	"reset-n-io",	"mrvl,nfc-uart" },
>  #endif
> -#if !IS_ENABLED(CONFIG_PCI_LANTIQ)
> +#if IS_ENABLED(CONFIG_PCI_LANTIQ)
>  		/* MIPS Lantiq PCI */
> -		{ "reset",	"gpios-reset",	"lantiq,pci-xway" },
> +		{ "reset",	"gpio-reset",	"lantiq,pci-xway" },
>  #endif
> 
>  		/*
> --
> 2.45.2.803.g4e1b14247a-goog

Acked-by: Martin Schiller <ms@dev.tdt.de>

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

* Re: [PATCH] gpiolib: of: fix lookup quirk for MIPS Lantiq
  2024-06-28 18:35 [PATCH] gpiolib: of: fix lookup quirk for MIPS Lantiq Dmitry Torokhov
  2024-07-01  6:12 ` Martin Schiller
@ 2024-07-01  8:51 ` Bartosz Golaszewski
  2024-07-01 17:35   ` Dmitry Torokhov
  1 sibling, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-07-01  8:51 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Martin Schiller, Hauke Mehrtens,
	Thomas Bogendoerfer, linux-gpio, linux-kernel

On Fri, Jun 28, 2024 at 8:35 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> As it turns out, there is a large number of out-of-tree DTSes (in
> OpenWrt project) that used to specify incorrect (active high) polarity
> for the Lantiq reset GPIO, so to keep compatibility while they are
> being updated a quirk for force the polarity low is needed. Luckily
> these old DTSes used nonstandard name for the property ("gpio-reset" vs
> "reset-gpios") so the quirk will not hurt if there are any new devices
> that need inverted polarity as they can specify the right polarity in
> their DTS when using the standard "reset-gpios" property.
>
> Additionally the condition to enable the translation from standard to
> non-standard reset GPIO property name was inverted and the replacement
> name for the property was not correct. Fix this as well.
>
> Fixes: fbbbcd177a27 ("gpiolib: of: add quirk for locating reset lines with legacy bindings")
> Fixes: 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API")
> Reported-by: Martin Schiller <ms@dev.tdt.de>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index 59c7f8a2431a..d21085830632 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -203,6 +203,16 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
>                  */
>                 { "qi,lb60",            "rb-gpios",     true },
>  #endif
> +#if IS_ENABLED(CONFIG_PCI_LANTIQ)
> +               /*
> +                * According to the PCI specification, the RST# pin is an
> +                * active-low signal. However, most of the device trees that
> +                * have been widely used for a long time incorrectly describe
> +                * reset GPIO as active-high, and were also using wrong name
> +                * for the property.
> +                */
> +               { "lantiq,pci-xway",    "gpio-reset",   false },
> +#endif
>  #if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2005)
>                 /*
>                  * DTS for Nokia N900 incorrectly specified "active high"
> @@ -512,9 +522,9 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
>                 { "reset",      "reset-n-io",   "marvell,nfc-uart" },
>                 { "reset",      "reset-n-io",   "mrvl,nfc-uart" },
>  #endif
> -#if !IS_ENABLED(CONFIG_PCI_LANTIQ)
> +#if IS_ENABLED(CONFIG_PCI_LANTIQ)
>                 /* MIPS Lantiq PCI */
> -               { "reset",      "gpios-reset",  "lantiq,pci-xway" },
> +               { "reset",      "gpio-reset",   "lantiq,pci-xway" },
>  #endif
>
>                 /*
> --
> 2.45.2.803.g4e1b14247a-goog
>
>
> --
> Dmitry

Can you rebase it on top of v6.10-rc6? It doesn't apply to my fixes branch.

Bart

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

* Re: [PATCH] gpiolib: of: fix lookup quirk for MIPS Lantiq
  2024-07-01  8:51 ` Bartosz Golaszewski
@ 2024-07-01 17:35   ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2024-07-01 17:35 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Martin Schiller, Hauke Mehrtens,
	Thomas Bogendoerfer, linux-gpio, linux-kernel

On Mon, Jul 01, 2024 at 10:51:00AM +0200, Bartosz Golaszewski wrote:
> On Fri, Jun 28, 2024 at 8:35 PM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> >
> > As it turns out, there is a large number of out-of-tree DTSes (in
> > OpenWrt project) that used to specify incorrect (active high) polarity
> > for the Lantiq reset GPIO, so to keep compatibility while they are
> > being updated a quirk for force the polarity low is needed. Luckily
> > these old DTSes used nonstandard name for the property ("gpio-reset" vs
> > "reset-gpios") so the quirk will not hurt if there are any new devices
> > that need inverted polarity as they can specify the right polarity in
> > their DTS when using the standard "reset-gpios" property.
> >
> > Additionally the condition to enable the translation from standard to
> > non-standard reset GPIO property name was inverted and the replacement
> > name for the property was not correct. Fix this as well.
> >
> > Fixes: fbbbcd177a27 ("gpiolib: of: add quirk for locating reset lines with legacy bindings")
> > Fixes: 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API")
> > Reported-by: Martin Schiller <ms@dev.tdt.de>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> >  drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> > index 59c7f8a2431a..d21085830632 100644
> > --- a/drivers/gpio/gpiolib-of.c
> > +++ b/drivers/gpio/gpiolib-of.c
> > @@ -203,6 +203,16 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
> >                  */
> >                 { "qi,lb60",            "rb-gpios",     true },
> >  #endif
> > +#if IS_ENABLED(CONFIG_PCI_LANTIQ)
> > +               /*
> > +                * According to the PCI specification, the RST# pin is an
> > +                * active-low signal. However, most of the device trees that
> > +                * have been widely used for a long time incorrectly describe
> > +                * reset GPIO as active-high, and were also using wrong name
> > +                * for the property.
> > +                */
> > +               { "lantiq,pci-xway",    "gpio-reset",   false },
> > +#endif
> >  #if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2005)
> >                 /*
> >                  * DTS for Nokia N900 incorrectly specified "active high"
> > @@ -512,9 +522,9 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
> >                 { "reset",      "reset-n-io",   "marvell,nfc-uart" },
> >                 { "reset",      "reset-n-io",   "mrvl,nfc-uart" },
> >  #endif
> > -#if !IS_ENABLED(CONFIG_PCI_LANTIQ)
> > +#if IS_ENABLED(CONFIG_PCI_LANTIQ)
> >                 /* MIPS Lantiq PCI */
> > -               { "reset",      "gpios-reset",  "lantiq,pci-xway" },
> > +               { "reset",      "gpio-reset",   "lantiq,pci-xway" },
> >  #endif
> >
> >                 /*
> > --
> > 2.45.2.803.g4e1b14247a-goog
> >
> >
> > --
> > Dmitry
> 
> Can you rebase it on top of v6.10-rc6? It doesn't apply to my fixes branch.

Ah, yes, I had another quirk to TSC2005 in my tree that gave the
conflict.

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2024-07-01 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 18:35 [PATCH] gpiolib: of: fix lookup quirk for MIPS Lantiq Dmitry Torokhov
2024-07-01  6:12 ` Martin Schiller
2024-07-01  8:51 ` Bartosz Golaszewski
2024-07-01 17:35   ` Dmitry Torokhov

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