Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH 4/8] OMAP2: fix ref timer time counter bug



From: Andy Shevchenko <andy.shevchenko%teleca.com@localhost>

The OMAP2 ref timer providing a base for generic timecounting was
configured to reload at HZ similarly to the clock providing the
tick interrupt at HZ. This and the fact that the tc framework
expected a full 32 bit counter range resulted in time running
~40 times faster than normal.

Configure the ref timer as a full range counter to fix this.
---
 sys/arch/arm/omap/omap2430_mputmr.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/sys/arch/arm/omap/omap2430_mputmr.c 
b/sys/arch/arm/omap/omap2430_mputmr.c
index d2a91cd..3b08f87 100644
--- a/sys/arch/arm/omap/omap2430_mputmr.c
+++ b/sys/arch/arm/omap/omap2430_mputmr.c
@@ -237,7 +237,7 @@ cpu_initclocks(void)
 
        setclockrate(clock_sc, hz);
        setclockrate(stat_sc, stathz);
-       setclockrate(ref_sc, hz);
+       setclockrate(ref_sc, 0);
 
 
        /*
@@ -301,6 +301,16 @@ calc_timer_factors(int ints_per_sec, timer_factors *tf)
        uint32_t count_freq;
        static const uint32_t us_per_sec = 1000000;
        
+       if (ints_per_sec == 0) {
+               /*
+                * When ints_per_sec equal to zero there is mean full range
+                * timer usage. Nevertheless autoreload mode is still enabled.
+                */
+               tf->ptv = 0;
+               tf->reload = 0;
+               tf->counts_per_usec = OMAP_MPU_TIMER_CLOCK_FREQ / us_per_sec;
+               return;
+       }
 
        tf->ptv = 8;
        for (;;) {
-- 
1.5.6.56.g29b0d



Home | Main Index | Thread Index | Old Index