diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2021-12-16 12:57:29 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-01-16 16:31:03 +0300 |
commit | e660cfad5339719721a96257090ae47bbc2abee6 (patch) | |
tree | eab5173cb3e1e1d2c178b81ea40c224b57b6ed50 /drivers | |
parent | b6e59617c8d876876e99e1516ed2d991f25c3fe6 (diff) | |
download | u-boot-e660cfad5339719721a96257090ae47bbc2abee6.tar.xz |
omap: timer: implement timer_get_boot_us
To make the OMAP DM timer driver useful for the timing of
bootstages, we need to implement timer_get_boot_us(..).
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/timer/omap-timer.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c index 721e385fd1..25a6108fef 100644 --- a/drivers/timer/omap-timer.c +++ b/drivers/timer/omap-timer.c @@ -83,6 +83,27 @@ static int omap_timer_of_to_plat(struct udevice *dev) return 0; } +#if CONFIG_IS_ENABLED(BOOTSTAGE) +ulong timer_get_boot_us(void) +{ + u64 ticks = 0; + u32 rate = 1; + u64 us; + int ret; + + ret = dm_timer_init(); + if (!ret) { + /* The timer is available */ + rate = timer_get_rate(gd->timer); + timer_get_count(gd->timer, &ticks); + } else { + return 0; + } + + us = (ticks * 1000) / rate; + return us; +} +#endif static const struct timer_ops omap_timer_ops = { .get_count = omap_timer_get_count, |