Commit 5c5fb40d authored by Petr Štetiar's avatar Petr Štetiar Committed by Bjorn Helgaas

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

We previously used of_get_named_gpio(), which ignores the OF flags cell, so
the reset GPIO defaulted to "active high." This doesn't work on the Toradex
Apalis SoM with Ixora base board, which has an active-low reset GPIO.

Use devm_gpiod_get_optional() instead so we pay attention to the active
high/low flag.  This also adds support for GPIOs described via ACPI.

[bhelgaas: changelog]
Signed-off-by: default avatarPetr Štetiar <ynezz@true.cz>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarLucas Stach <l.stach@pengutronix.de>
parent bd534e69
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define to_imx6_pcie(x) container_of(x, struct imx6_pcie, pp) #define to_imx6_pcie(x) container_of(x, struct imx6_pcie, pp)
struct imx6_pcie { struct imx6_pcie {
int reset_gpio; struct gpio_desc *reset_gpio;
struct clk *pcie_bus; struct clk *pcie_bus;
struct clk *pcie_phy; struct clk *pcie_phy;
struct clk *pcie; struct clk *pcie;
...@@ -287,10 +287,10 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) ...@@ -287,10 +287,10 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
usleep_range(200, 500); usleep_range(200, 500);
/* Some boards don't have PCIe reset GPIO. */ /* Some boards don't have PCIe reset GPIO. */
if (gpio_is_valid(imx6_pcie->reset_gpio)) { if (imx6_pcie->reset_gpio) {
gpio_set_value_cansleep(imx6_pcie->reset_gpio, 0); gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 0);
msleep(100); msleep(100);
gpio_set_value_cansleep(imx6_pcie->reset_gpio, 1); gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 1);
} }
return 0; return 0;
...@@ -560,7 +560,6 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) ...@@ -560,7 +560,6 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
{ {
struct imx6_pcie *imx6_pcie; struct imx6_pcie *imx6_pcie;
struct pcie_port *pp; struct pcie_port *pp;
struct device_node *np = pdev->dev.of_node;
struct resource *dbi_base; struct resource *dbi_base;
int ret; int ret;
...@@ -581,15 +580,8 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) ...@@ -581,15 +580,8 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
return PTR_ERR(pp->dbi_base); return PTR_ERR(pp->dbi_base);
/* Fetch GPIOs */ /* Fetch GPIOs */
imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); imx6_pcie->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
if (gpio_is_valid(imx6_pcie->reset_gpio)) { GPIOD_OUT_LOW);
ret = devm_gpio_request_one(&pdev->dev, imx6_pcie->reset_gpio,
GPIOF_OUT_INIT_LOW, "PCIe reset");
if (ret) {
dev_err(&pdev->dev, "unable to get reset gpio\n");
return ret;
}
}
/* Fetch clocks */ /* Fetch clocks */
imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy"); imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment