public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] twl6030: regulator: Fix vsel calculations in set/get voltage apis
@ 2010-02-17 15:24 Rajendra Nayak
  2010-02-17 15:24 ` [PATCH 2/2] twl6030: regulator: Configure STATE register instead of REMAP Rajendra Nayak
  2010-02-17 16:15 ` [PATCH 1/2] twl6030: regulator: Fix vsel calculations in set/get voltage apis Mark Brown
  0 siblings, 2 replies; 13+ messages in thread
From: Rajendra Nayak @ 2010-02-17 15:24 UTC (permalink / raw)
  To: linux-omap; +Cc: Rajendra Nayak, Liam Girdwood, Samuel Ortiz, Mark Brown

TWL6030 has a formula to be used to calculate the vsel values
to be programmed in the VREG_VOLTAGE registers.

Voltage(in mV) = 1000mv + 100mv * (vsel - 1)

Ex: if vsel = 0x9, mV = 1000 + 100 * (9 -1) = 1800mV.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/regulator/twl-regulator.c |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 7e67485..e7871d6 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -367,11 +367,17 @@ twlldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
 		/* REVISIT for VAUX2, first match may not be best/lowest */
 
 		/* use the first in-range value */
-		if (min_uV <= uV && uV <= max_uV)
+		if (min_uV <= uV && uV <= max_uV) {
+			if (twl_class_is_6030())
+				/*
+				 * Use the below formula to calculate vsel
+				 * mV = 1000mv + 100mv * (vsel - 1)
+				 */
+				vsel = (LDO_MV(mV) - 1000)/100 + 1;
 			return twlreg_write(info, TWL_MODULE_PM_RECEIVER,
 							VREG_VOLTAGE, vsel);
+		}
 	}
-
 	return -EDOM;
 }
 
@@ -384,8 +390,17 @@ static int twlldo_get_voltage(struct regulator_dev *rdev)
 	if (vsel < 0)
 		return vsel;
 
-	vsel &= info->table_len - 1;
-	return LDO_MV(info->table[vsel]) * 1000;
+	if (twl_class_is_4030()) {
+		vsel &= info->table_len - 1;
+		return LDO_MV(info->table[vsel]) * 1000;
+	} else if (twl_class_is_6030()) {
+		/*
+		 * Use the below formula to calculate vsel
+		 * mV = 1000mv + 100mv * (vsel - 1)
+		 */
+		return (1000 + (100 * (vsel - 1))) * 1000;
+	}
+	return -EDOM;
 }
 
 static struct regulator_ops twlldo_ops = {
-- 
1.5.4.7


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-02-19  9:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-17 15:24 [PATCH 1/2] twl6030: regulator: Fix vsel calculations in set/get voltage apis Rajendra Nayak
2010-02-17 15:24 ` [PATCH 2/2] twl6030: regulator: Configure STATE register instead of REMAP Rajendra Nayak
2010-02-17 16:15   ` Mark Brown
2010-02-18 12:33   ` Liam Girdwood
2010-02-17 16:15 ` [PATCH 1/2] twl6030: regulator: Fix vsel calculations in set/get voltage apis Mark Brown
2010-02-18  6:32   ` Nayak, Rajendra
2010-02-18  9:48     ` Mark Brown
2010-02-18 10:19       ` Nayak, Rajendra
2010-02-18 10:40         ` Mark Brown
2010-02-18 11:39           ` Nayak, Rajendra
2010-02-18 11:42             ` Mark Brown
2010-02-19  6:39               ` Nayak, Rajendra
2010-02-19  9:27                 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox