diff options
author | Yadwinder Singh Brar <yadi.brar@samsung.com> | 2013-06-24 16:50:56 +0530 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-07-15 11:28:25 +0100 |
commit | 1e1598ed04d831f5bb42a197b4045e6780365217 (patch) | |
tree | 9463fea126c28024e09c6c5af276f254fb3a13df /drivers/regulator/s2mps11.c | |
parent | ad81f0545ef01ea651886dddac4bef6cec930092 (diff) |
regulator: s2mps11: Implement set_voltage_time_sel() ops for bucks
Currently driver uses local struct s2mps11_info to store ramp rate for bucks
whic its getting through platform data, so instead of using regulator
constraints it should use s2mps11_info to calculate ramp delay.
Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/s2mps11.c')
-rw-r--r-- | drivers/regulator/s2mps11.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 2f62564ca93..a671eb63a4e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -53,6 +53,57 @@ static int get_ramp_delay(int ramp_delay) return cnt; } +static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev, + unsigned int old_selector, + unsigned int new_selector) +{ + struct s2mps11_info *s2mps11 = rdev_get_drvdata(rdev); + unsigned int ramp_delay = 0; + int old_volt, new_volt; + + switch (rdev->desc->id) { + case S2MPS11_BUCK2: + if (!s2mps11->buck2_ramp) + return 0; + ramp_delay = s2mps11->ramp_delay2; + break; + case S2MPS11_BUCK3: + if (!s2mps11->buck3_ramp) + return 0; + ramp_delay = s2mps11->ramp_delay34; + break; + case S2MPS11_BUCK4: + if (!s2mps11->buck4_ramp) + return 0; + ramp_delay = s2mps11->ramp_delay34; + break; + case S2MPS11_BUCK5: + ramp_delay = s2mps11->ramp_delay5; + break; + case S2MPS11_BUCK6: + if (!s2mps11->buck6_ramp) + return 0; + case S2MPS11_BUCK1: + ramp_delay = s2mps11->ramp_delay16; + break; + case S2MPS11_BUCK7: + case S2MPS11_BUCK8: + case S2MPS11_BUCK10: + ramp_delay = s2mps11->ramp_delay7810; + break; + case S2MPS11_BUCK9: + ramp_delay = s2mps11->ramp_delay9; + } + + if (ramp_delay == 0) + ramp_delay = rdev->desc->ramp_delay; + + old_volt = rdev->desc->min_uV + (rdev->desc->uV_step * old_selector); + new_volt = rdev->desc->min_uV + (rdev->desc->uV_step * new_selector); + + return DIV_ROUND_UP(abs(new_volt - old_volt), ramp_delay); +} + static struct regulator_ops s2mps11_ldo_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, @@ -72,7 +123,7 @@ static struct regulator_ops s2mps11_buck_ops = { .disable = regulator_disable_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, - .set_voltage_time_sel = regulator_set_voltage_time_sel, + .set_voltage_time_sel = s2mps11_regulator_set_voltage_time_sel, }; #define regulator_desc_ldo1(num) { \ |