PCI: j721e: Add voltage regulator support
Subsystems (5)
cover PCI: j721e: Add voltage regulator support
From: Vitor Soares <[email protected]>
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/[email protected]/
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(+)
Signature · 1 line
2.51.0
PATCH 1/2 dt-bindings: PCI: ti,j721e-pci-host: Add optional regulator supplies
From: Vitor Soares <[email protected]>
Add optional regulator supply properties for PCIe endpoints on TI SoCs. Some boards provide dedicated regulators for PCIe devices, such as 1.5V (miniPCIe), 3.3V (common for M.2 or miniPCIe), or 12V (for high-power devices). These supplies are now described as optional properties to allow the driver to control endpoint power where supported.
--- .../devicetree/bindings/pci/ti,j721e-pci-host.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml +14 -0
@@ -110,6 +110,18 @@ properties: interrupts: maxItems: 1 + vpcie1v5-supply: + description: 1.5V regulator used to power PCIe interfaces, + typically present on miniPCIe slots. + + vpcie3v3-supply: + description: 3.3V regulator used to power PCIe interfaces + or endpoint connectors such as M.2 or miniPCIe. + + vpcie12v-supply: + description: 12V regulator used to power PCIe slots that + require higher-voltage devices (e.g. full-size cards). + allOf: - $ref: cdns-pcie-host.yaml# - if:
@@ -202,5 +214,7 @@ examples: ranges = <0x01000000 0x0 0x10001000 0x00 0x10001000 0x0 0x0010000>, <0x02000000 0x0 0x10011000 0x00 0x10011000 0x0 0x7fef000>; dma-ranges = <0x02000000 0x0 0x0 0x0 0x0 0x10000 0x0>; + vpcie3v3-supply = <&pcie_3v3>; + vpcie12v-supply = <&pcie_12v>; }; };
Signature · 1 line
2.51.0
Re: [PATCH v1 1/2] dt-bindings: PCI: ti,j721e-pci-host: Add optional regulator supplies
Quoted 7 lines · Vitor Soares
From: Vitor Soares <[email protected]>
Add optional regulator supply properties for PCIe endpoints on TI SoCs. Some boards provide dedicated regulators for PCIe devices, such as 1.5V (miniPCIe), 3.3V (common for M.2 or miniPCIe), or 12V (for high-power devices). These supplies are now described as optional properties to allow the driver to control endpoint power where supported.
Last sentence is completely redundant. Please do not describe DT, we all can read the patch. Driver is irrelevant here.
How you described here and in descriptions, suggests these are rather port properties, not the controller.
Quoted 11 lines
Signed-off-by Vitor Soares <[email protected]>--- .../devicetree/bindings/pci/ti,j721e-pci-host.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+)Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml +0
-0
Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml properties: · line 113
Quoted 4 lines
Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml +1
-0@@ -110,6 +110,18 @@ properties: interrupts: maxItems: 1 + vpcie1v5-supply:
How is it called in this device datasheet (not the board schematics)?
Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml properties: · line 115
Quoted 2 lines
Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml +2
-0+ description: 1.5V regulator used to power PCIe interfaces, + typically present on miniPCIe slots.
Best regards,
Krzysztof
Re: [PATCH v1 1/2] dt-bindings: PCI: ti,j721e-pci-host: Add optional regulator supplies
Hi Krzysztof,
Thank you for the feedback.
Quoted 13 lines · Krzysztof Kozlowski
Quoted 7 lines · Vitor Soares
From: Vitor Soares <[email protected]>
Add optional regulator supply properties for PCIe endpoints on TI SoCs. Some boards provide dedicated regulators for PCIe devices, such as 1.5V (miniPCIe), 3.3V (common for M.2 or miniPCIe), or 12V (for high-power devices). These supplies are now described as optional properties to allow the driver to control endpoint power where supported.
Last sentence is completely redundant. Please do not describe DT, we all can read the patch. Driver is irrelevant here.
Ack, I will remove last sentence.
Quoted 3 lines
How you described here and in descriptions, suggests these are rather port properties, not the controller.
You are right - these supplies power the PCIe slot/connector, not the controller itself. However, as per my understanding, the current kernel practice is to place slot supplies in the root complex node rather than the endpoint node. as seen in e.g.:
- imx6q-pcie.yaml
- rockchip-dw-pcie.yaml
- rcar-pci-host.yaml
This seems consistent with those existing bindings, but please let me know if I’m overlooking something specific to this case.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Vitor Soares <[email protected]>---
.../devicetree/bindings/pci/ti,j721e-pci-host.yaml | 14 ++++++++++++++1 file changed, 14 insertions(+)
Quoted 12 lines
Quoted 10 lines
Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml +0
-0@@ -110,6 +110,18 @@ properties:interrupts:
maxItems: 1
+ vpcie1v5-supply:How is it called in this device datasheet (not the board schematics)?
The TI SoC datasheet describes the controller interface but doesn’t define these external supply rails - they are board-level regulators specific to the slot.
Quoted 7 lines
Quoted 3 lines
+ description: 1.5V regulator used to power PCIe interfaces, + typically present on miniPCIe slots.
Best regards,
Krzysztof
Best regards,
Vitor Soares
Manivannan Sadhasivam
maintainerRe: [PATCH v1 1/2] dt-bindings: PCI: ti,j721e-pci-host: Add optional regulator supplies
Quoted 32 lines · Vitor Soares
Hi Krzysztof,
Thank you for the feedback.
Quoted 13 lines · Krzysztof Kozlowski
Quoted 7 lines · Vitor Soares
From: Vitor Soares <[email protected]>
Add optional regulator supply properties for PCIe endpoints on TI SoCs. Some boards provide dedicated regulators for PCIe devices, such as 1.5V (miniPCIe), 3.3V (common for M.2 or miniPCIe), or 12V (for high-power devices). These supplies are now described as optional properties to allow the driver to control endpoint power where supported.
Last sentence is completely redundant. Please do not describe DT, we all can read the patch. Driver is irrelevant here.
Ack, I will remove last sentence.
Quoted 3 lines
How you described here and in descriptions, suggests these are rather port properties, not the controller.
You are right - these supplies power the PCIe slot/connector, not the controller itself. However, as per my understanding, the current kernel practice is to place slot supplies in the root complex node rather than the endpoint node. as seen in e.g.:
-imx6q-pcie.yaml
-rockchip-dw-pcie.yaml
-rcar-pci-host.yaml
Quoted 3 lines
This seems consistent with those existing bindings, but please let me know if I’m overlooking something specific to this case.
We do not properly document it, but defining the slot supplies in host bridge (controller) node is deprecated. Some bindings still do it for legacy reasons, but the new ones should define them in the Root Port nodes as they belong to. We do not have a separate DT node for PCI slots, but rather reuse the Root Port node.
There are also bindings that define supplies in the endpoint node. They do it for devices directly connected to the PCI bus without a connector (like in PCB).
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH v1 1/2] dt-bindings: PCI: ti,j721e-pci-host: Add optional regulator supplies
Quoted 48 lines · Manivannan Sadhasivam
Quoted 35 lines · Vitor Soares
Hi Krzysztof,
Thank you for the feedback.
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Vitor Soares
From: Vitor Soares <[email protected]>
Add optional regulator supply properties for PCIe endpoints on TI SoCs. Some boards provide dedicated regulators for PCIe devices, such as 1.5V (miniPCIe), 3.3V (common for M.2 or miniPCIe), or 12V (for high-power devices). These supplies are now described as optional properties to allow the driver to control endpoint power where supported.
Quoted 4 lines
Last sentence is completely redundant. Please do not describe DT, we all can read the patch. Driver is irrelevant here.
Ack, I will remove last sentence.
Quoted 3 lines
How you described here and in descriptions, suggests these are rather port properties, not the controller.
You are right - these supplies power the PCIe slot/connector, not the controller
itself. However, as per my understanding, the current kernel practice is to place slot supplies in the root complex node rather than the endpoint node. as
seen in e.g.:
-imx6q-pcie.yaml
-rockchip-dw-pcie.yaml
-rcar-pci-host.yamlQuoted 4 lines
This seems consistent with those existing bindings, but please let me know if
I’m overlooking something specific to this case.We do not properly document it, but defining the slot supplies in host bridge (controller) node is deprecated. Some bindings still do it for legacy reasons, but the new ones should define them in the Root Port nodes as they belong to. We
do not have a separate DT node for PCI slots, but rather reuse the Root Port node.
Quoted 6 lines
There are also bindings that define supplies in the endpoint node. They do it for devices directly connected to the PCI bus without a connector (like in PCB).
- Mani
Thanks for the clarification and context. From what I understand, the recommendation is to define the supply regulators under the individual root port node rather than in the host bridge (controller) node, as the supplies conceptually belong to each port rather than the controller itself.
On the j721e PCIe controller, the current driver implementation assumes a single root port and doesn’t parse child port nodes. To follow the new convention, I’d need to refactor the driver to support root port subnodes, and I wonder if the PHY reference and reset should also be moved to the Root Port node in that case.
Could you please point me to an example of a PCIe controller binding or driver that already follows this approach?
Best regards,
Vitor Soares
PATCH 2/2 PCI: j721e: Add support for optional regulator supplies
In reply to Vitor SoaresFrom: Vitor Soares <[email protected]>
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.
--- drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/pci/controller/cadence/pci-j721e.c +13 -0
@@ -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);
Signature · 1 line
2.51.0
Manivannan Sadhasivam
maintainerRe: [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies
Quoted 29 lines · Vitor Soares
From: Vitor Soares <[email protected]>
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 <[email protected]>--- drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/controller/cadence/pci-j721e.c +1
-0@@ -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"
drivers/pci/controller/cadence/pci-j721e.c static const struct of_device_id of_j721e_pcie_match[] = { · line 473
Quoted 6 lines
drivers/pci/controller/cadence/pci-j721e.c +3
-0@@ -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
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies
Hello Mani,
Thank you for the feedback.
Quoted 43 lines · Manivannan Sadhasivam
Quoted 34 lines · Vitor Soares
From: Vitor Soares <[email protected]>
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 <[email protected]>---
drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++1 file changed, 13 insertions(+)drivers/pci/controller/cadence/pci-j721e.c +1
-0@@ -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"drivers/pci/controller/cadence/pci-j721e.c +0
-0@@ -467,6 +468,10 @@ static const struct of_device_id of_j721e_pcie_match[] = { }; MODULE_DEVICE_TABLE(of, of_j721e_pcie_match);drivers/pci/controller/cadence/pci-j721e.c static const struct of_device_id of_j721e_pcie_match[] = { · line 473
Quoted 3 lines
drivers/pci/controller/cadence/pci-j721e.c +3
-0+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.
Quoted 2 lines
- 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
Manivannan Sadhasivam
maintainerRe: [PATCH v1 2/2] PCI: j721e: Add support for optional regulator supplies
Quoted 64 lines · Vitor Soares
Hello Mani,
Thank you for the feedback.
Quoted 43 lines · Manivannan Sadhasivam
Quoted 34 lines · Vitor Soares
From: Vitor Soares <[email protected]>
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 <[email protected]>---
drivers/pci/controller/cadence/pci-j721e.c | 13 +++++++++++++1 file changed, 13 insertions(+)drivers/pci/controller/cadence/pci-j721e.c +1
-0@@ -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"drivers/pci/controller/cadence/pci-j721e.c +0
-0@@ -467,6 +468,10 @@ static const struct of_device_id of_j721e_pcie_match[] = { }; MODULE_DEVICE_TABLE(of, of_j721e_pcie_match);drivers/pci/controller/cadence/pci-j721e.c static const struct of_device_id of_j721e_pcie_match[] = { · line 473
Quoted 3 lines
drivers/pci/controller/cadence/pci-j721e.c +3
-0+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.Quoted 2 lines
- 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 withregulator_bulk_enable()
- Add cleanup/disable logic in remove path
- Handle error cleanup path manuallyThis 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.
Quoted 7 lines
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
Signature · 1 line
மணிவண்ணன் சதாசிவம்