* [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
@ 2025-09-05 11:27 Anand Moon
2025-10-18 5:51 ` Anand Moon
2025-10-19 6:38 ` Manivannan Sadhasivam
0 siblings, 2 replies; 6+ messages in thread
From: Anand Moon @ 2025-09-05 11:27 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Liam Girdwood, Mark Brown, Niklas Cassel, Shawn Lin, Hans Zhang,
Wilfred Mallawa,
open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS,
moderated list:ARM/Rockchip SoC support,
open list:ARM/Rockchip SoC support, open list
Cc: Anand Moon
Replace manual get/enable logic with devm_regulator_get_enable_optional()
to reduce boilerplate and improve error handling. This devm helper ensures
the regulator is enabled during probe and automatically disabled on driver
removal. Dropping the vpcie3v3 struct member eliminates redundant state
tracking, resulting in cleaner and more maintainable code.
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 23 +++++--------------
1 file changed, 6 insertions(+), 17 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index b5f5eee5a50e..56baca52c3e9 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -76,7 +76,6 @@ struct rockchip_pcie {
unsigned int clk_cnt;
struct reset_control *rst;
struct gpio_desc *rst_gpio;
- struct regulator *vpcie3v3;
struct irq_domain *irq_domain;
const struct rockchip_pcie_of_data *data;
};
@@ -644,22 +643,15 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
return ret;
/* DON'T MOVE ME: must be enable before PHY init */
- rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
- if (IS_ERR(rockchip->vpcie3v3)) {
- if (PTR_ERR(rockchip->vpcie3v3) != -ENODEV)
- return dev_err_probe(dev, PTR_ERR(rockchip->vpcie3v3),
- "failed to get vpcie3v3 regulator\n");
- rockchip->vpcie3v3 = NULL;
- } else {
- ret = regulator_enable(rockchip->vpcie3v3);
- if (ret)
- return dev_err_probe(dev, ret,
- "failed to enable vpcie3v3 regulator\n");
- }
+ ret = devm_regulator_get_enable_optional(dev, "vpcie3v3");
+ if (ret < 0 && ret != -ENODEV)
+ return dev_err_probe(dev, ret,
+ "failed to enable vpcie3v3 regulator\n");
ret = rockchip_pcie_phy_init(rockchip);
if (ret)
- goto disable_regulator;
+ return dev_err_probe(dev, ret,
+ "failed to initialize the phy\n");
ret = reset_control_deassert(rockchip->rst);
if (ret)
@@ -692,9 +684,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
deinit_phy:
rockchip_pcie_phy_deinit(rockchip);
-disable_regulator:
- if (rockchip->vpcie3v3)
- regulator_disable(rockchip->vpcie3v3);
return ret;
}
base-commit: d69eb204c255c35abd9e8cb621484e8074c75eaa
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
2025-09-05 11:27 [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional() Anand Moon
@ 2025-10-18 5:51 ` Anand Moon
2025-10-19 6:25 ` Manivannan Sadhasivam
2025-10-19 6:38 ` Manivannan Sadhasivam
1 sibling, 1 reply; 6+ messages in thread
From: Anand Moon @ 2025-10-18 5:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Liam Girdwood, Mark Brown, Niklas Cassel, Shawn Lin, Hans Zhang,
Wilfred Mallawa,
open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS,
moderated list:ARM/Rockchip SoC support,
open list:ARM/Rockchip SoC support, open list
Hi All,
On Fri, 5 Sept 2025 at 16:57, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Replace manual get/enable logic with devm_regulator_get_enable_optional()
> to reduce boilerplate and improve error handling. This devm helper ensures
> the regulator is enabled during probe and automatically disabled on driver
> removal. Dropping the vpcie3v3 struct member eliminates redundant state
> tracking, resulting in cleaner and more maintainable code.
>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 23 +++++--------------
> 1 file changed, 6 insertions(+), 17 deletions(-)
>
If we compile the kernel with phy and regulator as modules,
I observe this message.
[ 25.473960][ T55] platform 3c0800000.pcie: deferred probe
pending: platform: supplier regulator-vcc3v3-pcie not ready
[ 25.474071][ T55] platform fe0a0000.hdmi: deferred probe pending:
platform: wait for supplier /i2c@fdd40000/pmic@20/regulators/LDO_REG9
[ 25.474124][ T55] platform regulator-vcc5v0-usb-otg: deferred
probe pending: reg-fixed-voltage: can't get GPIO
[ 25.474171][ T55] platform fdc20000.syscon:io-domains: deferred
probe pending: platform: wait for supplier
/i2c@fdd40000/pmic@20/regulators/SWITCH_REG1
[ 25.474218][ T55] platform cpufreq-dt: deferred probe pending:
(reason unknown)
[ 25.474264][ T55] platform regulator-vcc3v3-pcie: deferred probe
pending: reg-fixed-voltage: can't get GPIO
[ 25.474343][ T55] rockchip-pm-domain
fdd90000.power-management:power-controller: Timed out. Forcing
sync_state()
[ 37.744968][ T2415] psi: inconsistent task state!
task=2280:(udev-worker) cpu=1 psi_flags=4 clear=0 set=4
[ 37.849725][ T50] fan53555-regulator 3-001c: FAN53555 Option[12]
Rev[15] Detected!
[ 37.990008][ T2216] SCSI subsystem initialized
Thanks
-Anand
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
2025-10-18 5:51 ` Anand Moon
@ 2025-10-19 6:25 ` Manivannan Sadhasivam
0 siblings, 0 replies; 6+ messages in thread
From: Manivannan Sadhasivam @ 2025-10-19 6:25 UTC (permalink / raw)
To: Anand Moon
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Heiko Stuebner, Liam Girdwood, Mark Brown,
Niklas Cassel, Shawn Lin, Hans Zhang, Wilfred Mallawa,
open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS,
moderated list:ARM/Rockchip SoC support,
open list:ARM/Rockchip SoC support, open list
On Sat, Oct 18, 2025 at 11:21:49AM +0530, Anand Moon wrote:
> Hi All,
>
> On Fri, 5 Sept 2025 at 16:57, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > Replace manual get/enable logic with devm_regulator_get_enable_optional()
> > to reduce boilerplate and improve error handling. This devm helper ensures
> > the regulator is enabled during probe and automatically disabled on driver
> > removal. Dropping the vpcie3v3 struct member eliminates redundant state
> > tracking, resulting in cleaner and more maintainable code.
> >
> > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > ---
> > drivers/pci/controller/dwc/pcie-dw-rockchip.c | 23 +++++--------------
> > 1 file changed, 6 insertions(+), 17 deletions(-)
> >
> If we compile the kernel with phy and regulator as modules,
> I observe this message.
>
> [ 25.473960][ T55] platform 3c0800000.pcie: deferred probe
> pending: platform: supplier regulator-vcc3v3-pcie not ready
> [ 25.474071][ T55] platform fe0a0000.hdmi: deferred probe pending:
> platform: wait for supplier /i2c@fdd40000/pmic@20/regulators/LDO_REG9
> [ 25.474124][ T55] platform regulator-vcc5v0-usb-otg: deferred
> probe pending: reg-fixed-voltage: can't get GPIO
> [ 25.474171][ T55] platform fdc20000.syscon:io-domains: deferred
> probe pending: platform: wait for supplier
> /i2c@fdd40000/pmic@20/regulators/SWITCH_REG1
> [ 25.474218][ T55] platform cpufreq-dt: deferred probe pending:
> (reason unknown)
> [ 25.474264][ T55] platform regulator-vcc3v3-pcie: deferred probe
> pending: reg-fixed-voltage: can't get GPIO
> [ 25.474343][ T55] rockchip-pm-domain
> fdd90000.power-management:power-controller: Timed out. Forcing
> sync_state()
> [ 37.744968][ T2415] psi: inconsistent task state!
> task=2280:(udev-worker) cpu=1 psi_flags=4 clear=0 set=4
> [ 37.849725][ T50] fan53555-regulator 3-001c: FAN53555 Option[12]
> Rev[15] Detected!
> [ 37.990008][ T2216] SCSI subsystem initialized
>
This is a deferred probe log and not related to this patch or the PCIe
controller driver. The controller drivers should still be functional once the
dependent GPIO driver is probed.
- Mani
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
2025-09-05 11:27 [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional() Anand Moon
2025-10-18 5:51 ` Anand Moon
@ 2025-10-19 6:38 ` Manivannan Sadhasivam
2025-10-31 6:57 ` Anand Moon
1 sibling, 1 reply; 6+ messages in thread
From: Manivannan Sadhasivam @ 2025-10-19 6:38 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Heiko Stuebner, Liam Girdwood, Mark Brown,
Niklas Cassel, Shawn Lin, Hans Zhang, Wilfred Mallawa, linux-pci,
linux-arm-kernel, linux-rockchip, linux-kernel, Anand Moon
On Fri, 05 Sep 2025 16:57:25 +0530, Anand Moon wrote:
> Replace manual get/enable logic with devm_regulator_get_enable_optional()
> to reduce boilerplate and improve error handling. This devm helper ensures
> the regulator is enabled during probe and automatically disabled on driver
> removal. Dropping the vpcie3v3 struct member eliminates redundant state
> tracking, resulting in cleaner and more maintainable code.
>
>
> [...]
Applied, thanks!
[1/1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
commit: c930b10f17c03858cfe19b9873ba5240128b4d1b
Best regards,
--
Manivannan Sadhasivam <mani@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
2025-10-19 6:38 ` Manivannan Sadhasivam
@ 2025-10-31 6:57 ` Anand Moon
2025-11-01 10:47 ` Anand Moon
0 siblings, 1 reply; 6+ messages in thread
From: Anand Moon @ 2025-10-31 6:57 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Heiko Stuebner, Liam Girdwood, Mark Brown,
Niklas Cassel, Shawn Lin, Hans Zhang, Wilfred Mallawa, linux-pci,
linux-arm-kernel, linux-rockchip, linux-kernel
Hi Manivannan,
On Sun, 19 Oct 2025 at 12:08, Manivannan Sadhasivam <mani@kernel.org> wrote:
>
>
> On Fri, 05 Sep 2025 16:57:25 +0530, Anand Moon wrote:
> > Replace manual get/enable logic with devm_regulator_get_enable_optional()
> > to reduce boilerplate and improve error handling. This devm helper ensures
> > the regulator is enabled during probe and automatically disabled on driver
> > removal. Dropping the vpcie3v3 struct member eliminates redundant state
> > tracking, resulting in cleaner and more maintainable code.
> >
> >
> > [...]
>
> Applied, thanks!
>
> [1/1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
> commit: c930b10f17c03858cfe19b9873ba5240128b4d1b
>
I am looking to suspend or resume the issue. We probably need to
toggle the regulator
to maintain the power status on the PCIe controller.
Therefore, dropping the patch is an option; I will add dev_err_probe
for PHY later in the patch.
> Best regards,
> --
> Manivannan Sadhasivam <mani@kernel.org>
>
Thanks
-Anand
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
2025-10-31 6:57 ` Anand Moon
@ 2025-11-01 10:47 ` Anand Moon
0 siblings, 0 replies; 6+ messages in thread
From: Anand Moon @ 2025-11-01 10:47 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
Bjorn Helgaas, Heiko Stuebner, Liam Girdwood, Mark Brown,
Niklas Cassel, Shawn Lin, Hans Zhang, Wilfred Mallawa, linux-pci,
linux-arm-kernel, linux-rockchip, linux-kernel
Hi Manivannan,
On Fri, 31 Oct 2025 at 12:27, Anand Moon <linux.amoon@gmail.com> wrote:
>
> Hi Manivannan,
>
> On Sun, 19 Oct 2025 at 12:08, Manivannan Sadhasivam <mani@kernel.org> wrote:
> >
> >
> > On Fri, 05 Sep 2025 16:57:25 +0530, Anand Moon wrote:
> > > Replace manual get/enable logic with devm_regulator_get_enable_optional()
> > > to reduce boilerplate and improve error handling. This devm helper ensures
> > > the regulator is enabled during probe and automatically disabled on driver
> > > removal. Dropping the vpcie3v3 struct member eliminates redundant state
> > > tracking, resulting in cleaner and more maintainable code.
> > >
> > >
> > > [...]
> >
> > Applied, thanks!
> >
> > [1/1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional()
> > commit: c930b10f17c03858cfe19b9873ba5240128b4d1b
> >
> I am looking to suspend or resume the issue. We probably need to
> toggle the regulator
> to maintain the power status on the PCIe controller.
> Therefore, dropping the patch is an option; I will add dev_err_probe
> for PHY later in the patch.
>
I found this series with the address system suspend support
[1] https://lore.kernel.org/linux-pci/20251029-rockchip-pcie-system-suspend-v4-0-ce2e1b0692d2@collabora.com/
This patch will conflict with
[2] https://lore.kernel.org/linux-pci/20251029-rockchip-pcie-system-suspend-v4-3-ce2e1b0692d2@collabora.com/
So please drop my patch.
Thanks
-Anand
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-01 10:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-05 11:27 [PATCH v1] PCI: dw-rockchip: Simplify regulator setup with devm_regulator_get_enable_optional() Anand Moon
2025-10-18 5:51 ` Anand Moon
2025-10-19 6:25 ` Manivannan Sadhasivam
2025-10-19 6:38 ` Manivannan Sadhasivam
2025-10-31 6:57 ` Anand Moon
2025-11-01 10:47 ` Anand Moon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).