diff options
author | Kangheui Won <khwon@chromium.org> | 2020-10-04 21:12:06 +1100 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2020-11-02 22:17:29 +0000 |
commit | 9f7df5c18a426947e173277a294537d7534eef48 (patch) | |
tree | 7b4eed9d8f1c70b3340ccfb9b429da75df445313 /src/soc/amd/picasso/monotonic_timer.c | |
parent | 5e6c30bc421757a11ec6f7c1f730bf36c7de1b57 (diff) |
soc/amd/picasso: add monotonic_timer
On Zork(picasso) platform we run verstage on the PSP. It has its own
timer, but the frequency is not matched with TSC.
To ease the work to merge timestamps from the PSP and TSC, add a layer
around tsc to have microsecond granularity for timestamp table. PSP
already records timestamp in microseconds.
BUG=b:159220781
BRANCH=zork
TEST=build, flash and boot, check timestamps are correct
Signed-off-by: Kangheui Won <khwon@chromium.org>
Change-Id: Ifced4a84071be8da547e252167ec21cd42f20ccc
Reviewed-on: https://review.coreboot.org/c/coreboot/+/46058
Reviewed-by: Martin Roth <martinroth@google.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Eric Peers <epeers@google.com>
Reviewed-by: Rob Barnes <robbarnes@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/soc/amd/picasso/monotonic_timer.c')
-rw-r--r-- | src/soc/amd/picasso/monotonic_timer.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/soc/amd/picasso/monotonic_timer.c b/src/soc/amd/picasso/monotonic_timer.c new file mode 100644 index 0000000000..941532cca6 --- /dev/null +++ b/src/soc/amd/picasso/monotonic_timer.c @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <cpu/x86/msr.h> +#include <cpu/x86/tsc.h> +#include <timer.h> +#include <timestamp.h> + +void timer_monotonic_get(struct mono_time *mt) +{ + mono_time_set_usecs(mt, timestamp_get()); +} + +uint64_t timestamp_get(void) +{ + return rdtscll() / tsc_freq_mhz(); +} |