diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-11 10:58:03 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-17 10:25:10 -0400 |
commit | 62bc4d4a702654cf5aefbb32c766991fb45bf15a (patch) | |
tree | 430f12959e7d097f2323e121308c352e23ff2a70 /drivers/regulator/max8997.c | |
parent | 9e96b3a7ade72cb66b95f2ad3c849bab702ed87b (diff) |
regulator: Convert max8997 to set_voltage_time_sel
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8997.c')
-rw-r--r-- | drivers/regulator/max8997.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 56402e87925e..ec99bd30e603 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -489,9 +489,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev, | |||
489 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | 489 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; |
490 | const struct voltage_map_desc *desc; | 490 | const struct voltage_map_desc *desc; |
491 | int rid = rdev_get_id(rdev); | 491 | int rid = rdev_get_id(rdev); |
492 | int reg, shift = 0, mask, ret; | 492 | int i, reg, shift, mask, ret; |
493 | int i; | ||
494 | u8 org; | ||
495 | 493 | ||
496 | switch (rid) { | 494 | switch (rid) { |
497 | case MAX8997_LDO1 ... MAX8997_LDO21: | 495 | case MAX8997_LDO1 ... MAX8997_LDO21: |
@@ -520,21 +518,50 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev, | |||
520 | if (ret) | 518 | if (ret) |
521 | return ret; | 519 | return ret; |
522 | 520 | ||
523 | max8997_read_reg(i2c, reg, &org); | ||
524 | org = (org & mask) >> shift; | ||
525 | |||
526 | ret = max8997_update_reg(i2c, reg, i << shift, mask << shift); | 521 | ret = max8997_update_reg(i2c, reg, i << shift, mask << shift); |
527 | *selector = i; | 522 | *selector = i; |
528 | 523 | ||
529 | if (rid == MAX8997_BUCK1 || rid == MAX8997_BUCK2 || | 524 | return ret; |
530 | rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) { | 525 | } |
531 | /* If the voltage is increasing */ | 526 | |
532 | if (org < i) | 527 | static int max8997_set_voltage_ldobuck_time_sel(struct regulator_dev *rdev, |
533 | udelay(DIV_ROUND_UP(desc->step * (i - org), | 528 | unsigned int old_selector, |
534 | max8997->ramp_delay)); | 529 | unsigned int new_selector) |
530 | { | ||
531 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | ||
532 | int rid = rdev_get_id(rdev); | ||
533 | const struct voltage_map_desc *desc = reg_voltage_map[rid]; | ||
534 | |||
535 | /* Delay is required only if the voltage is increasing */ | ||
536 | if (old_selector >= new_selector) | ||
537 | return 0; | ||
538 | |||
539 | /* No need to delay if gpio_dvs_mode */ | ||
540 | switch (rid) { | ||
541 | case MAX8997_BUCK1: | ||
542 | if (max8997->buck1_gpiodvs) | ||
543 | return 0; | ||
544 | break; | ||
545 | case MAX8997_BUCK2: | ||
546 | if (max8997->buck2_gpiodvs) | ||
547 | return 0; | ||
548 | break; | ||
549 | case MAX8997_BUCK5: | ||
550 | if (max8997->buck5_gpiodvs) | ||
551 | return 0; | ||
552 | break; | ||
553 | } | ||
554 | |||
555 | switch (rid) { | ||
556 | case MAX8997_BUCK1: | ||
557 | case MAX8997_BUCK2: | ||
558 | case MAX8997_BUCK4: | ||
559 | case MAX8997_BUCK5: | ||
560 | return DIV_ROUND_UP(desc->step * (new_selector - old_selector), | ||
561 | max8997->ramp_delay); | ||
535 | } | 562 | } |
536 | 563 | ||
537 | return ret; | 564 | return 0; |
538 | } | 565 | } |
539 | 566 | ||
540 | /* | 567 | /* |
@@ -780,6 +807,7 @@ static struct regulator_ops max8997_ldo_ops = { | |||
780 | .disable = max8997_reg_disable, | 807 | .disable = max8997_reg_disable, |
781 | .get_voltage_sel = max8997_get_voltage_sel, | 808 | .get_voltage_sel = max8997_get_voltage_sel, |
782 | .set_voltage = max8997_set_voltage_ldobuck, | 809 | .set_voltage = max8997_set_voltage_ldobuck, |
810 | .set_voltage_time_sel = max8997_set_voltage_ldobuck_time_sel, | ||
783 | .set_suspend_enable = max8997_reg_enable_suspend, | 811 | .set_suspend_enable = max8997_reg_enable_suspend, |
784 | .set_suspend_disable = max8997_reg_disable_suspend, | 812 | .set_suspend_disable = max8997_reg_disable_suspend, |
785 | }; | 813 | }; |
@@ -791,6 +819,7 @@ static struct regulator_ops max8997_buck_ops = { | |||
791 | .disable = max8997_reg_disable, | 819 | .disable = max8997_reg_disable, |
792 | .get_voltage_sel = max8997_get_voltage_sel, | 820 | .get_voltage_sel = max8997_get_voltage_sel, |
793 | .set_voltage = max8997_set_voltage_buck, | 821 | .set_voltage = max8997_set_voltage_buck, |
822 | .set_voltage_time_sel = max8997_set_voltage_ldobuck_time_sel, | ||
794 | .set_suspend_enable = max8997_reg_enable_suspend, | 823 | .set_suspend_enable = max8997_reg_enable_suspend, |
795 | .set_suspend_disable = max8997_reg_disable_suspend, | 824 | .set_suspend_disable = max8997_reg_disable_suspend, |
796 | }; | 825 | }; |