* [PATCH v1 0/2] PCI: j721e: Add voltage regulator support @ 2025-10-14 11:25 Vitor Soares 2025-10-14 11:25 ` [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies Vitor Soares 0 siblings, 1 reply; 5+ messages in thread From: Vitor Soares @ 2025-10-14 11:25 UTC (permalink / raw) To: Bjorn Helgaas, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Vignesh Raghavendra, Siddharth Vadapalli, Kishon Vijay Abraham I Cc: Vitor Soares, linux-pci, devicetree, linux-kernel, linux-omap, linux-arm-kernel, ivitro From: Vitor Soares <vitor.soares@toradex.com> Some PCIe endpoints or slots connected to the TI J721E PCIe root complex may require external voltage regulators to provide 1.5V, 3.3V, or 12V supplies. These regulators depend on the specific board design — for example, M.2 or miniPCIe connectors often need 3.3V or 1.5V, while full-size PCIe slots may also require 12V. This series adds bindings and driver support for these optional regulators. When present, the driver enables them automatically using devm_regulator_get_enable_optional(), ensuring proper cleanup on removal. Tested on a Toradex Aquila AM69 platform with a Wi-Fi PCIe endpoint requiring 3.3V. These changes are based on upstream discussion: https://lore.kernel.org/linux-pci/20231105092908.3792-1-wsa+renesas@sang-engineering.com/ Vitor Soares (2): dt-bindings: PCI: ti,j721e-pci-host: Add optional regulator supplies PCI: j721e: Add support for optional regulator supplies .../devicetree/bindings/pci/ti,j721e-pci-host.yaml | 14 ++++++++++++++ drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++ 2 files changed, 27 insertions(+) -- 2.51.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies 2025-10-14 11:25 [PATCH v1 0/2] PCI: j721e: Add voltage regulator support Vitor Soares @ 2025-10-14 11:25 ` Vitor Soares 2025-10-21 2:06 ` Manivannan Sadhasivam 0 siblings, 1 reply; 5+ messages in thread From: Vitor Soares @ 2025-10-14 11:25 UTC (permalink / raw) To: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi, Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas Cc: Vitor Soares, linux-omap, linux-pci, linux-arm-kernel, linux-kernel, ivitro From: Vitor Soares <vitor.soares@toradex.com> Some boards require external regulators to power PCIe endpoints. Add support for optional 1.5V, 3.3V, and 12V supplies, which may be defined in the device tree as vpcie1v5-supply, vpcie3v3-supply, and vpcie12v-supply. Use devm_regulator_get_enable_optional() to obtain and enable each supply, so it will be automatically disabled when the driver is removed. Signed-off-by: Vitor Soares <vitor.soares@toradex.com> --- drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 5bc5ab20aa6d..f29ce2aef04e 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -21,6 +21,7 @@ #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include "../../pci.h" #include "pcie-cadence.h" @@ -467,6 +468,10 @@ static const struct of_device_id of_j721e_pcie_match[] = { }; MODULE_DEVICE_TABLE(of, of_j721e_pcie_match); +static const char * const j721e_pcie_supplies[] = { + "vpcie12v", "vpcie3v3", "vpcie1v5" +}; + static int j721e_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -480,6 +485,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) struct gpio_desc *gpiod; void __iomem *base; struct clk *clk; + unsigned int i; u32 num_lanes; u32 mode; int ret; @@ -565,6 +571,13 @@ static int j721e_pcie_probe(struct platform_device *pdev) if (irq < 0) return irq; + for (i = 0; i < ARRAY_SIZE(j721e_pcie_supplies); i++) { + ret = devm_regulator_get_enable_optional(dev, j721e_pcie_supplies[i]); + if (ret < 0 && ret != -ENODEV) + return dev_err_probe(dev, ret, "can't enable regulator %s\n", + j721e_pcie_supplies[i]); + } + dev_set_drvdata(dev, pcie); pm_runtime_enable(dev); ret = pm_runtime_get_sync(dev); -- 2.51.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies 2025-10-14 11:25 ` [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies Vitor Soares @ 2025-10-21 2:06 ` Manivannan Sadhasivam 2025-10-27 20:24 ` Vitor Soares 0 siblings, 1 reply; 5+ messages in thread From: Manivannan Sadhasivam @ 2025-10-21 2:06 UTC (permalink / raw) To: Vitor Soares Cc: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, Vitor Soares, linux-omap, linux-pci, linux-arm-kernel, linux-kernel On Tue, Oct 14, 2025 at 12:25:49PM +0100, Vitor Soares wrote: > From: Vitor Soares <vitor.soares@toradex.com> > > Some boards require external regulators to power PCIe endpoints. > Add support for optional 1.5V, 3.3V, and 12V supplies, which may be > defined in the device tree as vpcie1v5-supply, vpcie3v3-supply, and > vpcie12v-supply. > > Use devm_regulator_get_enable_optional() to obtain and enable each > supply, so it will be automatically disabled when the driver is > removed. > > Signed-off-by: Vitor Soares <vitor.soares@toradex.com> > --- > drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c > index 5bc5ab20aa6d..f29ce2aef04e 100644 > --- a/drivers/pci/controller/cadence/pci-j721e.c > +++ b/drivers/pci/controller/cadence/pci-j721e.c > @@ -21,6 +21,7 @@ > #include <linux/platform_device.h> > #include <linux/pm_runtime.h> > #include <linux/regmap.h> > +#include <linux/regulator/consumer.h> > > #include "../../pci.h" > #include "pcie-cadence.h" > @@ -467,6 +468,10 @@ static const struct of_device_id of_j721e_pcie_match[] = { > }; > MODULE_DEVICE_TABLE(of, of_j721e_pcie_match); > > +static const char * const j721e_pcie_supplies[] = { > + "vpcie12v", "vpcie3v3", "vpcie1v5" > +}; Please don't hardcode the supplies in driver. The DT binding should make sure the relevant supplies are passed (including the optional ones). Just use of_regulator_bulk_get_all() to acquire all the passed supplies. - Mani -- மணிவண்ணன் சதாசிவம் ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies 2025-10-21 2:06 ` Manivannan Sadhasivam @ 2025-10-27 20:24 ` Vitor Soares 2025-10-28 5:46 ` Manivannan Sadhasivam 0 siblings, 1 reply; 5+ messages in thread From: Vitor Soares @ 2025-10-27 20:24 UTC (permalink / raw) To: Manivannan Sadhasivam Cc: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, Vitor Soares, linux-omap, linux-pci, linux-arm-kernel, linux-kernel Hello Mani, Thank you for the feedback. On Tue, 2025-10-21 at 07:36 +0530, Manivannan Sadhasivam wrote: > On Tue, Oct 14, 2025 at 12:25:49PM +0100, Vitor Soares wrote: > > From: Vitor Soares <vitor.soares@toradex.com> > > > > Some boards require external regulators to power PCIe endpoints. > > Add support for optional 1.5V, 3.3V, and 12V supplies, which may be > > defined in the device tree as vpcie1v5-supply, vpcie3v3-supply, and > > vpcie12v-supply. > > > > Use devm_regulator_get_enable_optional() to obtain and enable each > > supply, so it will be automatically disabled when the driver is > > removed. > > > > Signed-off-by: Vitor Soares <vitor.soares@toradex.com> > > --- > > drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/drivers/pci/controller/cadence/pci-j721e.c > > b/drivers/pci/controller/cadence/pci-j721e.c > > index 5bc5ab20aa6d..f29ce2aef04e 100644 > > --- a/drivers/pci/controller/cadence/pci-j721e.c > > +++ b/drivers/pci/controller/cadence/pci-j721e.c > > @@ -21,6 +21,7 @@ > > #include <linux/platform_device.h> > > #include <linux/pm_runtime.h> > > #include <linux/regmap.h> > > +#include <linux/regulator/consumer.h> > > > > #include "../../pci.h" > > #include "pcie-cadence.h" > > @@ -467,6 +468,10 @@ static const struct of_device_id of_j721e_pcie_match[] > > = { > > }; > > MODULE_DEVICE_TABLE(of, of_j721e_pcie_match); > > > > +static const char * const j721e_pcie_supplies[] = { > > + "vpcie12v", "vpcie3v3", "vpcie1v5" > > +}; > > Please don't hardcode the supplies in driver. The DT binding should make sure > the relevant supplies are passed (including the optional ones). Just use > of_regulator_bulk_get_all() to acquire all the passed supplies. > > - Mani > I checked the bulk regulator APIs as suggested and of_regulator_bulk_get_all() does handle optional supplies correctly, however it is not a managed function and doesn't enable the regulators automatically. To use of_regulator_bulk_get_all(), I would need to: - Manually enable regulators with regulator_bulk_enable() - Add cleanup/disable logic in remove path - Handle error cleanup path manually This would actually make the code more complex and error-prone compared to the current approach using devm_regulator_get_enable_optional(), which provides managed cleanup and automatic enable for optional supplies. I also checked devm_regulator_bulk_get_enable(), it treats all supplies as required and needs the supplies name as well. Unless there is a devm_regulator_bulk_get_optional_enable() API I'm not aware of, the current per-supply approach is the standard kernel pattern for this use case. Would you still prefer the bulk approach despite these limitations? Best regards, Vitor Soares ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies 2025-10-27 20:24 ` Vitor Soares @ 2025-10-28 5:46 ` Manivannan Sadhasivam 0 siblings, 0 replies; 5+ messages in thread From: Manivannan Sadhasivam @ 2025-10-28 5:46 UTC (permalink / raw) To: Vitor Soares Cc: Vignesh Raghavendra, Siddharth Vadapalli, Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas, Vitor Soares, linux-omap, linux-pci, linux-arm-kernel, linux-kernel On Mon, Oct 27, 2025 at 08:24:12PM +0000, Vitor Soares wrote: > Hello Mani, > > Thank you for the feedback. > > On Tue, 2025-10-21 at 07:36 +0530, Manivannan Sadhasivam wrote: > > On Tue, Oct 14, 2025 at 12:25:49PM +0100, Vitor Soares wrote: > > > From: Vitor Soares <vitor.soares@toradex.com> > > > > > > Some boards require external regulators to power PCIe endpoints. > > > Add support for optional 1.5V, 3.3V, and 12V supplies, which may be > > > defined in the device tree as vpcie1v5-supply, vpcie3v3-supply, and > > > vpcie12v-supply. > > > > > > Use devm_regulator_get_enable_optional() to obtain and enable each > > > supply, so it will be automatically disabled when the driver is > > > removed. > > > > > > Signed-off-by: Vitor Soares <vitor.soares@toradex.com> > > > --- > > > drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++ > > > 1 file changed, 13 insertions(+) > > > > > > diff --git a/drivers/pci/controller/cadence/pci-j721e.c > > > b/drivers/pci/controller/cadence/pci-j721e.c > > > index 5bc5ab20aa6d..f29ce2aef04e 100644 > > > --- a/drivers/pci/controller/cadence/pci-j721e.c > > > +++ b/drivers/pci/controller/cadence/pci-j721e.c > > > @@ -21,6 +21,7 @@ > > > #include <linux/platform_device.h> > > > #include <linux/pm_runtime.h> > > > #include <linux/regmap.h> > > > +#include <linux/regulator/consumer.h> > > > > > > #include "../../pci.h" > > > #include "pcie-cadence.h" > > > @@ -467,6 +468,10 @@ static const struct of_device_id of_j721e_pcie_match[] > > > = { > > > }; > > > MODULE_DEVICE_TABLE(of, of_j721e_pcie_match); > > > > > > +static const char * const j721e_pcie_supplies[] = { > > > + "vpcie12v", "vpcie3v3", "vpcie1v5" > > > +}; > > > > Please don't hardcode the supplies in driver. The DT binding should make sure > > the relevant supplies are passed (including the optional ones). Just use > > of_regulator_bulk_get_all() to acquire all the passed supplies. > > > > - Mani > > > > I checked the bulk regulator APIs as suggested and of_regulator_bulk_get_all() > does handle optional supplies correctly, however it is not a managed function > and doesn't enable the regulators automatically. > > To use of_regulator_bulk_get_all(), I would need to: > - Manually enable regulators with regulator_bulk_enable() > - Add cleanup/disable logic in remove path > - Handle error cleanup path manually > > This would actually make the code more complex and error-prone compared to the > current approach using devm_regulator_get_enable_optional(), which provides > managed cleanup and automatic enable for optional supplies. > > I also checked devm_regulator_bulk_get_enable(), it treats all supplies as > required and needs the supplies name as well. > > Unless there is a devm_regulator_bulk_get_optional_enable() API I'm not aware > of, the current per-supply approach is the standard kernel pattern for this use > case. Would you still prefer the bulk approach despite these limitations? > Fine then. If you do not have a reason to manualy turn off/on the supplies (during suspend/resume), then it might be better to use devm_regulator_get_enable_optional() for now. I'd love to add the managed version of of_regulator_bulk_get_all(), but I guess Mark wouldn't want it. - Mani -- மணிவண்ணன் சதாசிவம் ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-10-28 5:46 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-10-14 11:25 [PATCH v1 0/2] PCI: j721e: Add voltage regulator support Vitor Soares 2025-10-14 11:25 ` [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies Vitor Soares 2025-10-21 2:06 ` Manivannan Sadhasivam 2025-10-27 20:24 ` Vitor Soares 2025-10-28 5:46 ` Manivannan Sadhasivam
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox