blob: 2423a0e378555efbc0982f1cefc41588a6f0cbb5 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Rob Herring37fc0ed2011-10-24 08:50:20 +00002/*
3 * Copyright 2010-2011 Calxeda, Inc.
4 *
5 * Based on arm926ejs/mx27/timer.c
Rob Herring37fc0ed2011-10-24 08:50:20 +00006 */
7
8#include <common.h>
Simon Glass691d7192020-05-10 11:40:02 -06009#include <init.h>
Rob Herring37fc0ed2011-10-24 08:50:20 +000010#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 Herring37fc0ed2011-10-24 08:50:20 +000015
Rob Herring37fc0ed2011-10-24 08:50:20 +000016static struct systimer *systimer_base = (struct systimer *)SYSTIMER_BASE;
17
18/*
19 * Start the timer
20 */
21int timer_init(void)
22{
23 /*
24 * Setup timer0
25 */
Rob Herring714d1f52013-06-12 22:24:49 -050026 writel(0, &systimer_base->timer0control);
Rob Herring37fc0ed2011-10-24 08:50:20 +000027 writel(SYSTIMER_RELOAD, &systimer_base->timer0load);
28 writel(SYSTIMER_RELOAD, &systimer_base->timer0value);
Rob Herring714d1f52013-06-12 22:24:49 -050029 writel(SYSTIMER_EN | SYSTIMER_32BIT | SYSTIMER_PRESC_256,
30 &systimer_base->timer0control);
Rob Herring37fc0ed2011-10-24 08:50:20 +000031
Rob Herring37fc0ed2011-10-24 08:50:20 +000032 return 0;
33
34}