* [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay implementation
@ 2013-07-30 14:47 Axel Lin
2013-07-31 15:47 ` Robin Gong
2013-07-31 16:53 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2013-07-30 14:47 UTC (permalink / raw)
To: Mark Brown; +Cc: Robin Gong, Liam Girdwood, linux-kernel
Simplify the equation to calculate ramp_delay.
Below equations are equivalent:
ramp_delay = 25000 / (2 * ramp_delay);
ramp_delay = 50000 / (4 * ramp_delay);
ramp_delay = 25000 / (2 * ramp_delay);
ramp_delay = 12500 / ramp_delay;
So we don't need to read BIT6 of rdev->desc->vsel_reg for applying different
equations.
Also use rdev->desc->vsel_reg instead of run-time calculate register address.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/pfuze100-regulator.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index e02d9b9..bda5561 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -93,26 +93,15 @@ static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
{
struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev);
int id = rdev->desc->id;
- unsigned int val, ramp_bits, reg;
+ unsigned int ramp_bits;
int ret;
if (id < PFUZE100_SWBST) {
- if (id == PFUZE100_SW1AB)
- reg = PFUZE100_SW1ABVOL;
- else
- reg = PFUZE100_SW1CVOL + (id - PFUZE100_SW1C) * 7;
- regmap_read(pfuze100->regmap, reg, &val);
-
- if (id <= PFUZE100_SW1C)
- ramp_delay = 25000 / (2 * ramp_delay);
- else if (val & 0x40)
- ramp_delay = 50000 / (4 * ramp_delay);
- else
- ramp_delay = 25000 / (2 * ramp_delay);
-
+ ramp_delay = 12500 / ramp_delay;
ramp_bits = (ramp_delay >> 1) - (ramp_delay >> 3);
- ret = regmap_update_bits(pfuze100->regmap, reg + 4 , 0xc0,
- ramp_bits << 6);
+ ret = regmap_update_bits(pfuze100->regmap,
+ rdev->desc->vsel_reg + 4,
+ 0xc0, ramp_bits << 6);
if (ret < 0)
dev_err(pfuze100->dev, "ramp failed, err %d\n", ret);
} else
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay implementation
2013-07-30 14:47 [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay implementation Axel Lin
@ 2013-07-31 15:47 ` Robin Gong
2013-07-31 16:53 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Robin Gong @ 2013-07-31 15:47 UTC (permalink / raw)
To: Axel Lin; +Cc: Mark Brown, Liam Girdwood, linux-kernel
>From software view this patch looks better, although original code match better
with the data sheet. Thanks Axel.
Reviewed-by: Robin Gong <b38343@freescale.com>
Thanks.
On Tue, Jul 30, 2013 at 10:47:44PM +0800, Axel Lin wrote:
> Simplify the equation to calculate ramp_delay.
> Below equations are equivalent:
> ramp_delay = 25000 / (2 * ramp_delay);
> ramp_delay = 50000 / (4 * ramp_delay);
> ramp_delay = 25000 / (2 * ramp_delay);
> ramp_delay = 12500 / ramp_delay;
> So we don't need to read BIT6 of rdev->desc->vsel_reg for applying different
> equations.
>
> Also use rdev->desc->vsel_reg instead of run-time calculate register address.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/regulator/pfuze100-regulator.c | 21 +++++----------------
> 1 file changed, 5 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
> index e02d9b9..bda5561 100644
> --- a/drivers/regulator/pfuze100-regulator.c
> +++ b/drivers/regulator/pfuze100-regulator.c
> @@ -93,26 +93,15 @@ static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
> {
> struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev);
> int id = rdev->desc->id;
> - unsigned int val, ramp_bits, reg;
> + unsigned int ramp_bits;
> int ret;
>
> if (id < PFUZE100_SWBST) {
> - if (id == PFUZE100_SW1AB)
> - reg = PFUZE100_SW1ABVOL;
> - else
> - reg = PFUZE100_SW1CVOL + (id - PFUZE100_SW1C) * 7;
> - regmap_read(pfuze100->regmap, reg, &val);
> -
> - if (id <= PFUZE100_SW1C)
> - ramp_delay = 25000 / (2 * ramp_delay);
> - else if (val & 0x40)
> - ramp_delay = 50000 / (4 * ramp_delay);
> - else
> - ramp_delay = 25000 / (2 * ramp_delay);
> -
> + ramp_delay = 12500 / ramp_delay;
> ramp_bits = (ramp_delay >> 1) - (ramp_delay >> 3);
> - ret = regmap_update_bits(pfuze100->regmap, reg + 4 , 0xc0,
> - ramp_bits << 6);
> + ret = regmap_update_bits(pfuze100->regmap,
> + rdev->desc->vsel_reg + 4,
> + 0xc0, ramp_bits << 6);
> if (ret < 0)
> dev_err(pfuze100->dev, "ramp failed, err %d\n", ret);
> } else
> --
> 1.8.1.2
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay implementation
2013-07-30 14:47 [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay implementation Axel Lin
2013-07-31 15:47 ` Robin Gong
@ 2013-07-31 16:53 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-07-31 16:53 UTC (permalink / raw)
To: Axel Lin; +Cc: Robin Gong, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 159 bytes --]
On Tue, Jul 30, 2013 at 10:47:44PM +0800, Axel Lin wrote:
> Simplify the equation to calculate ramp_delay.
> Below equations are equivalent:
Applied, 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:[~2013-07-31 16:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-30 14:47 [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay implementation Axel Lin
2013-07-31 15:47 ` Robin Gong
2013-07-31 16:53 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox