Ley Foon Tan | 4eadafc2 | 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> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 8 | #include <init.h> |
Ley Foon Tan | 4eadafc2 | 2018-05-24 00:17:29 +0800 | [diff] [blame] | 9 | #include <asm/io.h> |
| 10 | #include <asm/arch/timer.h> |
| 11 | |
| 12 | /* |
| 13 | * Timer initialization |
| 14 | */ |
| 15 | int timer_init(void) |
| 16 | { |
Chee Hong Ang | 92dc7ae | 2020-07-10 23:53:13 +0800 | [diff] [blame^] | 17 | #ifdef CONFIG_SPL_BUILD |
Ley Foon Tan | 4eadafc2 | 2018-05-24 00:17:29 +0800 | [diff] [blame] | 18 | int enable = 0x3; /* timer enable + output signal masked */ |
| 19 | int loadval = ~0; |
| 20 | |
| 21 | /* enable system counter */ |
| 22 | writel(enable, SOCFPGA_GTIMER_SEC_ADDRESS); |
| 23 | /* enable processor pysical counter */ |
| 24 | asm volatile("msr cntp_ctl_el0, %0" : : "r" (enable)); |
| 25 | asm volatile("msr cntp_tval_el0, %0" : : "r" (loadval)); |
Chee Hong Ang | 92dc7ae | 2020-07-10 23:53:13 +0800 | [diff] [blame^] | 26 | #endif |
Ley Foon Tan | 4eadafc2 | 2018-05-24 00:17:29 +0800 | [diff] [blame] | 27 | return 0; |
| 28 | } |