Skip to content
Snippets Groups Projects
Commit 9fb34b01 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

bootstage: Provide a default timer function


If CONFIG_SYS_TIMER_COUNTER is used we can provide a default microsecond
timer implementation.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent 9cb5eaf2
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,23 @@ unsigned long notrace timer_read_counter(void)
return readl(CONFIG_SYS_TIMER_COUNTER);
#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
extern unsigned long __weak timer_read_counter(void);
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment