linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear
@ 2013-01-18  3:58 Axel Lin
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2013-01-18  3:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, patches, linux-kernel

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




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-18  6:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-18  3:58 [PATCH 1/2] regulator: wm8994: Convert wm8994_ldo2_ops to use regulator_list_voltage_linear Axel Lin
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).