]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/cpu/arm1136/omap24xx/timer.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[u-boot] / arch / arm / cpu / arm1136 / omap24xx / timer.c
index 73bf4a7b4c2fe51bbd72cfd4d6a73b0c00e3ef76..53015cb77dc954016d6bbbec541d4d9c54d8cd02 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static void reset_timer_masked (void)
-{
-       /* reset time */
-       gd->lastinc = READ_TIMER;       /* capture current incrementer value time */
-       gd->tbl = 0;                    /* start "advancing" time stamp from 0 */
-}
-
 int timer_init (void)
 {
        int32_t val;
@@ -57,7 +50,9 @@ int timer_init (void)
        val = (CONFIG_SYS_PTV << 2) | BIT5 | BIT1 | BIT0;               /* mask to enable timer*/
        *((int32_t *) (CONFIG_SYS_TIMERBASE + TCLR)) = val;     /* start timer */
 
-       reset_timer_masked(); /* init the timestamp and lastinc value */
+       /* reset time */
+       gd->arch.lastinc = READ_TIMER;  /* capture current incrementer value */
+       gd->arch.tbl = 0;               /* start "advancing" time stamp */
 
        return(0);
 }
@@ -84,10 +79,13 @@ void __udelay (unsigned long usec)
        }
 
        tmp = get_timer (0);            /* get current timestamp */
-       if ( (tmo + tmp + 1) < tmp )    /* if setting this forward will roll time stamp */
-               reset_timer_masked ();  /* reset "advancing" timestamp to 0, set lastinc value */
-       else
+       if ((tmo + tmp + 1) < tmp) {    /* if setting this forward will roll */
+                                       /* time stamp, then reset time */
+               gd->arch.lastinc = READ_TIMER;  /* capture incrementer value */
+               gd->arch.tbl = 0;                       /* start time stamp */
+       } else {
                tmo     += tmp;         /* else, set advancing stamp wake up time */
+       }
        while (get_timer_masked () < tmo)/* loop till event */
                /*NOP*/;
 }
@@ -96,12 +94,15 @@ ulong get_timer_masked (void)
 {
        ulong now = READ_TIMER;         /* current tick value */
 
-       if (now >= gd->lastinc)         /* normal mode (non roll) */
-               gd->tbl += (now - gd->lastinc); /* move stamp fordward with absoulte diff ticks */
-       else                            /* we have rollover of incrementer */
-               gd->tbl += (0xFFFFFFFF - gd->lastinc) + now;
-       gd->lastinc = now;
-       return gd->tbl;
+       if (now >= gd->arch.lastinc) {          /* normal mode (non roll) */
+               /* move stamp fordward with absoulte diff ticks */
+               gd->arch.tbl += (now - gd->arch.lastinc);
+       } else {
+               /* we have rollover of incrementer */
+               gd->arch.tbl += (0xFFFFFFFF - gd->arch.lastinc) + now;
+       }
+       gd->arch.lastinc = now;
+       return gd->arch.tbl;
 }
 
 /* waits specified delay value and resets timestamp */