Skip to contentSkip to conversation

Add support for regulator operation mode of mt6397

PATCH Superseded Henry Chen 2 participants 4 messages May 11, 2016

Subsystems (3)
lore
Share & tools
lore

Henry Chen

author
#0 lore raw

Some regulators support different operating modes, but there is no suitable property that can pass the opeation mode constraints on runtime at present.

This series making the change to specify supported modes as a devicetree list. Consumers can change or get the regulator operation mode by regulator_set_mode /regulator_get_mode and define the support operating mode on devicetree.

There is a requirement from SVS driver. SVS calibartion requires that the regulator be in its low-noise (pwm mode) state at boot, but at all other times it can be normal mode for power saving.
http://www.spinics.net/lists/devicetree/msg111204.html

author
#1 lore raw

PATCH 1/2 regulator: Add support for parsing operation mode

Some regulators support their operating mode to be changed by consumers for module specific purpose.

This patch adds support to parse those properties and fill the regulator constraints so the regulator core can call the regualtor_set_mode to change the modes.

---
 Documentation/devicetree/bindings/regulator/regulator.txt | 10 ++++++++++
 drivers/regulator/of_regulator.c                          | 14 ++++++++++++++
 2 files changed, 24 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +10 -0
index ecfc593..88f98f0 100644
@@ -49,6 +49,16 @@ Optional properties:
 	0: Disable active discharge.
 	1: Enable active discharge.
 	Absence of this property will leave configuration to default.
+- regulator-allow-change-mode: allow the regulator mode to be configured
+- regulator-supported-modes: Regulators can run in a variety of different operating
+  modes depending on output load. This allows further system power savings by
+  selecting the best (and most efficient) regulator mode for a desired load.
+  The definition for each of these operation is defined at
+  include/linux/regulator/consumer.h
+	0: FAST.
+	1: NORMAL.
+	2: IDLE.
+	3: STANDBY.
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
drivers/regulator/of_regulator.c +14 -0
index 6b0aa80..12fe8c8 100644
@@ -167,6 +167,20 @@ static void of_get_regulation_constraints(struct device_node *np,
 		suspend_state = NULL;
 		suspend_np = NULL;
 	}
+
+	if (of_property_read_bool(np, "regulator-allow-change-mode"))
+		constraints->valid_ops_mask |= REGULATOR_CHANGE_MODE;
+
+	ret = of_property_count_elems_of_size(np,
+					      "regulator-supported-modes",
+					      sizeof(u32));
+	for (i = 0; i < ret; i++) {
+		u32 mode;
+
+		of_property_read_u32_index(np, "regulator-supported-modes",
+					   i, &mode);
+		constraints->valid_modes_mask |= (1 << mode);
+	}
 }
 
 /**
Signature · 1 line
1.8.1.1.dirty
author
#3 lore raw

PATCH 2/2 regulator: mt6397: Add buck change mode regulator interface for mt6397

In reply to Henry Chen

BUCKs of mt6397 have auto mode and pwm mode. User can use regulator interfaces to control modes.

---
 .../bindings/regulator/mt6397-regulator.txt        | 22 +++++
 drivers/regulator/mt6397-regulator.c               | 95 +++++++++++++++++++---
 2 files changed, 105 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/regulator/mt6397-regulator.txt +22 -0
index a42b1d6..d3167f2 100644
@@ -7,6 +7,26 @@ Required properties:
   The definition for each of these nodes is defined using the standard binding
   for regulators at Documentation/devicetree/bindings/regulator/regulator.txt.
 
+The mt6397 buck supports two different operating modes: Fast and Normal
+Mode. Some regulators support the modes to be changed by the consumers during
+normal operation.
+
+The regulators that support the standard "regulator-allow-change-mode" property,
+changing their mode during normal operation are:
+  buck_vpca15, buck_vpca7, buck_vsramca15, buck_vsramca7, buck_vcore, buck_vgpu,
+  buck_vdrm, buck_vio18
+
+The possible values for "regulator-supported-modes" are:
+	0: PWM mode, mapping to regulator fast mode, allow the
+	converter to remain in the PWM mode regardless of the load current, so
+	that the noise spectrum of the converter can be minimized for certain
+	highly-noise-sensitive handset applications.
+	1: Auto mode, mapping to regulator normal mode, mode switch by current
+	loading. At light load currents, the converter automatically enters
+	PFM mode to save power and improve light load efficiency. At heavy
+	load currents, the converter automatically enters PWM mode to minimiz
+	the noise spectrum of the converter.
+
 The valid names for regulators are::
 BUCK:
   buck_vpca15, buck_vpca7, buck_vsramca15, buck_vsramca7, buck_vcore, buck_vgpu,
@@ -30,6 +50,8 @@ Example:
 				regulator-max-microvolt = <1350000>;
 				regulator-ramp-delay = <12500>;
 				regulator-enable-ramp-delay = <200>;
+				regulator-allow-change-mode;
+				regulator-supported-modes = <0 1>;
 			};
 
 			mt6397_vpca7_reg: buck_vpca7 {
drivers/regulator/mt6397-regulator.c +83 -12

162 lines not on this page · raw message

Signature · 1 line
1.8.1.1.dirty
#2 lore raw

Re: [PATCH 1/2] regulator: Add support for parsing operation mode

In reply to Henry Chen

Hi Henry,

Quoted 19 lines · Henry Chen

Some regulators support their operating mode to be changed by consumers for module specific purpose.

This patch adds support to parse those properties and fill the regulator constraints so the regulator core can call the regualtor_set_mode to change the modes.

---
 Documentation/devicetree/bindings/regulator/regulator.txt | 10 ++++++++++
 drivers/regulator/of_regulator.c                          | 14 ++++++++++++++
 2 files changed, 24 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +0 -0
index ecfc593..88f98f0 100644

Documentation/devicetree/bindings/regulator/regulator.txt Optional properties: · line 52

Quoted 4 lines
Documentation/devicetree/bindings/regulator/regulator.txt +1 -0
@@ -49,6 +49,16 @@ Optional properties:
        0: Disable active discharge.
        1: Enable active discharge.
        Absence of this property will leave configuration to default.
+- regulator-allow-change-mode: allow the regulator mode to be configured

As mentioned by broonie earlier, the explicit 'allow' property is redundant, if regulator-supported-modes is present, then set REGULATOR_CHANGE_MODE invalid_ops_mask , else leave it clear.

drivers/regulator/of_regulator.c

Quoted 16 lines
Documentation/devicetree/bindings/regulator/regulator.txt +9 -0
+- regulator-supported-modes: Regulators can run in a variety of different operating
+  modes depending on output load. This allows further system power savings by
+  selecting the best (and most efficient) regulator mode for a desired load.
+  The definition for each of these operation is defined at
+  include/linux/regulator/consumer.h
+       0: FAST.
+       1: NORMAL.
+       2: IDLE.
+       3: STANDBY.
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
drivers/regulator/of_regulator.c +0 -0
index 6b0aa80..12fe8c8 100644

Also, I thought binding document changes are generally in a separate patch from their implementation.

-Dan

Quoted 24 lines
drivers/regulator/of_regulator.c +14 -1
@@ -167,6 +167,20 @@ static void of_get_regulation_constraints(struct device_node *np,
                suspend_state = NULL;
                suspend_np = NULL;
        }
+
+       if (of_property_read_bool(np, "regulator-allow-change-mode"))
+               constraints->valid_ops_mask |= REGULATOR_CHANGE_MODE;
+
+       ret = of_property_count_elems_of_size(np,
+                                             "regulator-supported-modes",
+                                             sizeof(u32));
+       for (i = 0; i < ret; i++) {
+               u32 mode;
+
+               of_property_read_u32_index(np, "regulator-supported-modes",
+                                          i, &mode);
+               constraints->valid_modes_mask |= (1 << mode);
+       }
 }
 
 /**
--

1.8.1.1.dirty