Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] OMAP3+: PM: VP: fix integer truncation error
@ 2012-03-06 18:32 Nishanth Menon
  2012-03-06 18:36 ` Shilimkar, Santosh
  0 siblings, 1 reply; 3+ messages in thread
From: Nishanth Menon @ 2012-03-06 18:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Yuan Jiangli <jlyuan@motorola.com>

commit 2f34ce81b8c05c900e45bd88595cc154f7bb5957
(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

Change-Id: I0ee22e60555e1cfd6cc3dea7ee44d0584ce182b6
Acked-by: Jon Hunter <jon-hunter@ti.com>
[nm at ti.com: slightly better implementation]
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Yuan Jiangli <jlyuan@motorola.com>
---
 arch/arm/mach-omap2/vp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 0df8882..f95c1ba 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -61,8 +61,8 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
 	vddmin = voltdm->pmic->vp_vddmin;
 	vddmax = voltdm->pmic->vp_vddmax;
 
-	waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) *
-		    sys_clk_rate) / 1000;
+	waittime = DIV_ROUND_UP(voltdm->pmic->step_size * sys_clk_rate,
+				1000 * voltdm->pmic->slew_rate);
 	vstepmin = voltdm->pmic->vp_vstepmin;
 	vstepmax = voltdm->pmic->vp_vstepmax;
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] OMAP3+: PM: VP: fix integer truncation error
  2012-03-06 18:32 [PATCH] OMAP3+: PM: VP: fix integer truncation error Nishanth Menon
@ 2012-03-06 18:36 ` Shilimkar, Santosh
  2012-03-06 18:50   ` Menon, Nishanth
  0 siblings, 1 reply; 3+ messages in thread
From: Shilimkar, Santosh @ 2012-03-06 18:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 6, 2012 at 7:32 PM, Nishanth Menon <nm@ti.com> wrote:
> From: Yuan Jiangli <jlyuan@motorola.com>
>
> commit 2f34ce81b8c05c900e45bd88595cc154f7bb5957
> (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
>
> Change-Id: I0ee22e60555e1cfd6cc3dea7ee44d0584ce182b6
You don't need above gerrit change id in commit message.

Regardas
Santosh

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] OMAP3+: PM: VP: fix integer truncation error
  2012-03-06 18:36 ` Shilimkar, Santosh
@ 2012-03-06 18:50   ` Menon, Nishanth
  0 siblings, 0 replies; 3+ messages in thread
From: Menon, Nishanth @ 2012-03-06 18:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Mar 6, 2012 at 12:36, Shilimkar, Santosh
<santosh.shilimkar@ti.com> wrote:
> > Change-Id: I0ee22e60555e1cfd6cc3dea7ee44d0584ce182b6
> You don't need above gerrit change id in commit message.
yow.. thanks for catching it, my bad.. thought i fixed it..
Regards,

Nishanth Menon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-06 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-06 18:32 [PATCH] OMAP3+: PM: VP: fix integer truncation error Nishanth Menon
2012-03-06 18:36 ` Shilimkar, Santosh
2012-03-06 18:50   ` Menon, Nishanth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox