regulator: tps80031: adjust tolerance if req minuV > dev minuV
Mallikarjun Kasoju [Tue, 17 Jul 2012 10:34:01 +0000 (15:34 +0530)]
Adjust the tolerance voltage only when requested minimum voltage is
more than the rail's minimum voltage.

bug 997415

Change-Id: Ie139c657f8550adba07b74a0cd5d69e2b53d62c2
Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Reviewed-on: http://git-master/r/116405
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

drivers/regulator/tps80031-regulator.c

index efc608c..33d4b62 100644 (file)
@@ -297,10 +297,11 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
        int vsel = 0;
        int ret;
 
-       min_uV = min_uV - ri->tolerance_uv;
-
        switch (ri->flags) {
        case 0:
+               if (min_uV >= (607700 + ri->tolerance_uv))
+                       min_uV = min_uV - ri->tolerance_uv;
+
                if (min_uV == 0)
                        vsel = 0;
                else if ((min_uV >= 607700) && (min_uV <= 1300000)) {
@@ -328,6 +329,8 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
                break;
 
        case DCDC_OFFSET_EN:
+               if (min_uV >= (700000 + ri->tolerance_uv))
+                       min_uV = min_uV - ri->tolerance_uv;
                if (min_uV == 0)
                        vsel = 0;
                else if ((min_uV >= 700000) && (min_uV <= 1420000)) {
@@ -355,6 +358,8 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
                break;
 
        case DCDC_EXTENDED_EN:
+               if (min_uV >= (1852000 + ri->tolerance_uv))
+                       min_uV = min_uV - ri->tolerance_uv;
                if (min_uV == 0)
                        vsel = 0;
                else if ((min_uV >= 1852000) && (max_uV <= 4013600)) {
@@ -366,6 +371,8 @@ static int __tps80031_dcdc_set_voltage(struct device *parent,
                break;
 
        case DCDC_OFFSET_EN|DCDC_EXTENDED_EN:
+               if (min_uV >= (2161000 + ri->tolerance_uv))
+                       min_uV = min_uV - ri->tolerance_uv;
                if (min_uV == 0)
                        vsel = 0;
                else if ((min_uV >= 2161000) && (max_uV <= 4321000)) {