Skip to contentSkip to conversation

gpiolib: of: fix lookup quirk for MIPS Lantiq

PATCH Superseded Dmitry Torokhov 3 participants 4 messages Jun 28, 2024 – Jul 1, 2024 GPIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpiolib: of: fix lookup quirk for MIPS Lantiq

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")
---
 drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-of.c +12 -2
index 59c7f8a2431a..d21085830632 100644
@@ -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
 
 		/*
Signature · 5 lines
2.45.2.803.g4e1b14247a-goog


-- 
Dmitry
Acked-by on v1 1/1
#1 lore raw
Quoted 56 lines · Dmitry Torokhov

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")
---
 drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-of.c +10 -0
index 59c7f8a2431a..d21085830632 100644
@@ -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)
 		/*
drivers/gpio/gpiolib-of.c +2 -2
 		 * 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
 
Quoted 3 lines

/*
--
2.45.2.803.g4e1b14247a-goog

#2 lore raw
In reply to Dmitry Torokhov
Quoted 59 lines · Dmitry Torokhov

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")
---
 drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-of.c +12 -3
index 59c7f8a2431a..d21085830632 100644
@@ -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

Quoted 2 lines

--
Dmitry

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

Bart

#3 lore raw
Quoted 61 lines · Bartosz Golaszewski
Quoted 59 lines · Dmitry Torokhov

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")
---
 drivers/gpio/gpiolib-of.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-of.c +12 -3
index 59c7f8a2431a..d21085830632 100644
@@ -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

Quoted 4 lines
Quoted 2 lines

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

Signature · 1 line
Dmitry