summaryrefslogtreecommitdiff
path: root/lib/time.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-11-01 09:23:21 -0400
committerTom Rini <trini@konsulko.com>2019-11-01 09:23:21 -0400
commit82679624f9aa6d1be733c46f3555d5166b6f5b72 (patch)
tree8a99cf79bc520b833e155094ef134c0526b1f005 /lib/time.c
parent412326d1bc2d346d7b4faad6fa547eaf065681a2 (diff)
parent5d80a1a93d42c8325d65516cc654ff6a9ceec58a (diff)
Merge branch '2019-10-30-master-imports'
- Migrate test.py to use python3 and current pytest. - NVMe bugfixes - Assorted other fixes - Android AVB updates.
Diffstat (limited to 'lib/time.c')
-rw-r--r--lib/time.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/time.c b/lib/time.c
index f5751ab162b..f30fc05804b 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -134,6 +134,20 @@ ulong __weak get_timer(ulong base)
return tick_to_time(get_ticks()) - base;
}
+static uint64_t notrace tick_to_time_us(uint64_t tick)
+{
+ ulong div = get_tbclk() / 1000;
+
+ tick *= CONFIG_SYS_HZ;
+ do_div(tick, div);
+ return tick;
+}
+
+uint64_t __weak get_timer_us(uint64_t base)
+{
+ return tick_to_time_us(get_ticks()) - base;
+}
+
unsigned long __weak notrace timer_get_us(void)
{
return tick_to_time(get_ticks() * 1000);