aboutsummaryrefslogtreecommitdiff
path: root/lib/time.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-08-23 15:44:54 -0400
committerTom Rini <trini@konsulko.com>2022-08-23 15:44:54 -0400
commitaea087a665c447dfb89bf2113cad74ad53fa17a0 (patch)
treefbb710bb7a66da927c142b8710cf4564b5652ced /lib/time.c
parent1247c35c80cb0f6f17c88d54c6575d6d1f50c608 (diff)
parent560a5c3bb3bedac7d1da93362401a1d926214660 (diff)
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell
- kirkwood: pogo_v4 & nsa310s: Add distro boot (Tony) - kirkwood: add DM timer support and use it on lsxl boards (Michael) - kirkwood: convert the Buffalo Linkstation LS-CHLv2 and XHL boards to DM (Michael) - mvebu: turris_mox/omnia: misc improments (Pali) - mvebu: mbus: Fix mbus driver to work also after U-Boot relocation (Pali)
Diffstat (limited to 'lib/time.c')
-rw-r--r--lib/time.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/time.c b/lib/time.c
index 96074b84af..bbf191f673 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -47,12 +47,15 @@ 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;
+#ifdef CONFIG_SYS_TIMER_RATE
+ const ulong timer_rate = CONFIG_SYS_TIMER_RATE;
+
+ if (timer_rate == 1000000)
+ return count;
+ else if (timer_rate > 1000000)
+ return lldiv(count, timer_rate / 1000000);
+ else
+ return (unsigned long long)count * 1000000 / timer_rate;
#else
/* Assume the counter is in microseconds */
return count;