|
11 | 11 | #include <linux/bitfield.h> |
12 | 12 | #include <linux/clk.h> |
13 | 13 | #include <linux/delay.h> |
14 | | -#include <linux/gpio.h> |
| 14 | +#include <linux/gpio/consumer.h> |
15 | 15 | #include <linux/kernel.h> |
16 | 16 | #include <linux/mfd/syscon.h> |
17 | 17 | #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> |
18 | 18 | #include <linux/mfd/syscon/imx7-iomuxc-gpr.h> |
19 | 19 | #include <linux/module.h> |
20 | 20 | #include <linux/of.h> |
21 | | -#include <linux/of_gpio.h> |
22 | 21 | #include <linux/of_address.h> |
23 | 22 | #include <linux/pci.h> |
24 | 23 | #include <linux/platform_device.h> |
@@ -107,8 +106,7 @@ struct imx6_pcie_drvdata { |
107 | 106 |
|
108 | 107 | struct imx6_pcie { |
109 | 108 | struct dw_pcie *pci; |
110 | | - int reset_gpio; |
111 | | - bool gpio_active_high; |
| 109 | + struct gpio_desc *reset_gpiod; |
112 | 110 | bool link_is_up; |
113 | 111 | struct clk_bulk_data clks[IMX6_PCIE_MAX_CLKS]; |
114 | 112 | struct regmap *iomuxc_gpr; |
@@ -721,9 +719,7 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) |
721 | 719 | } |
722 | 720 |
|
723 | 721 | /* 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); |
727 | 723 | } |
728 | 724 |
|
729 | 725 | 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) |
771 | 767 | } |
772 | 768 |
|
773 | 769 | /* Some boards don't have PCIe reset GPIO. */ |
774 | | - if (gpio_is_valid(imx6_pcie->reset_gpio)) { |
| 770 | + if (imx6_pcie->reset_gpiod) { |
775 | 771 | 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); |
778 | 773 | /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ |
779 | 774 | msleep(100); |
780 | 775 | } |
@@ -1285,22 +1280,11 @@ static int imx6_pcie_probe(struct platform_device *pdev) |
1285 | 1280 | return PTR_ERR(pci->dbi_base); |
1286 | 1281 |
|
1287 | 1282 | /* 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"); |
1304 | 1288 |
|
1305 | 1289 | if (imx6_pcie->drvdata->clks_cnt >= IMX6_PCIE_MAX_CLKS) |
1306 | 1290 | return dev_err_probe(dev, -ENOMEM, "clks_cnt is too big\n"); |
|
0 commit comments