In my previous attempt to solve the PCI problems for the lantiq targets,
I did not pay attention to the fact that the original accesses to the
GPIO took place in RAW mode. As a result, the polarity defined in the
device trees (apart from the initial value) was irrelevant.
In addition, the expected name of the GPIO in the dts has changed due to
the upstream change and therefore no RESET is currently performed.
As discussed in [1] on the linux-mips mailing list, we will now adapt
the dts files accordingly instead of patching the driver:
- dts property will be renamed to "reset-gpios"
- Polarity is set to "GPIO_ACTIVE_LOW".
I have verified this with a TP-Link TD-W8980. The PCI device is now
recognized by the system.
[1] https://patchwork.kernel.org/project/linux-mips/patch/
20240607090400.
1816612-1-ms@dev.tdt.de/
Signed-off-by: Martin Schiller <ms@dev.tdt.de>
Tested-by: Aleksander Jan Bajkowski <olek2@wp.pl> # Tested on AVM 7330 (ar9)
Link: https://github.com/openwrt/openwrt/pull/15731
Signed-off-by: Robert Marko <robimarko@gmail.com>
pinctrl-names = "default";
req-mask = <0xf>;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_LOW>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@0,0 {
compatible = "pci0,0";
<&pci_req3_pins>, <&pci_req4_pins>;
req-mask = <0xf>;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@0,0 {
compatible = "pci0,0";
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@7000 {
reg = <0x7000 0 0 0 0>;
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@168c,0029 {
compatible = "pci168c,0029";
0x7800 0 0 2 &icu0 66
0x7800 0 0 3 &icu0 66
>;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
req-mask = <0x7>;
};
<&pci_req1_pins>, <&pci_req2_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
req-mask = <0xf>;
};
&pci0 {
status = "okay";
lantiq,external-clock;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
req-mask = <0xf>;
};
pinctrl-names = "default";
lantiq,external-clock;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
&usb_phy {
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
/* #define ARV4525PW_RELAY 31 */
pinctrl-names = "default";
lantiq,external-clock;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
&usb_phy {
pinctrl-names = "default";
lantiq,external-clock;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@1814,3592 {
compatible = "pci1814,3592";
0x7800 0 0 2 &icu0 135
0x7800 0 0 3 &icu0 135
>;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
req-mask = <0x3>;
wifi@1814,3592 {
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
lantiq,external-clock;
req-mask = <0xf>;
pinctrl-names = "default";
lantiq,external-clock;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
req-mask = <0xf>;
wifi@0,0 {
pinctrl-names = "default";
lantiq,external-clock;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
interrupt-map = <0x7000 0 0 1 &icu0 135>;
req-mask = <0x3>;
0x7800 0 0 2 &icu0 135
0x7800 0 0 3 &icu0 135
>;
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
req-mask = <0x3>;
wifi@1814,3592 {
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@168c,0029 {
compatible = "pci168c,0029";
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@168c,0027 {
compatible = "pci168c,0027";
&pci0 {
status = "okay";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
&usb_phy {
&pci0 {
status = "okay";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@1814,3592 {
compatible = "pci1814,3592";
&pci0 {
status = "okay";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@1814,3091 {
compatible = "pci1814,3091";
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
&pcie0 {
&pci0 {
status = "okay";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
wifi@168c,002d {
compatible = "pci168c,002d";
&pci0 {
status = "okay";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
&pci0 {
status = "okay";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
&spi {
pinctrl-0 = <&pci_gnt1_pins>, <&pci_req1_pins>;
pinctrl-names = "default";
- gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
};
&stp {
+++ /dev/null
-From f038380835033e376d89c72516f087254792bbad Mon Sep 17 00:00:00 2001
-From: Martin Schiller <ms@dev.tdt.de>
-Date: Mon, 6 May 2024 09:41:42 +0200
-Subject: [PATCH] MIPS: pci: lantiq: restore reset gpio polarity
-
-Commit 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API") not
-only switched to the gpiod API, but also inverted / changed the polarity
-of the GPIO.
-
-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 (mainly in the openWrt project) define this GPIO as
-active-high and the old driver code inverted the signal internally.
-
-Apparently there are actually boards where the reset gpio must be
-operated inverted. For this reason, we cannot use the GPIOD_OUT_LOW/HIGH
-flag for initialization. Instead, we must explicitly set the gpio to
-value 1 in order to take into account any "GPIO_ACTIVE_LOW" flag that
-may have been set.
-
-In order to remain compatible with all these existing device trees, we
-should therefore keep the logic as it was before the commit.
-
-Fixes: 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API")
-Cc: stable@vger.kernel.org
-Signed-off-by: Martin Schiller <ms@dev.tdt.de>
----
- arch/mips/pci/pci-lantiq.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
---- a/arch/mips/pci/pci-lantiq.c
-+++ b/arch/mips/pci/pci-lantiq.c
-@@ -124,14 +124,14 @@ static int ltq_pci_startup(struct platfo
- clk_disable(clk_external);
-
- /* setup reset gpio used by pci */
-- reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
-- GPIOD_OUT_LOW);
-+ reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_ASIS);
- error = PTR_ERR_OR_ZERO(reset_gpio);
- if (error) {
- dev_err(&pdev->dev, "failed to request gpio: %d\n", error);
- return error;
- }
- gpiod_set_consumer_name(reset_gpio, "pci_reset");
-+ gpiod_direction_output(reset_gpio, 1);
-
- /* enable auto-switching between PCI and EBU */
- ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);
-@@ -194,10 +194,10 @@ static int ltq_pci_startup(struct platfo
-
- /* toggle reset pin */
- if (reset_gpio) {
-- gpiod_set_value_cansleep(reset_gpio, 1);
-+ gpiod_set_value_cansleep(reset_gpio, 0);
- wmb();
- mdelay(1);
-- gpiod_set_value_cansleep(reset_gpio, 0);
-+ gpiod_set_value_cansleep(reset_gpio, 1);
- }
- return 0;
- }
+++ /dev/null
-From f038380835033e376d89c72516f087254792bbad Mon Sep 17 00:00:00 2001
-From: Martin Schiller <ms@dev.tdt.de>
-Date: Mon, 6 May 2024 09:41:42 +0200
-Subject: [PATCH] MIPS: pci: lantiq: restore reset gpio polarity
-
-Commit 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API") not
-only switched to the gpiod API, but also inverted / changed the polarity
-of the GPIO.
-
-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 (mainly in the openWrt project) define this GPIO as
-active-high and the old driver code inverted the signal internally.
-
-Apparently there are actually boards where the reset gpio must be
-operated inverted. For this reason, we cannot use the GPIOD_OUT_LOW/HIGH
-flag for initialization. Instead, we must explicitly set the gpio to
-value 1 in order to take into account any "GPIO_ACTIVE_LOW" flag that
-may have been set.
-
-In order to remain compatible with all these existing device trees, we
-should therefore keep the logic as it was before the commit.
-
-Fixes: 90c2d2eb7ab5 ("MIPS: pci: lantiq: switch to using gpiod API")
-Cc: stable@vger.kernel.org
-Signed-off-by: Martin Schiller <ms@dev.tdt.de>
----
- arch/mips/pci/pci-lantiq.c | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
---- a/arch/mips/pci/pci-lantiq.c
-+++ b/arch/mips/pci/pci-lantiq.c
-@@ -124,14 +124,14 @@ static int ltq_pci_startup(struct platfo
- clk_disable(clk_external);
-
- /* setup reset gpio used by pci */
-- reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
-- GPIOD_OUT_LOW);
-+ reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_ASIS);
- error = PTR_ERR_OR_ZERO(reset_gpio);
- if (error) {
- dev_err(&pdev->dev, "failed to request gpio: %d\n", error);
- return error;
- }
- gpiod_set_consumer_name(reset_gpio, "pci_reset");
-+ gpiod_direction_output(reset_gpio, 1);
-
- /* enable auto-switching between PCI and EBU */
- ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);
-@@ -194,10 +194,10 @@ static int ltq_pci_startup(struct platfo
-
- /* toggle reset pin */
- if (reset_gpio) {
-- gpiod_set_value_cansleep(reset_gpio, 1);
-+ gpiod_set_value_cansleep(reset_gpio, 0);
- wmb();
- mdelay(1);
-- gpiod_set_value_cansleep(reset_gpio, 0);
-+ gpiod_set_value_cansleep(reset_gpio, 1);
- }
- return 0;
- }