mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
bootstage: Provide a default timer function
If CONFIG_SYS_TIMER_COUNTER is used we can provide a default microsecond timer implementation. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
17
lib/time.c
17
lib/time.c
@ -36,6 +36,23 @@ unsigned long notrace timer_read_counter(void)
|
|||||||
return readl(CONFIG_SYS_TIMER_COUNTER);
|
return readl(CONFIG_SYS_TIMER_COUNTER);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ulong timer_get_boot_us(void)
|
||||||
|
{
|
||||||
|
ulong count = timer_read_counter();
|
||||||
|
|
||||||
|
#if CONFIG_SYS_TIMER_RATE == 1000000
|
||||||
|
return count;
|
||||||
|
#elif CONFIG_SYS_TIMER_RATE > 1000000
|
||||||
|
return lldiv(count, CONFIG_SYS_TIMER_RATE / 1000000);
|
||||||
|
#elif defined(CONFIG_SYS_TIMER_RATE)
|
||||||
|
return (unsigned long long)count * 1000000 / CONFIG_SYS_TIMER_RATE;
|
||||||
|
#else
|
||||||
|
/* Assume the counter is in microseconds */
|
||||||
|
return count;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
extern unsigned long __weak timer_read_counter(void);
|
extern unsigned long __weak timer_read_counter(void);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user