blob: 8a30d8aefa6cca7aa03b0b01a759edfa59c4aa3a [file] [log] [blame]
developer65014b82015-04-13 14:47:57 +08001/*
2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
developer65014b82015-04-13 14:47:57 +08005 */
6#include <arch_helpers.h>
7#include <mcucfg.h>
8#include <mmio.h>
9#include <mt8173_def.h>
10#include <mt_cpuxgpt.h>
11
12static void write_cpuxgpt(unsigned int reg_index, unsigned int value)
13{
14 mmio_write_32((uintptr_t)&mt8173_mcucfg->xgpt_idx, reg_index);
15 mmio_write_32((uintptr_t)&mt8173_mcucfg->xgpt_ctl, value);
16}
17
18static void cpuxgpt_set_init_cnt(unsigned int countH, unsigned int countL)
19{
20 write_cpuxgpt(INDEX_CNT_H_INIT, countH);
21 /* update count when countL programmed */
22 write_cpuxgpt(INDEX_CNT_L_INIT, countL);
23}
24
25void generic_timer_backup(void)
26{
27 uint64_t cval;
28
29 cval = read_cntpct_el0();
30 cpuxgpt_set_init_cnt((uint32_t)(cval >> 32),
31 (uint32_t)(cval & 0xffffffff));
32}