Ley Foon Tan | 73aede5 | 2018-05-24 00:17:29 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2017-2018 Intel Corporation <www.intel.com> |
| 4 | * |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/timer.h> |
| 10 | |
| 11 | /* |
| 12 | * Timer initialization |
| 13 | */ |
| 14 | int timer_init(void) |
| 15 | { |
| 16 | int enable = 0x3; /* timer enable + output signal masked */ |
| 17 | int loadval = ~0; |
| 18 | |
| 19 | /* enable system counter */ |
| 20 | writel(enable, SOCFPGA_GTIMER_SEC_ADDRESS); |
| 21 | /* enable processor pysical counter */ |
| 22 | asm volatile("msr cntp_ctl_el0, %0" : : "r" (enable)); |
| 23 | asm volatile("msr cntp_tval_el0, %0" : : "r" (loadval)); |
| 24 | |
| 25 | return 0; |
| 26 | } |