]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpiolib: of: fix lookup quirk for MIPS Lantiq
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 1 Jul 2024 17:38:50 +0000 (10:38 -0700)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 2 Jul 2024 06:50:00 +0000 (08:50 +0200)
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 transition 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>
Acked-by: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/ZoLpqv1PN08xHioh@google.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib-of.c

index d75f6ee370282eb3017993ec561ca35c85ff90a9..38679cf1969f9b562be3887af3f6f67ef52ad99b 100644 (file)
@@ -202,6 +202,16 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
                 * helper, and be consistent with what other drivers do.
                 */
                { "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
        };
        unsigned int i;
@@ -504,9 +514,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
 
                /*