]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/cpu/armv8/generic_timer.c
Merge git://git.denx.de/u-boot-mpc85xx
[u-boot] / arch / arm / cpu / armv8 / generic_timer.c
index 8e60baebc53487d17556facc322003e23dfbd15f..cd92b2c7617dcc1f4fb7531a08b9eb19d63ca008 100644 (file)
@@ -9,6 +9,8 @@
 #include <command.h>
 #include <asm/system.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /*
  * Generic timer implementation of get_tbclk()
  */
@@ -40,3 +42,23 @@ unsigned long timer_read_counter(void)
 #endif
        return cntpct;
 }
+
+unsigned long long get_ticks(void)
+{
+       unsigned long ticks = timer_read_counter();
+
+       gd->arch.tbl = ticks;
+
+       return ticks;
+}
+
+unsigned long usec2ticks(unsigned long usec)
+{
+       ulong ticks;
+       if (usec < 1000)
+               ticks = ((usec * (get_tbclk()/1000)) + 500) / 1000;
+       else
+               ticks = ((usec / 10) * (get_tbclk() / 100000));
+
+       return ticks;
+}