Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: anatop: improve precision of delay time

For cpufreq example, it takes 13 steps (25 mV for one step) to increase
vddcore from 0.95 V to 1.275 V, and the time of 64 clock cycles at
24 MHz for one step is ~2.67 uS, so the total delay time would be
~34.71 uS. But the current calculation in the driver gives 39 uS.
Change the formula to have the addition of 1 be the last step, so that
we can get a more precise delay time. For example above, the new
formula will give 35 uS.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Shawn Guo and committed by
Mark Brown
ff1ce057 9ee417c0

+2 -2
+2 -2
drivers/regulator/anatop-regulator.c
··· 80 80 regmap_read(anatop_reg->anatop, anatop_reg->delay_reg, &val); 81 81 val = (val >> anatop_reg->delay_bit_shift) & 82 82 ((1 << anatop_reg->delay_bit_width) - 1); 83 - ret = (new_sel - old_sel) * ((LDO_RAMP_UP_UNIT_IN_CYCLES << 84 - val) / LDO_RAMP_UP_FREQ_IN_MHZ + 1); 83 + ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES << 84 + val) / LDO_RAMP_UP_FREQ_IN_MHZ + 1; 85 85 } 86 86 87 87 return ret;