[RFC] regulator: anatop-regulator: Also provide a delay when voltage decreases

From: Fabio Estevam
Date: Fri Dec 20 2013 - 09:48:40 EST


From: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx>

Currently we only wait for a delay for the LDO voltages to settle when it goes
from a lower voltage to a higher one.

Also provide the delay when the opposite transition happens.

Signed-off-by: Fabio Estevam <fabio.estevam@xxxxxxxxxxxxx>
---
Hi Anson/Shawn,

I could not find in the reference manual anywhere that says that the delay
should de done only when the voltage increases.


drivers/regulator/anatop-regulator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index 7d7c05e..843c5d1 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -70,7 +70,7 @@ static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg,
int ret = 0;

/* check whether need to care about LDO ramp up speed */
- if (anatop_reg->delay_bit_width && new_sel > old_sel) {
+ if (anatop_reg->delay_bit_width) {
/*
* the delay for LDO ramp up time is
* based on the register setting, we need
@@ -80,7 +80,7 @@ static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg,
regmap_read(anatop_reg->anatop, anatop_reg->delay_reg, &val);
val = (val >> anatop_reg->delay_bit_shift) &
((1 << anatop_reg->delay_bit_width) - 1);
- ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES <<
+ ret = abs(new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES <<
val) / LDO_RAMP_UP_FREQ_IN_MHZ + 1;
}

--
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/