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