diff mbox series

[RFC,2/3] PCI: rcar-host: add support for optional regulators

Message ID 20230508104557.47889-3-wsa+renesas@sang-engineering.com (mailing list archive)
State Superseded
Delegated to: Krzysztof Wilczyński
Headers show
Series KingFisher: support regulators for PCIe | expand

Commit Message

Wolfram Sang May 8, 2023, 10:45 a.m. UTC
The KingFisher board has regulators. They just need to be en-/disabled,
so we can leave the handling to devm.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/pci/controller/pcie-rcar-host.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Geert Uytterhoeven May 8, 2023, 1:45 p.m. UTC | #1
Hi Wolfram,

On Mon, May 8, 2023 at 12:47 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> The KingFisher board has regulators. They just need to be en-/disabled,
> so we can leave the handling to devm.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks for your patch!

> --- a/drivers/pci/controller/pcie-rcar-host.c
> +++ b/drivers/pci/controller/pcie-rcar-host.c

> @@ -992,6 +993,14 @@ static int rcar_pcie_probe(struct platform_device *pdev)
>         pcie->dev = dev;
>         platform_set_drvdata(pdev, host);
>
> +       err = devm_regulator_get_enable_optional(dev, "vpcie3v3");
> +       if (err < 0 && err != -ENODEV)
> +               dev_err_probe(dev, err, "error enabling 3.3V regulator");
> +
> +       err = devm_regulator_get_enable_optional(dev, "vpcie1v5");
> +       if (err < 0 && err != -ENODEV)
> +               dev_err_probe(dev, err, "error enabling 1.5V regulator");

As per my comment on patch 1/3, I think you want to grab
"vpcie12v0-supply", too.
And perhaps factor out the voltage as a parameter in the error message,
to increase string sharing?

I don't know if PCIe specifies some ordering w.r.t. power supply
enablement.

> +
>         pm_runtime_enable(pcie->dev);
>         err = pm_runtime_get_sync(pcie->dev);
>         if (err < 0) {

Gr{oetje,eeting}s,

                        Geert
Wolfram Sang May 9, 2023, 10:20 a.m. UTC | #2
> I don't know if PCIe specifies some ordering w.r.t. power supply
> enablement.

I found this which is good enough for me:

"There is no requirement for supply sequencing in either
PCI Express or PCI Express Mini Card; the supplies may
come up or go down in any order." [1]

Thanks, Linear Technology!

[1] https://www.analog.com/media/en/reference-design-documentation/design-notes/dn346f.pdf
diff mbox series

Patch

diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
index e80e56b2a842..b0e4834176d2 100644
--- a/drivers/pci/controller/pcie-rcar-host.c
+++ b/drivers/pci/controller/pcie-rcar-host.c
@@ -29,6 +29,7 @@ 
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
 
 #include "pcie-rcar.h"
 
@@ -992,6 +993,14 @@  static int rcar_pcie_probe(struct platform_device *pdev)
 	pcie->dev = dev;
 	platform_set_drvdata(pdev, host);
 
+	err = devm_regulator_get_enable_optional(dev, "vpcie3v3");
+	if (err < 0 && err != -ENODEV)
+		dev_err_probe(dev, err, "error enabling 3.3V regulator");
+
+	err = devm_regulator_get_enable_optional(dev, "vpcie1v5");
+	if (err < 0 && err != -ENODEV)
+		dev_err_probe(dev, err, "error enabling 1.5V regulator");
+
 	pm_runtime_enable(pcie->dev);
 	err = pm_runtime_get_sync(pcie->dev);
 	if (err < 0) {