lantiq: pcie: use devm_gpiod_get_optional ltq_dts_pci_cleanup
authorMathias Kresin <dev@kresin.me>
Thu, 7 Jan 2021 00:32:00 +0000 (01:32 +0100)
committerMathias Kresin <dev@kresin.me>
Mon, 12 Apr 2021 21:52:24 +0000 (23:52 +0200)
Use devm_gpiod_get_optional to aquire the reset gpio and get rid of
quite some code this way.

The devicetree property name changes from gpio-reset to reset-gpios due
to this change.

Signed-off-by: Mathias Kresin <dev@kresin.me>
16 files changed:
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_alphanetworks_asl56026.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_arcadyan_arv7519rw22.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_arcadyan_vg3503j.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz3370-rev2.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz3390.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz736x.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7412.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7430.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_buffalo_wbmr-300hpd.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_lantiq_easy80920.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_tdw89x0.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_tplink_vr200.dtsi
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_zyxel_p-2812hnu-f3.dts
target/linux/lantiq/patches-5.10/0151-lantiq-ifxmips_pcie-use-of.patch
target/linux/lantiq/patches-5.4/0151-lantiq-ifxmips_pcie-use-of.patch

index e7937c1952e129edf1ed1a98204701e57c7850f9..ea59edc35c6d6789f4a61c84fc99a18b4586e1a3 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
index 9c43c1486199d310bf17fa1de1fa27a03e77ece3..bd6954fb7a450f04a5dc8f6909da265ba9be962e 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 &usb_phy0 {
index 93d3a9feb4141a13659a0b955b857a407c0d162b..6afaf5f09c18a06768803422fac11c95501c0d28 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
index a69b7b68b235d779cc77e8048417914039afc9b2..c1fe73e498c155ef972cb1a850af0608b019ee22 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 };
 
 &pcie_bridge0 {
index d887e10c456f97b4b477a7691ecaa99a3c3d634c..b941da23e2d5cfb8a95490e82a37cc3ee9ba1d32 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_HIGH>;
 };
 
 &pcie_bridge0 {
index 064c5c25af9636dcd34110e7ec528932fcccf670..fda7993d6e272b0c89eb7c2acc79e98af82785ed 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 21 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 21 GPIO_ACTIVE_HIGH>;
 };
 
 &pcie_bridge0 {
index 37929a2febeac151cb3537b852d1860c75111b35..fb67b8363c8fc7cca366a1b767d99482f341ce8e 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 11 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
 };
 
 &pcie_bridge0 {
index 5d53cd5092e860f01642f27fffd859e47b6b07d5..2c37784eacf45c03ec04ac5922466f6a13879ef9 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 11 GPIO_ACTIVE_HIGH>;
+       reset-gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
 };
 
 &pcie_bridge0 {
index 3afe801c36d511b1ac93796a9018ad51e6960020..fe395b40d1245c91eec38d060d82ad8b8fc1e0c1 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
 
 &usb_phy0 {
index 3fbcd8ef4084e1372274b57e0b7c0bae4d53bcf5..bc67e197d983678e6255a43f8254b1cfd793276c 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
index df835d72a99174eeee75047148d7be31d0f37cec..1dfc8a1528bd56f5b8ad5948e0a75ef36d084873 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
index 70ae5314ef430e4fbbdeeb0e54bb384e06968391..0e44bc39fd8ab82282a57efe2ee4fea7e03580db 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
 
 &pcie_bridge0 {
index 346f026878544ded94742c03be81632f1651e502..fa345fb0c1dc534f0f6c49ffcb4ee57d783e5057 100644 (file)
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
 
 &pcie_bridge0 {
index e52fbb0668d63a3d8f032c4f225552f4abb96ab9..1baa0eb4a21e5e2eba946e4546e535ae327b556b 100644 (file)
@@ -72,5 +72,5 @@
 
 &pcie0 {
        status = "okay";
-       gpio-reset = <&gpio 38 GPIO_ACTIVE_LOW>;
+       reset-gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
 };
index 794ff23cc7791b821a1c331fbfc2dc6c3cc4f23e..1691e4c2f6eb61d092e06874fd3570c88698c149 100644 (file)
@@ -20,7 +20,7 @@
  static DEFINE_SPINLOCK(ifx_pcie_lock);
  
  u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
-+static int pcie_reset_gpio;
++static struct gpio_desc *pcie_reset_gpio;
 +static struct phy *ltq_pcie_phy;
 +static struct reset_control *ltq_pcie_reset;
 +static struct regmap *ltq_rcu_regmap;
  
 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
 +{
-+      gpio_set_value(pcie_reset_gpio, 0);
++      gpiod_set_value(pcie_reset_gpio, 0);
 +}
 +
 +static inline void pcie_device_rst_assert(int pcie_port)
 +{
-+      gpio_set_value(pcie_reset_gpio, 1);
++      gpiod_set_value(pcie_reset_gpio, 1);
 +}
 +
 +static inline void pcie_device_rst_deassert(int pcie_port)
 +{
 +      mdelay(100);
-+      gpio_set_value(pcie_reset_gpio, 0);
++      gpiod_set_value(pcie_reset_gpio, 0);
 +}
  
  static inline int pcie_ltssm_enable(int pcie_port)
        }
        if (i >= IFX_PCIE_PHY_LOOP_CNT) {
                printk(KERN_ERR "%s link up failed!!!!!\n", __func__);
-@@ -1045,17 +1082,67 @@ pcie_rc_initialize(int pcie_port)
+@@ -1045,17 +1082,63 @@ pcie_rc_initialize(int pcie_port)
        return 0;
  }
  
 +    if (IS_ERR(ltq_rcu_regmap))
 +        return PTR_ERR(ltq_rcu_regmap);
 +
-+    pcie_reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
-+    if (gpio_is_valid(pcie_reset_gpio)) {
-+        int ret = devm_gpio_request(&pdev->dev, pcie_reset_gpio, "pcie-reset");
-+        if (ret) {
-+            dev_err(&pdev->dev, "failed to request gpio %d\n", pcie_reset_gpio);
-+            return ret;
-+        }
-+        gpio_direction_output(pcie_reset_gpio, 0);
-+    }
++    pcie_reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
++                                              GPIOD_OUT_LOW);
++    if (IS_ERR(pcie_reset_gpio)) {
++        return dev_err_probe(&pdev->dev, PTR_ERR(pcie_reset_gpio),
++                             "failed to request gpio\n");
 +
      for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
        if (pcie_rc_initialize(pcie_port) == 0) {
            IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n", 
-@@ -1067,6 +1154,7 @@ static int __init ifx_pcie_bios_init(voi
+@@ -1067,6 +1150,7 @@ static int __init ifx_pcie_bios_init(voi
                  return -ENOMEM;
              }
              ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
  
              register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
              /* XXX, clear error status */
-@@ -1083,6 +1171,30 @@ static int __init ifx_pcie_bios_init(voi
+@@ -1083,6 +1167,30 @@ static int __init ifx_pcie_bios_init(voi
  
      return 0;
  }
index b4ef88e94f9f46efc1ec450edb1d63ad6306abfc..36bf442f02f2e0bd316a7e7a24bc69011e0c3b24 100644 (file)
@@ -20,7 +20,7 @@
  static DEFINE_SPINLOCK(ifx_pcie_lock);
  
  u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
-+static int pcie_reset_gpio;
++static struct gpio_desc *pcie_reset_gpio;
 +static struct phy *ltq_pcie_phy;
 +static struct reset_control *ltq_pcie_reset;
 +static struct regmap *ltq_rcu_regmap;
  
 +static inline void pcie_ep_gpio_rst_init(int pcie_port)
 +{
-+      gpio_set_value(pcie_reset_gpio, 0);
++      gpiod_set_value(pcie_reset_gpio, 0);
 +}
 +
 +static inline void pcie_device_rst_assert(int pcie_port)
 +{
-+      gpio_set_value(pcie_reset_gpio, 1);
++      gpiod_set_value(pcie_reset_gpio, 1);
 +}
 +
 +static inline void pcie_device_rst_deassert(int pcie_port)
 +{
 +      mdelay(100);
-+      gpio_set_value(pcie_reset_gpio, 0);
++      gpiod_set_value(pcie_reset_gpio, 0);
 +}
  
  static inline int pcie_ltssm_enable(int pcie_port)
        }
        if (i >= IFX_PCIE_PHY_LOOP_CNT) {
                printk(KERN_ERR "%s link up failed!!!!!\n", __func__);
-@@ -1045,17 +1082,67 @@ pcie_rc_initialize(int pcie_port)
+@@ -1045,17 +1082,66 @@ pcie_rc_initialize(int pcie_port)
        return 0;
  }
  
 +    if (IS_ERR(ltq_rcu_regmap))
 +        return PTR_ERR(ltq_rcu_regmap);
 +
-+    pcie_reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
-+    if (gpio_is_valid(pcie_reset_gpio)) {
-+        int ret = devm_gpio_request(&pdev->dev, pcie_reset_gpio, "pcie-reset");
-+        if (ret) {
-+            dev_err(&pdev->dev, "failed to request gpio %d\n", pcie_reset_gpio);
-+            return ret;
-+        }
-+        gpio_direction_output(pcie_reset_gpio, 0);
++    pcie_reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
++                                              GPIOD_OUT_LOW);
++    if (IS_ERR(pcie_reset_gpio)) {
++        if (PTR_ERR(pcie_reset_gpio) != -EPROBE_DEFER)
++            dev_err(&pdev->dev, "failed to request gpio\n");
++
++        return PTR_ERR(pcie_reset_gpio);
 +    }
 +
      for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
        if (pcie_rc_initialize(pcie_port) == 0) {
            IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n", 
-@@ -1067,6 +1154,7 @@ static int __init ifx_pcie_bios_init(voi
+@@ -1067,6 +1153,7 @@ static int __init ifx_pcie_bios_init(voi
                  return -ENOMEM;
              }
              ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
  
              register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
              /* XXX, clear error status */
-@@ -1083,6 +1171,30 @@ static int __init ifx_pcie_bios_init(voi
+@@ -1083,6 +1170,30 @@ static int __init ifx_pcie_bios_init(voi
  
      return 0;
  }