blob: d156f1d38356ff4e3bf8f7a322382773a53c7839 [file] [log] [blame]
Patrick Georgi11f00792020-03-04 15:10:45 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Stefan Reinauer3a6550d2013-08-01 13:31:44 -07003
4#include <cpu/x86/tsc.h>
5#include <timestamp.h>
6
7uint64_t timestamp_get(void)
8{
9 return rdtscll();
10}
Aaron Durbinc49014e2015-08-30 21:19:55 -050011
Aaron Durbinc49014e2015-08-30 21:19:55 -050012int timestamp_tick_freq_mhz(void)
13{
14 /* Chipsets that have a constant TSC provide this value correctly. */
Kyösti Mälkki0d6ddf82019-10-31 14:52:20 +020015 if (tsc_constant_rate())
Kyösti Mälkki6c19cb52019-01-08 19:14:41 +020016 return tsc_freq_mhz();
17
18 /* Filling tick_freq_mhz = 0 in timestamps-table will trigger
19 * userspace utility to try deduce it from the running system.
20 */
21 return 0;
Aaron Durbinc49014e2015-08-30 21:19:55 -050022}