• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <arch_helpers.h>
8 #include <lib/mmio.h>
9 
10 #include <mcucfg.h>
11 #include <mt8173_def.h>
12 #include <mt_cpuxgpt.h>
13 
write_cpuxgpt(unsigned int reg_index,unsigned int value)14 static void write_cpuxgpt(unsigned int reg_index, unsigned int value)
15 {
16 	mmio_write_32((uintptr_t)&mt8173_mcucfg->xgpt_idx, reg_index);
17 	mmio_write_32((uintptr_t)&mt8173_mcucfg->xgpt_ctl, value);
18 }
19 
cpuxgpt_set_init_cnt(unsigned int countH,unsigned int countL)20 static void cpuxgpt_set_init_cnt(unsigned int countH, unsigned int countL)
21 {
22 	write_cpuxgpt(INDEX_CNT_H_INIT, countH);
23 	/* update count when countL programmed */
24 	write_cpuxgpt(INDEX_CNT_L_INIT, countL);
25 }
26 
generic_timer_backup(void)27 void generic_timer_backup(void)
28 {
29 	uint64_t cval;
30 
31 	cval = read_cntpct_el0();
32 	cpuxgpt_set_init_cnt((uint32_t)(cval >> 32),
33 			       (uint32_t)(cval & 0xffffffff));
34 }
35