diff options
Diffstat (limited to 'drivers/regulator/max8998.c')
-rw-r--r-- | drivers/regulator/max8998.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index c96b87abf335..4ca22f9b52e3 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -359,8 +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, i, j, previous_sel; | 362 | int i, j, previous_sel; |
363 | u8 val = 0; | ||
364 | static u8 buck1_last_val; | 363 | static u8 buck1_last_val; |
365 | 364 | ||
366 | if (buck >= ARRAY_SIZE(ldo_voltage_map)) | 365 | if (buck >= ARRAY_SIZE(ldo_voltage_map)) |
@@ -484,19 +483,40 @@ buck2_exit: | |||
484 | break; | 483 | break; |
485 | } | 484 | } |
486 | 485 | ||
486 | return ret; | ||
487 | } | ||
488 | |||
489 | static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev, | ||
490 | unsigned int old_selector, | ||
491 | unsigned int new_selector) | ||
492 | { | ||
493 | struct max8998_data *max8998 = rdev_get_drvdata(rdev); | ||
494 | struct i2c_client *i2c = max8998->iodev->i2c; | ||
495 | const struct voltage_map_desc *desc; | ||
496 | int buck = rdev_get_id(rdev); | ||
497 | u8 val = 0; | ||
498 | int difference, ret; | ||
499 | |||
500 | if (buck < MAX8998_BUCK1 || buck > MAX8998_BUCK4) | ||
501 | return -EINVAL; | ||
502 | |||
503 | desc = ldo_voltage_map[buck]; | ||
504 | |||
487 | /* Voltage stabilization */ | 505 | /* Voltage stabilization */ |
488 | max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val); | 506 | ret = max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val); |
507 | if (ret) | ||
508 | return ret; | ||
489 | 509 | ||
490 | /* lp3974 hasn't got ENRAMP bit - ramp is assumed as true */ | 510 | /* lp3974 hasn't got ENRAMP bit - ramp is assumed as true */ |
491 | /* MAX8998 has ENRAMP bit implemented, so test it*/ | 511 | /* MAX8998 has ENRAMP bit implemented, so test it*/ |
492 | if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP)) | 512 | if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP)) |
493 | return ret; | 513 | return 0; |
494 | 514 | ||
495 | difference = (i - previous_sel) * desc->step; | 515 | difference = (new_selector - old_selector) * desc->step; |
496 | if (difference > 0) | 516 | if (difference > 0) |
497 | udelay(difference / ((val & 0x0f) + 1)); | 517 | return difference / ((val & 0x0f) + 1); |
498 | 518 | ||
499 | return ret; | 519 | return 0; |
500 | } | 520 | } |
501 | 521 | ||
502 | static struct regulator_ops max8998_ldo_ops = { | 522 | static struct regulator_ops max8998_ldo_ops = { |
@@ -517,6 +537,7 @@ static struct regulator_ops max8998_buck_ops = { | |||
517 | .disable = max8998_ldo_disable, | 537 | .disable = max8998_ldo_disable, |
518 | .get_voltage_sel = max8998_get_voltage_sel, | 538 | .get_voltage_sel = max8998_get_voltage_sel, |
519 | .set_voltage = max8998_set_voltage_buck, | 539 | .set_voltage = max8998_set_voltage_buck, |
540 | .set_voltage_time_sel = max8998_set_voltage_buck_time_sel, | ||
520 | .set_suspend_enable = max8998_ldo_enable, | 541 | .set_suspend_enable = max8998_ldo_enable, |
521 | .set_suspend_disable = max8998_ldo_disable, | 542 | .set_suspend_disable = max8998_ldo_disable, |
522 | }; | 543 | }; |