mt_cpuxgpt.c 818 Bytes
Newer Older
1
2
3
/*
 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
 */
6

7
#include <arch_helpers.h>
8
9
#include <lib/mmio.h>

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <mcucfg.h>
#include <mt8173_def.h>
#include <mt_cpuxgpt.h>

static void write_cpuxgpt(unsigned int reg_index, unsigned int value)
{
	mmio_write_32((uintptr_t)&mt8173_mcucfg->xgpt_idx, reg_index);
	mmio_write_32((uintptr_t)&mt8173_mcucfg->xgpt_ctl, value);
}

static void cpuxgpt_set_init_cnt(unsigned int countH, unsigned int countL)
{
	write_cpuxgpt(INDEX_CNT_H_INIT, countH);
	/* update count when countL programmed */
	write_cpuxgpt(INDEX_CNT_L_INIT, countL);
}

void generic_timer_backup(void)
{
	uint64_t cval;

	cval = read_cntpct_el0();
	cpuxgpt_set_init_cnt((uint32_t)(cval >> 32),
			       (uint32_t)(cval & 0xffffffff));
}