aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2016-04-14 15:17:27 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-05-03 07:46:50 -0400
commit8c12ad8e916ee0477f7a0a0f00b0a87b9a21ebf7 (patch)
treec63e10b16952e55f8ecc50872b01bab6a6d03dd2
parent1591196ebdec9202b44d35b5a000910fd7a1898a (diff)
regulator: pwm: Use pwm_get_args() where appropriate
The PWM framework has clarified the concept of reference PWM config (the platform dependent config retrieved from the DT or the PWM lookup table) and real PWM state. Use pwm_get_args() when the PWM user wants to retrieve this reference config and not the current state. This is part of the rework allowing the PWM framework to support hardware readout and expose real PWM state even when the PWM has just been requested (before the user calls pwm_config/enable/disable()). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Mark Brown <broonie@kernel.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
-rw-r--r--drivers/regulator/pwm-regulator.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index 4689d62f4841..ffdb895ace0a 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -59,16 +59,16 @@ static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev,
59 unsigned selector) 59 unsigned selector)
60{ 60{
61 struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); 61 struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev);
62 unsigned int pwm_reg_period; 62 struct pwm_args pargs;
63 int dutycycle; 63 int dutycycle;
64 int ret; 64 int ret;
65 65
66 pwm_reg_period = pwm_get_period(drvdata->pwm); 66 pwm_get_args(drvdata->pwm, &pargs);
67 67
68 dutycycle = (pwm_reg_period * 68 dutycycle = (pargs.period *
69 drvdata->duty_cycle_table[selector].dutycycle) / 100; 69 drvdata->duty_cycle_table[selector].dutycycle) / 100;
70 70
71 ret = pwm_config(drvdata->pwm, dutycycle, pwm_reg_period); 71 ret = pwm_config(drvdata->pwm, dutycycle, pargs.period);
72 if (ret) { 72 if (ret) {
73 dev_err(&rdev->dev, "Failed to configure PWM\n"); 73 dev_err(&rdev->dev, "Failed to configure PWM\n");
74 return ret; 74 return ret;
@@ -138,13 +138,15 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
138{ 138{
139 struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); 139 struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev);
140 unsigned int ramp_delay = rdev->constraints->ramp_delay; 140 unsigned int ramp_delay = rdev->constraints->ramp_delay;
141 unsigned int period = pwm_get_period(drvdata->pwm); 141 struct pwm_args pargs;
142 int duty_cycle; 142 int duty_cycle;
143 int ret; 143 int ret;
144 144
145 pwm_get_args(drvdata->pwm, &pargs);
145 duty_cycle = pwm_voltage_to_duty_cycle_percentage(rdev, min_uV); 146 duty_cycle = pwm_voltage_to_duty_cycle_percentage(rdev, min_uV);
146 147
147 ret = pwm_config(drvdata->pwm, (period / 100) * duty_cycle, period); 148 ret = pwm_config(drvdata->pwm, (pargs.period / 100) * duty_cycle,
149 pargs.period);
148 if (ret) { 150 if (ret) {
149 dev_err(&rdev->dev, "Failed to configure PWM\n"); 151 dev_err(&rdev->dev, "Failed to configure PWM\n");
150 return ret; 152 return ret;
@@ -281,6 +283,12 @@ static int pwm_regulator_probe(struct platform_device *pdev)
281 return PTR_ERR(drvdata->pwm); 283 return PTR_ERR(drvdata->pwm);
282 } 284 }
283 285
286 /*
287 * FIXME: pwm_apply_args() should be removed when switching to the
288 * atomic PWM API.
289 */
290 pwm_apply_args(drvdata->pwm);
291
284 regulator = devm_regulator_register(&pdev->dev, 292 regulator = devm_regulator_register(&pdev->dev,
285 &drvdata->desc, &config); 293 &drvdata->desc, &config);
286 if (IS_ERR(regulator)) { 294 if (IS_ERR(regulator)) {