From: Yadwinder Singh Brar <yadi.brar01@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
Liam Girdwood <lrg@ti.com>,
Yadwinder Singh Brar <yadi.brar@samsung.com>
Subject: [PATCH v2 1/2] regulator: core: Add regulator_set_voltage_time_sel to calculate ramp delay.
Date: Sat, 9 Jun 2012 16:40:38 +0530 [thread overview]
Message-ID: <1339240239-5626-1-git-send-email-yadi.brar@samsung.com> (raw)
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>
---
drivers/regulator/core.c | 24 ++++++++++++++++++++++++
include/linux/regulator/driver.h | 5 +++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 876f5fc..f4c056a 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2289,6 +2289,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
*
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 8022638..ae5c253 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -170,6 +170,7 @@ enum regulator_type {
*
* @min_uV: Voltage given by the lowest selector (if linear mapping)
* @uV_step: Voltage increase with each selector (if linear mapping)
+ * @ramp_delay: Time to settle down after voltage change (unit: mV/us)
* @volt_table: Voltage mapping table (if table based mapping)
*
* @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
@@ -189,6 +190,7 @@ struct regulator_desc {
unsigned int min_uV;
unsigned int uV_step;
+ unsigned int ramp_delay;
const unsigned int *volt_table;
@@ -285,6 +287,9 @@ int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel);
int regulator_is_enabled_regmap(struct regulator_dev *rdev);
int regulator_enable_regmap(struct regulator_dev *rdev);
int regulator_disable_regmap(struct regulator_dev *rdev);
+int regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+ unsigned int old_selector,
+ unsigned int new_selector);
void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
--
1.7.0.4
next reply other threads:[~2012-06-09 11:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-09 11:10 Yadwinder Singh Brar [this message]
2012-06-09 11:10 ` [PATCH v2 2/2] regulator: Parse ramp_delay in while parsing DT for regulators Yadwinder Singh Brar
2012-06-11 4:07 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339240239-5626-1-git-send-email-yadi.brar@samsung.com \
--to=yadi.brar01@gmail.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=yadi.brar@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®