From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Lee Jones <lee.jones@linaro.org>,
Linus Walleij <linus.walleij@stericsson.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Liam Girdwood <lrg@ti.com>, Anuj Aggarwal <anuj.aggarwal@ti.com>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: [PATCH RFC/RFT 1/7] regulator: core: Allow drivers to set voltage mapping table in regulator_desc
Date: Sun, 20 May 2012 10:30:21 +0800 [thread overview]
Message-ID: <1337481021.7204.1.camel@phoenix> (raw)
Some regulator hardware use table based mapping can set volt_table in
regulator_desc and use regulator_list_voltage_table() for their list_voltage
callback.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/core.c | 25 +++++++++++++++++++++++++
include/linux/regulator/driver.h | 5 +++++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index faa0532..0b15587 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1880,6 +1880,31 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
/**
+ * regulator_list_voltage_table - List voltages with table based mapping
+ *
+ * @rdev: Regulator device
+ * @selector: Selector to convert into a voltage
+ *
+ * Regulators with table based mapping between voltages and
+ * selectors can set volt_table in the regulator descriptor
+ * and then use this function as their list_voltage() operation.
+ */
+int regulator_list_voltage_table(struct regulator_dev *rdev,
+ unsigned int selector)
+{
+ if (!rdev->desc->volt_table) {
+ BUG_ON(!rdev->desc->volt_table);
+ return -EINVAL;
+ }
+
+ if (selector >= rdev->desc->n_voltages)
+ return -EINVAL;
+
+ return rdev->desc->volt_table[selector];
+}
+EXPORT_SYMBOL_GPL(regulator_list_voltage_table);
+
+/**
* regulator_list_voltage - enumerate supported voltages
* @regulator: regulator source
* @selector: identify voltage to list
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index b0432cc..8022638 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)
+ * @volt_table: Voltage mapping table (if table based mapping)
*
* @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
* @vsel_mask: Mask for register bitfield used for selector
@@ -189,6 +190,8 @@ struct regulator_desc {
unsigned int min_uV;
unsigned int uV_step;
+ const unsigned int *volt_table;
+
unsigned int vsel_reg;
unsigned int vsel_mask;
unsigned int enable_reg;
@@ -271,6 +274,8 @@ int regulator_mode_to_status(unsigned int);
int regulator_list_voltage_linear(struct regulator_dev *rdev,
unsigned int selector);
+int regulator_list_voltage_table(struct regulator_dev *rdev,
+ unsigned int selector);
int regulator_map_voltage_linear(struct regulator_dev *rdev,
int min_uV, int max_uV);
int regulator_map_voltage_iterate(struct regulator_dev *rdev,
--
1.7.5.4
next reply other threads:[~2012-05-20 2:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-20 2:30 Axel Lin [this message]
2012-05-20 2:31 ` [PATCH RFC/RFT 2/7] regulator: ab3100: Use regulator_list_voltage_table() Axel Lin
2012-05-21 9:16 ` Linus Walleij
2012-05-20 2:33 ` [PATCH RFC/RFT 3/7] regulator: ab8500: " Axel Lin
2012-05-21 10:43 ` Linus Walleij
2012-05-21 11:17 ` Mark Brown
2012-05-20 2:34 ` [PATCH RFC/RFT 4/7] regulator: lp3971: " Axel Lin
2012-05-20 2:36 ` [PATCH RFC/RFT 5/7] regulator: lp3972: " Axel Lin
2012-05-20 2:37 ` [PATCH RFC/RFT 6/7] regulator: tps6105x: " Axel Lin
2012-05-21 16:06 ` Linus Walleij
2012-05-20 2:39 ` [PATCH RFC/RFT 7/7] regulator: tps6507x: " Axel Lin
2012-05-20 21:48 ` [PATCH RFC/RFT 1/7] regulator: core: Allow drivers to set voltage mapping table in regulator_desc 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=1337481021.7204.1.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=anuj.aggarwal@ti.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=m.szyprowski@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