common: Drop init.h from common header
[oweals/u-boot.git] / arch / arm / mach-mvebu / timer.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) Marvell International Ltd. and its affiliates
4  * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
5  *
6  * Copyright (C) 2015 Stefan Roese <sr@denx.de>
7  */
8
9 #include <common.h>
10 #include <init.h>
11 #include <asm/io.h>
12 #include <asm/arch/soc.h>
13
14 #define TIMER_LOAD_VAL                  0xffffffff
15
16 static int init_done __attribute__((section(".data"))) = 0;
17
18 /*
19  * Timer initialization
20  */
21 int timer_init(void)
22 {
23         /* Only init the timer once */
24         if (init_done)
25                 return 0;
26         init_done = 1;
27
28         /* load value into timer */
29         writel(TIMER_LOAD_VAL, MVEBU_TIMER_BASE + 0x10);
30         writel(TIMER_LOAD_VAL, MVEBU_TIMER_BASE + 0x14);
31
32 #if defined(CONFIG_ARCH_MVEBU)
33         /* On Armada XP / 38x ..., the 25MHz clock source needs to be enabled */
34         setbits_le32(MVEBU_TIMER_BASE + 0x00, BIT(11));
35 #endif
36         /* enable timer in auto reload mode */
37         setbits_le32(MVEBU_TIMER_BASE + 0x00, 0x3);
38
39         return 0;
40 }