Dinh Nguyen | 7775440 | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Altera Corporation <www.altera.com> |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Dinh Nguyen | 7775440 | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/timer.h> |
| 10 | |
Marek Vasut | 2110eea | 2014-09-08 14:08:45 +0200 | [diff] [blame] | 11 | #define TIMER_LOAD_VAL 0xFFFFFFFF |
| 12 | |
Dinh Nguyen | 7775440 | 2012-10-04 06:46:02 +0000 | [diff] [blame] | 13 | static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE; |
| 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 | } |