Skip to content

Commit 2e81122

Browse files
andy-shevbjorn-helgaas
authored andcommitted
PCI: imx6: Convert to use agnostic GPIO API
The of_gpio.h legacy API is going to be removed. In preparation for that, convert the driver to the agnostic API. [kwilczynski: commit log] Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 050a5e4 commit 2e81122

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

drivers/pci/controller/dwc/pci-imx6.c

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
#include <linux/bitfield.h>
1212
#include <linux/clk.h>
1313
#include <linux/delay.h>
14-
#include <linux/gpio.h>
14+
#include <linux/gpio/consumer.h>
1515
#include <linux/kernel.h>
1616
#include <linux/mfd/syscon.h>
1717
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
1818
#include <linux/mfd/syscon/imx7-iomuxc-gpr.h>
1919
#include <linux/module.h>
2020
#include <linux/of.h>
21-
#include <linux/of_gpio.h>
2221
#include <linux/of_address.h>
2322
#include <linux/pci.h>
2423
#include <linux/platform_device.h>
@@ -107,8 +106,7 @@ struct imx6_pcie_drvdata {
107106

108107
struct imx6_pcie {
109108
struct dw_pcie *pci;
110-
int reset_gpio;
111-
bool gpio_active_high;
109+
struct gpio_desc *reset_gpiod;
112110
bool link_is_up;
113111
struct clk_bulk_data clks[IMX6_PCIE_MAX_CLKS];
114112
struct regmap *iomuxc_gpr;
@@ -721,9 +719,7 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)
721719
}
722720

723721
/* Some boards don't have PCIe reset GPIO. */
724-
if (gpio_is_valid(imx6_pcie->reset_gpio))
725-
gpio_set_value_cansleep(imx6_pcie->reset_gpio,
726-
imx6_pcie->gpio_active_high);
722+
gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 1);
727723
}
728724

729725
static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
@@ -771,10 +767,9 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
771767
}
772768

773769
/* Some boards don't have PCIe reset GPIO. */
774-
if (gpio_is_valid(imx6_pcie->reset_gpio)) {
770+
if (imx6_pcie->reset_gpiod) {
775771
msleep(100);
776-
gpio_set_value_cansleep(imx6_pcie->reset_gpio,
777-
!imx6_pcie->gpio_active_high);
772+
gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 0);
778773
/* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
779774
msleep(100);
780775
}
@@ -1285,22 +1280,11 @@ static int imx6_pcie_probe(struct platform_device *pdev)
12851280
return PTR_ERR(pci->dbi_base);
12861281

12871282
/* Fetch GPIOs */
1288-
imx6_pcie->reset_gpio = of_get_named_gpio(node, "reset-gpio", 0);
1289-
imx6_pcie->gpio_active_high = of_property_read_bool(node,
1290-
"reset-gpio-active-high");
1291-
if (gpio_is_valid(imx6_pcie->reset_gpio)) {
1292-
ret = devm_gpio_request_one(dev, imx6_pcie->reset_gpio,
1293-
imx6_pcie->gpio_active_high ?
1294-
GPIOF_OUT_INIT_HIGH :
1295-
GPIOF_OUT_INIT_LOW,
1296-
"PCIe reset");
1297-
if (ret) {
1298-
dev_err(dev, "unable to get reset gpio\n");
1299-
return ret;
1300-
}
1301-
} else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) {
1302-
return imx6_pcie->reset_gpio;
1303-
}
1283+
imx6_pcie->reset_gpiod = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
1284+
if (IS_ERR(imx6_pcie->reset_gpiod))
1285+
return dev_err_probe(dev, PTR_ERR(imx6_pcie->reset_gpiod),
1286+
"unable to get reset gpio\n");
1287+
gpiod_set_consumer_name(imx6_pcie->reset_gpiod, "PCIe reset");
13041288

13051289
if (imx6_pcie->drvdata->clks_cnt >= IMX6_PCIE_MAX_CLKS)
13061290
return dev_err_probe(dev, -ENOMEM, "clks_cnt is too big\n");

0 commit comments

Comments
 (0)