Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / arch / arm / cpu / armv8 / generic_timer.c
index 8e60baebc53487d17556facc322003e23dfbd15f..a2dda333fe5f63979f5b4d4fbf4d40b18ff9934d 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;
 }
+
+uint64_t 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;
+}