]> git.sur5r.net Git - u-boot/commitdiff
omap2420-h4: Fix get_timer() and CONFIG_SYS_HZ
authorHunter, Jon <jon-hunter@ti.com>
Wed, 3 Apr 2013 09:35:36 +0000 (09:35 +0000)
committerTom Rini <trini@ti.com>
Mon, 8 Apr 2013 15:29:05 +0000 (11:29 -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/arm1136/omap24xx/timer.c
include/configs/omap2420h4.h

index 53015cb77dc954016d6bbbec541d4d9c54d8cd02..3b6666b7914143d3c39d7b55bc7f090f9b66a389 100644 (file)
  */
 
 #include <common.h>
+#include <asm/io.h>
 #include <asm/arch/bits.h>
 #include <asm/arch/omap2420.h>
 
+#define TIMER_CLOCK    (CONFIG_SYS_CLK_FREQ / (2 << CONFIG_SYS_PTV))
 #define TIMER_LOAD_VAL 0
 
 /* macro to read the 32 bit timer */
-#define READ_TIMER (*((volatile ulong *)(CONFIG_SYS_TIMERBASE+TCRR)))
+#define READ_TIMER     readl(CONFIG_SYS_TIMERBASE+TCRR) \
+                       / (TIMER_CLOCK / CONFIG_SYS_HZ)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -99,7 +102,8 @@ ulong get_timer_masked (void)
                gd->arch.tbl += (now - gd->arch.lastinc);
        } else {
                /* we have rollover of incrementer */
-               gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now;
+               gd->arch.tbl += ((0xFFFFFFFF / (TIMER_CLOCK / CONFIG_SYS_HZ))
+                                - gd->arch.lastinc) + now;
        }
        gd->arch.lastinc = now;
        return gd->arch.tbl;
index e144ae9d28103c98000fb43b2949106613af052c..04e8d3ad513efe7f94b8c6cf917ccc2ad8020c94 100644 (file)
 
 #define CONFIG_SYS_TIMERBASE           OMAP2420_GPT2
 #define CONFIG_SYS_PTV                 V_PTV   /* 2^(PTV+1) */
-#define CONFIG_SYS_HZ                  ((CONFIG_SYS_CLK_FREQ)/(2 << CONFIG_SYS_PTV))
+#define CONFIG_SYS_HZ                  1000
 
 /*-----------------------------------------------------------------------
  * Physical Memory Map