summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-02-02 16:19:40 +0530
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-02-13 06:23:17 -0800
commit9483d46c233bc69721e315dfc3f3aacbdfe08c12 (patch)
tree4c05b0522f9e612b7662f231ad58814fcd22d73b /drivers
parente1e0f303cd2a343545e53cf53a1fe84a9cf599dd (diff)
regulator: tps80031: Correct voltage selection logics
Fixing the voltage selection logics for a given mininum/maximum range. bug 934544 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/78970 (cherry picked from commit 59b0264b6eda9f1e8123ee5cd82eae7104c3513e) Change-Id: Ib9f6e8b1b1f0603aeb02af8345704110cd87b51a Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/79512 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/tps80031-regulator.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
index 874abebd0e43..411b839f1a74 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -300,12 +300,16 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
case 0:
if (min_uV == 0)
vsel = 0;
- else if ((min_uV >= 607700) && (max_uV <= 1300000)) {
+ else if ((min_uV >= 607700) && (min_uV <= 1300000)) {
+ int cal_volt;
vsel = (10 * (min_uV - 607700)) / 1266;
if (vsel % 100)
vsel += 100;
vsel /= 100;
vsel++;
+ cal_volt = (607700 + (12660 * (vsel - 1)));
+ if (cal_volt > max_uV)
+ return -EINVAL;
} else if ((min_uV > 1900000) && (max_uV >= 2100000))
vsel = 62;
else if ((min_uV > 1800000) && (max_uV >= 1900000))
@@ -323,17 +327,21 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
case DCDC_OFFSET_EN:
if (min_uV == 0)
vsel = 0;
- else if ((min_uV >= 700000) && (max_uV <= 1420000)) {
- vsel = (min_uV - 600000) / 125;
+ else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
+ int cal_volt;
+ vsel = (min_uV - 700000) / 125;
if (vsel % 100)
vsel += 100;
vsel /= 100;
vsel++;
+ cal_volt = (700000 + (12500 * (vsel - 1)));
+ if (cal_volt > max_uV)
+ return -EINVAL;
} else if ((min_uV > 1900000) && (max_uV >= 2100000))
vsel = 62;
else if ((min_uV > 1800000) && (max_uV >= 1900000))
vsel = 61;
- else if ((min_uV > 1350000) && (max_uV >= 1800000))
+ else if ((min_uV > 1500000) && (max_uV >= 1800000))
vsel = 60;
else if ((min_uV > 1350000) && (max_uV >= 1500000))
vsel = 59;
@@ -350,7 +358,6 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
vsel = (min_uV - 1852000) / 386;
if (vsel % 100)
vsel += 100;
- vsel /= 100;
vsel++;
}
break;
@@ -359,7 +366,7 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
if (min_uV == 0)
vsel = 0;
else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {
- vsel = (min_uV - 1852000) / 386;
+ vsel = (min_uV - 2161000) / 386;
if (vsel % 100)
vsel += 100;
vsel /= 100;