linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC RESEND 1/3] regulator: core: Handle fixed voltage in map_voltage_linear
@ 2012-06-07  7:01 Axel Lin
  2012-06-07  7:02 ` [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
  2012-06-07  7:03 ` [PATCH RFC RESEND 3/3] regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address Axel Lin
  0 siblings, 2 replies; 5+ messages in thread
From: Axel Lin @ 2012-06-07  7:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Liam Girdwood, Mark Brown, Eric Miao, Mike Rapoport

Fixed voltage is a kind of linear mapping where n_voltages is 1.
This change allows [list|map]_voltage_linear to be used for fixed voltage.

For fixed voltage, n_voltages is 1 and the only valid selector is 0.
Thus we actually don't care the uV_step setting.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
This patch is v2 of 
[PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage.

I change the subject line because for fixed voltage, we actually don't care the uV_step setting.

 drivers/regulator/core.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 02c1940..45baa72 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2070,6 +2070,15 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
 {
 	int ret, voltage;
 
+	/* For fixed voltage, check if voltage falls within specified range */
+	if (rdev->desc->n_voltages == 1) {
+		if (min_uV <= rdev->desc->min_uV &&
+		    rdev->desc->min_uV <= max_uV)
+			return 0;
+		else
+			return -EINVAL;
+	}
+
 	if (!rdev->desc->uV_step) {
 		BUG_ON(!rdev->desc->uV_step);
 		return -EINVAL;
-- 
1.7.9.5




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

* [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops
  2012-06-07  7:01 [PATCH RFC RESEND 1/3] regulator: core: Handle fixed voltage in map_voltage_linear Axel Lin
@ 2012-06-07  7:02 ` Axel Lin
  2012-06-08  0:08   ` Axel Lin
  2012-06-07  7:03 ` [PATCH RFC RESEND 3/3] regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address Axel Lin
  1 sibling, 1 reply; 5+ messages in thread
From: Axel Lin @ 2012-06-07  7:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Liam Girdwood, Mark Brown, Eric Miao, Mike Rapoport

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

diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index 56d273f..4a11b82a 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -75,19 +75,13 @@ static struct regulator_ops isl_core_ops = {
 
 static int isl6271a_get_fixed_voltage(struct regulator_dev *dev)
 {
-	int id = rdev_get_id(dev);
-	return (id == 1) ? 1100000 : 1300000;
-}
-
-static int isl6271a_list_fixed_voltage(struct regulator_dev *dev, unsigned selector)
-{
-	int id = rdev_get_id(dev);
-	return (id == 1) ? 1100000 : 1300000;
+	return dev->desc->min_uV;
 }
 
 static struct regulator_ops isl_fixed_ops = {
 	.get_voltage	= isl6271a_get_fixed_voltage,
-	.list_voltage	= isl6271a_list_fixed_voltage,
+	.list_voltage	= regulator_list_voltage_linear,
+	.map_voltage	= regulator_map_voltage_linear,
 };
 
 static const struct regulator_desc isl_rd[] = {
@@ -107,6 +101,7 @@ static const struct regulator_desc isl_rd[] = {
 		.ops		= &isl_fixed_ops,
 		.type		= REGULATOR_VOLTAGE,
 		.owner		= THIS_MODULE,
+		.min_uV		= 1100000,
 	}, {
 		.name		= "LDO2",
 		.id		= 2,
@@ -114,6 +109,7 @@ static const struct regulator_desc isl_rd[] = {
 		.ops		= &isl_fixed_ops,
 		.type		= REGULATOR_VOLTAGE,
 		.owner		= THIS_MODULE,
+		.min_uV		= 1300000,
 	},
 };
 
-- 
1.7.9.5




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

* [PATCH RFC RESEND 3/3] regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address
  2012-06-07  7:01 [PATCH RFC RESEND 1/3] regulator: core: Handle fixed voltage in map_voltage_linear Axel Lin
  2012-06-07  7:02 ` [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
@ 2012-06-07  7:03 ` Axel Lin
  1 sibling, 0 replies; 5+ messages in thread
From: Axel Lin @ 2012-06-07  7:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Liam Girdwood, Mark Brown, Eric Miao, Mike Rapoport

For fixed voltage, DA9030_LDO13 and DA9034_LDO5, the info->vol_reg is
DA9030_INVAL/DA9034_INVAL.
It does not make sense to read/write to DA9030_INVAL/DA9034_INVAL address.

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

diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 1005f5f..36c5b92 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -107,6 +107,9 @@ static int da903x_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
 	struct device *da9034_dev = to_da903x_dev(rdev);
 	uint8_t val, mask;
 
+	if (rdev->desc->n_voltages == 1)
+		return -EINVAL;
+
 	val = selector << info->vol_shift;
 	mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
 
@@ -120,6 +123,9 @@ static int da903x_get_voltage_sel(struct regulator_dev *rdev)
 	uint8_t val, mask;
 	int ret;
 
+	if (rdev->desc->n_voltages == 1)
+		return 0;
+
 	ret = da903x_read(da9034_dev, info->vol_reg, &val);
 	if (ret)
 		return ret;
-- 
1.7.9.5




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

* Re: [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops
  2012-06-07  7:02 ` [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
@ 2012-06-08  0:08   ` Axel Lin
  2012-06-08  0:31     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Axel Lin @ 2012-06-08  0:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Liam Girdwood, Mark Brown, Eric Miao, Mike Rapoport

>
>  static struct regulator_ops isl_fixed_ops = {
>        .get_voltage    = isl6271a_get_fixed_voltage,
> -       .list_voltage   = isl6271a_list_fixed_voltage,
> +       .list_voltage   = regulator_list_voltage_linear,
> +       .map_voltage    = regulator_map_voltage_linear,
>  };

Oh. isl_fixed_ops does not implement set_voltage_sel callback, adding
map_voltage here
seems misleading. I'll send a v2 soon.

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

* Re: [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops
  2012-06-08  0:08   ` Axel Lin
@ 2012-06-08  0:31     ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-06-08  0:31 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Marek Vasut, Liam Girdwood, Eric Miao, Mike Rapoport

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

On Fri, Jun 08, 2012 at 08:08:41AM +0800, Axel Lin wrote:

> Oh. isl_fixed_ops does not implement set_voltage_sel callback, adding
> map_voltage here
> seems misleading. I'll send a v2 soon.

Please send an incremental patch, this is already applied.

[-- 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-06-08  0:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07  7:01 [PATCH RFC RESEND 1/3] regulator: core: Handle fixed voltage in map_voltage_linear Axel Lin
2012-06-07  7:02 ` [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
2012-06-08  0:08   ` Axel Lin
2012-06-08  0:31     ` Mark Brown
2012-06-07  7:03 ` [PATCH RFC RESEND 3/3] regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address Axel Lin

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).