]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/arm/cpu/armv7/omap-common/timer.c
OMAP: Timer: Replace bss variable by gd
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / omap-common / timer.c
index 69e285ff1dd9b86e0a285f065c64562edf5cac00..9beebb1e7451d21fbd1c6ed3a142fd07667105ae 100644 (file)
 #include <common.h>
 #include <asm/io.h>
 
-static ulong timestamp;
-static ulong lastinc;
+DECLARE_GLOBAL_DATA_PTR;
+
 static struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE;
 
 /*
  * Nothing really to do with interrupts, just starts up a counter.
- * We run the counter with 13MHz, divided by 8, resulting in timer
- * frequency of 1.625MHz. With 32bit counter register, counter
- * overflows in ~44min
  */
 
-/* 13MHz / 8 = 1.625MHz */
 #define TIMER_CLOCK    (V_SCLK / (2 << CONFIG_SYS_PTV))
 #define TIMER_LOAD_VAL 0xffffffff
 
@@ -78,17 +74,12 @@ ulong get_timer(ulong base)
 
 void set_timer(ulong t)
 {
-       timestamp = t;
+       gd->tbl = t;
 }
 
 /* delay x useconds */
 void __udelay(unsigned long usec)
 {
-#if defined(CONFIG_OMAP44XX)
-       /* TODO temporary hack until OMAP4 clock setup routines are present */
-       if (usec > 1000)
-               usec = usec/1000;
-#endif
        long tmo = usec * (TIMER_CLOCK / 1000) / 1000;
        unsigned long now, last = readl(&timer_base->tcrr);
 
@@ -105,8 +96,8 @@ void __udelay(unsigned long usec)
 void reset_timer_masked(void)
 {
        /* reset time, capture current incrementer value time */
-       lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
-       timestamp = 0;          /* start "advancing" time stamp from 0 */
+       gd->lastinc = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
+       gd->tbl = 0;            /* start "advancing" time stamp from 0 */
 }
 
 ulong get_timer_masked(void)
@@ -114,14 +105,14 @@ ulong get_timer_masked(void)
        /* current tick value */
        ulong now = readl(&timer_base->tcrr) / (TIMER_CLOCK / CONFIG_SYS_HZ);
 
-       if (now >= lastinc)     /* normal mode (non roll) */
+       if (now >= gd->lastinc) /* normal mode (non roll) */
                /* move stamp fordward with absoulte diff ticks */
-               timestamp += (now - lastinc);
+               gd->tbl += (now - gd->lastinc);
        else    /* we have rollover of incrementer */
-               timestamp += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
-                               - lastinc) + now;
-       lastinc = now;
-       return timestamp;
+               gd->tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
+                            - gd->lastinc) + now;
+       gd->lastinc = now;
+       return gd->tbl;
 }
 
 /*