]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/arm/cpu/arm926ejs/pantheon/timer.c
Merge branch 'master' of git://git.denx.de/u-boot-x86
[karo-tx-uboot.git] / arch / arm / cpu / arm926ejs / pantheon / timer.c
index c71162a8be697abedf379296de0f7ed0bd456edf..2d9ddbad24001ae6a546cb03ff4edb30d3512d66 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <common.h>
+#include <asm/arch/cpu.h>
 #include <asm/arch/pantheon.h>
 
 /*
@@ -59,7 +60,7 @@ struct panthtmr_registers {
 #define        COUNT_RD_REQ            0x1
 
 DECLARE_GLOBAL_DATA_PTR;
-/* Using gd->tbu from timestamp and gd->tbl for lastdec */
+/* Using gd->arch.tbu from timestamp and gd->arch.tbl for lastdec */
 
 /*
  * For preventing risk of instability in reading counter value,
@@ -89,16 +90,16 @@ ulong get_timer_masked(void)
 {
        ulong now = read_timer();
 
-       if (now >= gd->tbl) {
+       if (now >= gd->arch.tbl) {
                /* normal mode */
-               gd->tbu += now - gd->tbl;
+               gd->arch.tbu += now - gd->arch.tbl;
        } else {
                /* we have an overflow ... */
-               gd->tbu += now + TIMER_LOAD_VAL - gd->tbl;
+               gd->arch.tbu += now + TIMER_LOAD_VAL - gd->arch.tbl;
        }
-       gd->tbl = now;
+       gd->arch.tbl = now;
 
-       return gd->tbu;
+       return gd->arch.tbu;
 }
 
 ulong get_timer(ulong base)
@@ -143,9 +144,9 @@ int timer_init(void)
 
        /* Enable timer 0 */
        writel(0x1, &panthtimers->cer);
-       /* init the gd->tbu and gd->tbl value */
-       gd->tbl = read_timer();
-       gd->tbu = 0;
+       /* init the gd->arch.tbu and gd->arch.tbl value */
+       gd->arch.tbl = read_timer();
+       gd->arch.tbu = 0;
 
        return 0;
 }
@@ -196,3 +197,21 @@ void reset_cpu (unsigned long ignored)
        /*enable functional WDT clock */
        writel(APBC_APBCLK | APBC_FNCLK, &mpmu->wdtpcr);
 }
+
+/*
+ * This function is derived from PowerPC code (read timebase as long long).
+ * On ARM it just returns the timer value.
+ */
+unsigned long long get_ticks(void)
+{
+       return get_timer(0);
+}
+
+/*
+ * This function is derived from PowerPC code (timebase clock frequency).
+ * On ARM it returns the number of timer ticks per second.
+ */
+ulong get_tbclk (void)
+{
+       return (ulong)CONFIG_SYS_HZ;
+}