]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: starfive: Use regulator APIs to control the 3v3 power supply of PCIe slots
authorHal Feng <hal.feng@starfivetech.com>
Thu, 18 Dec 2025 10:21:49 +0000 (18:21 +0800)
committerManivannan Sadhasivam <mani@kernel.org>
Tue, 13 Jan 2026 14:05:34 +0000 (19:35 +0530)
The driver has been using the "enable-gpios" property to control the 3v3
power supply of PCIe slots. But it is not documented in the dt-bindings and
also using GPIO APIs is not a standard way to control PCIe slot power, so
use the documented "vpcie3v3-supply" property and regulator APIs to control
the slot supply.

This change will break the DTs which used "enable-gpio" or "enable-gpios"
property under the controller node. Since these properties were not defined
in the bindings, it is safe to switch to "vpcie3v3-supply". Any out-of-tree
DTS impacted by this change should migrate to "vpcie3v3-supply" instead.

Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
[mani: reworded description]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Acked-by: Kevin Xie <kevin.xie@starfivetech.com>
Link: https://patch.msgid.link/20251218102149.28062-1-hal.feng@starfivetech.com
drivers/pci/controller/plda/pcie-starfive.c

index 3caf53c6c082386dbd51c41572f9ee407e5c4f6f..298036c3e7f9491ea6f4206d2cb931f981995947 100644 (file)
@@ -55,7 +55,7 @@ struct starfive_jh7110_pcie {
        struct reset_control *resets;
        struct clk_bulk_data *clks;
        struct regmap *reg_syscon;
-       struct gpio_desc *power_gpio;
+       struct regulator *vpcie3v3;
        struct gpio_desc *reset_gpio;
        struct phy *phy;
 
@@ -153,11 +153,13 @@ static int starfive_pcie_parse_dt(struct starfive_jh7110_pcie *pcie,
                return dev_err_probe(dev, PTR_ERR(pcie->reset_gpio),
                                     "failed to get perst-gpio\n");
 
-       pcie->power_gpio = devm_gpiod_get_optional(dev, "enable",
-                                                  GPIOD_OUT_LOW);
-       if (IS_ERR(pcie->power_gpio))
-               return dev_err_probe(dev, PTR_ERR(pcie->power_gpio),
-                                    "failed to get power-gpio\n");
+       pcie->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
+       if (IS_ERR(pcie->vpcie3v3)) {
+               if (PTR_ERR(pcie->vpcie3v3) != -ENODEV)
+                       return dev_err_probe(dev, PTR_ERR(pcie->vpcie3v3),
+                                            "failed to get vpcie3v3 regulator\n");
+               pcie->vpcie3v3 = NULL;
+       }
 
        return 0;
 }
@@ -270,8 +272,8 @@ static void starfive_pcie_host_deinit(struct plda_pcie_rp *plda)
                container_of(plda, struct starfive_jh7110_pcie, plda);
 
        starfive_pcie_clk_rst_deinit(pcie);
-       if (pcie->power_gpio)
-               gpiod_set_value_cansleep(pcie->power_gpio, 0);
+       if (pcie->vpcie3v3)
+               regulator_disable(pcie->vpcie3v3);
        starfive_pcie_disable_phy(pcie);
 }
 
@@ -304,8 +306,11 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
        if (ret)
                return ret;
 
-       if (pcie->power_gpio)
-               gpiod_set_value_cansleep(pcie->power_gpio, 1);
+       if (pcie->vpcie3v3) {
+               ret = regulator_enable(pcie->vpcie3v3);
+               if (ret)
+                       dev_err_probe(dev, ret, "failed to enable vpcie3v3 regulator\n");
+       }
 
        if (pcie->reset_gpio)
                gpiod_set_value_cansleep(pcie->reset_gpio, 1);