From: Axel Lin <axel.lin@ingics.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
patches@opensource.wolfsonmicro.com,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear
Date: Fri, 18 Jan 2013 11:58:33 +0800 [thread overview]
Message-ID: <1358481513.25899.6.camel@phoenix> (raw)
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/wm8994-regulator.c | 57 ++++++++++++++++------------------
1 file changed, 26 insertions(+), 31 deletions(-)
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 6ff8723..fef2692 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -27,7 +27,6 @@
struct wm8994_ldo {
struct regulator_dev *regulator;
- struct wm8994 *wm8994;
};
#define WM8994_LDO1_MAX_SELECTOR 0x7
@@ -40,39 +39,14 @@ static struct regulator_ops wm8994_ldo1_ops = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
};
-static int wm8994_ldo2_list_voltage(struct regulator_dev *rdev,
- unsigned int selector)
-{
- struct wm8994_ldo *ldo = rdev_get_drvdata(rdev);
-
- if (selector > WM8994_LDO2_MAX_SELECTOR)
- return -EINVAL;
-
- switch (ldo->wm8994->type) {
- case WM8994:
- return (selector * 100000) + 900000;
- case WM8958:
- return (selector * 100000) + 1000000;
- case WM1811:
- switch (selector) {
- case 0:
- return -EINVAL;
- default:
- return (selector * 100000) + 950000;
- }
- break;
- default:
- return -EINVAL;
- }
-}
-
static struct regulator_ops wm8994_ldo2_ops = {
- .list_voltage = wm8994_ldo2_list_voltage,
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
};
-static const struct regulator_desc wm8994_ldo_desc[] = {
+static struct regulator_desc wm8994_ldo_desc[] = {
{
.name = "LDO1",
.id = 1,
@@ -116,8 +90,6 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
return -ENOMEM;
}
- ldo->wm8994 = wm8994;
-
config.dev = wm8994->dev;
config.driver_data = ldo;
config.regmap = wm8994->regmap;
@@ -126,6 +98,29 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
config.ena_gpio = pdata->ldo[id].enable;
}
+ /* LDO2, id starts from 0 */
+ if (id == 1) {
+ switch (wm8994->type) {
+ case WM8994:
+ wm8994_ldo_desc[id].min_uV = 900000;
+ wm8994_ldo_desc[id].uV_step = 100000;
+ break;
+ case WM8958:
+ wm8994_ldo_desc[id].min_uV = 1000000;
+ wm8994_ldo_desc[id].uV_step = 100000;
+ break;
+ case WM1811:
+ wm8994_ldo_desc[id].min_uV = 1050000;
+ wm8994_ldo_desc[id].uV_step = 100000;
+ wm8994_ldo_desc[id].linear_min_sel = 1;
+ break;
+ default:
+ dev_err(&pdev->dev, "Unknown wm8994 device type %d\n",
+ wm8994->type);
+ return -EINVAL;
+ }
+ }
+
ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
if (IS_ERR(ldo->regulator)) {
ret = PTR_ERR(ldo->regulator);
--
1.7.9.5
next reply other threads:[~2013-01-18 3:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-18 3:58 Axel Lin [this message]
2013-01-18 3:59 ` [PATCH 2/2] regulator: wm8994: Merge wm8994_ldo1_ops and wm8994_ldo2_ops Axel Lin
2013-01-18 6:13 ` [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear 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=1358481513.25899.6.camel@phoenix \
--to=axel.lin@ingics.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.wolfsonmicro.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®