All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0
@ 2012-03-24  1:37 Axel Lin
  2012-03-24  1:38 ` [PATCH 2/4] regulator: Convert tps6586x to get_voltage_sel Axel Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-24  1:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Rapoport, Danny Huang, Liam Girdwood, Mark Brown

According to the datasheet, LDO0 has minimal voltage 1.2V rather than 1.25V.

Table 3-39. VLDO0[2:0] Settings
VLDOx[2:0] VOUT (V) VLDOx[2:0] VOUT (V)
000        1.20     100        2.70
001        1.50     101        2.85
010        1.80     110        3.10
011        2.50     111        3.30

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/tps6586x-regulator.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 29b615c..cfc1f16 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -79,6 +79,11 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev,
 				     unsigned selector)
 {
 	struct tps6586x_regulator *info = rdev_get_drvdata(rdev);
+	int rid = rdev_get_id(rdev);
+
+	/* LDO0 has minimal voltage 1.2V rather than 1.25V */
+	if ((rid == TPS6586X_ID_LDO_0) && (selector == 0))
+		return (info->voltages[0] - 50) * 1000;
 
 	return info->voltages[selector] * 1000;
 }
-- 
1.7.5.4




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

* [PATCH 2/4] regulator: Convert tps6586x to get_voltage_sel
  2012-03-24  1:37 [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Axel Lin
@ 2012-03-24  1:38 ` Axel Lin
  2012-03-24  1:42 ` [PATCH 3/4] regulator: Convert tps6586x to set_voltage_sel Axel Lin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-24  1:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Rapoport, Danny Huang, Liam Girdwood, Mark Brown

This also fixes a bug, LDO0 has minimal voltage 1.2V rather than 1.25V.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/tps6586x-regulator.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index cfc1f16..af3559b 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -129,7 +129,7 @@ static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev,
 					  selector);
 }
 
-static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev)
+static int tps6586x_get_voltage_sel(struct regulator_dev *rdev)
 {
 	struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
 	struct device *parent = to_tps6586x_dev(rdev);
@@ -146,7 +146,7 @@ static int tps6586x_ldo_get_voltage(struct regulator_dev *rdev)
 	if (val >= ri->desc.n_voltages)
 		BUG();
 
-	return ri->voltages[val] * 1000;
+	return val;
 }
 
 static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev,
@@ -198,7 +198,7 @@ static int tps6586x_regulator_is_enabled(struct regulator_dev *rdev)
 
 static struct regulator_ops tps6586x_regulator_ldo_ops = {
 	.list_voltage = tps6586x_ldo_list_voltage,
-	.get_voltage = tps6586x_ldo_get_voltage,
+	.get_voltage_sel = tps6586x_get_voltage_sel,
 	.set_voltage = tps6586x_ldo_set_voltage,
 
 	.is_enabled = tps6586x_regulator_is_enabled,
@@ -208,7 +208,7 @@ static struct regulator_ops tps6586x_regulator_ldo_ops = {
 
 static struct regulator_ops tps6586x_regulator_dvm_ops = {
 	.list_voltage = tps6586x_ldo_list_voltage,
-	.get_voltage = tps6586x_ldo_get_voltage,
+	.get_voltage_sel = tps6586x_get_voltage_sel,
 	.set_voltage = tps6586x_dvm_set_voltage,
 
 	.is_enabled = tps6586x_regulator_is_enabled,
-- 
1.7.5.4




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

* [PATCH 3/4] regulator: Convert tps6586x to set_voltage_sel
  2012-03-24  1:37 [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Axel Lin
  2012-03-24  1:38 ` [PATCH 2/4] regulator: Convert tps6586x to get_voltage_sel Axel Lin
@ 2012-03-24  1:42 ` Axel Lin
  2012-03-24  1:44 ` [PATCH 4/4] regulator: Merge tps6586x_regulator_ldo_ops and tps6586x_regulator_dvm_ops Axel Lin
  2012-03-26 10:56 ` [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-24  1:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Rapoport, Danny Huang, Liam Girdwood, Mark Brown

Convert both tps6586x_[ldo|dvm]_set_voltage to one set_voltage_sel callback.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/tps6586x-regulator.c |   70 +++++++++----------------------
 1 files changed, 21 insertions(+), 49 deletions(-)

diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index af3559b..51ca882 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -89,44 +89,31 @@ static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev,
 }
 
 
-static int __tps6586x_ldo_set_voltage(struct device *parent,
-				      struct tps6586x_regulator *ri,
-				      int min_uV, int max_uV,
-				      unsigned *selector)
+static int tps6586x_set_voltage_sel(struct regulator_dev *rdev,
+				    unsigned selector)
 {
-	int val, uV;
+	struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
+	struct device *parent = to_tps6586x_dev(rdev);
+	int ret, val, rid = rdev_get_id(rdev);
 	uint8_t mask;
 
-	for (val = 0; val < ri->desc.n_voltages; val++) {
-		uV = ri->voltages[val] * 1000;
-
-		/* LDO0 has minimal voltage 1.2 rather than 1.25 */
-		if (ri->desc.id == TPS6586X_ID_LDO_0 && val == 0)
-			uV -= 50 * 1000;
-
-		/* use the first in-range value */
-		if (min_uV <= uV && uV <= max_uV) {
-
-			*selector = val;
+	val = selector << ri->volt_shift;
+	mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift;
 
-			val <<= ri->volt_shift;
-			mask = ((1 << ri->volt_nbits) - 1) << ri->volt_shift;
+	ret = tps6586x_update(parent, ri->volt_reg, val, mask);
+	if (ret)
+		return ret;
 
-			return tps6586x_update(parent, ri->volt_reg, val, mask);
-		}
+	/* Update go bit for DVM regulators */
+	switch (rid) {
+	case TPS6586X_ID_LDO_2:
+	case TPS6586X_ID_LDO_4:
+	case TPS6586X_ID_SM_0:
+	case TPS6586X_ID_SM_1:
+		ret = tps6586x_set_bits(parent, ri->go_reg, 1 << ri->go_bit);
+		break;
 	}
-
-	return -EINVAL;
-}
-
-static int tps6586x_ldo_set_voltage(struct regulator_dev *rdev,
-				    int min_uV, int max_uV, unsigned *selector)
-{
-	struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
-	struct device *parent = to_tps6586x_dev(rdev);
-
-	return __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV,
-					  selector);
+	return ret;
 }
 
 static int tps6586x_get_voltage_sel(struct regulator_dev *rdev)
@@ -149,21 +136,6 @@ static int tps6586x_get_voltage_sel(struct regulator_dev *rdev)
 	return val;
 }
 
-static int tps6586x_dvm_set_voltage(struct regulator_dev *rdev,
-				    int min_uV, int max_uV, unsigned *selector)
-{
-	struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
-	struct device *parent = to_tps6586x_dev(rdev);
-	int ret;
-
-	ret = __tps6586x_ldo_set_voltage(parent, ri, min_uV, max_uV,
-					 selector);
-	if (ret)
-		return ret;
-
-	return tps6586x_set_bits(parent, ri->go_reg, 1 << ri->go_bit);
-}
-
 static int tps6586x_regulator_enable(struct regulator_dev *rdev)
 {
 	struct tps6586x_regulator *ri = rdev_get_drvdata(rdev);
@@ -199,7 +171,7 @@ static int tps6586x_regulator_is_enabled(struct regulator_dev *rdev)
 static struct regulator_ops tps6586x_regulator_ldo_ops = {
 	.list_voltage = tps6586x_ldo_list_voltage,
 	.get_voltage_sel = tps6586x_get_voltage_sel,
-	.set_voltage = tps6586x_ldo_set_voltage,
+	.set_voltage_sel = tps6586x_set_voltage_sel,
 
 	.is_enabled = tps6586x_regulator_is_enabled,
 	.enable = tps6586x_regulator_enable,
@@ -209,7 +181,7 @@ static struct regulator_ops tps6586x_regulator_ldo_ops = {
 static struct regulator_ops tps6586x_regulator_dvm_ops = {
 	.list_voltage = tps6586x_ldo_list_voltage,
 	.get_voltage_sel = tps6586x_get_voltage_sel,
-	.set_voltage = tps6586x_dvm_set_voltage,
+	.set_voltage_sel = tps6586x_set_voltage_sel,
 
 	.is_enabled = tps6586x_regulator_is_enabled,
 	.enable = tps6586x_regulator_enable,
-- 
1.7.5.4




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

* [PATCH 4/4] regulator: Merge tps6586x_regulator_ldo_ops and tps6586x_regulator_dvm_ops
  2012-03-24  1:37 [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Axel Lin
  2012-03-24  1:38 ` [PATCH 2/4] regulator: Convert tps6586x to get_voltage_sel Axel Lin
  2012-03-24  1:42 ` [PATCH 3/4] regulator: Convert tps6586x to set_voltage_sel Axel Lin
@ 2012-03-24  1:44 ` Axel Lin
  2012-03-26 10:56 ` [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-03-24  1:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mike Rapoport, Danny Huang, Liam Girdwood, Mark Brown

Now all the callback implementation are the same for both ldo and dvm
regulator_ops, merge them to tps6586x_regulator_ops.

Also rename tps6586x_ldo_list_voltage to tps6586x_list_voltage.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/tps6586x-regulator.c |   25 +++++++------------------
 1 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index 51ca882..18f5337 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -75,8 +75,7 @@ static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev)
 	return rdev_get_dev(rdev)->parent->parent;
 }
 
-static int tps6586x_ldo_list_voltage(struct regulator_dev *rdev,
-				     unsigned selector)
+static int tps6586x_list_voltage(struct regulator_dev *rdev, unsigned selector)
 {
 	struct tps6586x_regulator *info = rdev_get_drvdata(rdev);
 	int rid = rdev_get_id(rdev);
@@ -168,18 +167,8 @@ static int tps6586x_regulator_is_enabled(struct regulator_dev *rdev)
 	return !!(reg_val & (1 << ri->enable_bit[0]));
 }
 
-static struct regulator_ops tps6586x_regulator_ldo_ops = {
-	.list_voltage = tps6586x_ldo_list_voltage,
-	.get_voltage_sel = tps6586x_get_voltage_sel,
-	.set_voltage_sel = tps6586x_set_voltage_sel,
-
-	.is_enabled = tps6586x_regulator_is_enabled,
-	.enable = tps6586x_regulator_enable,
-	.disable = tps6586x_regulator_disable,
-};
-
-static struct regulator_ops tps6586x_regulator_dvm_ops = {
-	.list_voltage = tps6586x_ldo_list_voltage,
+static struct regulator_ops tps6586x_regulator_ops = {
+	.list_voltage = tps6586x_list_voltage,
 	.get_voltage_sel = tps6586x_get_voltage_sel,
 	.set_voltage_sel = tps6586x_set_voltage_sel,
 
@@ -213,11 +202,11 @@ static int tps6586x_dvm_voltages[] = {
 	1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500,
 };
 
-#define TPS6586X_REGULATOR(_id, vdata, _ops, vreg, shift, nbits,	\
+#define TPS6586X_REGULATOR(_id, vdata, vreg, shift, nbits,		\
 			   ereg0, ebit0, ereg1, ebit1)			\
 	.desc	= {							\
 		.name	= "REG-" #_id,					\
-		.ops	= &tps6586x_regulator_##_ops,			\
+		.ops	= &tps6586x_regulator_ops,			\
 		.type	= REGULATOR_VOLTAGE,				\
 		.id	= TPS6586X_ID_##_id,				\
 		.n_voltages = ARRAY_SIZE(tps6586x_##vdata##_voltages),	\
@@ -239,14 +228,14 @@ static int tps6586x_dvm_voltages[] = {
 #define TPS6586X_LDO(_id, vdata, vreg, shift, nbits,			\
 		     ereg0, ebit0, ereg1, ebit1)			\
 {									\
-	TPS6586X_REGULATOR(_id, vdata, ldo_ops, vreg, shift, nbits,	\
+	TPS6586X_REGULATOR(_id, vdata, vreg, shift, nbits,		\
 			   ereg0, ebit0, ereg1, ebit1)			\
 }
 
 #define TPS6586X_DVM(_id, vdata, vreg, shift, nbits,			\
 		     ereg0, ebit0, ereg1, ebit1, goreg, gobit)		\
 {									\
-	TPS6586X_REGULATOR(_id, vdata, dvm_ops, vreg, shift, nbits,	\
+	TPS6586X_REGULATOR(_id, vdata, vreg, shift, nbits,		\
 			   ereg0, ebit0, ereg1, ebit1)			\
 	TPS6586X_REGULATOR_DVM_GOREG(goreg, gobit)			\
 }
-- 
1.7.5.4




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

* Re: [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0
  2012-03-24  1:37 [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Axel Lin
                   ` (2 preceding siblings ...)
  2012-03-24  1:44 ` [PATCH 4/4] regulator: Merge tps6586x_regulator_ldo_ops and tps6586x_regulator_dvm_ops Axel Lin
@ 2012-03-26 10:56 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-03-26 10:56 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Mike Rapoport, Danny Huang, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 155 bytes --]

On Sat, Mar 24, 2012 at 09:37:30AM +0800, Axel Lin wrote:
> According to the datasheet, LDO0 has minimal voltage 1.2V rather than 1.25V.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-03-26 10:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-24  1:37 [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Axel Lin
2012-03-24  1:38 ` [PATCH 2/4] regulator: Convert tps6586x to get_voltage_sel Axel Lin
2012-03-24  1:42 ` [PATCH 3/4] regulator: Convert tps6586x to set_voltage_sel Axel Lin
2012-03-24  1:44 ` [PATCH 4/4] regulator: Merge tps6586x_regulator_ldo_ops and tps6586x_regulator_dvm_ops Axel Lin
2012-03-26 10:56 ` [PATCH 1/4] regulator: tps6586x: Fix list minimal voltage setting for LDO0 Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.