Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2010-2011 Calxeda, Inc. |
| 4 | * |
| 5 | * Based on arm926ejs/mx27/timer.c |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 9 | #include <asm/io.h> |
| 10 | #include <asm/arch-armv7/systimer.h> |
| 11 | |
| 12 | #undef SYSTIMER_BASE |
| 13 | #define SYSTIMER_BASE 0xFFF34000 /* Timer 0 and 1 base */ |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 14 | |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 15 | static struct systimer *systimer_base = (struct systimer *)SYSTIMER_BASE; |
| 16 | |
| 17 | /* |
| 18 | * Start the timer |
| 19 | */ |
| 20 | int timer_init(void) |
| 21 | { |
| 22 | /* |
| 23 | * Setup timer0 |
| 24 | */ |
Rob Herring | d7dadc7 | 2013-06-12 22:24:49 -0500 | [diff] [blame] | 25 | writel(0, &systimer_base->timer0control); |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 26 | writel(SYSTIMER_RELOAD, &systimer_base->timer0load); |
| 27 | writel(SYSTIMER_RELOAD, &systimer_base->timer0value); |
Rob Herring | d7dadc7 | 2013-06-12 22:24:49 -0500 | [diff] [blame] | 28 | writel(SYSTIMER_EN | SYSTIMER_32BIT | SYSTIMER_PRESC_256, |
| 29 | &systimer_base->timer0control); |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 30 | |
Rob Herring | 73089ad | 2011-10-24 08:50:20 +0000 | [diff] [blame] | 31 | return 0; |
| 32 | |
| 33 | } |