2 * Copyright (C) 2012-2014 Panasonic Corporation
3 * Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/arch/arm-mpcore.h>
12 #define PERIPHCLK (50 * 1000 * 1000) /* 50 MHz */
13 #define PRESCALER ((PERIPHCLK) / (CONFIG_SYS_TIMER_RATE) - 1)
15 static void *get_global_timer_base(void)
19 asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (val) : : "memory");
21 return val + GLOBAL_TIMER_OFFSET;
24 unsigned long timer_read_counter(void)
27 * ARM 64bit Global Timer is too much for our purpose.
28 * We use only lower 32 bit of the timer counter.
30 return readl(get_global_timer_base() + GTIMER_CNT_L);
36 writel(PRESCALER << 8 | 1, get_global_timer_base() + GTIMER_CTRL);