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