Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2012 Altera Corporation <www.altera.com> |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 6 | #include <config.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 7 | #include <init.h> |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/timer.h> |
| 10 | |
Marek Vasut | 8fea4ae | 2014-09-08 14:08:45 +0200 | [diff] [blame] | 11 | #define TIMER_LOAD_VAL 0xFFFFFFFF |
| 12 | |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 13 | static const struct socfpga_timer *timer_base = (void *)CFG_SYS_TIMERBASE; |
Dinh Nguyen | ad51f7c | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 14 | |
| 15 | /* |
| 16 | * Timer initialization |
| 17 | */ |
| 18 | int timer_init(void) |
| 19 | { |
| 20 | writel(TIMER_LOAD_VAL, &timer_base->load_val); |
| 21 | writel(TIMER_LOAD_VAL, &timer_base->curr_val); |
| 22 | writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl); |
| 23 | return 0; |
| 24 | } |