1 From: Axel Lin <axel.lin@ingics.com>
2 Subject: [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay
5 Simplify the equation to calculate ramp_delay.
6 Below equations are equivalent:
7 ramp_delay = 25000 / (2 * ramp_delay);
8 ramp_delay = 50000 / (4 * ramp_delay);
9 ramp_delay = 25000 / (2 * ramp_delay);
10 ramp_delay = 12500 / ramp_delay;
11 So we don't need to read BIT6 of rdev->desc->vsel_reg for applying different
14 Also use rdev->desc->vsel_reg instead of run-time calculate register address.
16 Signed-off-by: Axel Lin <axel.lin@ingics.com>
17 Reviewed-by: Robin Gong <b38343@freescale.com>
18 Signed-off-by: Mark Brown <broonie@linaro.org>
20 drivers/regulator/pfuze100-regulator.c | 21 +++++----------------
21 1 file changed, 5 insertions(+), 16 deletions(-)
23 --- a/drivers/regulator/pfuze100-regulator.c
24 +++ b/drivers/regulator/pfuze100-regulator.c
25 @@ -93,26 +93,15 @@ static int pfuze100_set_ramp_delay(struc
27 struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev);
28 int id = rdev->desc->id;
29 - unsigned int val, ramp_bits, reg;
30 + unsigned int ramp_bits;
33 if (id < PFUZE100_SWBST) {
34 - if (id == PFUZE100_SW1AB)
35 - reg = PFUZE100_SW1ABVOL;
37 - reg = PFUZE100_SW1CVOL + (id - PFUZE100_SW1C) * 7;
38 - regmap_read(pfuze100->regmap, reg, &val);
40 - if (id <= PFUZE100_SW1C)
41 - ramp_delay = 25000 / (2 * ramp_delay);
42 - else if (val & 0x40)
43 - ramp_delay = 50000 / (4 * ramp_delay);
45 - ramp_delay = 25000 / (2 * ramp_delay);
47 + ramp_delay = 12500 / ramp_delay;
48 ramp_bits = (ramp_delay >> 1) - (ramp_delay >> 3);
49 - ret = regmap_update_bits(pfuze100->regmap, reg + 4 , 0xc0,
51 + ret = regmap_update_bits(pfuze100->regmap,
52 + rdev->desc->vsel_reg + 4,
53 + 0xc0, ramp_bits << 6);
55 dev_err(pfuze100->dev, "ramp failed, err %d\n", ret);