Commit f11d08c3 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: Use list_voltage() to get voltage in regulator_set_voltage_time_sel

With this change, regulator_set_voltage_time_sel() can be more generic and not
limited to linear and table based mapping now.
One side-effect of this change is that list_voltage() must be implemented.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent baae019e
...@@ -2296,8 +2296,7 @@ EXPORT_SYMBOL_GPL(regulator_set_voltage_time); ...@@ -2296,8 +2296,7 @@ EXPORT_SYMBOL_GPL(regulator_set_voltage_time);
* Provided with the starting and target voltage selectors, this function * Provided with the starting and target voltage selectors, this function
* returns time in microseconds required to rise or fall to this new voltage * returns time in microseconds required to rise or fall to this new voltage
* *
* Drivers providing uV_step or volt_table in their regulator_desc and * Drivers providing ramp_delay in regulation_constraints can use this as their
* ramp_delay in regulation_constraints can use this as their
* set_voltage_time_sel() operation. * set_voltage_time_sel() operation.
*/ */
int regulator_set_voltage_time_sel(struct regulator_dev *rdev, int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
...@@ -2305,6 +2304,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, ...@@ -2305,6 +2304,7 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
unsigned int new_selector) unsigned int new_selector)
{ {
unsigned int ramp_delay = 0; unsigned int ramp_delay = 0;
int old_volt, new_volt;
if (rdev->constraints->ramp_delay) if (rdev->constraints->ramp_delay)
ramp_delay = rdev->constraints->ramp_delay; ramp_delay = rdev->constraints->ramp_delay;
...@@ -2316,19 +2316,14 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, ...@@ -2316,19 +2316,14 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
return 0; return 0;
} }
if (rdev->desc->uV_step) { /* sanity check */
return DIV_ROUND_UP(rdev->desc->uV_step * if (!rdev->desc->ops->list_voltage)
abs(new_selector - old_selector), return -EINVAL;
ramp_delay);
} else if (rdev->desc->volt_table) {
return DIV_ROUND_UP(abs(rdev->desc->volt_table[new_selector] -
rdev->desc->volt_table[old_selector]),
ramp_delay);
} else {
rdev_warn(rdev, "Unsupported voltage mapping settings\n");
}
return 0; old_volt = rdev->desc->ops->list_voltage(rdev, old_selector);
new_volt = rdev->desc->ops->list_voltage(rdev, new_selector);
return DIV_ROUND_UP(abs(new_volt - old_volt), ramp_delay);
} }
EXPORT_SYMBOL_GPL(regulator_set_voltage_time_sel); EXPORT_SYMBOL_GPL(regulator_set_voltage_time_sel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment