Skip to contentSkip to conversation

Parse missing regulator constraints from device tree blob

PATCH Saurabh Singh 2 participants 2 messages Jan 16, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Mark,

New patch incorporating your suggestions is given below.

Quoted 4 lines

* None of these properties are documented. Documentation is required so that the contract is defined. That allows people to learn how to use the properties, and makes clear what we can and cannot change kernel-side.

Done. The documentation is in the patch below.

Quoted 3 lines

* It leaks Linux internal details (e.g. suspend_state_t values, valid_mode_mask) without any attempt at abstraction, in violation of dt principles.

Unlike valid_ops_mask, valid_mode_mask cannot be derived from the other settings. It depends on the hardware (regulator) capability. So, it has to be specified in DT blob.

Quoted 3 lines

* Accessors are used poorly. Endianness conversion is done manually rather than being left to accessors, and property lengths aren't checked.

Used the accessors for u32 and bool.

Quoted 5 lines
	u32 uv;
	of_property_read_u32(np, "regulator-state-uv", &uv);

However, as far as I can see this value should come from an input supply anyway.

This is not input supply. This is operating voltage to be set when device suspends.

diffstat for this patch is:

 Documentation/devicetree/bindings/regulator/regulator.txt |   19 ++++++
 drivers/regulator/of_regulator.c                          |   41 ++++++++++++++
 2 files changed, 60 insertions(+)

To apply the patch, in the root of a kernel tree use:
patch -p1 < of_regulator.patch

Please let me know any feedback you have on this patch or the approach used.

Regards,
=====================
Saurabh Singh Sengar
Lead Engineer
Samsung R&D Institute
India
Samsung
=====================

--------------------------------------------------------------------------------

Documentation/devicetree/bindings/regulator/regulator.txt +19 -0
diff -uprN -X linux-3.12.6-vanilla/Documentation/dontdiff linux-3.12.6-vanilla/Documentation/devicetree/bindings/regulator/regulator.txt linux-3.12.6/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -14,6 +14,17 @@ Optional properties:
 - regulator-ramp-delay: ramp delay for regulator(in uV/uS)
   For hardwares which support disabling ramp rate, it should be explicitly
   intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay.
+- regulator-valid-modes-mask: valid operations for regulator on particular machine
+- regulator-input-uv: regulator input voltage, only if supply is another regulator
+- regulator-initial-mode: default mode to set on startup
+- regulator-initial-state: suspend state to set at init
+- regulator-state-mem, regulator-state-disk, regulator-state-standby:
+	defines regulator suspend to memory, suspend to disk (hibernate) and standby respectively.
+	have following sub-constarints:
+	- regulator-state-uv: suspend voltage
+	- regulator-state-mode: suspend regulator operating mode
+	- regulator-state-enabled: is regulator enabled in this suspend state
+	- regulator-state-disabled: is the regulator disbled in this suspend state
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
@@ -29,6 +40,14 @@ Example:
 		regulator-max-microvolt = <2500000>;
 		regulator-always-on;
 		vin-supply = <&vin>;
+		regulator-valid-modes-mask = <REGULATOR_MODE_FAST>;
+		regulator-initial-mode = <REGULATOR_MODE_STANDBY>;
+		regulator-initial-state = <PM_SUSPEND_MEM>;
+		regulator-state-mem {
+			regulator-state-mode = <REGULATOR_MODE_IDLE>;
+			regulator-state-enabled;
+		};
+
 	};
 
 Regulator Consumers:
drivers/regulator/of_regulator.c +41 -0

58 lines not on this page · raw message

maintainer
#1 lore raw
Quoted 9 lines · Saurabh Singh

Hi Mark,

New patch incorporating your suggestions is given below.

Quoted 4 lines

* None of these properties are documented. Documentation is required so that the contract is defined. That allows people to learn how to use the properties, and makes clear what we can and cannot change kernel-side.

Done. The documentation is in the patch below.

Please send patches using the process in SubmittingPatches, the formatting of the submission is very important for tools like git am which people use to work with patches.