Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | fa1f73f | 2016-07-19 21:56:13 +0900 | [diff] [blame] | 2 | * Copyright (C) 2016 Socionext Inc. |
| 3 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 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 | |
Masahiro Yamada | fa1f73f | 2016-07-19 21:56:13 +0900 | [diff] [blame] | 23 | base = ioremap(CNT_CONTROL_BASE, SZ_4K); |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 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 | |
Masahiro Yamada | fa1f73f | 2016-07-19 21:56:13 +0900 | [diff] [blame] | 34 | iounmap(base); |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 35 | |
| 36 | return 0; |
| 37 | } |