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