blob: 0a9de6bfb9596c94d3b34784f38a25b7b16eaf44 [file] [log] [blame]
Angel Ponse67ab182020-04-04 18:51:11 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Yidi Lin3d7b6062015-07-31 17:10:40 +08002
Kyösti Mälkki13f66502019-03-03 08:01:05 +02003#include <device/mmio.h>
Yidi Lin3d7b6062015-07-31 17:10:40 +08004#include <soc/mcucfg.h>
5#include <soc/timer.h>
6
Tristan Shieh4c8d4872018-06-06 13:35:12 +08007void timer_prepare(void)
Yidi Lin3d7b6062015-07-31 17:10:40 +08008{
9 /* Set XGPT_IDX to 0, then the bit field of XGPT_CTL will be programmed
10 * with following definition.
11 *
12 * [10: 8] Clock mode
13 * 100: 26Mhz / 4
14 * 010: 26Mhz / 2
15 * 001: 26Mhz
16 * [ 1: 1] Halt-on-debug enable bit
17 * [ 0: 0] XGPT enable bit
18 */
19 write32(&mt8173_mcucfg->xgpt_idx, 0);
20 /* Set clock mode to 13Mhz and enable XGPT */
Tristan Shieha76e6542019-04-08 11:01:40 +080021 write32(&mt8173_mcucfg->xgpt_ctl, (0x1 | ((26 / GPT_MHZ) << 8)));
Yidi Lin3d7b6062015-07-31 17:10:40 +080022}