From bdc1c878992076da145b3c1d775f86adaa37ecde Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Fri, 28 Aug 2015 01:58:18 -0500 Subject: 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 Original-Commit-Id: 6d60ef204fc92c26748ab57d4ff37830cd8dc664 Original-Change-Id: Ibdb6b9e20b9f2d48ff0f8a8c782f5c1f7ddde4f7 Original-Signed-off-by: Aaron Durbin Original-Reviewed-on: https://chromium-review.googlesource.com/295237 Original-Reviewed-by: Duncan Laurie Reviewed-on: http://review.coreboot.org/11540 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc Reviewed-by: Aaron Durbin --- src/soc/intel/skylake/Makefile.inc | 1 + src/soc/intel/skylake/monotonic_timer.c | 27 ++------------------------- 2 files changed, 3 insertions(+), 25 deletions(-) (limited to 'src/soc/intel/skylake') 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 #include -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); } -- cgit v1.2.3