]> git.baikalelectronics.ru Git - kernel.git/commit
ARM: OMAP3+: PM: VP: fix integer truncation error
authorYuan Jiangli <jlyuan@motorola.com>
Tue, 6 Mar 2012 18:51:12 +0000 (12:51 -0600)
committerTony Lindgren <tony@atomide.com>
Wed, 7 Mar 2012 00:13:50 +0000 (16:13 -0800)
commitf7c7217be4c6e48162447d4534be253ad014d41c
treeded5e0942403e6ef09787a2fbbe319896ec2e2bc
parent7d44081bfe504a40bef45e0c2d4641c0de9d2beb
ARM: OMAP3+: PM: VP: fix integer truncation error

commit d10c9fdfbff3c90cd7cd0496f5e60035f9e57e27
(OMAP3: PM: Adding voltage driver support.)
introduced runtime computation of waittime to handle all potential
sys clocks available.

In the voltage processor, the SPMSUpdateWait is calculated based on
the slew rate and the voltage step (SMPSUpdateWait = slew rate *
Voltage Step). After the voltage processor receives the SMPS_Ack
signal, the Voltage Controller will wait for SMPSUpdateWait clock
cycles for the voltage to settle to the new value. For all
practical purposes, the waittime parameter is the OMAP hardware
translation of what the slew rate on the PMIC is.

As an example, with TPS62361 on OMAP4460,
step_size = 10000
slew_rate = 32000
sys_clk_rate = 38400

Our current computation results in the following:
 = ((step_size / slew_rate) * sys_clk_rate) / 1000
 = ((10000 / 32000) * 38400 / 1000
 = 0

Fix the same using DIV_ROUND_UP as an extra wait clock cycle
is better than lesser clock cycle. For the above example, this
translates to:
 = (10000 * 38400) / (1000 * 32000)
 = 12

Acked-by: Jon Hunter <jon-hunter@ti.com>
[nm@ti.com: slightly better implementation]
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Yuan Jiangli <jlyuan@motorola.com>
Acked-by: Kevin Hilman <khilman@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/vp.c