mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs
@ 2009-03-10 16:28 Mark Brown
  2009-03-10 16:28 ` [PATCH 2/2] regulator: Don't warn on omitted voltage constraints Mark Brown
  2009-03-11 14:29 ` [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs Liam Girdwood
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2009-03-10 16:28 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, Mark Brown

All DCDCs and LDOs are identical.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/regulator/wm8400-regulator.c |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 6ed43b0..1574260 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -43,6 +43,18 @@ static int wm8400_ldo_disable(struct regulator_dev *dev)
 			       WM8400_LDO1_ENA, 0);
 }
 
+static int wm8400_ldo_list_voltage(struct regulator_dev *dev,
+				   unsigned selector)
+{
+	if (selector > WM8400_LDO1_VSEL_MASK)
+		return -EINVAL;
+
+	if (selector < 15)
+		return 900000 + (selector * 50000);
+	else
+		return 1600000 + ((selector - 14) * 100000);
+}
+
 static int wm8400_ldo_get_voltage(struct regulator_dev *dev)
 {
 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
@@ -51,10 +63,7 @@ static int wm8400_ldo_get_voltage(struct regulator_dev *dev)
 	val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev));
 	val &= WM8400_LDO1_VSEL_MASK;
 
-	if (val < 15)
-		return 900000 + (val * 50000);
-	else
-		return 1600000 + ((val - 14) * 100000);
+	return wm8400_ldo_list_voltage(dev, val);
 }
 
 static int wm8400_ldo_set_voltage(struct regulator_dev *dev,
@@ -92,6 +101,7 @@ static struct regulator_ops wm8400_ldo_ops = {
 	.is_enabled = wm8400_ldo_is_enabled,
 	.enable = wm8400_ldo_enable,
 	.disable = wm8400_ldo_disable,
+	.list_voltage = wm8400_ldo_list_voltage,
 	.get_voltage = wm8400_ldo_get_voltage,
 	.set_voltage = wm8400_ldo_set_voltage,
 };
@@ -124,6 +134,15 @@ static int wm8400_dcdc_disable(struct regulator_dev *dev)
 			       WM8400_DC1_ENA, 0);
 }
 
+static int wm8400_dcdc_list_voltage(struct regulator_dev *dev,
+				    unsigned selector)
+{
+	if (selector > WM8400_DC1_VSEL_MASK)
+		return -EINVAL;
+
+	return 850000 + (selector * 25000);
+}
+
 static int wm8400_dcdc_get_voltage(struct regulator_dev *dev)
 {
 	struct wm8400 *wm8400 = rdev_get_drvdata(dev);
@@ -237,6 +256,7 @@ static struct regulator_ops wm8400_dcdc_ops = {
 	.is_enabled = wm8400_dcdc_is_enabled,
 	.enable = wm8400_dcdc_enable,
 	.disable = wm8400_dcdc_disable,
+	.list_voltage = wm8400_dcdc_list_voltage,
 	.get_voltage = wm8400_dcdc_get_voltage,
 	.set_voltage = wm8400_dcdc_set_voltage,
 	.get_mode = wm8400_dcdc_get_mode,
@@ -249,6 +269,7 @@ static struct regulator_desc regulators[] = {
 		.name = "LDO1",
 		.id = WM8400_LDO1,
 		.ops = &wm8400_ldo_ops,
+		.n_voltages = WM8400_LDO1_VSEL_MASK + 1,
 		.type = REGULATOR_VOLTAGE,
 		.owner = THIS_MODULE,
 	},
@@ -256,6 +277,7 @@ static struct regulator_desc regulators[] = {
 		.name = "LDO2",
 		.id = WM8400_LDO2,
 		.ops = &wm8400_ldo_ops,
+		.n_voltages = WM8400_LDO2_VSEL_MASK + 1,
 		.type = REGULATOR_VOLTAGE,
 		.owner = THIS_MODULE,
 	},
@@ -263,6 +285,7 @@ static struct regulator_desc regulators[] = {
 		.name = "LDO3",
 		.id = WM8400_LDO3,
 		.ops = &wm8400_ldo_ops,
+		.n_voltages = WM8400_LDO3_VSEL_MASK + 1,
 		.type = REGULATOR_VOLTAGE,
 		.owner = THIS_MODULE,
 	},
@@ -270,6 +293,7 @@ static struct regulator_desc regulators[] = {
 		.name = "LDO4",
 		.id = WM8400_LDO4,
 		.ops = &wm8400_ldo_ops,
+		.n_voltages = WM8400_LDO4_VSEL_MASK + 1,
 		.type = REGULATOR_VOLTAGE,
 		.owner = THIS_MODULE,
 	},
@@ -277,6 +301,7 @@ static struct regulator_desc regulators[] = {
 		.name = "DCDC1",
 		.id = WM8400_DCDC1,
 		.ops = &wm8400_dcdc_ops,
+		.n_voltages = WM8400_DC1_VSEL_MASK + 1,
 		.type = REGULATOR_VOLTAGE,
 		.owner = THIS_MODULE,
 	},
@@ -284,6 +309,7 @@ static struct regulator_desc regulators[] = {
 		.name = "DCDC2",
 		.id = WM8400_DCDC2,
 		.ops = &wm8400_dcdc_ops,
+		.n_voltages = WM8400_DC2_VSEL_MASK + 1,
 		.type = REGULATOR_VOLTAGE,
 		.owner = THIS_MODULE,
 	},
-- 
1.6.2


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

* [PATCH 2/2] regulator: Don't warn on omitted voltage constraints
  2009-03-10 16:28 [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs Mark Brown
@ 2009-03-10 16:28 ` Mark Brown
  2009-03-11 14:29   ` Liam Girdwood
  2009-03-11 14:29 ` [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs Liam Girdwood
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2009-03-10 16:28 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: linux-kernel, Mark Brown

Specifying voltage constraints is optional (and only needed if the
consumer is allowed to change the voltage) so don't complain unless
a voltage has been specified.

Also avoid surprises with a dangling else while we're here.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/regulator/core.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 464e9b1..08441e2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -709,8 +709,12 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 			cmax = INT_MAX;
 		}
 
+		/* voltage constraints are optional */
+		if ((cmin == 0) && (cmax == 0))
+			goto out;
+
 		/* else require explicit machine-level constraints */
-		else if (cmin <= 0 || cmax <= 0 || cmax < cmin) {
+		if (cmin <= 0 || cmax <= 0 || cmax < cmin) {
 			pr_err("%s: %s '%s' voltage constraints\n",
 				       __func__, "invalid", name);
 			ret = -EINVAL;
-- 
1.6.2


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

* Re: [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs
  2009-03-10 16:28 [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs Mark Brown
  2009-03-10 16:28 ` [PATCH 2/2] regulator: Don't warn on omitted voltage constraints Mark Brown
@ 2009-03-11 14:29 ` Liam Girdwood
  1 sibling, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2009-03-11 14:29 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel

On Tue, 2009-03-10 at 16:28 +0000, Mark Brown wrote:
> All DCDCs and LDOs are identical.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---

Applied.

Thanks

Liam


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

* Re: [PATCH 2/2] regulator: Don't warn on omitted voltage constraints
  2009-03-10 16:28 ` [PATCH 2/2] regulator: Don't warn on omitted voltage constraints Mark Brown
@ 2009-03-11 14:29   ` Liam Girdwood
  0 siblings, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2009-03-11 14:29 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel

On Tue, 2009-03-10 at 16:28 +0000, Mark Brown wrote:
> Specifying voltage constraints is optional (and only needed if the
> consumer is allowed to change the voltage) so don't complain unless
> a voltage has been specified.
> 
> Also avoid surprises with a dangling else while we're here.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  drivers/regulator/core.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)

Applied.

Thanks

Liam


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

end of thread, other threads:[~2009-03-11 14:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10 16:28 [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs Mark Brown
2009-03-10 16:28 ` [PATCH 2/2] regulator: Don't warn on omitted voltage constraints Mark Brown
2009-03-11 14:29   ` Liam Girdwood
2009-03-11 14:29 ` [PATCH 1/2] regulator: Implement list_voltage() for WM8400 DCDCs and LDOs Liam Girdwood

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®