Skip to content

Commit 05a75df

Browse files
hal-fengMani-Sadhasivam
authored andcommitted
PCI: starfive: Use regulator APIs to control the 3v3 power supply of PCIe slots
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
1 parent 8f0b4cc commit 05a75df

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

drivers/pci/controller/plda/pcie-starfive.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct starfive_jh7110_pcie {
5555
struct reset_control *resets;
5656
struct clk_bulk_data *clks;
5757
struct regmap *reg_syscon;
58-
struct gpio_desc *power_gpio;
58+
struct regulator *vpcie3v3;
5959
struct gpio_desc *reset_gpio;
6060
struct phy *phy;
6161

@@ -153,11 +153,13 @@ static int starfive_pcie_parse_dt(struct starfive_jh7110_pcie *pcie,
153153
return dev_err_probe(dev, PTR_ERR(pcie->reset_gpio),
154154
"failed to get perst-gpio\n");
155155

156-
pcie->power_gpio = devm_gpiod_get_optional(dev, "enable",
157-
GPIOD_OUT_LOW);
158-
if (IS_ERR(pcie->power_gpio))
159-
return dev_err_probe(dev, PTR_ERR(pcie->power_gpio),
160-
"failed to get power-gpio\n");
156+
pcie->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
157+
if (IS_ERR(pcie->vpcie3v3)) {
158+
if (PTR_ERR(pcie->vpcie3v3) != -ENODEV)
159+
return dev_err_probe(dev, PTR_ERR(pcie->vpcie3v3),
160+
"failed to get vpcie3v3 regulator\n");
161+
pcie->vpcie3v3 = NULL;
162+
}
161163

162164
return 0;
163165
}
@@ -270,8 +272,8 @@ static void starfive_pcie_host_deinit(struct plda_pcie_rp *plda)
270272
container_of(plda, struct starfive_jh7110_pcie, plda);
271273

272274
starfive_pcie_clk_rst_deinit(pcie);
273-
if (pcie->power_gpio)
274-
gpiod_set_value_cansleep(pcie->power_gpio, 0);
275+
if (pcie->vpcie3v3)
276+
regulator_disable(pcie->vpcie3v3);
275277
starfive_pcie_disable_phy(pcie);
276278
}
277279

@@ -304,8 +306,11 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)
304306
if (ret)
305307
return ret;
306308

307-
if (pcie->power_gpio)
308-
gpiod_set_value_cansleep(pcie->power_gpio, 1);
309+
if (pcie->vpcie3v3) {
310+
ret = regulator_enable(pcie->vpcie3v3);
311+
if (ret)
312+
dev_err_probe(dev, ret, "failed to enable vpcie3v3 regulator\n");
313+
}
309314

310315
if (pcie->reset_gpio)
311316
gpiod_set_value_cansleep(pcie->reset_gpio, 1);

0 commit comments

Comments
 (0)