]> git.sur5r.net Git - u-boot/commitdiff
omap5912-osk: Fix get_timer() and CONFIG_SYS_HZ
authorJon Hunter <jon-hunter@ti.com>
Tue, 9 Apr 2013 21:41:33 +0000 (16:41 -0500)
committerTom Rini <trini@ti.com>
Wed, 10 Apr 2013 20:03:02 +0000 (16:03 -0400)
The function get_timer() should return time in ms and CONFIG_SYS_HZ
should be set to 1000 by default. Fix both of these items.

Signed-off-by: Jon Hunter <jon-hunter@ti.com>
arch/arm/cpu/arm926ejs/omap/timer.c
include/configs/omap5912osk.h

index 34ec7b2b1ccc6f6a7b24dcb7378978f07c250399..16530b03b8986e1e9160abe51c53427bcdb80b8e 100644 (file)
  */
 
 #include <common.h>
+#include <asm/io.h>
 
-#define TIMER_LOAD_VAL 0xffffffff
+#define TIMER_CLOCK    (CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV))
+#define TIMER_LOAD_VAL 0xffffffff
 
 /* macro to read the 32 bit timer */
-#define READ_TIMER (*(volatile ulong *)(CONFIG_SYS_TIMERBASE+8))
+#define READ_TIMER     readl(CONFIG_SYS_TIMERBASE+8) \
+                       / (TIMER_CLOCK / CONFIG_SYS_HZ)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -114,7 +117,8 @@ ulong get_timer_masked (void)
                 * (TLV-now) amount of time after passing though -1
                 * nts = new "advancing time stamp"...it could also roll and cause problems.
                 */
-               timestamp += lastdec + TIMER_LOAD_VAL - now;
+               timestamp += lastdec + (TIMER_LOAD_VAL / (TIMER_CLOCK /
+                                       CONFIG_SYS_HZ)) - now;
        }
        lastdec = now;
 
@@ -160,8 +164,5 @@ unsigned long long get_ticks(void)
  */
 ulong get_tbclk (void)
 {
-       ulong tbclk;
-
-       tbclk = CONFIG_SYS_HZ;
-       return tbclk;
+       return CONFIG_SYS_HZ;
 }
index 3276a5070a76057506ea03097f648438ef34f59c..c5797a238fa98363d9c950d9eab5c47d0987ae16 100644 (file)
  */
 #define CONFIG_SYS_TIMERBASE   0xFFFEC500      /* use timer 1 */
 #define CONFIG_SYS_PTV         7       /* 2^(PTV+1), divide by 256 */
-#define CONFIG_SYS_HZ          ((CONFIG_SYS_CLK_FREQ)/(2 << CONFIG_SYS_PTV))
+#define CONFIG_SYS_HZ          1000
 
 /*-----------------------------------------------------------------------
  * Physical Memory Map