Skip to content

Commit 5c5fb40

Browse files
ynezzbjorn-helgaas
authored andcommitted
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: Petr Štetiar <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Lucas Stach <[email protected]>
1 parent bd534e6 commit 5c5fb40

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/pci/host/pci-imx6.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define to_imx6_pcie(x) container_of(x, struct imx6_pcie, pp)
3333

3434
struct imx6_pcie {
35-
int reset_gpio;
35+
struct gpio_desc *reset_gpio;
3636
struct clk *pcie_bus;
3737
struct clk *pcie_phy;
3838
struct clk *pcie;
@@ -287,10 +287,10 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
287287
usleep_range(200, 500);
288288

289289
/* Some boards don't have PCIe reset GPIO. */
290-
if (gpio_is_valid(imx6_pcie->reset_gpio)) {
291-
gpio_set_value_cansleep(imx6_pcie->reset_gpio, 0);
290+
if (imx6_pcie->reset_gpio) {
291+
gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 0);
292292
msleep(100);
293-
gpio_set_value_cansleep(imx6_pcie->reset_gpio, 1);
293+
gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 1);
294294
}
295295
return 0;
296296

@@ -560,7 +560,6 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
560560
{
561561
struct imx6_pcie *imx6_pcie;
562562
struct pcie_port *pp;
563-
struct device_node *np = pdev->dev.of_node;
564563
struct resource *dbi_base;
565564
int ret;
566565

@@ -581,15 +580,8 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
581580
return PTR_ERR(pp->dbi_base);
582581

583582
/* Fetch GPIOs */
584-
imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
585-
if (gpio_is_valid(imx6_pcie->reset_gpio)) {
586-
ret = devm_gpio_request_one(&pdev->dev, imx6_pcie->reset_gpio,
587-
GPIOF_OUT_INIT_LOW, "PCIe reset");
588-
if (ret) {
589-
dev_err(&pdev->dev, "unable to get reset gpio\n");
590-
return ret;
591-
}
592-
}
583+
imx6_pcie->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
584+
GPIOD_OUT_LOW);
593585

594586
/* Fetch clocks */
595587
imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy");

0 commit comments

Comments
 (0)