]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/armv8/generic_timer.c
3 * David Feng <fenghua@phytium.com.cn>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/system.h>
13 * Generic timer implementation of get_tbclk()
15 unsigned long get_tbclk(void)
18 asm volatile("mrs %0, cntfrq_el0" : "=r" (cntfrq
));
23 * Generic timer implementation of timer_read_counter()
25 unsigned long timer_read_counter(void)
28 #ifdef CONFIG_SYS_FSL_ERRATUM_A008585
29 /* This erratum number needs to be confirmed to match ARM document */
33 asm volatile("mrs %0, cntpct_el0" : "=r" (cntpct
));
34 #ifdef CONFIG_SYS_FSL_ERRATUM_A008585
35 asm volatile("mrs %0, cntpct_el0" : "=r" (temp
));
36 while (temp
!= cntpct
) {
37 asm volatile("mrs %0, cntpct_el0" : "=r" (cntpct
));
38 asm volatile("mrs %0, cntpct_el0" : "=r" (temp
));
44 unsigned long usec2ticks(unsigned long usec
)
48 ticks
= ((usec
* (get_tbclk()/1000)) + 500) / 1000;
50 ticks
= ((usec
/ 10) * (get_tbclk() / 100000));