aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c24
-rw-r--r--include/linux/regulator/driver.h5
2 files changed, 29 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 5c6aedaa934d..ff76abde3ab3 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2280,6 +2280,30 @@ int regulator_set_voltage_time(struct regulator *regulator,
2280EXPORT_SYMBOL_GPL(regulator_set_voltage_time); 2280EXPORT_SYMBOL_GPL(regulator_set_voltage_time);
2281 2281
2282/** 2282/**
2283 *regulator_set_voltage_time_sel - get raise/fall time
2284 * @regulator: regulator source
2285 * @old_selector: selector for starting voltage
2286 * @new_selector: selector for target voltage
2287 *
2288 * Provided with the starting and target voltage selectors, this function
2289 * returns time in microseconds required to rise or fall to this new voltage
2290 *
2291 * Drivers providing uV_step in their regulator_desc and ramp_delay in
2292 * regulation_constraints can use this as their set_voltage_time_sel()
2293 * operation.
2294 */
2295int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
2296 unsigned int old_selector,
2297 unsigned int new_selector)
2298{
2299 if (rdev->desc->ramp_delay && rdev->desc->uV_step)
2300 return DIV_ROUND_UP(rdev->desc->uV_step *
2301 abs(new_selector - old_selector),
2302 rdev->desc->ramp_delay) * 1000;
2303 return 0;
2304}
2305
2306/**
2283 * regulator_sync_voltage - re-apply last regulator output voltage 2307 * regulator_sync_voltage - re-apply last regulator output voltage
2284 * @regulator: regulator source 2308 * @regulator: regulator source
2285 * 2309 *
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 80226383e561..ae5c25379237 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -170,6 +170,7 @@ enum regulator_type {
170 * 170 *
171 * @min_uV: Voltage given by the lowest selector (if linear mapping) 171 * @min_uV: Voltage given by the lowest selector (if linear mapping)
172 * @uV_step: Voltage increase with each selector (if linear mapping) 172 * @uV_step: Voltage increase with each selector (if linear mapping)
173 * @ramp_delay: Time to settle down after voltage change (unit: mV/us)
173 * @volt_table: Voltage mapping table (if table based mapping) 174 * @volt_table: Voltage mapping table (if table based mapping)
174 * 175 *
175 * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_ 176 * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
@@ -189,6 +190,7 @@ struct regulator_desc {
189 190
190 unsigned int min_uV; 191 unsigned int min_uV;
191 unsigned int uV_step; 192 unsigned int uV_step;
193 unsigned int ramp_delay;
192 194
193 const unsigned int *volt_table; 195 const unsigned int *volt_table;
194 196
@@ -285,6 +287,9 @@ int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel);
285int regulator_is_enabled_regmap(struct regulator_dev *rdev); 287int regulator_is_enabled_regmap(struct regulator_dev *rdev);
286int regulator_enable_regmap(struct regulator_dev *rdev); 288int regulator_enable_regmap(struct regulator_dev *rdev);
287int regulator_disable_regmap(struct regulator_dev *rdev); 289int regulator_disable_regmap(struct regulator_dev *rdev);
290int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
291 unsigned int old_selector,
292 unsigned int new_selector);
288 293
289void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); 294void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
290 295