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