X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=arch%2Farm%2Fcpu%2Farmv8%2Fgeneric_timer.c;h=cd92b2c7617dcc1f4fb7531a08b9eb19d63ca008;hb=0ff27d4a94637d4b1937c625d33212375bd118d9;hp=8e60baebc53487d17556facc322003e23dfbd15f;hpb=060ef094600373ea2b25111006edc56c072d9bd7;p=u-boot diff --git a/arch/arm/cpu/armv8/generic_timer.c b/arch/arm/cpu/armv8/generic_timer.c index 8e60baebc5..cd92b2c761 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; } + +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; +}