blob: 32ec6f0ac0e2fecb5a6cea7deb0ee785daffbc74 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Rob Herring73089ad2011-10-24 08:50:20 +00002/*
3 * Copyright 2010-2011 Calxeda, Inc.
4 *
5 * Based on arm926ejs/mx27/timer.c
Rob Herring73089ad2011-10-24 08:50:20 +00006 */
7
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Rob Herring73089ad2011-10-24 08:50:20 +00009#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 Herring73089ad2011-10-24 08:50:20 +000014
Rob Herring73089ad2011-10-24 08:50:20 +000015static struct systimer *systimer_base = (struct systimer *)SYSTIMER_BASE;
16
17/*
18 * Start the timer
19 */
20int timer_init(void)
21{
22 /*
23 * Setup timer0
24 */
Rob Herringd7dadc72013-06-12 22:24:49 -050025 writel(0, &systimer_base->timer0control);
Rob Herring73089ad2011-10-24 08:50:20 +000026 writel(SYSTIMER_RELOAD, &systimer_base->timer0load);
27 writel(SYSTIMER_RELOAD, &systimer_base->timer0value);
Rob Herringd7dadc72013-06-12 22:24:49 -050028 writel(SYSTIMER_EN | SYSTIMER_32BIT | SYSTIMER_PRESC_256,
29 &systimer_base->timer0control);
Rob Herring73089ad2011-10-24 08:50:20 +000030
Rob Herring73089ad2011-10-24 08:50:20 +000031 return 0;
32
33}