blob: 174a24d88f9376c8174de238ce869ff816e2e869 [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 */
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00006
developer65014b82015-04-13 14:47:57 +08007#include <arch_helpers.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <lib/mmio.h>
9
developer65014b82015-04-13 14:47:57 +080010#include <mcucfg.h>
developer65014b82015-04-13 14:47:57 +080011#include <mt8173_def.h>
12#include <mt_cpuxgpt.h>
13
14static 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
20static 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
27void 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}