]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
Xilinx: ARM: Correct timekeeping (DT 584643)
authorBrian Hill <brian.hill@xilinx.com>
Thu, 19 May 2011 20:24:55 +0000 (14:24 -0600)
committerBrian Hill <brian.hill@xilinx.com>
Thu, 19 May 2011 20:24:55 +0000 (14:24 -0600)
arch/arm/cpu/armv7/pele/timer.c
include/configs/xpele.h

index dccb864d3e712988d1b4d7bd3c599c8fa6f89cef..2caf628db67991751bcf2dac477dc792a6236540 100644 (file)
@@ -19,8 +19,6 @@
  * (C) Copyright 2008
  * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
  *
- * And thoroughly mangled into dragonfire form, probably never to escape Xilinx.
- *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -87,7 +85,7 @@ int timer_init()
        /* Clear prescaler control bits */
        val &= ~XSCUTIMER_CONTROL_PRESCALER_MASK;
        /* Set prescaler value */
-       val |= (0xFF << XSCUTIMER_CONTROL_PRESCALER_SHIFT);
+       val |= (CONFIG_TIMER_PRESCALE << XSCUTIMER_CONTROL_PRESCALER_SHIFT);
        /* Enable the decrementer */
        val |= XSCUTIMER_CONTROL_ENABLE_MASK;
        XScuTimer_WriteReg(XSCUTIMER_CONTROL_OFFSET, val);
@@ -129,8 +127,7 @@ unsigned long long get_ticks(void)
  */
 ulong get_tbclk(void)
 {
-       /* We overrun in 100s */
-       return (ulong)(TIMER_LOAD_VAL / 100);
+       return (ulong)CONFIG_SYS_HZ;
 }
 
 void reset_timer_masked(void)
@@ -148,7 +145,6 @@ void reset_timer(void)
 ulong get_timer_masked(void)
 {
        unsigned long long res = get_ticks();
-       do_div (res, (CONFIG_SYS_HZ / 1000000) );
        return res;
 }
 
@@ -159,7 +155,7 @@ ulong get_timer(ulong base)
 
 void set_timer(ulong t)
 {
-       timestamp = t * (TIMER_LOAD_VAL / (100 * CONFIG_SYS_HZ));
+       timestamp = t;
 }
 
 void __udelay(unsigned long usec)
@@ -167,9 +163,11 @@ void __udelay(unsigned long usec)
        unsigned long long tmp;
        ulong tmo;
 
-       tmo = (usec + 9) / 10;
+       tmo = usec / (1000000 / CONFIG_SYS_HZ);
        tmp = get_ticks() + tmo;        /* get current timestamp */
 
-       while (get_ticks() < tmp)/* loop till event */
+       while (get_ticks() < tmp) { /* loop till event */ 
                 /*NOP*/;
+       }
 }
+
index 537cb141e66e9750b4908d26930a3cdf1dc9c781..36855caad6941ae3e915003823020df8f3126991 100644 (file)
 #define CONFIG_TTC0    1
 #define CONFIG_GEM0    1
 
-/* XPAR_CPU_CORTEXA9_CORE_CLOCK_FREQ_HZ */
-#define CONFIG_SYS_HZ  10000000 
+#define TIMER_CLOCK                     5000000
+#define CONFIG_TIMER_PRESCALE           255
+#define CONFIG_SYS_HZ                   (TIMER_CLOCK / CONFIG_TIMER_PRESCALE)
 
 /* And here... */
 #define CONFIG_SYS_LOAD_ADDR   0 /* default? */