summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/core.c
diff options
context:
space:
mode:
authorYadwinder Singh Brar <yadi.brar01@gmail.com>2012-06-09 16:40:38 +0530
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-11 12:01:46 +0800
commit98a175b60f46a80dfa44fb0e0807f2e5a351f35f (patch)
tree07c81163935868d9b1334a1bb33f8edddc6a29ca /drivers/regulator/core.c
parentab0d1cbe55014ac65cfc317f8ef2cd5fa4b7d4da (diff)
downloadlinux-98a175b60f46a80dfa44fb0e0807f2e5a351f35f.tar.bz2
regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay.
This patch adds regulator_set_voltage_time_sel(), to move into core, the commonly used code by drivers to provide the .set_voltage_time_sel callback. It will also allow us to configure different ramp delay for different regulators easily. Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/core.c')
-rw-r--r--drivers/regulator/core.c24
1 files changed, 24 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,
EXPORT_SYMBOL_GPL(regulator_set_voltage_time);
/**
+ *regulator_set_voltage_time_sel - get raise/fall time
+ * @regulator: regulator source
+ * @old_selector: selector for starting voltage
+ * @new_selector: selector for target voltage
+ *
+ * Provided with the starting and target voltage selectors, this function
+ * returns time in microseconds required to rise or fall to this new voltage
+ *
+ * Drivers providing uV_step in their regulator_desc and ramp_delay in
+ * regulation_constraints can use this as their set_voltage_time_sel()
+ * operation.
+ */
+int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+ unsigned int old_selector,
+ unsigned int new_selector)
+{
+ if (rdev->desc->ramp_delay && rdev->desc->uV_step)
+ return DIV_ROUND_UP(rdev->desc->uV_step *
+ abs(new_selector - old_selector),
+ rdev->desc->ramp_delay) * 1000;
+ return 0;
+}
+
+/**
* regulator_sync_voltage - re-apply last regulator output voltage
* @regulator: regulator source
*