mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-23 13:36:05 +00:00

The timer driver can be shared with mt8195. Move the the timer driver to common/. Signed-off-by: Yidi Lin <yidi.lin@mediatek.com> Change-Id: I84c97ab9cc9b469f35e0f44dd8e7b2b95f1b3926
38 lines
771 B
C
38 lines
771 B
C
/*
|
|
* Copyright (c) 2020, MediaTek Inc. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <arch_helpers.h>
|
|
#include <lib/mmio.h>
|
|
#include <mt_timer.h>
|
|
#include <platform_def.h>
|
|
|
|
|
|
uint64_t normal_time_base;
|
|
uint64_t atf_time_base;
|
|
|
|
void sched_clock_init(uint64_t normal_base, uint64_t atf_base)
|
|
{
|
|
normal_time_base += normal_base;
|
|
atf_time_base = atf_base;
|
|
}
|
|
|
|
uint64_t sched_clock(void)
|
|
{
|
|
uint64_t cval;
|
|
uint64_t rel_base;
|
|
|
|
rel_base = read_cntpct_el0() - atf_time_base;
|
|
cval = ((rel_base * 1000U) / SYS_COUNTER_FREQ_IN_MHZ)
|
|
- normal_time_base;
|
|
return cval;
|
|
}
|
|
|
|
void mt_systimer_init(void)
|
|
{
|
|
/* Enable access in NS mode */
|
|
mmio_write_32(CNTWACR_REG, CNT_WRITE_ACCESS_CTL_MASK);
|
|
mmio_write_32(CNTRACR_REG, CNT_READ_ACCESS_CTL_MASK);
|
|
}
|