aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-07-30 10:47:44 -0400
committerMark Brown <broonie@linaro.org>2013-07-31 12:53:46 -0400
commite56566699ca64ec44dd134ec5310a3585ffacfec (patch)
treedb37fc92b7e218247012e0e0960db548aa5086de
parentd9493234e20e8153495fa118b60bdff22fdfc6c8 (diff)
regulator: pfuze100: Simplify pfuze100_set_ramp_delay implementation
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> Reviewed-by: Robin Gong <b38343@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/pfuze100-regulator.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index e02d9b921ed3..bda55617092b 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)
93{ 93{
94 struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev); 94 struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev);
95 int id = rdev->desc->id; 95 int id = rdev->desc->id;
96 unsigned int val, ramp_bits, reg; 96 unsigned int ramp_bits;
97 int ret; 97 int ret;
98 98
99 if (id < PFUZE100_SWBST) { 99 if (id < PFUZE100_SWBST) {
100 if (id == PFUZE100_SW1AB) 100 ramp_delay = 12500 / ramp_delay;
101 reg = PFUZE100_SW1ABVOL;
102 else
103 reg = PFUZE100_SW1CVOL + (id - PFUZE100_SW1C) * 7;
104 regmap_read(pfuze100->regmap, reg, &val);
105
106 if (id <= PFUZE100_SW1C)
107 ramp_delay = 25000 / (2 * ramp_delay);
108 else if (val & 0x40)
109 ramp_delay = 50000 / (4 * ramp_delay);
110 else
111 ramp_delay = 25000 / (2 * ramp_delay);
112
113 ramp_bits = (ramp_delay >> 1) - (ramp_delay >> 3); 101 ramp_bits = (ramp_delay >> 1) - (ramp_delay >> 3);
114 ret = regmap_update_bits(pfuze100->regmap, reg + 4 , 0xc0, 102 ret = regmap_update_bits(pfuze100->regmap,
115 ramp_bits << 6); 103 rdev->desc->vsel_reg + 4,
104 0xc0, ramp_bits << 6);
116 if (ret < 0) 105 if (ret < 0)
117 dev_err(pfuze100->dev, "ramp failed, err %d\n", ret); 106 dev_err(pfuze100->dev, "ramp failed, err %d\n", ret);
118 } else 107 } else