aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8998.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-11 01:58:09 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-13 04:54:45 -0400
commit7b4354b46564a2224e624429f2f6eba3a2f99000 (patch)
tree509f74b2f4a5c6e4d4ca930b2e4cc88a202fe098 /drivers/regulator/max8998.c
parentb6f476c2c12d19b48364c9b0c818182280c2d1ae (diff)
regulator: Convert max8998 to get_voltage_sel
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8998.c')
-rw-r--r--drivers/regulator/max8998.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 7e831a94bf84..c96b87abf335 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -277,7 +277,7 @@ static int max8998_get_voltage_register(struct regulator_dev *rdev,
277 return 0; 277 return 0;
278} 278}
279 279
280static int max8998_get_voltage(struct regulator_dev *rdev) 280static int max8998_get_voltage_sel(struct regulator_dev *rdev)
281{ 281{
282 struct max8998_data *max8998 = rdev_get_drvdata(rdev); 282 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
283 struct i2c_client *i2c = max8998->iodev->i2c; 283 struct i2c_client *i2c = max8998->iodev->i2c;
@@ -295,7 +295,7 @@ static int max8998_get_voltage(struct regulator_dev *rdev)
295 val >>= shift; 295 val >>= shift;
296 val &= mask; 296 val &= mask;
297 297
298 return max8998_list_voltage(rdev, val); 298 return val;
299} 299}
300 300
301static int max8998_set_voltage_ldo(struct regulator_dev *rdev, 301static int max8998_set_voltage_ldo(struct regulator_dev *rdev,
@@ -359,7 +359,7 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
359 const struct voltage_map_desc *desc; 359 const struct voltage_map_desc *desc;
360 int buck = rdev_get_id(rdev); 360 int buck = rdev_get_id(rdev);
361 int reg, shift = 0, mask, ret; 361 int reg, shift = 0, mask, ret;
362 int difference = 0, i, j = 0, previous_vol = 0; 362 int difference, i, j, previous_sel;
363 u8 val = 0; 363 u8 val = 0;
364 static u8 buck1_last_val; 364 static u8 buck1_last_val;
365 365
@@ -388,13 +388,14 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
388 if (ret) 388 if (ret)
389 return ret; 389 return ret;
390 390
391 previous_vol = max8998_get_voltage(rdev); 391 previous_sel = max8998_get_voltage_sel(rdev);
392 392
393 /* Check if voltage needs to be changed */ 393 /* Check if voltage needs to be changed */
394 /* if previous_voltage equal new voltage, return */ 394 /* if previous_voltage equal new voltage, return */
395 if (previous_vol == max8998_list_voltage(rdev, i)) { 395 if (previous_sel == i) {
396 dev_dbg(max8998->dev, "No voltage change, old:%d, new:%d\n", 396 dev_dbg(max8998->dev, "No voltage change, old:%d, new:%d\n",
397 previous_vol, max8998_list_voltage(rdev, i)); 397 max8998_list_voltage(rdev, previous_sel),
398 max8998_list_voltage(rdev, i));
398 return ret; 399 return ret;
399 } 400 }
400 401
@@ -491,7 +492,7 @@ buck2_exit:
491 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP)) 492 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP))
492 return ret; 493 return ret;
493 494
494 difference = desc->min + desc->step*i - previous_vol/1000; 495 difference = (i - previous_sel) * desc->step;
495 if (difference > 0) 496 if (difference > 0)
496 udelay(difference / ((val & 0x0f) + 1)); 497 udelay(difference / ((val & 0x0f) + 1));
497 498
@@ -503,7 +504,7 @@ static struct regulator_ops max8998_ldo_ops = {
503 .is_enabled = max8998_ldo_is_enabled, 504 .is_enabled = max8998_ldo_is_enabled,
504 .enable = max8998_ldo_enable, 505 .enable = max8998_ldo_enable,
505 .disable = max8998_ldo_disable, 506 .disable = max8998_ldo_disable,
506 .get_voltage = max8998_get_voltage, 507 .get_voltage_sel = max8998_get_voltage_sel,
507 .set_voltage = max8998_set_voltage_ldo, 508 .set_voltage = max8998_set_voltage_ldo,
508 .set_suspend_enable = max8998_ldo_enable, 509 .set_suspend_enable = max8998_ldo_enable,
509 .set_suspend_disable = max8998_ldo_disable, 510 .set_suspend_disable = max8998_ldo_disable,
@@ -514,7 +515,7 @@ static struct regulator_ops max8998_buck_ops = {
514 .is_enabled = max8998_ldo_is_enabled, 515 .is_enabled = max8998_ldo_is_enabled,
515 .enable = max8998_ldo_enable, 516 .enable = max8998_ldo_enable,
516 .disable = max8998_ldo_disable, 517 .disable = max8998_ldo_disable,
517 .get_voltage = max8998_get_voltage, 518 .get_voltage_sel = max8998_get_voltage_sel,
518 .set_voltage = max8998_set_voltage_buck, 519 .set_voltage = max8998_set_voltage_buck,
519 .set_suspend_enable = max8998_ldo_enable, 520 .set_suspend_enable = max8998_ldo_enable,
520 .set_suspend_disable = max8998_ldo_disable, 521 .set_suspend_disable = max8998_ldo_disable,