imx6: update 3.10 patches
[openwrt.git] / target / linux / imx6 / patches-3.10 / 0027-regulator-pfuze100-Simplify-pfuze100_set_ramp_delay-.patch
1 From: Axel Lin <axel.lin@ingics.com>
2 Subject: [PATCH] regulator: pfuze100: Simplify pfuze100_set_ramp_delay
3  implementation
4
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
12 equations.
13
14 Also use rdev->desc->vsel_reg instead of run-time calculate register address.
15
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>
19 ---
20  drivers/regulator/pfuze100-regulator.c | 21 +++++----------------
21  1 file changed, 5 insertions(+), 16 deletions(-)
22
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
26  {
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;
31         int ret;
32  
33         if (id < PFUZE100_SWBST) {
34 -               if (id == PFUZE100_SW1AB)
35 -                       reg = PFUZE100_SW1ABVOL;
36 -               else
37 -                       reg = PFUZE100_SW1CVOL + (id - PFUZE100_SW1C) * 7;
38 -               regmap_read(pfuze100->regmap, reg, &val);
39 -
40 -               if (id <= PFUZE100_SW1C)
41 -                       ramp_delay = 25000 / (2 * ramp_delay);
42 -               else if (val & 0x40)
43 -                       ramp_delay = 50000 / (4 * ramp_delay);
44 -               else
45 -                       ramp_delay = 25000 / (2 * ramp_delay);
46 -
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,
50 -                               ramp_bits << 6);
51 +               ret = regmap_update_bits(pfuze100->regmap,
52 +                                        rdev->desc->vsel_reg + 4,
53 +                                        0xc0, ramp_bits << 6);
54                 if (ret < 0)
55                         dev_err(pfuze100->dev, "ramp failed, err %d\n", ret);
56         } else