aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/soc/nvidia/tegra132/timer.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/soc/nvidia/tegra132/timer.c b/src/soc/nvidia/tegra132/timer.c
index e2b0b82f1e..4a43208f61 100644
--- a/src/soc/nvidia/tegra132/timer.c
+++ b/src/soc/nvidia/tegra132/timer.c
@@ -28,4 +28,18 @@ void init_timer(void)
void udelay(unsigned usec)
{
+ struct mono_time current, end;
+
+ if (!thread_yield_microseconds(usec))
+ return;
+
+ /*
+ * As the hardware clock granularity is in microseconds pad the
+ * requested delay by one to get at least >= requested usec delay.
+ */
+ timer_monotonic_get(&end);
+ mono_time_add_usecs(&end, usec + 1);
+ do {
+ timer_monotonic_get(&current);
+ } while (mono_time_before(&current, &end));
}