* [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607
@ 2012-03-28 6:58 Axel Lin
2012-03-28 6:59 ` [PATCH 2/4] regulator: Add missing n_voltages setting " Axel Lin
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Axel Lin @ 2012-03-28 6:58 UTC (permalink / raw)
To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown, Jett.Zhou
Current code implements pm8607_list_voltage but does not set the list_voltage
callback function in pm8607_regulator_ops. Fix it.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/88pm8607.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 28b81ae..981b47a 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -328,6 +328,7 @@ static int pm8607_is_enabled(struct regulator_dev *rdev)
}
static struct regulator_ops pm8607_regulator_ops = {
+ .list_voltage = pm8607_list_voltage,
.set_voltage = pm8607_set_voltage,
.get_voltage = pm8607_get_voltage,
.enable = pm8607_enable,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] regulator: Add missing n_voltages setting for 88pm8607
2012-03-28 6:58 [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Axel Lin
@ 2012-03-28 6:59 ` Axel Lin
2012-03-28 7:00 ` [PATCH 3/4] regulator: Convert 88pm8607 to set_voltage_sel Axel Lin
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2012-03-28 6:59 UTC (permalink / raw)
To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown, Jett.Zhou
Then we can remove the vol_nbits field from struct pm8607_regulator_info.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/88pm8607.c | 51 ++++++++++++++++++++---------------------
1 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 981b47a..81b6659 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -29,7 +29,6 @@ struct pm8607_regulator_info {
int vol_reg;
int vol_shift;
- int vol_nbits;
int update_reg;
int update_bit;
int enable_reg;
@@ -216,7 +215,7 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
int ret = -EINVAL;
- if (info->vol_table && (index < (1 << info->vol_nbits))) {
+ if (info->vol_table && (index < rdev->desc->n_voltages)) {
ret = info->vol_table[index];
if (info->slope_double)
ret <<= 1;
@@ -234,7 +233,7 @@ static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
max_uV = max_uV >> 1;
}
if (info->vol_table) {
- for (i = 0; i < (1 << info->vol_nbits); i++) {
+ for (i = 0; i < rdev->desc->n_voltages; i++) {
if (!info->vol_table[i])
break;
if ((min_uV <= info->vol_table[i])
@@ -266,7 +265,7 @@ static int pm8607_set_voltage(struct regulator_dev *rdev,
return -EINVAL;
*selector = ret;
val = (uint8_t)(ret << info->vol_shift);
- mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
+ mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
if (ret)
@@ -292,7 +291,7 @@ static int pm8607_get_voltage(struct regulator_dev *rdev)
if (ret < 0)
return ret;
- mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
+ mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
val = ((unsigned char)ret & mask) >> info->vol_shift;
return pm8607_list_voltage(rdev, val);
@@ -336,7 +335,7 @@ static struct regulator_ops pm8607_regulator_ops = {
.is_enabled = pm8607_is_enabled,
};
-#define PM8607_DVC(vreg, nbits, ureg, ubit, ereg, ebit) \
+#define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \
{ \
.desc = { \
.name = #vreg, \
@@ -344,10 +343,10 @@ static struct regulator_ops pm8607_regulator_ops = {
.type = REGULATOR_VOLTAGE, \
.id = PM8607_ID_##vreg, \
.owner = THIS_MODULE, \
+ .n_voltages = ARRAY_SIZE(vreg##_table), \
}, \
.vol_reg = PM8607_##vreg, \
.vol_shift = (0), \
- .vol_nbits = (nbits), \
.update_reg = PM8607_##ureg, \
.update_bit = (ubit), \
.enable_reg = PM8607_##ereg, \
@@ -357,7 +356,7 @@ static struct regulator_ops pm8607_regulator_ops = {
.vol_suspend = (unsigned int *)&vreg##_suspend_table, \
}
-#define PM8607_LDO(_id, vreg, shift, nbits, ereg, ebit) \
+#define PM8607_LDO(_id, vreg, shift, ereg, ebit) \
{ \
.desc = { \
.name = "LDO" #_id, \
@@ -365,10 +364,10 @@ static struct regulator_ops pm8607_regulator_ops = {
.type = REGULATOR_VOLTAGE, \
.id = PM8607_ID_LDO##_id, \
.owner = THIS_MODULE, \
+ .n_voltages = ARRAY_SIZE(LDO##_id##_table), \
}, \
.vol_reg = PM8607_##vreg, \
.vol_shift = (shift), \
- .vol_nbits = (nbits), \
.enable_reg = PM8607_##ereg, \
.enable_bit = (ebit), \
.slope_double = (0), \
@@ -377,23 +376,23 @@ static struct regulator_ops pm8607_regulator_ops = {
}
static struct pm8607_regulator_info pm8607_regulator_info[] = {
- PM8607_DVC(BUCK1, 6, GO, 0, SUPPLIES_EN11, 0),
- PM8607_DVC(BUCK2, 6, GO, 1, SUPPLIES_EN11, 1),
- PM8607_DVC(BUCK3, 6, GO, 2, SUPPLIES_EN11, 2),
-
- PM8607_LDO( 1, LDO1, 0, 2, SUPPLIES_EN11, 3),
- PM8607_LDO( 2, LDO2, 0, 3, SUPPLIES_EN11, 4),
- PM8607_LDO( 3, LDO3, 0, 3, SUPPLIES_EN11, 5),
- PM8607_LDO( 4, LDO4, 0, 3, SUPPLIES_EN11, 6),
- PM8607_LDO( 5, LDO5, 0, 2, SUPPLIES_EN11, 7),
- PM8607_LDO( 6, LDO6, 0, 3, SUPPLIES_EN12, 0),
- PM8607_LDO( 7, LDO7, 0, 3, SUPPLIES_EN12, 1),
- PM8607_LDO( 8, LDO8, 0, 3, SUPPLIES_EN12, 2),
- PM8607_LDO( 9, LDO9, 0, 3, SUPPLIES_EN12, 3),
- PM8607_LDO(10, LDO10, 0, 4, SUPPLIES_EN12, 4),
- PM8607_LDO(12, LDO12, 0, 4, SUPPLIES_EN12, 5),
- PM8607_LDO(13, VIBRATOR_SET, 1, 3, VIBRATOR_SET, 0),
- PM8607_LDO(14, LDO14, 0, 3, SUPPLIES_EN12, 6),
+ PM8607_DVC(BUCK1, GO, 0, SUPPLIES_EN11, 0),
+ PM8607_DVC(BUCK2, GO, 1, SUPPLIES_EN11, 1),
+ PM8607_DVC(BUCK3, GO, 2, SUPPLIES_EN11, 2),
+
+ PM8607_LDO(1, LDO1, 0, SUPPLIES_EN11, 3),
+ PM8607_LDO(2, LDO2, 0, SUPPLIES_EN11, 4),
+ PM8607_LDO(3, LDO3, 0, SUPPLIES_EN11, 5),
+ PM8607_LDO(4, LDO4, 0, SUPPLIES_EN11, 6),
+ PM8607_LDO(5, LDO5, 0, SUPPLIES_EN11, 7),
+ PM8607_LDO(6, LDO6, 0, SUPPLIES_EN12, 0),
+ PM8607_LDO(7, LDO7, 0, SUPPLIES_EN12, 1),
+ PM8607_LDO(8, LDO8, 0, SUPPLIES_EN12, 2),
+ PM8607_LDO(9, LDO9, 0, SUPPLIES_EN12, 3),
+ PM8607_LDO(10, LDO10, 0, SUPPLIES_EN12, 4),
+ PM8607_LDO(12, LDO12, 0, SUPPLIES_EN12, 5),
+ PM8607_LDO(13, VIBRATOR_SET, 1, VIBRATOR_SET, 0),
+ PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6),
};
static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] regulator: Convert 88pm8607 to set_voltage_sel
2012-03-28 6:58 [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Axel Lin
2012-03-28 6:59 ` [PATCH 2/4] regulator: Add missing n_voltages setting " Axel Lin
@ 2012-03-28 7:00 ` Axel Lin
2012-03-28 7:01 ` [PATCH 4/4] regulator: Convert 88pm8607 to get_voltage_sel Axel Lin
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2012-03-28 7:00 UTC (permalink / raw)
To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown, Jett.Zhou
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/88pm8607.c | 43 +++--------------------------------------
1 files changed, 4 insertions(+), 39 deletions(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 81b6659..7fafff2 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -223,51 +223,16 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
return ret;
}
-static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
-{
- struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
- int i, ret = -ENOENT;
-
- if (info->slope_double) {
- min_uV = min_uV >> 1;
- max_uV = max_uV >> 1;
- }
- if (info->vol_table) {
- for (i = 0; i < rdev->desc->n_voltages; i++) {
- if (!info->vol_table[i])
- break;
- if ((min_uV <= info->vol_table[i])
- && (max_uV >= info->vol_table[i])) {
- ret = i;
- break;
- }
- }
- }
- if (ret < 0)
- pr_err("invalid voltage range (%d %d) uV\n", min_uV, max_uV);
- return ret;
-}
-
-static int pm8607_set_voltage(struct regulator_dev *rdev,
- int min_uV, int max_uV, unsigned *selector)
+static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
{
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
uint8_t val, mask;
int ret;
- if (min_uV > max_uV) {
- pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
- return -EINVAL;
- }
-
- ret = choose_voltage(rdev, min_uV, max_uV);
- if (ret < 0)
- return -EINVAL;
- *selector = ret;
- val = (uint8_t)(ret << info->vol_shift);
+ val = (uint8_t)(selector << info->vol_shift);
mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
- ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, val);
+ ret = pm860x_set_bits(info->i2c, info->vol_reg, mask, selector);
if (ret)
return ret;
switch (info->desc.id) {
@@ -328,7 +293,7 @@ static int pm8607_is_enabled(struct regulator_dev *rdev)
static struct regulator_ops pm8607_regulator_ops = {
.list_voltage = pm8607_list_voltage,
- .set_voltage = pm8607_set_voltage,
+ .set_voltage_sel = pm8607_set_voltage_sel,
.get_voltage = pm8607_get_voltage,
.enable = pm8607_enable,
.disable = pm8607_disable,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] regulator: Convert 88pm8607 to get_voltage_sel
2012-03-28 6:58 [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Axel Lin
2012-03-28 6:59 ` [PATCH 2/4] regulator: Add missing n_voltages setting " Axel Lin
2012-03-28 7:00 ` [PATCH 3/4] regulator: Convert 88pm8607 to set_voltage_sel Axel Lin
@ 2012-03-28 7:01 ` Axel Lin
2012-03-29 2:39 ` [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Jett Zhou
2012-03-29 11:25 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2012-03-28 7:01 UTC (permalink / raw)
To: linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown, Jett.Zhou
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/88pm8607.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 7fafff2..11e5ddd 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -246,7 +246,7 @@ static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
return ret;
}
-static int pm8607_get_voltage(struct regulator_dev *rdev)
+static int pm8607_get_voltage_sel(struct regulator_dev *rdev)
{
struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
uint8_t val, mask;
@@ -259,7 +259,7 @@ static int pm8607_get_voltage(struct regulator_dev *rdev)
mask = (rdev->desc->n_voltages - 1) << info->vol_shift;
val = ((unsigned char)ret & mask) >> info->vol_shift;
- return pm8607_list_voltage(rdev, val);
+ return val;
}
static int pm8607_enable(struct regulator_dev *rdev)
@@ -294,7 +294,7 @@ static int pm8607_is_enabled(struct regulator_dev *rdev)
static struct regulator_ops pm8607_regulator_ops = {
.list_voltage = pm8607_list_voltage,
.set_voltage_sel = pm8607_set_voltage_sel,
- .get_voltage = pm8607_get_voltage,
+ .get_voltage_sel = pm8607_get_voltage_sel,
.enable = pm8607_enable,
.disable = pm8607_disable,
.is_enabled = pm8607_is_enabled,
--
1.7.5.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607
2012-03-28 6:58 [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Axel Lin
` (2 preceding siblings ...)
2012-03-28 7:01 ` [PATCH 4/4] regulator: Convert 88pm8607 to get_voltage_sel Axel Lin
@ 2012-03-29 2:39 ` Jett Zhou
2012-03-29 11:25 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Jett Zhou @ 2012-03-29 2:39 UTC (permalink / raw)
To: Axel Lin, linux-kernel; +Cc: Haojian Zhuang, Liam Girdwood, Mark Brown
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1221 bytes --]
Tested these patch by jett zhou, it works ok!
Thanks
-----Original Message-----
From: Axel Lin [mailto:axel.lin@gmail.com]
Sent: Wednesday, March 28, 2012 2:58 PM
To: linux-kernel@vger.kernel.org
Cc: Haojian Zhuang; Liam Girdwood; Mark Brown; Jett Zhou
Subject: [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607
Current code implements pm8607_list_voltage but does not set the list_voltage
callback function in pm8607_regulator_ops. Fix it.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/88pm8607.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index 28b81ae..981b47a 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -328,6 +328,7 @@ static int pm8607_is_enabled(struct regulator_dev *rdev)
}
static struct regulator_ops pm8607_regulator_ops = {
+ .list_voltage = pm8607_list_voltage,
.set_voltage = pm8607_set_voltage,
.get_voltage = pm8607_get_voltage,
.enable = pm8607_enable,
--
1.7.5.4
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607
2012-03-28 6:58 [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Axel Lin
` (3 preceding siblings ...)
2012-03-29 2:39 ` [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Jett Zhou
@ 2012-03-29 11:25 ` Mark Brown
4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2012-03-29 11:25 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Haojian Zhuang, Liam Girdwood, Jett.Zhou
[-- Attachment #1: Type: text/plain, Size: 213 bytes --]
On Wed, Mar 28, 2012 at 02:58:29PM +0800, Axel Lin wrote:
> Current code implements pm8607_list_voltage but does not set the list_voltage
> callback function in pm8607_regulator_ops. Fix it.
Applied all, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-29 11:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28 6:58 [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Axel Lin
2012-03-28 6:59 ` [PATCH 2/4] regulator: Add missing n_voltages setting " Axel Lin
2012-03-28 7:00 ` [PATCH 3/4] regulator: Convert 88pm8607 to set_voltage_sel Axel Lin
2012-03-28 7:01 ` [PATCH 4/4] regulator: Convert 88pm8607 to get_voltage_sel Axel Lin
2012-03-29 2:39 ` [PATCH 1/4] regulator: Set list_voltage callback for 88pm8607 Jett Zhou
2012-03-29 11:25 ` Mark Brown
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).