diff options
Diffstat (limited to 'src/cpu')
-rw-r--r-- | src/cpu/samsung/exynos5250/monotonic_timer.c | 28 | ||||
-rw-r--r-- | src/cpu/samsung/exynos5420/monotonic_timer.c | 28 |
2 files changed, 8 insertions, 48 deletions
diff --git a/src/cpu/samsung/exynos5250/monotonic_timer.c b/src/cpu/samsung/exynos5250/monotonic_timer.c index 57e3ae3104..267d9c3aef 100644 --- a/src/cpu/samsung/exynos5250/monotonic_timer.c +++ b/src/cpu/samsung/exynos5250/monotonic_timer.c @@ -18,40 +18,20 @@ */ #include <stdint.h> -#include <delay.h> #include <timer.h> #include "clk.h" -static struct monotonic_counter { - int initialized; - struct mono_time time; - uint64_t last_value; -} mono_counter; +static int initialized; static const uint32_t clocks_per_usec = MCT_HZ/1000000; void timer_monotonic_get(struct mono_time *mt) { - uint64_t current_tick; - uint64_t usecs_elapsed; - - if (!mono_counter.initialized) { + if (!initialized) { mct_start(); - mono_counter.last_value = mct_raw_value(); - mono_counter.initialized = 1; - } - - current_tick = mct_raw_value(); - 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; + initialized = 1; } - /* Save result. */ - *mt = mono_counter.time; + mono_time_set_usecs(mt, mct_raw_value() / clocks_per_usec); } diff --git a/src/cpu/samsung/exynos5420/monotonic_timer.c b/src/cpu/samsung/exynos5420/monotonic_timer.c index 57e3ae3104..267d9c3aef 100644 --- a/src/cpu/samsung/exynos5420/monotonic_timer.c +++ b/src/cpu/samsung/exynos5420/monotonic_timer.c @@ -18,40 +18,20 @@ */ #include <stdint.h> -#include <delay.h> #include <timer.h> #include "clk.h" -static struct monotonic_counter { - int initialized; - struct mono_time time; - uint64_t last_value; -} mono_counter; +static int initialized; static const uint32_t clocks_per_usec = MCT_HZ/1000000; void timer_monotonic_get(struct mono_time *mt) { - uint64_t current_tick; - uint64_t usecs_elapsed; - - if (!mono_counter.initialized) { + if (!initialized) { mct_start(); - mono_counter.last_value = mct_raw_value(); - mono_counter.initialized = 1; - } - - current_tick = mct_raw_value(); - 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; + initialized = 1; } - /* Save result. */ - *mt = mono_counter.time; + mono_time_set_usecs(mt, mct_raw_value() / clocks_per_usec); } |