blob: 781f940b694fb2f8faeb3646a0ca389dcf243827 [file] [log] [blame]
developer86ada3c2020-07-03 09:19:06 +08001/*
2 * Copyright (c) 2020, MediaTek Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch_helpers.h>
8#include <mt_timer.h>
9#include <platform_def.h>
10
11
12uint64_t normal_time_base;
13uint64_t atf_time_base;
14
15void sched_clock_init(uint64_t normal_base, uint64_t atf_base)
16{
17 normal_time_base += normal_base;
18 atf_time_base = atf_base;
19}
20
21uint64_t sched_clock(void)
22{
23 uint64_t cval;
24 uint64_t rel_base;
25
26 rel_base = read_cntpct_el0() - atf_time_base;
27 cval = ((rel_base * 1000U) / SYS_COUNTER_FREQ_IN_MHZ)
28 - normal_time_base;
29 return cval;
30}