All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14
@ 2012-05-08 11:46 Axel Lin
  2012-05-08 11:47 ` [PATCH RFT 2/2] regulator: da903x: Convert to get_voltage_sel Axel Lin
  2012-05-12 10:14 ` [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14 Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-05-08 11:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: Eric Miao, Mike Rapoport, Liam Girdwood, Mark Brown

da903x_list_voltage does not return correct voltage for da9030 ldo14.
Implement da9030_list_ldo14_voltage to return correct voltage for da9030 ldo14.

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

diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 682bdb3..a9c4590 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -267,6 +267,24 @@ static int da9030_get_ldo14_voltage(struct regulator_dev *rdev)
 			info->step_uV * (val & ~0x4);
 }
 
+static int da9030_list_ldo14_voltage(struct regulator_dev *rdev,
+				     unsigned selector)
+{
+	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
+	int volt;
+
+	if (selector & 0x4)
+		volt = info->min_uV + info->step_uV * (3 - (selector & ~0x4));
+	else
+		volt = (info->max_uV + info->min_uV) / 2 +
+		       info->step_uV * (selector & ~0x4);
+
+	if (volt > info->max_uV)
+		return -EINVAL;
+
+	return volt;
+}
+
 /* DA9034 specific operations */
 static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
 				  int min_uV, int max_uV, unsigned *selector)
@@ -357,7 +375,7 @@ static struct regulator_ops da903x_regulator_ldo_ops = {
 static struct regulator_ops da9030_regulator_ldo14_ops = {
 	.set_voltage	= da9030_set_ldo14_voltage,
 	.get_voltage	= da9030_get_ldo14_voltage,
-	.list_voltage	= da903x_list_voltage,
+	.list_voltage	= da9030_list_ldo14_voltage,
 	.enable		= da903x_enable,
 	.disable	= da903x_disable,
 	.is_enabled	= da903x_is_enabled,
-- 
1.7.5.4




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

* [PATCH RFT 2/2] regulator: da903x: Convert to get_voltage_sel
  2012-05-08 11:46 [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14 Axel Lin
@ 2012-05-08 11:47 ` Axel Lin
  2012-05-12 10:14 ` [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14 Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-05-08 11:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Eric Miao, Mike Rapoport, Liam Girdwood, Mark Brown

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

diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index a9c4590..c75e7b7 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -88,10 +88,6 @@ struct da903x_regulator_info {
 	int	enable_bit;
 };
 
-static int da9034_ldo12_data[] = { 1700, 1750, 1800, 1850, 1900, 1950,
-				   2000, 2050, 2700, 2750, 2800, 2850,
-				   2900, 2950, 3000, 3050 };
-
 static inline struct device *to_da903x_dev(struct regulator_dev *rdev)
 {
 	return rdev_get_dev(rdev)->parent->parent;
@@ -127,7 +123,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
 	return da903x_update(da9034_dev, info->vol_reg, val, mask);
 }
 
-static int da903x_get_voltage(struct regulator_dev *rdev)
+static int da903x_get_voltage_sel(struct regulator_dev *rdev)
 {
 	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
 	struct device *da9034_dev = to_da903x_dev(rdev);
@@ -141,7 +137,7 @@ static int da903x_get_voltage(struct regulator_dev *rdev)
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
 	val = (val & mask) >> info->vol_shift;
 
-	return info->min_uV + info->step_uV * val;
+	return val;
 }
 
 static int da903x_enable(struct regulator_dev *rdev)
@@ -246,7 +242,7 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
 	return da903x_update(da903x_dev, info->vol_reg, val, mask);
 }
 
-static int da9030_get_ldo14_voltage(struct regulator_dev *rdev)
+static int da9030_get_ldo14_voltage_sel(struct regulator_dev *rdev)
 {
 	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
 	struct device *da903x_dev = to_da903x_dev(rdev);
@@ -260,11 +256,7 @@ static int da9030_get_ldo14_voltage(struct regulator_dev *rdev)
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
 	val = (val & mask) >> info->vol_shift;
 
-	if (val & 0x4)
-		return info->min_uV + info->step_uV * (3 - (val & ~0x4));
-	else
-		return (info->max_uV + info->min_uV) / 2 +
-			info->step_uV * (val & ~0x4);
+	return val;
 }
 
 static int da9030_list_ldo14_voltage(struct regulator_dev *rdev,
@@ -334,7 +326,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
 	return da903x_update(da9034_dev, info->vol_reg, val, mask);
 }
 
-static int da9034_get_ldo12_voltage(struct regulator_dev *rdev)
+static int da9034_get_ldo12_voltage_sel(struct regulator_dev *rdev)
 {
 	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
 	struct device *da9034_dev = to_da903x_dev(rdev);
@@ -348,23 +340,29 @@ static int da9034_get_ldo12_voltage(struct regulator_dev *rdev)
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
 	val = (val & mask) >> info->vol_shift;
 
-	if (val >= 8)
-		return 2700000 + info->step_uV * (val - 8);
-
-	return info->min_uV + info->step_uV * val;
+	return val;
 }
 
 static int da9034_list_ldo12_voltage(struct regulator_dev *rdev,
 				     unsigned selector)
 {
-	if (selector >= ARRAY_SIZE(da9034_ldo12_data))
+	struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
+	int volt;
+
+	if (selector >= 8)
+		volt = 2700000 + info->step_uV * (selector - 8);
+	else
+		volt = info->min_uV + info->step_uV * selector;
+
+	if (volt > info->max_uV)
 		return -EINVAL;
-	return da9034_ldo12_data[selector] * 1000;
+
+	return volt;
 }
 
 static struct regulator_ops da903x_regulator_ldo_ops = {
 	.set_voltage	= da903x_set_ldo_voltage,
-	.get_voltage	= da903x_get_voltage,
+	.get_voltage_sel = da903x_get_voltage_sel,
 	.list_voltage	= da903x_list_voltage,
 	.enable		= da903x_enable,
 	.disable	= da903x_disable,
@@ -374,7 +372,7 @@ static struct regulator_ops da903x_regulator_ldo_ops = {
 /* NOTE: this is dedicated for the insane DA9030 LDO14 */
 static struct regulator_ops da9030_regulator_ldo14_ops = {
 	.set_voltage	= da9030_set_ldo14_voltage,
-	.get_voltage	= da9030_get_ldo14_voltage,
+	.get_voltage_sel = da9030_get_ldo14_voltage_sel,
 	.list_voltage	= da9030_list_ldo14_voltage,
 	.enable		= da903x_enable,
 	.disable	= da903x_disable,
@@ -384,7 +382,7 @@ static struct regulator_ops da9030_regulator_ldo14_ops = {
 /* NOTE: this is dedicated for the DA9030 LDO1 and LDO15 that have locks  */
 static struct regulator_ops da9030_regulator_ldo1_15_ops = {
 	.set_voltage	= da9030_set_ldo1_15_voltage,
-	.get_voltage	= da903x_get_voltage,
+	.get_voltage_sel = da903x_get_voltage_sel,
 	.list_voltage	= da903x_list_voltage,
 	.enable		= da903x_enable,
 	.disable	= da903x_disable,
@@ -393,7 +391,7 @@ static struct regulator_ops da9030_regulator_ldo1_15_ops = {
 
 static struct regulator_ops da9034_regulator_dvc_ops = {
 	.set_voltage	= da9034_set_dvc_voltage,
-	.get_voltage	= da903x_get_voltage,
+	.get_voltage_sel = da903x_get_voltage_sel,
 	.list_voltage	= da903x_list_voltage,
 	.enable		= da903x_enable,
 	.disable	= da903x_disable,
@@ -403,7 +401,7 @@ static struct regulator_ops da9034_regulator_dvc_ops = {
 /* NOTE: this is dedicated for the insane LDO12 */
 static struct regulator_ops da9034_regulator_ldo12_ops = {
 	.set_voltage	= da9034_set_ldo12_voltage,
-	.get_voltage	= da9034_get_ldo12_voltage,
+	.get_voltage_sel = da9034_get_ldo12_voltage_sel,
 	.list_voltage	= da9034_list_ldo12_voltage,
 	.enable		= da903x_enable,
 	.disable	= da903x_disable,
@@ -546,7 +544,7 @@ static int __devinit da903x_regulator_probe(struct platform_device *pdev)
 	/* Workaround for the weird LDO12 voltage setting */
 	if (ri->desc.id == DA9034_ID_LDO12) {
 		ri->desc.ops = &da9034_regulator_ldo12_ops;
-		ri->desc.n_voltages = ARRAY_SIZE(da9034_ldo12_data);
+		ri->desc.n_voltages = 16;
 	}
 
 	if (ri->desc.id == DA9030_ID_LDO14)
-- 
1.7.5.4




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

* Re: [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14
  2012-05-08 11:46 [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14 Axel Lin
  2012-05-08 11:47 ` [PATCH RFT 2/2] regulator: da903x: Convert to get_voltage_sel Axel Lin
@ 2012-05-12 10:14 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-05-12 10:14 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Eric Miao, Mike Rapoport, Liam Girdwood

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

On Tue, May 08, 2012 at 07:46:10PM +0800, Axel Lin wrote:
> da903x_list_voltage does not return correct voltage for da9030 ldo14.
> Implement da9030_list_ldo14_voltage to return correct voltage for da9030 ldo14.

Applied both, thanks.

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

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

end of thread, other threads:[~2012-05-12 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-08 11:46 [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14 Axel Lin
2012-05-08 11:47 ` [PATCH RFT 2/2] regulator: da903x: Convert to get_voltage_sel Axel Lin
2012-05-12 10:14 ` [PATCH RFT 1/2] regulator: da903x: Fix list voltage for da9030 ldo14 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.