2009-06-20 09:01:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) Marvell International Ltd. and its affiliates
|
|
|
|
* Written-by: Prafulla Wadaskar <prafulla@marvell.com>
|
|
|
|
*
|
2015-10-22 10:36:31 +00:00
|
|
|
* Copyright (C) 2015 Stefan Roese <sr@denx.de>
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2009-06-20 09:01:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2011-10-18 14:41:42 +00:00
|
|
|
#include <asm/io.h>
|
2014-10-22 10:13:06 +00:00
|
|
|
#include <asm/arch/soc.h>
|
2009-06-20 09:01:53 +00:00
|
|
|
|
2011-01-20 22:56:39 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2015-10-22 10:36:31 +00:00
|
|
|
#define TIMER_LOAD_VAL 0xffffffff
|
2009-06-20 09:01:53 +00:00
|
|
|
|
2015-10-22 10:36:31 +00:00
|
|
|
static int init_done __attribute__((section(".data"))) = 0;
|
2009-06-20 09:01:53 +00:00
|
|
|
|
|
|
|
/*
|
2015-10-22 10:36:31 +00:00
|
|
|
* Timer initialization
|
2009-06-20 09:01:53 +00:00
|
|
|
*/
|
|
|
|
int timer_init(void)
|
|
|
|
{
|
2015-07-15 13:36:52 +00:00
|
|
|
/* Only init the timer once */
|
|
|
|
if (init_done)
|
|
|
|
return 0;
|
|
|
|
init_done = 1;
|
|
|
|
|
2009-06-20 09:01:53 +00:00
|
|
|
/* load value into timer */
|
2015-10-22 10:36:31 +00:00
|
|
|
writel(TIMER_LOAD_VAL, MVEBU_TIMER_BASE + 0x10);
|
|
|
|
writel(TIMER_LOAD_VAL, MVEBU_TIMER_BASE + 0x14);
|
2009-06-20 09:01:53 +00:00
|
|
|
|
2015-12-21 12:56:33 +00:00
|
|
|
#if defined(CONFIG_ARCH_MVEBU)
|
2015-10-22 10:36:31 +00:00
|
|
|
/* On Armada XP / 38x ..., the 25MHz clock source needs to be enabled */
|
|
|
|
setbits_le32(MVEBU_TIMER_BASE + 0x00, BIT(11));
|
|
|
|
#endif
|
2009-06-20 09:01:53 +00:00
|
|
|
/* enable timer in auto reload mode */
|
2015-10-22 10:36:31 +00:00
|
|
|
setbits_le32(MVEBU_TIMER_BASE + 0x00, 0x3);
|
2009-06-20 09:01:53 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|