aboutsummaryrefslogtreecommitdiff
path: root/src/soc/ti/am335x/monotonic_timer.c
diff options
context:
space:
mode:
authorSam Lewis <sam.vr.lewis@gmail.com>2020-08-04 19:47:50 +1000
committerPatrick Georgi <pgeorgi@google.com>2020-11-22 22:32:46 +0000
commitfde084bc490daf99da85292ef87d6dcf3446c212 (patch)
treef005134a3dadedc4fa91ff0f9c07fdd69412fba8 /src/soc/ti/am335x/monotonic_timer.c
parentb5353965e1b7eff860faaa3312728a935311a8c6 (diff)
soc/ti/am335x: Fix timer implementation
Implements the monotonic timer using the am335x dmtimer peripheral. Change-Id: I4736b6d3b6e26370be9e8f369fc02285ad519223 Signed-off-by: Sam Lewis <sam.vr.lewis@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/44383 Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/ti/am335x/monotonic_timer.c')
-rw-r--r--src/soc/ti/am335x/monotonic_timer.c40
1 files changed, 0 insertions, 40 deletions
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 <stdint.h>
-#include <delay.h>
-#include <timer.h>
-
-#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;
-}