blob: c10903ae58fdee2849c406e11e156e69a27ae914 [file] [log] [blame]
Masahiro Yamada063eb1e2016-04-21 14:43:18 +09001/*
Masahiro Yamadafa1f73f2016-07-19 21:56:13 +09002 * Copyright (C) 2016 Socionext Inc.
3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada063eb1e2016-04-21 14:43:18 +09004 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
Masahiro Yamada063eb1e2016-04-21 14:43:18 +09008#include <linux/bitops.h>
9#include <linux/io.h>
10#include <linux/sizes.h>
11
12#define CNT_CONTROL_BASE 0x60E00000
13
14#define CNTCR 0x000
15#define CNTCR_EN BIT(0)
16
17/* setup ARMv8 Generic Timer */
18int timer_init(void)
19{
20 void __iomem *base;
21 u32 tmp;
22
Masahiro Yamadafa1f73f2016-07-19 21:56:13 +090023 base = ioremap(CNT_CONTROL_BASE, SZ_4K);
Masahiro Yamada063eb1e2016-04-21 14:43:18 +090024
25 /*
26 * Note:
27 * In a system that implements both Secure and Non-secure states,
28 * this register is only writable in Secure state.
29 */
30 tmp = readl(base + CNTCR);
31 tmp |= CNTCR_EN;
32 writel(tmp, base + CNTCR);
33
Masahiro Yamadafa1f73f2016-07-19 21:56:13 +090034 iounmap(base);
Masahiro Yamada063eb1e2016-04-21 14:43:18 +090035
36 return 0;
37}