Skip to content

Commit 277a036

Browse files
sch-mtsbogend
authored andcommitted
MIPS: pci: lantiq: restore reset gpio polarity
Commit 90c2d2e ("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: 90c2d2e ("MIPS: pci: lantiq: switch to using gpiod API") Cc: [email protected] Signed-off-by: Martin Schiller <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent ae9daff commit 277a036

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

arch/mips/pci/pci-lantiq.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ static int ltq_pci_startup(struct platform_device *pdev)
124124
clk_disable(clk_external);
125125

126126
/* setup reset gpio used by pci */
127-
reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
128-
GPIOD_OUT_LOW);
127+
reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", GPIOD_ASIS);
129128
error = PTR_ERR_OR_ZERO(reset_gpio);
130129
if (error) {
131130
dev_err(&pdev->dev, "failed to request gpio: %d\n", error);
132131
return error;
133132
}
134133
gpiod_set_consumer_name(reset_gpio, "pci_reset");
134+
gpiod_direction_output(reset_gpio, 1);
135135

136136
/* enable auto-switching between PCI and EBU */
137137
ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);
@@ -194,10 +194,10 @@ static int ltq_pci_startup(struct platform_device *pdev)
194194

195195
/* toggle reset pin */
196196
if (reset_gpio) {
197-
gpiod_set_value_cansleep(reset_gpio, 1);
197+
gpiod_set_value_cansleep(reset_gpio, 0);
198198
wmb();
199199
mdelay(1);
200-
gpiod_set_value_cansleep(reset_gpio, 0);
200+
gpiod_set_value_cansleep(reset_gpio, 1);
201201
}
202202
return 0;
203203
}

0 commit comments

Comments
 (0)