regulator: core: Add set_voltage_time op
The new op is analogous to set_voltage_time_sel. It can be used by regulators which don't have a table of discrete voltages. The function returns the time for the regulator output voltage to stabilize after being set to a new value, in microseconds. If the op is not set a default implementation is used to calculate the delay. This change also removes the ramp_delay calculation in the PWM regulator, since the driver now uses the core code for the calculation of the delay. Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:

committed by
Mark Brown

parent
d89564efe7
commit
73e705bf81
@@ -10,7 +10,6 @@
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/err.h>
|
||||
@@ -194,12 +193,10 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
|
||||
unsigned int min_uV_duty = drvdata->continuous.min_uV_dutycycle;
|
||||
unsigned int max_uV_duty = drvdata->continuous.max_uV_dutycycle;
|
||||
unsigned int duty_unit = drvdata->continuous.dutycycle_unit;
|
||||
unsigned int ramp_delay = rdev->constraints->ramp_delay;
|
||||
int min_uV = rdev->constraints->min_uV;
|
||||
int max_uV = rdev->constraints->max_uV;
|
||||
int diff_uV = max_uV - min_uV;
|
||||
struct pwm_state pstate;
|
||||
int old_uV = pwm_regulator_get_voltage(rdev);
|
||||
unsigned int diff_duty;
|
||||
unsigned int dutycycle;
|
||||
int ret;
|
||||
@@ -233,13 +230,6 @@ static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ramp_delay == 0) || !pwm_regulator_is_enabled(rdev))
|
||||
return 0;
|
||||
|
||||
/* Ramp delay is in uV/uS. Adjust to uS and delay */
|
||||
ramp_delay = DIV_ROUND_UP(abs(req_min_uV - old_uV), ramp_delay);
|
||||
usleep_range(ramp_delay, ramp_delay + DIV_ROUND_UP(ramp_delay, 10));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user