Commit 9fb34b01f7757ed772b77dd90e463c6e7499fef8
Committed by
Tom Rini
1 parent
9cb5eaf2cf
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
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>
Showing 1 changed file with 17 additions and 0 deletions Side-by-side Diff
lib/time.c
... | ... | @@ -36,6 +36,23 @@ |
36 | 36 | return readl(CONFIG_SYS_TIMER_COUNTER); |
37 | 37 | #endif |
38 | 38 | } |
39 | + | |
40 | +ulong timer_get_boot_us(void) | |
41 | +{ | |
42 | + ulong count = timer_read_counter(); | |
43 | + | |
44 | +#if CONFIG_SYS_TIMER_RATE == 1000000 | |
45 | + return count; | |
46 | +#elif CONFIG_SYS_TIMER_RATE > 1000000 | |
47 | + return lldiv(count, CONFIG_SYS_TIMER_RATE / 1000000); | |
48 | +#elif defined(CONFIG_SYS_TIMER_RATE) | |
49 | + return (unsigned long long)count * 1000000 / CONFIG_SYS_TIMER_RATE; | |
50 | +#else | |
51 | + /* Assume the counter is in microseconds */ | |
52 | + return count; | |
53 | +#endif | |
54 | +} | |
55 | + | |
39 | 56 | #else |
40 | 57 | extern unsigned long __weak timer_read_counter(void); |
41 | 58 | #endif |