dt-bindings: regulator: Add support for multiple supplies
Subsystems (2)
PATCH v2 1/2 dt-bindings: regulator: Add support for multiple supplies
Add optional DT property 'regulator-supplies' to handle connectors with multiple supplies.
If this property is present, it will determine all regulator supplies. Otherwise, the 'vout' supply will be used as a fallback.
This change improves support for connector like PCIe connectors on mainboards that can be powered by 12V and 3.3V supplies.
...
Change in V2:
- Added example
- Update property type & description.
- Improve commit message
--- .../bindings/regulator/regulator-output.yaml | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/regulator/regulator-output.yaml +18 -3
@@ -21,13 +21,22 @@ properties: compatible: const: regulator-output - vout-supply: + regulator-supplies: + $ref: /schemas/types.yaml#/definitions/string-array description: - Phandle of the regulator supplying the output. + Optional property that specifies supply names provided by + the regulator. Defaults to "vout" if not specified. The + array contains a list of supply names. + Each supply name corresponds to a phandle in the + patternProperties. + +patternProperties: + ".*-supply": + description: + Specifies the phandle for various supplies required: - compatible - - vout-supply additionalProperties: false
@@ -37,3 +46,9 @@ examples: compatible = "regulator-output"; vout-supply = <&output_reg>; }; + out2 { + compatible = "regulator-output"; + regulator-supplies = "sw0", "sw1"; + sw0-supply = <&out2_sw0>; + sw1-supply = <&out2_sw1>; + };
base-commit: 43c75e470e5b56a992acb08474810e6822f0989c
Signature · 1 line
2.39.1
PATCH v2 2/2 regulator: userspace-consumer: Support multiple supplies in DT
Add support for optional DT property 'regulator-supplies' to handle connectors with multiple supplies.
If this property is present, it will determine all regulator supplies. Otherwise, the 'vout' supply will be used as a fallback.
This change improves support for some connector output like PCIe connectors on mainboards that can be powered by 12V and 3.3V supplies.
...
Change in V2:
- Update commit message
- Code improved to add fallback if the property isn't used.
--- drivers/regulator/userspace-consumer.c | 33 +++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-)
drivers/regulator/userspace-consumer.c +27 -6
@@ -120,7 +120,10 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)struct regulator_userspace_consumer_data tmpdata;struct regulator_userspace_consumer_data *pdata;struct userspace_consumer_data *drvdata; -int ret; +struct device_node *np = pdev->dev.of_node; +struct property *prop; +const char *supply; +int ret, count =0 ; pdata =dev_get_platdata (&pdev->dev);if (!pdata) {
@@ -131,11 +134,29 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)memset (pdata,0 ,sizeof (*pdata)); pdata->no_autoswitch = true; - pdata->num_supplies =1 ; - pdata->supplies =devm_kzalloc (&pdev->dev,sizeof (*pdata->supplies),GFP_KERNEL ); -if (!pdata->supplies) -return -ENOMEM ; - pdata->supplies[0 ].supply ="vout" ; + +if (of_find_property (np,"regulator-supplies" ,NULL )) { + pdata->num_supplies =of_property_count_strings (np,"regulator-supplies" ); +if (pdata->num_supplies <1 ) { +dev_err (&pdev->dev, +"could not parse property regulator-supplies\n" ); +return -EINVAL ; + } + pdata->supplies =devm_kzalloc (&pdev->dev,sizeof (*pdata->supplies) * + pdata->num_supplies,GFP_KERNEL ); +if (!pdata->supplies) +return -ENOMEM ; +of_property_for_each_string (np,"regulator-supplies" , prop, supply) { + pdata->supplies[count++].supply = supply; + } + }else { + pdata->num_supplies =1 ; + pdata->supplies =devm_kzalloc (&pdev->dev,sizeof (*pdata->supplies), +GFP_KERNEL ); +if (!pdata->supplies) +return -ENOMEM ; + pdata->supplies[0 ].supply ="vout" ; + } }if (pdata->num_supplies <1 ) {
Signature · 1 line
2.39.1
Rob Herring
maintainerQuoted 31 lines · Naresh Solanki
Add optional DT property 'regulator-supplies' to handle connectors with multiple supplies.
If this property is present, it will determine all regulator supplies. Otherwise, the 'vout' supply will be used as a fallback.This change improves support for connector like PCIe connectors on mainboards that can be powered by 12V and 3.3V supplies.
Signed-off-by Naresh Solanki <[email protected]>...
Change in V2:
- Added example
- Update property type & description.
- Improve commit message--- .../bindings/regulator/regulator-output.yaml | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)Documentation/devicetree/bindings/regulator/regulator-output.yaml +2
-2@@ -21,13 +21,22 @@ properties: compatible: const: regulator-output - vout-supply: + regulator-supplies: + $ref: /schemas/types.yaml#/definitions/string-array description: - Phandle of the regulator supplying the output.
Documentation/devicetree/bindings/regulator/regulator-output.yaml properties: · line 36
Quoted 10 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +10
-0+ Optional property that specifies supply names provided by + the regulator. Defaults to "vout" if not specified. The + array contains a list of supply names. + Each supply name corresponds to a phandle in the + patternProperties. + +patternProperties: + ".*-supply": + description: + Specifies the phandle for various supplies
While you say use 'vout-supply' for a single supply, nothing enforces that anymore.
Quoted 8 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +0
-1required: - compatible - - vout-supply additionalProperties: false
Documentation/devicetree/bindings/regulator/regulator-output.yaml examples: · line 53
Quoted 8 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +5
-0@@ -37,3 +46,9 @@ examples: compatible = "regulator-output"; vout-supply = <&output_reg>; }; + out2 { + compatible = "regulator-output"; + regulator-supplies = "sw0", "sw1"; + sw0-supply = <&out2_sw0>; + sw1-supply = <&out2_sw1>;
Names in the consumer are relative to the consumer. You appear to be naming these by the supplier. Just add vout[0-9]-supply and iterate over that name in the driver. Then you don't need "regulator-supplies". Really, you never did. You could just find all properties ending in "-supply".
Rob
Hi Rob,
Quoted 53 lines · Rob Herring
Quoted 31 lines · Naresh Solanki
Add optional DT property 'regulator-supplies' to handle connectors with multiple supplies.
If this property is present, it will determine all regulator supplies. Otherwise, the 'vout' supply will be used as a fallback.This change improves support for connector like PCIe connectors on mainboards that can be powered by 12V and 3.3V supplies.
Signed-off-by Naresh Solanki <[email protected]>...
Change in V2:
- Added example
- Update property type & description.
- Improve commit message--- .../bindings/regulator/regulator-output.yaml | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)Documentation/devicetree/bindings/regulator/regulator-output.yaml +2
-2@@ -21,13 +21,22 @@ properties: compatible: const: regulator-output - vout-supply: + regulator-supplies: + $ref: /schemas/types.yaml#/definitions/string-array description: - Phandle of the regulator supplying the output.Documentation/devicetree/bindings/regulator/regulator-output.yaml properties: · line 36
Quoted 10 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +10
-0+ Optional property that specifies supply names provided by + the regulator. Defaults to "vout" if not specified. The + array contains a list of supply names. + Each supply name corresponds to a phandle in the + patternProperties. + +patternProperties: + ".*-supply": + description: + Specifies the phandle for various suppliesWhile you say use 'vout-supply' for a single supply, nothing enforces that anymore.
Quoted 7 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +0
-1required: - compatible - - vout-supply additionalProperties: false
Quoted 15 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml examples: · line 53
Quoted 9 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +5
-0@@ -37,3 +46,9 @@ examples: compatible = "regulator-output"; vout-supply = <&output_reg>; }; + out2 { + compatible = "regulator-output"; + regulator-supplies = "sw0", "sw1"; + sw0-supply = <&out2_sw0>; + sw1-supply = <&out2_sw1>;Names in the consumer are relative to the consumer. You appear to be naming these by the supplier. Just add vout[0-9]-supply and iterate over that name in the driver. Then you don't need "regulator-supplies". Really, you never did. You could just find all properties ending in "-supply".
Please correct me if I have misunderstood anything
What I understood is:
1. Use 'for_each_property_of_node' & iterate each property,
2. String compare each property name ending with '-supply',
3. If there is match then initialize accordingly.
This way all *-supply property are also included including vout-supply. This way, regulator-supplies isn't needed.
Shall I go ahead in this way ?
Quoted 2 lines
Rob
Regards,
Naresh
Hi Rob,
Quoted 67 lines · Naresh Solanki
Hi Rob,
Quoted 56 lines · Rob Herring
Quoted 35 lines · Naresh Solanki
Add optional DT property 'regulator-supplies' to handle connectors with multiple supplies.
If this property is present, it will determine all regulator supplies. Otherwise, the 'vout' supply will be used as a fallback.This change improves support for connector like PCIe connectors on mainboards that can be powered by 12V and 3.3V supplies.
Signed-off-by Naresh Solanki <[email protected]>...
Change in V2:
- Added example
- Update property type & description.
- Improve commit message
---
.../bindings/regulator/regulator-output.yaml | 21 ++++++++++++++++---1 file changed, 18 insertions(+), 3 deletions(-)Documentation/devicetree/bindings/regulator/regulator-output.yaml +0
-0@@ -21,13 +21,22 @@ properties:compatible:
const: regulator-output
- vout-supply:
+ regulator-supplies:
+ $ref: /schemas/types.yaml#/definitions/string-array description:
- Phandle of the regulator supplying the output. + Optional property that specifies supply names provided by + the regulator. Defaults to "vout" if not specified. The + array contains a list of supply names.
+ Each supply name corresponds to a phandle in the + patternProperties.Documentation/devicetree/bindings/regulator/regulator-output.yaml properties: · line 36
Quoted 5 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +5
-0+ +patternProperties: + ".*-supply": + description: + Specifies the phandle for various suppliesWhile you say use 'vout-supply' for a single supply, nothing enforces that anymore.
Quoted 11 lines
required:
- compatible
- - vout-supply
additionalProperties: falseDocumentation/devicetree/bindings/regulator/regulator-output.yaml +3
-0@@ -37,3 +46,9 @@ examples: compatible = "regulator-output"; vout-supply = <&output_reg>; }; + out2 { + compatible = "regulator-output"; + regulator-supplies = "sw0", "sw1";Quoted 8 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml examples: · line 53
Quoted 2 lines
Documentation/devicetree/bindings/regulator/regulator-output.yaml +2
-0+ sw0-supply = <&out2_sw0>; + sw1-supply = <&out2_sw1>;Names in the consumer are relative to the consumer. You appear to be naming these by the supplier. Just add vout[0-9]-supply and iterate over that name in the driver. Then you don't need "regulator-supplies". Really, you never did. You could just find all properties ending in "-supply".
Quoted 8 lines
Please correct me if I have misunderstood anything
What I understood is:
1. Use 'for_each_property_of_node' & iterate each property,
2. String compare each property name ending with '-supply',
3. If there is match then initialize accordingly.
This way all *-supply property are also included including vout-supply. This way, regulator-supplies isn't needed.
Shall I go ahead in this way ?
I wanted to follow up on our previous discussion regarding the naming of properties in the consumer. Based on your feedback, I believe that I should use 'for_each_property_of_node' to iterate over each property and then string compare each property name to find those that end with '-supply'. This way, all *-supply properties will be included, including vout-supply, and the 'regulator-supplies' won't be needed. Can you please confirm if my understanding is correct?
Thank you.
Quoted 5 lines
Quoted 3 lines
Rob
Regards,
Naresh