diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-08-28 01:58:18 -0500 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-09-08 11:22:24 +0000 |
commit | bdc1c878992076da145b3c1d775f86adaa37ecde (patch) | |
tree | c9bcd234885afafe656a30400c13bb6247d7f613 | |
parent | c97106fd48daf34bf89cf8422455e2b6e0878dd2 (diff) | |
download | coreboot-bdc1c878992076da145b3c1d775f86adaa37ecde.tar.xz |
skylake: allow timer_monotonic_get() in all stages
The timer_monotonic_get() function wasn't being compiled for
romstage. To simplify the implementation don't keep track of
partial microsecond ticks and just return the MSR value divided
by 24 (24MHz clock).
BUG=chrome-os-partner:42115
BRANCH=None
TEST=Build and booted glados. Used monotonic timers in romstage
in subsequent patches.
Change-Id: I8294c74abe09947fb4438bf5c1d0fc5265491694
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 6d60ef204fc92c26748ab57d4ff37830cd8dc664
Original-Change-Id: Ibdb6b9e20b9f2d48ff0f8a8c782f5c1f7ddde4f7
Original-Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/295237
Original-Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: http://review.coreboot.org/11540
Tested-by: build bot (Jenkins)
Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r-- | src/soc/intel/skylake/Makefile.inc | 1 | ||||
-rw-r--r-- | src/soc/intel/skylake/monotonic_timer.c | 27 |
2 files changed, 3 insertions, 25 deletions
diff --git a/src/soc/intel/skylake/Makefile.inc b/src/soc/intel/skylake/Makefile.inc index defb94502b..3bd9823738 100644 --- a/src/soc/intel/skylake/Makefile.inc +++ b/src/soc/intel/skylake/Makefile.inc @@ -13,6 +13,7 @@ subdirs-y += ../../../cpu/x86/tsc romstage-y += flash_controller.c romstage-y += gpio.c romstage-y += memmap.c +romstage-y += monotonic_timer.c romstage-y += pch.c romstage-y += pcr.c romstage-y += pei_data.c diff --git a/src/soc/intel/skylake/monotonic_timer.c b/src/soc/intel/skylake/monotonic_timer.c index 35ad911168..55430ef2b1 100644 --- a/src/soc/intel/skylake/monotonic_timer.c +++ b/src/soc/intel/skylake/monotonic_timer.c @@ -23,12 +23,6 @@ #include <timer.h> #include <soc/msr.h> -static struct monotonic_counter { - int initialized; - struct mono_time time; - uint32_t last_value; -} mono_counter; - static inline uint32_t read_counter_msr(void) { /* @@ -44,23 +38,6 @@ static inline uint32_t read_counter_msr(void) void timer_monotonic_get(struct mono_time *mt) { - uint32_t current_tick; - uint32_t usecs_elapsed; - - if (!mono_counter.initialized) { - mono_counter.last_value = read_counter_msr(); - mono_counter.initialized = 1; - } - - current_tick = read_counter_msr(); - usecs_elapsed = (current_tick - mono_counter.last_value) / 24; - - /* 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; + /* Always increases. Don't normalize to 0 between stages. */ + mono_time_set_usecs(mt, read_counter_msr() / 24); } |