Skip to contentSkip to conversation

regulator: adding disable options for regulator-always-on and regulator-boots-on

PATCH In review Hugh Kang 4 participants 7 messages Nov 3, 2014 – Nov 6, 2014 Voltage and current regulator framework

lore
Share & tools
lore

Hugh Kang

author
#0 lore raw

PATCH 1/1 regulator: adding disable options for regulator-always-on and regulator-boots-on

From: "hugh.kang" <[email protected]>

If a regulator is set by always-on option, the regulator will be set forever.
For example, suppose LDO1 is set to always-on at RevA.dts with including of a.dtsi. After that RevB.dts may wants to include the same a.dtsi but override the LDO1 always-on option. However, currently there is no way to delete the always-on option, even when we change the LDO1 option value, the always-on setting is still remains.

---
 drivers/regulator/of_regulator.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/regulator/of_regulator.c +6 -0
index ee5e67b..4178dbd 100644
@@ -52,7 +52,13 @@ static void of_get_regulation_constraints(struct device_node *np,
 		constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT;
 
 	constraints->boot_on = of_property_read_bool(np, "regulator-boot-on");
+	if (of_property_read_bool(np, "regulator-disable-boot-on"))
+		constraints->boot_on = false;
+
 	constraints->always_on = of_property_read_bool(np, "regulator-always-on");
+	if (of_property_read_bool(np, "regulator-disable-always-on"))
+		constraints->always_on = false;
+
 	if (!constraints->always_on) /* status change should be possible. */
 		constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS;
 
Signature · 1 line
1.8.3.2
#1 lore raw

Hi,

Quoted 7 lines · Hugh Kang

From: "hugh.kang" <[email protected]>

If a regulator is set by always-on option, the regulator will be set forever.
For example, suppose LDO1 is set to always-on at RevA.dts with including of a.dtsi. After that RevB.dts may wants to include the same a.dtsi but override the LDO1 always-on option. However, currently there is no way to delete the always-on option, even when we change the LDO1 option value, the always-on setting is still remains.

Why don't you split your devicetrees according to the real hardware and set the always-on property only for revA?

Regards,

Markus

Quoted 33 lines
---
 drivers/regulator/of_regulator.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/regulator/of_regulator.c +6 -0
index ee5e67b..4178dbd 100644
@@ -52,7 +52,13 @@ static void of_get_regulation_constraints(struct device_node *np,
 		constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT;
 
 	constraints->boot_on = of_property_read_bool(np, "regulator-boot-on");
+	if (of_property_read_bool(np, "regulator-disable-boot-on"))
+		constraints->boot_on = false;
+
 	constraints->always_on = of_property_read_bool(np, "regulator-always-on");
+	if (of_property_read_bool(np, "regulator-disable-always-on"))
+		constraints->always_on = false;
+
 	if (!constraints->always_on) /* status change should be possible. */
 		constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS;
 
Signature · 7 lines
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
maintainer
#2 lore raw
In reply to Hugh Kang
Quoted 7 lines · Hugh Kang

From: "hugh.kang" <[email protected]>

If a regulator is set by always-on option, the regulator will be set forever.
For example, suppose LDO1 is set to always-on at RevA.dts with including of a.dtsi. After that RevB.dts may wants to include the same a.dtsi but override the LDO1 always-on option. However, currently there is no way to delete the always-on option, even when we change the LDO1 option value, the always-on setting is still remains.

This sounds like a problem with the way the DTSs have been written - I'd expect the thing to do here is just to move the property to the rev A DTS when rev B is created. Why is that not the way forward?

Otherwise this is an issue which affects any boolean property in the DT so if it's something we need to fix we should be fixing it in a generic fashion that will work for other properties too.

author
#3 lore raw

Hello

Quoted 8 lines · Mark Brown
Quoted 7 lines · Hugh Kang

From: "hugh.kang" <[email protected]>

If a regulator is set by always-on option, the regulator will be set forever.
For example, suppose LDO1 is set to always-on at RevA.dts with including of a.dtsi. After that RevB.dts may wants to include the same a.dtsi but override the LDO1 always-on option. However, currently there is no way to delete the always-on option, even when we change the LDO1 option value, the always-on setting is still remains.

Quoted 7 lines

This sounds like a problem with the way the DTSs have been written - I'd expect the thing to do here is just to move the property to the rev A DTS when rev B is created. Why is that not the way forward?

Otherwise this is an issue which affects any boolean property in the DT so if it's something we need to fix we should be fixing it in a generic fashion that will work for other properties too.

I understand that I could make Rev.B with b.dtsi due to LDOs option is different. However, aim to use device tree is that making easy steps. Refer to dts option, if you set to be set status disabled option, the driver dose not probe when the system boot up. Even though, the system has different board revision exist. So dts have to be no corrupts any overlap situation. I have mentions the simple example to change only one LDOs. However, if someone want to edit many regulators with similar configuration, he has to do lots of copy and paste works. Because he has to create new dts file. So I would suggest to make it as simple as I could.

Also, I have somehow agree with you that affects any boolean property in the DT.

#4 lore raw
Quoted 15 lines · Hugh Kang

Hello

Quoted 12 lines · Mark Brown
Quoted 7 lines · Hugh Kang

From: "hugh.kang" <[email protected]>

If a regulator is set by always-on option, the regulator will be set forever.
For example, suppose LDO1 is set to always-on at RevA.dts with including of a.dtsi. After that RevB.dts may wants to include the same a.dtsi but override the LDO1 always-on option. However, currently there is no way to delete the always-on option, even when we change the LDO1 option value, the always-on setting is still remains.

This sounds like a problem with the way the DTSs have been written - I'd expect the thing to do here is just to move the property to the rev A DTS when rev B is created. Why is that not the way forward?

Quoted 8 lines
Quoted 3 lines

Otherwise this is an issue which affects any boolean property in the DT so if it's something we need to fix we should be fixing it in a generic fashion that will work for other properties too.

I understand that I could make Rev.B with b.dtsi due to LDOs option is different. However, aim to use device tree is that making easy steps. Refer to dts option, if you set to be set status disabled option, the driver dose not probe when the system boot up. Even though, the system has different board revision exist. So dts have to be no corrupts any overlap situation. I have mentions the simple example to change only one LDOs. However, if someone want to edit many regulators with similar configuration, he has to do lots of copy and paste works. Because he has to create new dts file. So I would suggest to make it as simple as I could.

Also, I have somehow agree with you that affects any boolean property in the DT.

Now you propose to have a final DTS like:

$ scripts/dtc/dtc -I dtb -O dts
	reg {
		regulator-name = "vdd";
		regulator-min-microvolt = <850000>;
		regulator-max-microvolt = <1100000>;
		regulator-always-on;
		regulator-disable-always-on;
	};
Which one of "always-on" is more important? Later one could add
"regulator-enable-always-even-if-disable-always-on;" ...

The "status" property can be overridden. So maybe the new property should behave the same way? Something like:

dts-common {
		regulator-status-on = "always-on";
		regulator-boot-on = "boot-on";
}
dst-rev-b {
		regulator-status-on = "default";
		regulator-boot-on = "default";
}

Best regards,
Krzysztof

maintainer
#5 lore raw
In reply to Hugh Kang

On Tue, Nov 04, 2014 at 05:20:11PM +0900, Hugh Kang wrote:

Please fix your mailer to word wrap within paragraphs.

Quoted 6 lines

I understand that I could make Rev.B with b.dtsi due to LDOs option is different. However, aim to use device tree is that making easy steps. Refer to dts option, if you set to be set status disabled option, the driver dose not probe when the system boot up. Even though, the system has different board revision exist. So dts have to be no corrupts any overlap situation.

Right, nothing is going to be perfect but equally if we use this sort of override property to do things it then becomes harder to read the DT for the system since you can't trust that a property you see in one file won't be overridden by another file somewhere else. This can happen to an extent already but normally not and it doesn't seem like a pattern we want to encourage.

Quoted 4 lines

I have mentions the simple example to change only one LDOs. However, if someone want to edit many regulators with similar configuration, he has to do lots of copy and paste works. Because he has to create new dts file. So I would suggest to make it as simple as I could.

Sure, but that's purely mechanical and very easy to review - you can do a code motion patch to split the bits of DT out then start changing things, and you can still keep the common paramters in the core file.

Quoted 1 line

Also, I have somehow agree with you that affects any boolean property in the DT.

This is a big one for me - it's going to be both time consuming and complex to add this sort of thing for more properties and we do get into complexity things if each individual property and its override has to be handled by hand.

author
#6 lore raw
Quoted 25 lines · Mark Brown

On Tue, Nov 04, 2014 at 05:20:11PM +0900, Hugh Kang wrote:

Please fix your mailer to word wrap within paragraphs.

Quoted 6 lines

I understand that I could make Rev.B with b.dtsi due to LDOs option is different. However, aim to use device tree is that making easy steps. Refer to dts option, if you set to be set status disabled option, the driver dose not probe when the system boot up. Even though, the system has different board revision exist. So dts have to be no corrupts any overlap situation.

Right, nothing is going to be perfect but equally if we use this sort of override property to do things it then becomes harder to read the DT for the system since you can't trust that a property you see in one file won't be overridden by another file somewhere else. This can happen to an extent already but normally not and it doesn't seem like a pattern we want to encourage.

Quoted 4 lines

I have mentions the simple example to change only one LDOs. However, if someone want to edit many regulators with similar configuration, he has to do lots of copy and paste works. Because he has to create new dts file. So I would suggest to make it as simple as I could.

Sure, but that's purely mechanical and very easy to review - you can do a code motion patch to split the bits of DT out then start changing things, and you can still keep the common paramters in the core file.

Quoted 5 lines
Quoted 1 line

Also, I have somehow agree with you that affects any boolean property in the DT.

This is a big one for me - it's going to be both time consuming and complex to add this sort of thing for more properties and we do get into complexity things if each individual property and its override has to be handled by hand.

Thank you for advising. I would take another way to apply it. Also, I would like to say thanks to Krzysztof, giving me a advice.