Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "PCI: imx6: Add support for active-low reset GPIO"

Commit 5c5fb40de8f1 ("PCI: imx6: Add support for active-low reset GPIO")
cause regressions on some boards like MX6 Gateworks Ventana, for example.

The reason for the breakage is that this commit sets the GPIO polarity in
the wrong logic level.

Also, the commit log is wrong because active-low reset GPIO is what the
driver used to support since the beginning.

So keep the old behavior that ignores the GPIO polarity specified in the
device tree and treat the PCI reset GPIO as active-low.

Reported-by: Krzysztof Hałasa <khalasa@piap.pl>
Tested-by: Tim Harvey <tharvey@gateworks.com> # Gateworks Ventana
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Tim Harvey <tharvey@gateworks.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
CC: stable@vger.kernel.org # v4.5+

authored by

Fabio Estevam and committed by
Bjorn Helgaas
b2d7a9cd 9735a227

+14 -6
+14 -6
drivers/pci/host/pci-imx6.c
··· 32 32 #define to_imx6_pcie(x) container_of(x, struct imx6_pcie, pp) 33 33 34 34 struct imx6_pcie { 35 - struct gpio_desc *reset_gpio; 35 + int reset_gpio; 36 36 struct clk *pcie_bus; 37 37 struct clk *pcie_phy; 38 38 struct clk *pcie; ··· 309 309 usleep_range(200, 500); 310 310 311 311 /* Some boards don't have PCIe reset GPIO. */ 312 - if (imx6_pcie->reset_gpio) { 313 - gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 0); 312 + if (gpio_is_valid(imx6_pcie->reset_gpio)) { 313 + gpio_set_value_cansleep(imx6_pcie->reset_gpio, 0); 314 314 msleep(100); 315 - gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 1); 315 + gpio_set_value_cansleep(imx6_pcie->reset_gpio, 1); 316 316 } 317 317 return 0; 318 318 ··· 523 523 { 524 524 struct imx6_pcie *imx6_pcie; 525 525 struct pcie_port *pp; 526 + struct device_node *np = pdev->dev.of_node; 526 527 struct resource *dbi_base; 527 528 struct device_node *node = pdev->dev.of_node; 528 529 int ret; ··· 545 544 return PTR_ERR(pp->dbi_base); 546 545 547 546 /* Fetch GPIOs */ 548 - imx6_pcie->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", 549 - GPIOD_OUT_LOW); 547 + imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); 548 + if (gpio_is_valid(imx6_pcie->reset_gpio)) { 549 + ret = devm_gpio_request_one(&pdev->dev, imx6_pcie->reset_gpio, 550 + GPIOF_OUT_INIT_LOW, "PCIe reset"); 551 + if (ret) { 552 + dev_err(&pdev->dev, "unable to get reset gpio\n"); 553 + return ret; 554 + } 555 + } 550 556 551 557 /* Fetch clocks */ 552 558 imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy");