diff mbox

regulator: core: Define regulator_set_voltage_triplet()

Message ID 28971ff9b110d18970fcc6291531f617cda18230.1439553400.git.viresh.kumar@linaro.org
State New
Headers show

Commit Message

Viresh Kumar Aug. 14, 2015, noon UTC
The OPP (Operating performance points) v2 bindings allows regulator
voltage to be supplied as a triplet of <target min max> voltages.

Add regulator_set_voltage_triplet() API in regulator core to support
that.

This first tries to set a voltage between the target voltage and the
upper limit, then fall back on the full range. The idea behind this is
to set regulator's voltage as close to the target voltage, as possible.

Based on regulator_set_voltage_tol().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
Hi Mark,

This is required for OPP-V2 bindings that we introduced recently, where
the voltage can be given as a triplet of <target min max>.

I don't have any dependency on this until the time I update regulator
support in OPP core and so sending it separately. You can take it
through your tree. Ofcourse, only if it looks fine :)

 include/linux/regulator/consumer.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox

Patch

diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index f8a689ed62a5..621e89315c55 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -552,6 +552,16 @@  static inline int regulator_count_voltages(struct regulator *regulator)
 }
 #endif
 
+static inline int regulator_set_voltage_triplet(struct regulator *regulator,
+						int target_uV, int min_uV,
+						int max_uV)
+{
+	if (!regulator_set_voltage(regulator, target_uV, max_uV))
+		return 0;
+
+	return regulator_set_voltage(regulator, min_uV, max_uV);
+}
+
 static inline int regulator_set_voltage_tol(struct regulator *regulator,
 					    int new_uV, int tol_uV)
 {