]> git.sur5r.net Git - u-boot/blob - arch/arm/mach-uniphier/arm64/timer.c
arm: at91: Add support for gurnard
[u-boot] / arch / arm / mach-uniphier / arm64 / timer.c
1 /*
2  * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <mapmem.h>
9 #include <linux/bitops.h>
10 #include <linux/io.h>
11 #include <linux/sizes.h>
12
13 #define CNT_CONTROL_BASE        0x60E00000
14
15 #define CNTCR                   0x000
16 #define   CNTCR_EN                      BIT(0)
17
18 /* setup ARMv8 Generic Timer */
19 int timer_init(void)
20 {
21         void __iomem *base;
22         u32 tmp;
23
24         base = map_sysmem(CNT_CONTROL_BASE, SZ_4K);
25
26         /*
27          * Note:
28          * In a system that implements both Secure and Non-secure states,
29          * this register is only writable in Secure state.
30          */
31         tmp = readl(base + CNTCR);
32         tmp |= CNTCR_EN;
33         writel(tmp, base + CNTCR);
34
35         unmap_sysmem(base);
36
37         return 0;
38 }