blob: 99de5744c48f42491d92bb92daa6a8e01cef5a9c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00002/*
3 * Copyright (C) 2012 Altera Corporation <www.altera.com>
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00004 */
5
Tom Rinic77f48c2024-04-30 07:35:34 -06006#include <config.h>
Simon Glass97589732020-05-10 11:40:02 -06007#include <init.h>
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00008#include <asm/io.h>
9#include <asm/arch/timer.h>
10
Marek Vasut8fea4ae2014-09-08 14:08:45 +020011#define TIMER_LOAD_VAL 0xFFFFFFFF
12
Tom Rini6a5dccc2022-11-16 13:10:41 -050013static const struct socfpga_timer *timer_base = (void *)CFG_SYS_TIMERBASE;
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000014
15/*
16 * Timer initialization
17 */
18int 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}