2012-06-07 07:01:55

by Axel Lin

[permalink] [raw]
Subject: [PATCH RFC RESEND 1/3] regulator: core: Handle fixed voltage in map_voltage_linear

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 <[email protected]>
---
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



2012-06-07 07:02:40

by Axel Lin

[permalink] [raw]
Subject: [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops

Signed-off-by: Axel Lin <[email protected]>
---
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


2012-06-07 07:03:30

by Axel Lin

[permalink] [raw]
Subject: [PATCH RFC RESEND 3/3] regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address

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 <[email protected]>
---
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


2012-06-08 00:09:04

by Axel Lin

[permalink] [raw]
Subject: Re: [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops

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

2012-06-08 00:57:11

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops

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.


Attachments:
(No filename) (251.00 B)
signature.asc (836.00 B)
Digital signature
Download all attachments