* [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info
@ 2012-04-05 6:04 Axel Lin
2012-04-05 6:07 ` [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage Axel Lin
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Axel Lin @ 2012-04-05 6:04 UTC (permalink / raw)
To: linux-kernel; +Cc: Laxman Dewangan, Liam Girdwood, Mark Brown
The nsteps can be calculated by (_max_mv - _min_mv) * 1000 / _step_uV + 1,
thus we can remove _nsteps from RC5T583_REG macro, and then remove
nsteps from struct rc5t583_regulator_info.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/rc5t583-regulator.c | 37 +++++++++++++++-----------------
1 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index dc9ebb9..578bd5d 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -49,7 +49,6 @@ struct rc5t583_regulator_info {
int min_uV;
int max_uV;
int step_uV;
- int nsteps;
/* Regulator specific turn-on delay and voltage settling time*/
int enable_uv_per_us;
@@ -131,7 +130,7 @@ static int rc5t583_set_voltage_sel(struct regulator_dev *rdev,
struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
struct rc5t583_regulator_info *ri = reg->reg_info;
int ret;
- if (selector >= ri->nsteps) {
+ if (selector >= rdev->desc->n_voltages) {
dev_err(&rdev->dev, "Invalid selector 0x%02x\n", selector);
return -EINVAL;
}
@@ -198,8 +197,7 @@ static struct regulator_ops rc5t583_ops = {
};
#define RC5T583_REG(_id, _en_reg, _en_bit, _disc_reg, _disc_bit, _vout_reg, \
- _vout_mask, _ds_reg, _min_mv, _max_mv, _step_uV, _nsteps, \
- _enable_mv) \
+ _vout_mask, _ds_reg, _min_mv, _max_mv, _step_uV, _enable_mv) \
{ \
.reg_en_reg = RC5T583_REG_##_en_reg, \
.en_bit = _en_bit, \
@@ -211,14 +209,13 @@ static struct regulator_ops rc5t583_ops = {
.min_uV = _min_mv * 1000, \
.max_uV = _max_mv * 1000, \
.step_uV = _step_uV, \
- .nsteps = _nsteps, \
.enable_uv_per_us = _enable_mv * 1000, \
.change_uv_per_us = 40 * 1000, \
.deepsleep_id = RC5T583_DS_##_id, \
.desc = { \
.name = "rc5t583-regulator-"#_id, \
.id = RC5T583_REGULATOR_##_id, \
- .n_voltages = _nsteps, \
+ .n_voltages = (_max_mv - _min_mv) * 1000 / _step_uV + 1, \
.ops = &rc5t583_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
@@ -227,33 +224,33 @@ static struct regulator_ops rc5t583_ops = {
static struct rc5t583_regulator_info rc5t583_reg_info[RC5T583_REGULATOR_MAX] = {
RC5T583_REG(DC0, DC0CTL, 0, DC0CTL, 1, DC0DAC, 0x7F, DC0DAC_DS,
- 700, 1500, 12500, 0x41, 4),
+ 700, 1500, 12500, 4),
RC5T583_REG(DC1, DC1CTL, 0, DC1CTL, 1, DC1DAC, 0x7F, DC1DAC_DS,
- 700, 1500, 12500, 0x41, 14),
+ 700, 1500, 12500, 14),
RC5T583_REG(DC2, DC2CTL, 0, DC2CTL, 1, DC2DAC, 0x7F, DC2DAC_DS,
- 900, 2400, 12500, 0x79, 14),
+ 900, 2400, 12500, 14),
RC5T583_REG(DC3, DC3CTL, 0, DC3CTL, 1, DC3DAC, 0x7F, DC3DAC_DS,
- 900, 2400, 12500, 0x79, 14),
+ 900, 2400, 12500, 14),
RC5T583_REG(LDO0, LDOEN2, 0, LDODIS2, 0, LDO0DAC, 0x7F, LDO0DAC_DS,
- 900, 3400, 25000, 0x65, 160),
+ 900, 3400, 25000, 160),
RC5T583_REG(LDO1, LDOEN2, 1, LDODIS2, 1, LDO1DAC, 0x7F, LDO1DAC_DS,
- 900, 3400, 25000, 0x65, 160),
+ 900, 3400, 25000, 160),
RC5T583_REG(LDO2, LDOEN2, 2, LDODIS2, 2, LDO2DAC, 0x7F, LDO2DAC_DS,
- 900, 3400, 25000, 0x65, 160),
+ 900, 3400, 25000, 160),
RC5T583_REG(LDO3, LDOEN2, 3, LDODIS2, 3, LDO3DAC, 0x7F, LDO3DAC_DS,
- 900, 3400, 25000, 0x65, 160),
+ 900, 3400, 25000, 160),
RC5T583_REG(LDO4, LDOEN2, 4, LDODIS2, 4, LDO4DAC, 0x3F, LDO4DAC_DS,
- 750, 1500, 12500, 0x3D, 133),
+ 750, 1500, 12500, 133),
RC5T583_REG(LDO5, LDOEN2, 5, LDODIS2, 5, LDO5DAC, 0x7F, LDO5DAC_DS,
- 900, 3400, 25000, 0x65, 267),
+ 900, 3400, 25000, 267),
RC5T583_REG(LDO6, LDOEN2, 6, LDODIS2, 6, LDO6DAC, 0x7F, LDO6DAC_DS,
- 900, 3400, 25000, 0x65, 133),
+ 900, 3400, 25000, 133),
RC5T583_REG(LDO7, LDOEN2, 7, LDODIS2, 7, LDO7DAC, 0x7F, LDO7DAC_DS,
- 900, 3400, 25000, 0x65, 233),
+ 900, 3400, 25000, 233),
RC5T583_REG(LDO8, LDOEN1, 0, LDODIS1, 0, LDO8DAC, 0x7F, LDO8DAC_DS,
- 900, 3400, 25000, 0x65, 233),
+ 900, 3400, 25000, 233),
RC5T583_REG(LDO9, LDOEN1, 1, LDODIS1, 1, LDO9DAC, 0x7F, LDO9DAC_DS,
- 900, 3400, 25000, 0x65, 133),
+ 900, 3400, 25000, 133),
};
static int __devinit rc5t583_regulator_probe(struct platform_device *pdev)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage
2012-04-05 6:04 [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info Axel Lin
@ 2012-04-05 6:07 ` Axel Lin
2012-04-05 7:01 ` Laxman Dewangan
2012-04-06 17:32 ` Mark Brown
2012-04-05 6:58 ` [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info Laxman Dewangan
2012-04-05 10:07 ` Mark Brown
2 siblings, 2 replies; 7+ messages in thread
From: Axel Lin @ 2012-04-05 6:07 UTC (permalink / raw)
To: linux-kernel; +Cc: Laxman Dewangan, Liam Girdwood, Mark Brown
Not every regulator driver should implement set_voltage_sel callback.
See commit e8eef82
"regulator: Provide a selector based set_voltage_sel() operation".
For rc5t583, the regulator voltage can be mapped onto selector values with a
simple calculation, thus implement set_voltage is better than set_voltage_sel.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
This patch also needs below patch to properly work.
https://lkml.org/lkml/2012/4/3/430
drivers/regulator/rc5t583-regulator.c | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index 578bd5d..43c8410 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -124,19 +124,26 @@ static int rc5t583_list_voltage(struct regulator_dev *rdev, unsigned selector)
return ri->min_uV + (ri->step_uV * selector);
}
-static int rc5t583_set_voltage_sel(struct regulator_dev *rdev,
- unsigned int selector)
+static int rc5t583_set_voltage(struct regulator_dev *rdev,
+ int min_uV, int max_uV, unsigned *selector)
{
struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
struct rc5t583_regulator_info *ri = reg->reg_info;
- int ret;
- if (selector >= rdev->desc->n_voltages) {
- dev_err(&rdev->dev, "Invalid selector 0x%02x\n", selector);
+ int sel, ret;
+
+ if (min_uV < ri->min_uV)
+ min_uV = ri->min_uV;
+
+ sel = DIV_ROUND_UP(min_uV - ri->min_uV, ri->step_uV);
+
+ if (sel >= rdev->desc->n_voltages) {
+ dev_err(&rdev->dev, "Invalid selector 0x%02x\n", sel);
return -EINVAL;
}
- ret = rc5t583_update(reg->mfd->dev, ri->vout_reg,
- selector, ri->vout_mask);
+ *selector = sel;
+
+ ret = rc5t583_update(reg->mfd->dev, ri->vout_reg, sel, ri->vout_mask);
if (ret < 0)
dev_err(&rdev->dev,
"Error in update voltage register 0x%02x\n", ri->vout_reg);
@@ -191,7 +198,7 @@ static struct regulator_ops rc5t583_ops = {
.disable = rc5t583_reg_disable,
.enable_time = rc5t583_regulator_enable_time,
.get_voltage_sel = rc5t583_get_voltage_sel,
- .set_voltage_sel = rc5t583_set_voltage_sel,
+ .set_voltage = rc5t583_set_voltage,
.list_voltage = rc5t583_list_voltage,
.set_voltage_time_sel = rc5t583_set_voltage_time_sel,
};
--
1.7.5.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info
2012-04-05 6:04 [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info Axel Lin
2012-04-05 6:07 ` [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage Axel Lin
@ 2012-04-05 6:58 ` Laxman Dewangan
2012-04-05 10:07 ` Mark Brown
2 siblings, 0 replies; 7+ messages in thread
From: Laxman Dewangan @ 2012-04-05 6:58 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown
On Thursday 05 April 2012 11:34 AM, Axel Lin wrote:
> The nsteps can be calculated by (_max_mv - _min_mv) * 1000 / _step_uV + 1,
> thus we can remove _nsteps from RC5T583_REG macro, and then remove
> nsteps from struct rc5t583_regulator_info.
>
> Signed-off-by: Axel Lin<axel.lin@gmail.com>
> ---
Acked-by: Laxman Dewangan <ldewangan@nvidia.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage
2012-04-05 6:07 ` [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage Axel Lin
@ 2012-04-05 7:01 ` Laxman Dewangan
2012-04-05 9:47 ` Mark Brown
2012-04-06 17:32 ` Mark Brown
1 sibling, 1 reply; 7+ messages in thread
From: Laxman Dewangan @ 2012-04-05 7:01 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, Mark Brown
On Thursday 05 April 2012 11:37 AM, Axel Lin wrote:
> Not every regulator driver should implement set_voltage_sel callback.
> See commit e8eef82
> "regulator: Provide a selector based set_voltage_sel() operation".
>
> For rc5t583, the regulator voltage can be mapped onto selector values with a
> simple calculation, thus implement set_voltage is better than set_voltage_sel.
>
> Signed-off-by: Axel Lin<axel.lin@gmail.com>
> ---
I wanted to provide the settling delay whenever voltage output get
change as per datasheet. In place of having this delay in the driver, I
wanted to use implementation of core and for this I need to implement
set_voltage_sel() not set_voltage().
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage
2012-04-05 7:01 ` Laxman Dewangan
@ 2012-04-05 9:47 ` Mark Brown
0 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2012-04-05 9:47 UTC (permalink / raw)
To: Laxman Dewangan; +Cc: Axel Lin, linux-kernel, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 489 bytes --]
On Thu, Apr 05, 2012 at 12:31:44PM +0530, Laxman Dewangan wrote:
> I wanted to provide the settling delay whenever voltage output get
> change as per datasheet. In place of having this delay in the
> driver, I wanted to use implementation of core and for this I need
> to implement set_voltage_sel() not set_voltage().
The correct thing to do here is to make the core able to do this with
set_voltage, which conveniently enough Axel sent a patch for yesterday
that I've not reviwed yet.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info
2012-04-05 6:04 [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info Axel Lin
2012-04-05 6:07 ` [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage Axel Lin
2012-04-05 6:58 ` [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info Laxman Dewangan
@ 2012-04-05 10:07 ` Mark Brown
2 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2012-04-05 10:07 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Laxman Dewangan, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 267 bytes --]
On Thu, Apr 05, 2012 at 02:04:48PM +0800, Axel Lin wrote:
> The nsteps can be calculated by (_max_mv - _min_mv) * 1000 / _step_uV + 1,
> thus we can remove _nsteps from RC5T583_REG macro, and then remove
> nsteps from struct rc5t583_regulator_info.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage
2012-04-05 6:07 ` [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage Axel Lin
2012-04-05 7:01 ` Laxman Dewangan
@ 2012-04-06 17:32 ` Mark Brown
1 sibling, 0 replies; 7+ messages in thread
From: Mark Brown @ 2012-04-06 17:32 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Laxman Dewangan, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
On Thu, Apr 05, 2012 at 02:07:36PM +0800, Axel Lin wrote:
> Not every regulator driver should implement set_voltage_sel callback.
> See commit e8eef82
> "regulator: Provide a selector based set_voltage_sel() operation".
>
> For rc5t583, the regulator voltage can be mapped onto selector values with a
> simple calculation, thus implement set_voltage is better than set_voltage_sel.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-04-06 17:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-05 6:04 [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info Axel Lin
2012-04-05 6:07 ` [PATCH RFT 2/2] regulator: Convert rc5t583 to set_voltage Axel Lin
2012-04-05 7:01 ` Laxman Dewangan
2012-04-05 9:47 ` Mark Brown
2012-04-06 17:32 ` Mark Brown
2012-04-05 6:58 ` [PATCH 1/2] regulator: rc5t583: Remove nsteps from struct rc5t583_regulator_info Laxman Dewangan
2012-04-05 10:07 ` 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).