From fde084bc490daf99da85292ef87d6dcf3446c212 Mon Sep 17 00:00:00 2001 From: Sam Lewis Date: Tue, 4 Aug 2020 19:47:50 +1000 Subject: soc/ti/am335x: Fix timer implementation Implements the monotonic timer using the am335x dmtimer peripheral. Change-Id: I4736b6d3b6e26370be9e8f369fc02285ad519223 Signed-off-by: Sam Lewis Reviewed-on: https://review.coreboot.org/c/coreboot/+/44383 Reviewed-by: Arthur Heymans Tested-by: build bot (Jenkins) --- src/soc/ti/am335x/monotonic_timer.c | 40 ------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/soc/ti/am335x/monotonic_timer.c (limited to 'src/soc/ti/am335x/monotonic_timer.c') diff --git a/src/soc/ti/am335x/monotonic_timer.c b/src/soc/ti/am335x/monotonic_timer.c deleted file mode 100644 index b57258b6c8..0000000000 --- a/src/soc/ti/am335x/monotonic_timer.c +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ - -#include -#include -#include - -#include "dmtimer.h" - -static struct monotonic_counter { - int initialized; - struct mono_time time; - uint64_t last_value; -} mono_counter; - -static const uint32_t clocks_per_usec = OSC_HZ/1000000; - -void timer_monotonic_get(struct mono_time *mt) -{ - uint64_t current_tick; - uint64_t usecs_elapsed; - - if (!mono_counter.initialized) { - init_timer(); - mono_counter.last_value = dmtimer_raw_value(0); - mono_counter.initialized = 1; - } - - current_tick = dmtimer_raw_value(0); - usecs_elapsed = (current_tick - mono_counter.last_value) / - clocks_per_usec; - - /* Update current time and tick values only if a full tick occurred. */ - if (usecs_elapsed) { - mono_time_add_usecs(&mono_counter.time, usecs_elapsed); - mono_counter.last_value = current_tick; - } - - /* Save result. */ - *mt = mono_counter.time; -} -- cgit v1.2.3