regulator: dt: add policy to match regulator with prop "regulator-compatible"
Subsystems (3)
v3 cover regulator: dt: add policy to match regulator with prop "regulator-compatible"
and patch V1 of this series:
add policy to match regulator with the property of "regulator-compatible" of each child regulator node with their hardware counterparts name.
Modify documentation as well to reflect this change and dts files.
Changes from V1:
- Modify the existing of_regulator_match() to use the property "regulator-compatible" of each child node of regulator for matching rather than child node name.
- Documentation change to reflect this policy who are using the of_regulator_match().
- Modify the dts file to absorb this policy.
Changes from V2:
- Making modification of the db8500.dtsi as first patch.
- Add break in te match loop in of_regulator_match() when match found.
- Add the policy in the dt documentation of regulator.txt if the regulators nodes are under regulator node.
Laxman Dewangan (3):
ARM: dts: db8500: add property "regulator-compatible" regulator node
regulator: dt: regulator match by regulator-compatible
regulator: dt: add policy to have property "regulator-compatible"
Documentation/devicetree/bindings/mfd/tps65910.txt | 54 +++++++++++++---- .../devicetree/bindings/regulator/regulator.txt | 5 ++ .../devicetree/bindings/regulator/tps6586x.txt | 60 +++++++++++++++----- arch/arm/boot/dts/db8500.dtsi | 30 ++++++++++ drivers/regulator/of_regulator.c | 51 +++++++++++------ 5 files changed, 154 insertions(+), 46 deletions(-)
PATCH v3 1/3 ARM: dts: db8500: add property "regulator-compatible" regulator node
Device's regulator matches their hardware counterparts with the property "regulator-compatible" of each child regulator node in place of the child node name.
Add the property "regulator-compatible" for each regulator with their hardware counterpart's name.
---
Changes from V2:
- Adding the regulator-compatible for each regulator child node.
- Remove the renaming of the child node.
arch/arm/boot/dts/db8500.dtsi | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
arch/arm/boot/dts/db8500.dtsi +30 -0
@@ -206,62 +206,74 @@ // DB8500_REGULATOR_VAPE db8500_vape_reg: db8500_vape { + regulator-compatible = "db8500_vape"; regulator-name = "db8500-vape"; regulator-always-on; }; // DB8500_REGULATOR_VARM db8500_varm_reg: db8500_varm { + regulator-compatible = "db8500_varm"; regulator-name = "db8500-varm"; }; // DB8500_REGULATOR_VMODEM db8500_vmodem_reg: db8500_vmodem { + regulator-compatible = "db8500_vmodem"; regulator-name = "db8500-vmodem"; }; // DB8500_REGULATOR_VPLL db8500_vpll_reg: db8500_vpll { + regulator-compatible = "db8500_vpll"; regulator-name = "db8500-vpll"; }; // DB8500_REGULATOR_VSMPS1 db8500_vsmps1_reg: db8500_vsmps1 { + regulator-compatible = "db8500_vsmps1"; regulator-name = "db8500-vsmps1"; }; // DB8500_REGULATOR_VSMPS2 db8500_vsmps2_reg: db8500_vsmps2 { + regulator-compatible = "db8500_vsmps2"; regulator-name = "db8500-vsmps2"; }; // DB8500_REGULATOR_VSMPS3 db8500_vsmps3_reg: db8500_vsmps3 { + regulator-compatible = "db8500_vsmps3"; regulator-name = "db8500-vsmps3"; }; // DB8500_REGULATOR_VRF1 db8500_vrf1_reg: db8500_vrf1 { + regulator-compatible = "db8500_vrf1"; regulator-name = "db8500-vrf1"; }; // DB8500_REGULATOR_SWITCH_SVAMMDSP db8500_sva_mmdsp_reg: db8500_sva_mmdsp { + regulator-compatible = "db8500_sva_mmdsp"; regulator-name = "db8500-sva-mmdsp"; }; // DB8500_REGULATOR_SWITCH_SVAMMDSPRET db8500_sva_mmdsp_ret_reg: db8500_sva_mmdsp_ret { + regulator-compatible = "db8500_sva_mmdsp_ret"; regulator-name = "db8500-sva-mmdsp-ret"; }; // DB8500_REGULATOR_SWITCH_SVAPIPE db8500_sva_pipe_reg: db8500_sva_pipe { + regulator-compatible = "db8500_sva_pipe"; regulator-name = "db8500_sva_pipe"; }; // DB8500_REGULATOR_SWITCH_SIAMMDSP db8500_sia_mmdsp_reg: db8500_sia_mmdsp { + regulator-compatible = "db8500_sia_mmdsp"; regulator-name = "db8500_sia_mmdsp"; };
@@ -272,38 +284,45 @@ // DB8500_REGULATOR_SWITCH_SIAPIPE db8500_sia_pipe_reg: db8500_sia_pipe { + regulator-compatible = "db8500_sia_pipe"; regulator-name = "db8500-sia-pipe"; }; // DB8500_REGULATOR_SWITCH_SGA db8500_sga_reg: db8500_sga { + regulator-compatible = "db8500_sga"; regulator-name = "db8500-sga"; vin-supply = <&db8500_vape_reg>; }; // DB8500_REGULATOR_SWITCH_B2R2_MCDE db8500_b2r2_mcde_reg: db8500_b2r2_mcde { + regulator-compatible = "db8500_b2r2_mcde"; regulator-name = "db8500-b2r2-mcde"; vin-supply = <&db8500_vape_reg>; }; // DB8500_REGULATOR_SWITCH_ESRAM12 db8500_esram12_reg: db8500_esram12 { + regulator-compatible = "db8500_esram12"; regulator-name = "db8500-esram12"; }; // DB8500_REGULATOR_SWITCH_ESRAM12RET db8500_esram12_ret_reg: db8500_esram12_ret { + regulator-compatible = "db8500_esram12_ret"; regulator-name = "db8500-esram12-ret"; }; // DB8500_REGULATOR_SWITCH_ESRAM34 db8500_esram34_reg: db8500_esram34 { + regulator-compatible = "db8500_esram34"; regulator-name = "db8500-esram34"; }; // DB8500_REGULATOR_SWITCH_ESRAM34RET db8500_esram34_ret_reg: db8500_esram34_ret { + regulator-compatible = "db8500_esram34_ret"; regulator-name = "db8500-esram34-ret"; }; };
@@ -318,6 +337,7 @@ // supplies to the display/camera ab8500_ldo_aux1_reg: ab8500_ldo_aux1 { + regulator-compatible = "ab8500_ldo_aux1"; regulator-name = "V-DISPLAY"; regulator-min-microvolt = <2500000>; regulator-max-microvolt = <2900000>;
@@ -328,6 +348,7 @@ // supplies to the on-board eMMC ab8500_ldo_aux2_reg: ab8500_ldo_aux2 { + regulator-compatible = "ab8500_ldo_aux2"; regulator-name = "V-eMMC1"; regulator-min-microvolt = <1100000>; regulator-max-microvolt = <3300000>;
@@ -335,6 +356,7 @@ // supply for VAUX3; SDcard slots ab8500_ldo_aux3_reg: ab8500_ldo_aux3 { + regulator-compatible = "ab8500_ldo_aux3"; regulator-name = "V-MMC-SD"; regulator-min-microvolt = <1100000>; regulator-max-microvolt = <3300000>;
@@ -342,41 +364,49 @@ // supply for v-intcore12; VINTCORE12 LDO ab8500_ldo_initcore_reg: ab8500_ldo_initcore { + regulator-compatible = "ab8500_ldo_initcore"; regulator-name = "V-INTCORE"; }; // supply for tvout; gpadc; TVOUT LDO ab8500_ldo_tvout_reg: ab8500_ldo_tvout { + regulator-compatible = "ab8500_ldo_tvout"; regulator-name = "V-TVOUT"; }; // supply for ab8500-usb; USB LDO ab8500_ldo_usb_reg: ab8500_ldo_usb { + regulator-compatible = "ab8500_ldo_usb"; regulator-name = "dummy"; }; // supply for ab8500-vaudio; VAUDIO LDO ab8500_ldo_audio_reg: ab8500_ldo_audio { + regulator-compatible = "ab8500_ldo_audio"; regulator-name = "V-AUD"; }; // supply for v-anamic1 VAMic1-LDO ab8500_ldo_anamic1_reg: ab8500_ldo_anamic1 { + regulator-compatible = "ab8500_ldo_anamic1"; regulator-name = "V-AMIC1"; }; // supply for v-amic2; VAMIC2 LDO; reuse constants for AMIC1 ab8500_ldo_amamic2_reg: ab8500_ldo_amamic2 { + regulator-compatible = "ab8500_ldo_amamic2"; regulator-name = "V-AMIC2"; }; // supply for v-dmic; VDMIC LDO ab8500_ldo_dmic_reg: ab8500_ldo_dmic { + regulator-compatible = "ab8500_ldo_dmic"; regulator-name = "V-DMIC"; }; // supply for U8500 CSI/DSI; VANA LDO ab8500_ldo_ana_reg: ab8500_ldo_ana { + regulator-compatible = "ab8500_ldo_ana"; regulator-name = "V-CSI/DSI"; }; };
Signature · 1 line
1.7.1.1
PATCH v3 2/3 regulator: dt: regulator match by regulator-compatible
In reply to Laxman DewanganMatch the device's regulators with the property of "regulator-compatible" of each regulator node.
---
Changes from V1:
- In place of adding new api, modify the existing api of_regulator_match() to look regulator-compatible for matching.
Changes from V2:
- Add break if the regualtor match found.
drivers/regulator/of_regulator.c | 51 ++++++++++++++++++++++++------------- 1 files changed, 33 insertions(+), 18 deletions(-)
drivers/regulator/of_regulator.c +33 -18
@@ -92,15 +92,17 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,EXPORT_SYMBOL_GPL (of_get_regulator_init_data);/** -* of_regulator_match - extract regulator init data +* of_regulator_match - extract regulator init data when node +* property "regulator-compatible" matches with the regulator name. * @dev: device requesting the data * @node: parent device node of the regulators * @matches: match table for the regulators * @num_matches: number of entries in match table * * This function uses a match table specified by the regulator driver and -* looks up the corresponding init data in the device tree. Note that the -* match table is modified in place. +* looks up the corresponding init data in the device tree if +* regulator-compatible matches. Note that the match table is modified +* in place. * * Returns the number of matches found or a negative error code on failure. */
@@ -110,27 +112,40 @@ int of_regulator_match(struct device *dev, struct device_node *node, {unsigned int count =0 ;unsigned int i; +const char *regulator_comp; +struct device_node *child;if (!dev || !node)return -EINVAL ; -for (i =0 ; i < num_matches; i++) { -struct of_regulator_match *match = &matches[i]; -struct device_node *child; - - child =of_find_node_by_name (node, match->name); -if (!child) -continue ; - - match->init_data =of_get_regulator_init_data (dev, child); -if (!match->init_data) { -dev_err (dev,"failed to parse DT for regulator %s\n" , +for_each_child_of_node (node, child) { + regulator_comp =of_get_property (child, +"regulator-compatible" ,NULL ); +if (!regulator_comp) { +dev_err (dev,"regulator-compatible is missing for node %s\n" , child->name); -return -EINVAL ; +continue ; + } +for (i =0 ; i < num_matches; i++) { +struct of_regulator_match *match = &matches[i]; +if (match->of_node) +continue ; + +if (strcmp (match->name, regulator_comp)) +continue ; + + match->init_data = +of_get_regulator_init_data (dev, child); +if (!match->init_data) { +dev_err (dev, +"failed to parse DT for regulator %s\n" , + child->name); +return -EINVAL ; + } + match->of_node = child; + count++; +break ; } - - match->of_node = child; - count++; }return count;
Signature · 1 line
1.7.1.1
PATCH v3 3/3 regulator: dt: add policy to have property "regulator-compatible"
In reply to Laxman DewanganAdd the policy for regulator DT such that if device have multiple regulator and its binding contains a child node that describes each regulator then each regulator child node must have the property "regulator-compatible" which matches with regulator name of their hardware counterparts.
Modify the DT documentation of regulator devices to reflect this policy.
---
Changes from V1:
- Add the doc change for the DT binding of tps6586x.
Changes from V2:
- Add the details of property "regulator-compatible" in regulator.txt.
Documentation/devicetree/bindings/mfd/tps65910.txt | 54 +++++++++++++---- .../devicetree/bindings/regulator/regulator.txt | 5 ++ .../devicetree/bindings/regulator/tps6586x.txt | 60 +++++++++++++++----- 3 files changed, 91 insertions(+), 28 deletions(-)
Documentation/devicetree/bindings/mfd/tps65910.txt +41 -13
@@ -17,8 +17,9 @@ Required properties: device need to be present. The definition for each of these nodes is defined using the standard binding for regulators found at Documentation/devicetree/bindings/regulator/regulator.txt. + The regulator is matched with the regulator-compatible. - The valid names for regulators are: + The valid regulator-compatible values are: tps65910: vrtc, vio, vdd1, vdd2, vdd3, vdig1, vdig2, vpll, vdac, vaux1, vaux2, vaux33, vmmc tps65911: vrtc, vio, vdd1, vdd3, vddctrl, ldo1, ldo2, ldo3, ldo4, ldo5,
@@ -57,73 +58,100 @@ Example: ti,en-gpio-sleep = <0 0 1 0 0 0 0 0 0>; regulators { - vdd1_reg: vdd1 { + #address-cells = <1>; + #size-cells = <0>; + + vdd1_reg: regulator@0 { + regulator-compatible = "vdd1"; + reg = <0>; regulator-min-microvolt = < 600000>; regulator-max-microvolt = <1500000>; regulator-always-on; regulator-boot-on; ti,regulator-ext-sleep-control = <0>; }; - vdd2_reg: vdd2 { + vdd2_reg: regulator@1 { + regulator-compatible = "vdd2"; + reg = <1>; regulator-min-microvolt = < 600000>; regulator-max-microvolt = <1500000>; regulator-always-on; regulator-boot-on; ti,regulator-ext-sleep-control = <4>; }; - vddctrl_reg: vddctrl { + vddctrl_reg: regulator@2 { + regulator-compatible = "vddctrl"; + reg = <2>; regulator-min-microvolt = < 600000>; regulator-max-microvolt = <1400000>; regulator-always-on; regulator-boot-on; ti,regulator-ext-sleep-control = <0>; }; - vio_reg: vio { + vio_reg: regulator@3 { + regulator-compatible = "vio"; + reg = <3>; regulator-min-microvolt = <1500000>; regulator-max-microvolt = <1800000>; regulator-always-on; regulator-boot-on; ti,regulator-ext-sleep-control = <1>; }; - ldo1_reg: ldo1 { + ldo1_reg: regulator@4 { + regulator-compatible = "ldo1"; + reg = <4>; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <3300000>; ti,regulator-ext-sleep-control = <0>; }; - ldo2_reg: ldo2 { + ldo2_reg: regulator@5 { + regulator-compatible = "ldo2"; + reg = <5>; regulator-min-microvolt = <1050000>; regulator-max-microvolt = <1050000>; ti,regulator-ext-sleep-control = <0>; }; - ldo3_reg: ldo3 { + ldo3_reg: regulator@6 { + regulator-compatible = "ldo3"; + reg = <6>; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <3300000>; ti,regulator-ext-sleep-control = <0>; }; - ldo4_reg: ldo4 { + ldo4_reg: regulator@7 { + regulator-compatible = "ldo4"; + reg = <7>; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <3300000>; regulator-always-on; ti,regulator-ext-sleep-control = <0>; }; - ldo5_reg: ldo5 { + ldo5_reg: regulator@8 { + regulator-compatible = "ldo5"; + reg = <8>; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <3300000>; ti,regulator-ext-sleep-control = <0>; }; - ldo6_reg: ldo6 { + ldo6_reg: regulator@9 { + regulator-compatible = "ldo6"; + reg = <9>; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1200000>; ti,regulator-ext-sleep-control = <0>; }; - ldo7_reg: ldo7 { + ldo7_reg: regulator@10 { + regulator-compatible = "ldo7"; + reg = <10>; regulator-min-microvolt = <1200000>; regulator-max-microvolt = <1200000>; regulator-always-on; regulator-boot-on; ti,regulator-ext-sleep-control = <1>; }; - ldo8_reg: ldo8 { + ldo8_reg: regulator@11 { + regulator-compatible = "ldo8"; + reg = <11>; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <3300000>; regulator-always-on;
Documentation/devicetree/bindings/regulator/regulator.txt +4 -0
@@ -11,6 +11,11 @@ Optional properties: - regulator-boot-on: bootloader/firmware enabled regulator - <name>-supply: phandle to the parent supply/regulator node - regulator-ramp-delay: ramp delay for regulator(in mV/uS) +- regulator-compatible: If a regulator chip contains multiple + regulators, and if the chip's binding contains a child node that + describes each regulator, then this property indicates which regulator + this child node is intended to configure. Example:
Documentation/devicetree/bindings/regulator/tps6586x.txt +45 -15
127 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Re: [PATCH V3 1/3] ARM: dts: db8500: add property "regulator-compatible" regulator node
In reply to Laxman DewanganQuoted 7 lines · Laxman Dewangan
Device's regulator matches their hardware counterparts with the property "regulator-compatible" of each child regulator node in place of the child node name.
Add the property "regulator-compatible" for each regulator with their hardware counterpart's name.Signed-off-by Laxman Dewangan <[email protected]>
This change is correct as far as it goes, so:
That said, the DT still should be modified to match the rules of correct DT formatting. That was a pre-existing issue though, so it's OK if that doesn't happen in this patch, and I'm happy leaving that to the maintainers of this file.
Re: [PATCH V3 3/3] regulator: dt: add policy to have property "regulator-compatible"
In reply to Laxman DewanganQuoted 9 lines · Laxman Dewangan
Add the policy for regulator DT such that if device have multiple regulator and its binding contains a child node that describes each regulator then each regulator child node must have the property "regulator-compatible" which matches with regulator name of their hardware counterparts.
Modify the DT documentation of regulator devices to reflect this policy.Signed-off-by Laxman Dewangan <[email protected]>
I'm personally OK with this change as-is, so
I suspect Mark may want the wording in regulators.txt modified a little to allow each regulator binding to choose whether they want the regulator child nodes identified using the new regulator-compatible property, or whether they want each instantiated as an actual device, using regular device instantiation techniques. That could always be a later patch though, and I'll leave this aspect up to Mark.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Laxman DewanganQuoted 5 lines · Laxman Dewangan
Match the device's regulators with the property of "regulator-compatible" of each regulator node.
Signed-off-by Laxman Dewangan <[email protected]>Acked-by Stephen Warren <[email protected]>
Quoted 7 lines
---
Changes from V1:
- In place of adding new api, modify the existing apiof_regulator_match()to look regulator-compatible for matching.Changes from V2:
- Add break if the regualtor match found.
I've read the entire series a few times and I still can't figure out why you're doing it. *Please* describe what the change is good for, now what you are doing in it.
All I can tell from the patch and/or description right now is that you are adding a third identifier next the phandle and the "regulalator-name", but not why this is a good idea.
Specifically, please explain these two things in the changelog:
1. What is it that the new property can express that cannot already be expressed by using the phandle.
2. Why is it called "regulator-compatible"? If it's similar to the "compatible" property, don't you have to have a binding for each possible string? If it's not related to the "compatible" property, why is it named in a similar way?
Arnd
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 2 lines · Arnd Bergmann
1. What is it that the new property can express that cannot already be expressed by using the phandle.
As well as being able to refer to the object from within the device tree we also need to be able to tell what the object represents - we have a bunch of regulators in an array under a node for a PMIC and we want to know which regulator on the physical device each array entry corresponds to. Previously this was being done by parsing the phandle name but that means we can't have more than one device with the same set of names.
Quoted 4 lines
2. Why is it called "regulator-compatible"? If it's similar to the "compatible" property, don't you have to have a binding for each possible string? If it's not related to the "compatible" property, why is it named in a similar way?
Yes, there are bindings defined already for all the relevant devices. Elsewhere in the binding document you'll see a list of all the regulators on the PMIC and the names by which the device tree binding knows them.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 11 lines · Mark Brown
Quoted 2 lines · Arnd Bergmann
1. What is it that the new property can express that cannot already be expressed by using the phandle.
As well as being able to refer to the object from within the device tree we also need to be able to tell what the object represents - we have a bunch of regulators in an array under a node for a PMIC and we want to know which regulator on the physical device each array entry corresponds to. Previously this was being done by parsing the phandle name but that
s/phandle name/node name/ in that line I think.
At least, I don't think it's common to refer to nodes as phandles; phandles are usually the values used at "client" sites to refer to nodes IIUC.
Quoted 12 lines
means we can't have more than one device with the same set of names.
Quoted 4 lines
2. Why is it called "regulator-compatible"? If it's similar to the "compatible" property, don't you have to have a binding for each possible string? If it's not related to the "compatible" property, why is it named in a similar way?
Yes, there are bindings defined already for all the relevant devices. Elsewhere in the binding document you'll see a list of all the regulators on the PMIC and the names by which the device tree binding knows them.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Mark BrownQuoted 11 lines · Mark Brown
Quoted 2 lines · Arnd Bergmann
1. What is it that the new property can express that cannot already be expressed by using the phandle.
As well as being able to refer to the object from within the device tree we also need to be able to tell what the object represents - we have a bunch of regulators in an array under a node for a PMIC and we want to know which regulator on the physical device each array entry corresponds to. Previously this was being done by parsing the phandle name but that means we can't have more than one device with the same set of names.
I see.
But that sounds more like what the "reg" property does than what the "compatible" property does for other devices. In other words, you want to know which instance you are describing, not what kind of object it is.
For a "compatible" property, I would expect two objects that have the same register-level interface but are responsible for different physical objects to have the same "compatible" values, but here you specifically need distinct "regulator-compatible" values.
Quoted 9 lines
Quoted 4 lines
2. Why is it called "regulator-compatible"? If it's similar to the "compatible" property, don't you have to have a binding for each possible string? If it's not related to the "compatible" property, why is it named in a similar way?
Yes, there are bindings defined already for all the relevant devices. Elsewhere in the binding document you'll see a list of all the regulators on the PMIC and the names by which the device tree binding knows them.
Ah, so we just change the way how the binding refers to those names, rather than the individual strings.
It makes much more sense now, so please let's make sure that explanation ends up in the changelog.
I still have two more questions:
* In case of tps65910, the individual regulators are all numbered, so the driver can find them by their "reg" property. Should we still mandate the use of the "regulator-compatible" property? It sounds to me that we could better make it an optional property in those cases.
* What is the difference between "regulator-name" and "regulator-compatible"? Those are the same most of the time in the patches, so can't we just make sure they are always the same, and drop the confusingly named "regulator-compatible" one?
Arnd
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 13 lines · Arnd Bergmann
Quoted 11 lines · Mark Brown
Quoted 2 lines · Arnd Bergmann
1. What is it that the new property can express that cannot already be expressed by using the phandle.
As well as being able to refer to the object from within the device tree we also need to be able to tell what the object represents - we have a bunch of regulators in an array under a node for a PMIC and we want to know which regulator on the physical device each array entry corresponds to. Previously this was being done by parsing the phandle name but that means we can't have more than one device with the same set of names.
Quoted 6 lines
I see.
But that sounds more like what the "reg" property does than what the "compatible" property does for other devices. In other words, you want to know which instance you are describing, not what kind of object it is.
Yes.
Quoted 4 lines
For a "compatible" property, I would expect two objects that have the same register-level interface but are responsible for different physical objects to have the same "compatible" values, but here you specifically need distinct "regulator-compatible" values.
I'd originally suggested "regulator-id" instead of "regulator-compatible" in order to avoid any association with the pre-existing "compatible" property. Mark didn't like that, although I don't think I quite understood why.
Quoted 16 lines
Quoted 9 lines
Quoted 4 lines
2. Why is it called "regulator-compatible"? If it's similar to the "compatible" property, don't you have to have a binding for each possible string? If it's not related to the "compatible" property, why is it named in a similar way?
Yes, there are bindings defined already for all the relevant devices. Elsewhere in the binding document you'll see a list of all the regulators on the PMIC and the names by which the device tree binding knows them.
Ah, so we just change the way how the binding refers to those names, rather than the individual strings.
It makes much more sense now, so please let's make sure that explanation ends up in the changelog.
Quoted 7 lines
I still have two more questions:
* In case of tps65910, the individual regulators are all numbered, so the driver can find them by their "reg" property. Should we still mandate the use of the "regulator-compatible" property? It sounds to me that we could better make it an optional property in those cases.
The problem is that dtc has no named constants. Using raw integers instead of names would make the .dts file rather unreadable. The issue is much more accute for regulators than say GPIOs or IRQs because there's likely no relative order to the set of regulators defined by the documentation, unlike for GPIOs/IRQs where the integer (often) is the object's primary ID.
Quoted 4 lines
* What is the difference between "regulator-name" and "regulator-compatible"? Those are the same most of the time in the patches, so can't we just make sure they are always the same, and drop the confusingly named "regulator-compatible" one?
regulator-compatible is the name of the regulator within the chip; the HW sub-module say.
regulator-name is the board-/system-level name of the regulator. Perhaps a signal name from the schematic, or maybe function name like "SD card supply".
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Arnd BergmannQuoted 4 lines · Arnd Bergmann
But that sounds more like what the "reg" property does than what the "compatible" property does for other devices. In other words, you want to know which instance you are describing, not what kind of object it is.
No, it's describing the kind of object. This stuff is for devices which throw a bunch of irregular regulators down on a chip with no particular similarity with each other.
Quoted 4 lines
For a "compatible" property, I would expect two objects that have the same register-level interface but are responsible for different physical objects to have the same "compatible" values, but here you specifically need distinct "regulator-compatible" values.
There's nothing stopping a driver drilling down deeper with other data once it's worked out what it's talking about, if it wants to read an additional id value or base register that's absolutely fine and probably even a good idea. The problem is that for a lot of hardware there's just a bunch of random irregular devices.
Quoted 2 lines
It makes much more sense now, so please let's make sure that explanation ends up in the changelog.
To be honest I just don't care, the old code hasn't been around for long enough or widely adopted enough for anyone to care and it's just more brain cycles gone.
Quoted 4 lines
* What is the difference between "regulator-name" and "regulator-compatible"? Those are the same most of the time in the patches, so can't we just make sure they are always the same, and drop the confusingly named "regulator-compatible" one?
As the binding documentation says the former is a display name for use so people can tell what the software is talking about, for example the name the supply has in the schematic. It's completely up to the user and the regulator driver can't use it for anything except printing so it needs something else to help it figure out what it's working with.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Stephen WarrenQuoted 11 lines · Stephen Warren
Quoted 4 lines · Arnd Bergmann
For a "compatible" property, I would expect two objects that have the same register-level interface but are responsible for different physical objects to have the same "compatible" values, but here you specifically need distinct "regulator-compatible" values.
I'd originally suggested "regulator-id" instead of "regulator-compatible" in order to avoid any association with the pre-existing "compatible" property. Mark didn't like that, although I don't think I quite understood why.
Like I said we already have names (and we have IDs inside the API as well) and it also seems better to make the "which thing is this?" property have the same name as the more generic "which thing is this?" property. I did mention the fact that drivers could read additional properties to further identify the regulator if they were so moved.
Ideally we'd just be able to have either named nodes directly in the parent or be able to have arrays function as a hash, really this is trying to simulate a hash.
Quoted 6 lines
The problem is that dtc has no named constants. Using raw integers instead of names would make the .dts file rather unreadable. The issue is much more accute for regulators than say GPIOs or IRQs because there's likely no relative order to the set of regulators defined by the documentation, unlike for GPIOs/IRQs where the integer (often) is the object's primary ID.
Well, there are actually a lot of chips which do provide useful indexes
- for example the wm831x devices just have a bunch of DCDCs and a bunch of LDOs which can usefully be referred to as DCDCn or LDOn. They will hopefully not need to use this interface. It's just that there's also a large class of devices we need to cater for which don't have any such regularity in their register map, this biding
mechanism is for them.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Stephen WarrenQuoted 3 lines · Stephen Warren
At least, I don't think it's common to refer to nodes as phandles; phandles are usually the values used at "client" sites to refer to nodes IIUC.
Right, I always think of the phandle as being the label (which is present at both ends of the link - the client refers to the handle the node provdes. Though now I think about it I suppose it might be Hungarian with the node having a handle and the client having a phandle...
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Mark BrownQuoted 8 lines · Mark Brown
Quoted 6 lines · Stephen Warren
The problem is that dtc has no named constants. Using raw integers instead of names would make the .dts file rather unreadable. The issue is much more accute for regulators than say GPIOs or IRQs because there's likely no relative order to the set of regulators defined by the documentation, unlike for GPIOs/IRQs where the integer (often) is the object's primary ID.
Quoted 7 lines
Well, there are actually a lot of chips which do provide useful indexes
- for example the wm831x devices just have a bunch of DCDCs and a bunch of LDOs which can usefully be referred to as DCDCn or LDOn. They will hopefully not need to use this interface. It's just that there's also a large class of devices we need to cater for which don't have any such regularity in their register map, this biding
mechanism is for them.
Ok, now it all makes sense. Thanks for bearing with me being a little slow on this topic.
It seems that the drivers that are changed to use this could also try to describe the individual regulators completely, by moving the contents of e.g. ab8500_regulator_info into the device tree, but having the string identifier with an in-kernel table makes sense when there is only one such table.
Arnd
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 5 lines · Arnd Bergmann
It seems that the drivers that are changed to use this could also try to describe the individual regulators completely, by moving the contents of e.g.
ab8500_regulator_infointo the device tree, but having the string identifier with an in-kernel table makes sense when there is only one such table.
I'm not that big a fan of moving all the data into device tree as it means that you need even more parsing code and you need to update the device trees for every board out there every time you want to add support for a new feature which doesn't seem like a win. Right now with the DT kept in the kernel it's not so bad but if we ever do start distributing it separately it becomes more of an issue.
I'm also not sure if the tooling works well for allowing people to include standard DTs for chips and add new properties to nodes for the board specific configuration, though I think I've seen a few things which suggested that was dealt with reasonably well.
It also means that the driver becomes useless on non-DT systems; while for something like ab85xx which is specific to a SoC that's not a problem it's a serious drawback for devices which may be used on other architectures (or older ARM systems for that matter). I'm quite worried by this tendency to try to just dump all our data structures into DT - it's similar to the issues with some of the MFDs just wanting to drop in the current Linux subdivision of the device even though that's often just reflecting our current internal structures which do change even without worrying about other OSs.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 9 lines · Mark Brown
Show Details
Quoted 5 lines · Arnd Bergmann
It seems that the drivers that are changed to use this could also try to describe the individual regulators completely, by moving the contents of e.g.
ab8500_regulator_infointo the device tree, but having the string identifier with an in-kernel table makes sense when there is only one such table.
Quoted 6 lines
I'm not that big a fan of moving all the data into device tree as it means that you need even more parsing code and you need to update the device trees for every board out there every time you want to add support for a new feature which doesn't seem like a win. Right now with the DT kept in the kernel it's not so bad but if we ever do start distributing it separately it becomes more of an issue.
Right. It's certainly a trade-off. If a company makes 100 SoCs that all have similar-but-different regulators, then it should be clear win to have the driver be very abstract and fed with DT data for configuragtion.
Quoted 4 lines
I'm also not sure if the tooling works well for allowing people to include standard DTs for chips and add new properties to nodes for the board specific configuration, though I think I've seen a few things which suggested that was dealt with reasonably well.
It should never be necessary to add board-specific properties in the nodes that describe the SoC specific bits. What I was referring to is just moving the data that currently resides in the regulator driver into DT.
Arnd
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 1 line · Arnd Bergmann
On Thursday 21 June 2012, Mark Brown wrote:
...
Quoted 9 lines
Quoted 4 lines
I'm also not sure if the tooling works well for allowing people to include standard DTs for chips and add new properties to nodes for the board specific configuration, though I think I've seen a few things which suggested that was dealt with reasonably well.
It should never be necessary to add board-specific properties in the nodes that describe the SoC specific bits. What I was referring to is just moving the data that currently resides in the regulator driver into DT.
I guess I must be misunderstanding that comment - there are many many examples of boards adding properties to nodes that describe the SoC. For example, the GPIOs used by SDHCI controllers, board-specific max clock rates for SDHCI or I2C controllers, pinmux configuration properties, to name just a few.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Arnd BergmannQuoted 9 lines · Arnd Bergmann
Quoted 6 lines · Mark Brown
I'm not that big a fan of moving all the data into device tree as it means that you need even more parsing code and you need to update the device trees for every board out there every time you want to add support for a new feature which doesn't seem like a win. Right now with the DT kept in the kernel it's not so bad but if we ever do start distributing it separately it becomes more of an issue.
Quoted 4 lines
Right. It's certainly a trade-off. If a company makes 100 SoCs that all have similar-but-different regulators, then it should be clear win to have the driver be very abstract and fed with DT data for configuragtion.
Well, nobody does that anyway but even if they were it doesn't help non-DT systems at all, nor does it help when we need to go and add new properties to every existing device tree using the device. We've got far more architectures don't use DT than do...
Quoted 9 lines
Quoted 4 lines
I'm also not sure if the tooling works well for allowing people to include standard DTs for chips and add new properties to nodes for the board specific configuration, though I think I've seen a few things which suggested that was dealt with reasonably well.
It should never be necessary to add board-specific properties in the nodes that describe the SoC specific bits. What I was referring to is just moving the data that currently resides in the regulator driver into DT.
How would this work given that we also need to put system specific configuration for the same devices into DT? As Stephen says it doesn't seem to match what we're currently doing.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Stephen WarrenQuoted 10 lines · Stephen Warren
Quoted 4 lines
It should never be necessary to add board-specific properties in the nodes that describe the SoC specific bits. What I was referring to is just moving the data that currently resides in the regulator driver into DT.
I guess I must be misunderstanding that comment - there are many many examples of boards adding properties to nodes that describe the SoC. For example, the GPIOs used by SDHCI controllers, board-specific max clock rates for SDHCI or I2C controllers, pinmux configuration properties, to name just a few.
The difference is that configuration is board specific, but capabilities of the hardware are soc specific. The regulator-compatible property identifies just the capabilities and the location of one regulator:
Look at struct ab8500_regulator_info, everything in there describes the soc: min/max voltages, register banks, startup delay. Those are all things that we could in theory have in the .dtsi file describing the soc.
The board specific settings on the other hand are about what to put into those registers and what voltage to use. From all I can tell, those settings belong into the node that actually uses the regulator, not the node that defines it.
Arnd
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to a message not in the archiveQuoted 7 lines · Mark Brown
Quoted 6 lines · Arnd Bergmann
Quoted 4 lines · Mark Brown
I'm not that big a fan of moving all the data into device tree as it means that you need even more parsing code and you need to update the device trees for every board out there every time you want to add support for a new feature which doesn't seem like a win.
Maybe I'm missing something, but in general it's not necessary to update old device trees to support new features. The trick is to define a new property that describes the new possibility. Absence of that property implies that the default - the thing that used to happen across the board, before the feature existed - applies.
Quoted 29 lines
Quoted 8 lines
Quoted 3 lines
Right now with
the DT kept in the kernel it's not so bad but if we ever do start distributing it separately it becomes more of an issue.Right. It's certainly a trade-off. If a company makes 100 SoCs that all have similar-but-different regulators, then it should be clear win to have the driver be very abstract and fed with DT data for configuragtion.
Well, nobody does that anyway but even if they were it doesn't help non-DT systems at all, nor does it help when we need to go and add new properties to every existing device tree using the device. We've got far more architectures don't use DT than do...
Quoted 9 lines
Quoted 4 lines
I'm also not sure if the tooling works well for allowing people to include standard DTs for chips and add new properties to nodes for the board specific configuration, though I think I've seen a few things which suggested that was dealt with reasonably well.
It should never be necessary to add board-specific properties in the nodes that describe the SoC specific bits. What I was referring to is just moving the data that currently resides in the regulator driver into DT.
How would this work given that we also need to put system specific configuration for the same devices into DT? As Stephen says it doesn't seem to match what we're currently doing.
Quoted 4 lines
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
On Thu, Jun 21, 2012 at 11:53:41AM -1000, Mitch Bradley wrote:
Whatever mail program you're using appears to be generating HTML mails and isn't doing an awesome job at formatting them, the plain text version is mangled too with most peculiar word wrapping which is quite hard to read. I've reflowed.
Quoted 9 lines · Mark Brown
Quoted 7 lines · Arnd Bergmann
Quoted 6 lines · Mark Brown
Quoted 5 lines
I'm not that big a fan of moving all the data into device tree as it means that you need even more parsing code and you need to update the device trees for every board out there every time you want to add support for a new feature which doesn't seem like a win.
Quoted 5 lines
Maybe I'm missing something, but in general it's not necessary to update old device trees to support new features. The trick is to define a new property that describes the new possibility. Absence of that property implies that the default - the thing that used to happen across the board, before the feature existed - applies.
Which is not a success in terms of deploying the new support, or indeed in terms of deploying bugfixes. It increases the overall complexity of the system and I'm having a hard time getting at all excited about any benefits.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Arnd BergmannQuoted 4 lines · Arnd Bergmann
The board specific settings on the other hand are about what to put into those registers and what voltage to use. From all I can tell, those settings belong into the node that actually uses the regulator, not the node that defines it.
This doesn't work. Each regulator may be used by multiple consumers, the configuration is for the supply as a whole not for an individual user. The main service the API is providing is arbitration between multiple consumers and the physical capabilities of the board.
Due to the fact that the binding of the device has to be done by the board you'd need to replace the regulator-compatible value with a phandle pointing to whatever nodes the .dtsi defines (and which would need to include some string as well so we can bind code to it). And of course if anyone wants to use the device on a non-DT architecture we'd need to replicate everything in code anyway.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Mark BrownQuoted 11 lines · Mark Brown
Quoted 2 lines · Arnd Bergmann
1. What is it that the new property can express that cannot already be expressed by using the phandle.
As well as being able to refer to the object from within the device tree we also need to be able to tell what the object represents - we have a bunch of regulators in an array under a node for a PMIC and we want to know which regulator on the physical device each array entry corresponds to. Previously this was being done by parsing the phandle name but that means we can't have more than one device with the same set of names.
I thought the reason was that matching the node names up with the regulator names was considered bad practice. As Stephen already noticed, the matching is done by node name, not phandle. Correct me if I'm wrong, but you can have more than one device with the children have the same names.
Thierry
_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 9 lines · Thierry Reding
Quoted 6 lines · Mark Brown
As well as being able to refer to the object from within the device tree we also need to be able to tell what the object represents - we have a bunch of regulators in an array under a node for a PMIC and we want to know which regulator on the physical device each array entry corresponds to. Previously this was being done by parsing the phandle name but that means we can't have more than one device with the same set of names.
Quoted 5 lines
I thought the reason was that matching the node names up with the regulator names was considered bad practice. As Stephen already noticed, the matching is done by node name, not phandle. Correct me if I'm wrong, but you can have more than one device with the children have the same names.
We're talking about consumers here, not the regulator driver finding its own regulators.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 10 lines · Mark Brown
Quoted 8 lines · Thierry Reding
Quoted 6 lines · Mark Brown
As well as being able to refer to the object from within the device tree we also need to be able to tell what the object represents - we have a bunch of regulators in an array under a node for a PMIC and we want to know which regulator on the physical device each array entry corresponds to. Previously this was being done by parsing the phandle name but that means we can't have more than one device with the same set of names.
Quoted 8 lines
Quoted 5 lines
I thought the reason was that matching the node names up with the regulator names was considered bad practice. As Stephen already noticed, the matching is done by node name, not phandle. Correct me if I'm wrong, but you can have more than one device with the children have the same names.
We're talking about consumers here, not the regulator driver finding its own regulators.
No we're not. of_regulator_match() isn't used by consumers but by regulator drivers to parse the DT.
Thierry
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 7 lines · Thierry Reding
Quoted 2 lines · Mark Brown
We're talking about consumers here, not the regulator driver finding its own regulators.
No we're not.
of_regulator_match()isn't used by consumers but by regulator drivers to parse the DT.
This subthread has wandered off the topic of the original patch somewhat though.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Mark,
Quoted 10 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 5 lines · Thierry Reding
Quoted 2 lines · Mark Brown
We're talking about consumers here, not the regulator driver finding its own regulators.
No we're not.
of_regulator_match()isn't used by consumers but by regulator drivers to parse the DT.This subthread has wandered off the topic of the original patch somewhat though.
I have not seen much oppose on this series as such and if you are OK on this then can we apply? If it need to buy some ACK from different stack holder then we can ask them.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 3 lines · Laxman Dewangan
I have not seen much oppose on this series as such and if you are OK on this then can we apply?
If it need to buy some ACK from different stack holder then we can ask them.
I've been waiting for the ST Ericsson guys who are already CCed. I generally give people who I expect might review at least a week to do so before I get bored and apply anyway.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 9 lines · Mark Brown
Quoted 3 lines · Laxman Dewangan
I have not seen much oppose on this series as such and if you are OK on this then can we apply?
If it need to buy some ACK from different stack holder then we can ask them.I've been waiting for the ST Ericsson guys who are already CCed. I generally give people who I expect might review at least a week to do so before I get bored and apply anyway.
You need Linus' ACK, but he is off until Monday.
Signature · 5 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead M: +44 77 88 633 515 Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH V3 3/3] regulator: dt: add policy to have property "regulator-compatible"
In reply to Laxman DewanganQuoted 5 lines · Laxman Dewangan
Add the policy for regulator DT such that if device have multiple regulator and its binding contains a child node that describes each regulator then each regulator child node must have the property "regulator-compatible" which matches with regulator name of their hardware counterparts.
I tried to apply this but both git and patch are upset with the patch at the line:
Documentation/devicetree/bindings/regulator/tps6586x.txt +0 -0
for reasons I'm not immediately able to discern. Can you please look into this?
Re: [PATCH V3 3/3] regulator: dt: add policy to have property "regulator-compatible"
Quoted 13 lines · Mark Brown
* PGP Signed by an unknown key
Quoted 5 lines · Laxman Dewangan
Add the policy for regulator DT such that if device have multiple regulator and its binding contains a child node that describes each regulator then each regulator child node must have the property "regulator-compatible" which matches with regulator name of their hardware counterparts.
I tried to apply this but both git and patch are upset with the patch at the line:
Documentation/devicetree/bindings/regulator/tps6586x.txt +0
-0
Quoted 2 lines
for reasons I'm not immediately able to discern. Can you please look into this?
I will locally try and will resend the patch if anything change.
Re: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
In reply to Lee JonesQuoted 10 lines · Lee Jones
Quoted 9 lines · Mark Brown
Quoted 4 lines · Laxman Dewangan
I have not seen much oppose on this series as such and if you are OK on this then can we apply?
If it need to buy some ACK from different stack holder then we can ask them.
Quoted 5 lines
Quoted 3 lines
I've been waiting for the ST Ericsson guys who are already CCed. I generally give people who I expect might review at least a week to do so before I get bored and apply anyway.
You need Linus' ACK, but he is off until Monday.
My ACK on this would be pointless since I barely grasp the issue.
I would much more appreciate your ACK or NACK on it, it's much more valuable since you've been working on this code... and this very aspect of it even, I guess?
Yours,
Linus Walleij
Lee Jones
Acked-byRe: [PATCH V3 2/3] regulator: dt: regulator match by regulator-compatible
Quoted 15 lines · Linus Walleij
Quoted 14 lines · Lee Jones
Quoted 12 lines · Mark Brown
Quoted 4 lines · Laxman Dewangan
I have not seen much oppose on this series as such and if you are OK on this then can we apply?
If it need to buy some ACK from different stack holder then we can ask them.I've been waiting for the ST Ericsson guys who are already CCed. I generally give people who I expect might review at least a week to do so before I get bored and apply anyway.
Quoted 7 lines
Quoted 1 line
You need Linus' ACK, but he is off until Monday.
My ACK on this would be pointless since I barely grasp the issue.
I would much more appreciate your ACK or NACK on it, it's much more valuable since you've been working on this code... and this very aspect of it even, I guess?
Very well. For the db8500.dtsi changes you have my:
Signature · 5 lines
Lee Jones Linaro ST-Ericsson Landing Team Lead M: +44 77 88 633 515 Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog