aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-03-14 03:30:58 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-03-14 08:37:41 -0400
commit18039e0f16d50c8243fe0388a587c25a3b155ece (patch)
tree3952623eee7b9f481fb966ddfba39583b5f2772a /drivers/regulator
parente3e5aff714c0da06201576304f1b41dcdd142ef4 (diff)
regulator: tps65910: Provide settling time for DCDC voltage change
Settling time is require when there is dcdc rail's voltage change. Returning proper delay time for dcdc voltage change to settle down the output voltage to new value. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/tps65910-regulator.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index f28f41aec284..3d1370f9bc7f 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -561,10 +561,10 @@ static unsigned int tps65910_get_mode(struct regulator_dev *dev)
561 return REGULATOR_MODE_NORMAL; 561 return REGULATOR_MODE_NORMAL;
562} 562}
563 563
564static int tps65910_get_voltage_dcdc(struct regulator_dev *dev) 564static int tps65910_get_voltage_dcdc_sel(struct regulator_dev *dev)
565{ 565{
566 struct tps65910_reg *pmic = rdev_get_drvdata(dev); 566 struct tps65910_reg *pmic = rdev_get_drvdata(dev);
567 int id = rdev_get_id(dev), voltage = 0; 567 int id = rdev_get_id(dev);
568 int opvsel = 0, srvsel = 0, vselmax = 0, mult = 0, sr = 0; 568 int opvsel = 0, srvsel = 0, vselmax = 0, mult = 0, sr = 0;
569 569
570 switch (id) { 570 switch (id) {
@@ -608,9 +608,7 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev)
608 srvsel = 3; 608 srvsel = 3;
609 if (srvsel > vselmax) 609 if (srvsel > vselmax)
610 srvsel = vselmax; 610 srvsel = vselmax;
611 srvsel -= 3; 611 return srvsel - 3;
612
613 voltage = (srvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100;
614 } else { 612 } else {
615 613
616 /* normalise to valid range*/ 614 /* normalise to valid range*/
@@ -618,14 +616,9 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev)
618 opvsel = 3; 616 opvsel = 3;
619 if (opvsel > vselmax) 617 if (opvsel > vselmax)
620 opvsel = vselmax; 618 opvsel = vselmax;
621 opvsel -= 3; 619 return opvsel - 3;
622
623 voltage = (opvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100;
624 } 620 }
625 621 return -EINVAL;
626 voltage *= mult;
627
628 return voltage;
629} 622}
630 623
631static int tps65910_get_voltage(struct regulator_dev *dev) 624static int tps65910_get_voltage(struct regulator_dev *dev)
@@ -894,6 +887,31 @@ static int tps65911_list_voltage(struct regulator_dev *dev, unsigned selector)
894 return (LDO_MIN_VOLT + selector * step_mv) * 1000; 887 return (LDO_MIN_VOLT + selector * step_mv) * 1000;
895} 888}
896 889
890static int tps65910_set_voltage_dcdc_time_sel(struct regulator_dev *dev,
891 unsigned int old_selector, unsigned int new_selector)
892{
893 int id = rdev_get_id(dev);
894 int old_volt, new_volt;
895
896 old_volt = tps65910_list_voltage_dcdc(dev, old_selector);
897 if (old_volt < 0)
898 return old_volt;
899
900 new_volt = tps65910_list_voltage_dcdc(dev, new_selector);
901 if (new_volt < 0)
902 return new_volt;
903
904 /* VDD1 and VDD2 are 12.5mV/us, VDDCTRL is 100mV/20us */
905 switch (id) {
906 case TPS65910_REG_VDD1:
907 case TPS65910_REG_VDD2:
908 return DIV_ROUND_UP(abs(old_volt - new_volt), 12500);
909 case TPS65911_REG_VDDCTRL:
910 return DIV_ROUND_UP(abs(old_volt - new_volt), 5000);
911 }
912 return -EINVAL;
913}
914
897/* Regulator ops (except VRTC) */ 915/* Regulator ops (except VRTC) */
898static struct regulator_ops tps65910_ops_dcdc = { 916static struct regulator_ops tps65910_ops_dcdc = {
899 .is_enabled = tps65910_is_enabled, 917 .is_enabled = tps65910_is_enabled,
@@ -902,8 +920,9 @@ static struct regulator_ops tps65910_ops_dcdc = {
902 .enable_time = tps65910_enable_time, 920 .enable_time = tps65910_enable_time,
903 .set_mode = tps65910_set_mode, 921 .set_mode = tps65910_set_mode,
904 .get_mode = tps65910_get_mode, 922 .get_mode = tps65910_get_mode,
905 .get_voltage = tps65910_get_voltage_dcdc, 923 .get_voltage_sel = tps65910_get_voltage_dcdc_sel,
906 .set_voltage_sel = tps65910_set_voltage_dcdc_sel, 924 .set_voltage_sel = tps65910_set_voltage_dcdc_sel,
925 .set_voltage_time_sel = tps65910_set_voltage_dcdc_time_sel,
907 .list_voltage = tps65910_list_voltage_dcdc, 926 .list_voltage = tps65910_list_voltage_dcdc,
908}; 927};
909 928