Merge branch 'rmobile' of git://git.denx.de/u-boot-sh
[platform/kernel/u-boot.git] / arch / arm / mach-uniphier / arm64 / timer.c
1 /*
2  * Copyright (C) 2016 Socionext Inc.
3  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #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 */
18 int timer_init(void)
19 {
20         void __iomem *base;
21         u32 tmp;
22
23         base = ioremap(CNT_CONTROL_BASE, SZ_4K);
24
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
34         iounmap(base);
35
36         return 0;
37 }