developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 5 | */ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 6 | |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 7 | #include <arch_helpers.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <lib/mmio.h> |
| 9 | |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 10 | #include <mcucfg.h> |
developer | 65014b8 | 2015-04-13 14:47:57 +0800 | [diff] [blame] | 11 | #include <mt8173_def.h> |
| 12 | #include <mt_cpuxgpt.h> |
| 13 | |
| 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 | |
| 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 | |
| 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 | } |