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 #include <linux/bitops.h> 14 15 #define TIMER_LOAD_VAL 0xffffffff 16 17 static int init_done __attribute__((section(".data"))) = 0; 18 19 /* 20 * Timer initialization 21 */ timer_init(void)22int timer_init(void) 23 { 24 /* Only init the timer once */ 25 if (init_done) 26 return 0; 27 init_done = 1; 28 29 /* load value into timer */ 30 writel(TIMER_LOAD_VAL, MVEBU_TIMER_BASE + 0x10); 31 writel(TIMER_LOAD_VAL, MVEBU_TIMER_BASE + 0x14); 32 33 #if defined(CONFIG_ARCH_MVEBU) 34 /* On Armada XP / 38x ..., the 25MHz clock source needs to be enabled */ 35 setbits_le32(MVEBU_TIMER_BASE + 0x00, BIT(11)); 36 #endif 37 /* enable timer in auto reload mode */ 38 setbits_le32(MVEBU_TIMER_BASE + 0x00, 0x3); 39 40 return 0; 41 } 42