X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=arch%2Farm%2Fcpu%2Farmv8%2Fgeneric_timer.c;h=a2dda333fe5f63979f5b4d4fbf4d40b18ff9934d;hb=b0ce187b1f8dfa30e3885caa7dca8c1742def973;hp=8e60baebc53487d17556facc322003e23dfbd15f;hpb=08442ec7633c69c882a4a6bd70831226d7a81556;p=oweals%2Fu-boot.git diff --git a/arch/arm/cpu/armv8/generic_timer.c b/arch/arm/cpu/armv8/generic_timer.c index 8e60baebc5..a2dda333fe 100644 --- a/arch/arm/cpu/armv8/generic_timer.c +++ b/arch/arm/cpu/armv8/generic_timer.c @@ -9,6 +9,8 @@ #include #include +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; +}