blob: 2db235a5da889584489fdf01f0c9bcc6fcc8bd77 [file] [log] [blame]
T Michael Turney3775f1c2018-04-24 10:15:46 -07001/*
2 * This file is part of the coreboot project.
3 *
T Michael Turney3775f1c2018-04-24 10:15:46 -07004 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <timer.h>
15#include <arch/lib_helpers.h>
16
17void timer_monotonic_get(struct mono_time *mt)
18{
19 uint64_t tvalue = raw_read_cntpct_el0();
20 uint32_t tfreq = raw_read_cntfrq_el0();
21 long usecs = (tvalue * 1000000) / tfreq;
22 mono_time_set_usecs(mt, usecs);
23}