diff options
author | Masahiro Yamada <yamada.m@jp.panasonic.com> | 2015-02-27 02:26:42 +0900 |
---|---|---|
committer | Masahiro Yamada <yamada.m@jp.panasonic.com> | 2015-03-01 00:01:56 +0900 |
commit | 4c425570214cac091d9bdcf840b936062fb8da12 (patch) | |
tree | a8a83c219c46dec073438df0c77031418c662b25 /arch/arm/mach-uniphier/timer.c | |
parent | 1606b34aa50804227806971dbb6b82ea0bf81f55 (diff) |
ARM: UniPhier: move SoC sources to mach-uniphier
Move
arch/arm/cpu/armv7/uniphier/* -> arch/arm/mach-uniphier/*
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Diffstat (limited to 'arch/arm/mach-uniphier/timer.c')
-rw-r--r-- | arch/arm/mach-uniphier/timer.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/arm/mach-uniphier/timer.c b/arch/arm/mach-uniphier/timer.c new file mode 100644 index 00000000000..6edc0842a91 --- /dev/null +++ b/arch/arm/mach-uniphier/timer.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2012-2014 Panasonic Corporation + * Author: Masahiro Yamada <yamada.m@jp.panasonic.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <asm/io.h> +#include <asm/arch/arm-mpcore.h> + +#define PERIPHCLK (50 * 1000 * 1000) /* 50 MHz */ +#define PRESCALER ((PERIPHCLK) / (CONFIG_SYS_TIMER_RATE) - 1) + +static void *get_global_timer_base(void) +{ + void *val; + + asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (val) : : "memory"); + + return val + GLOBAL_TIMER_OFFSET; +} + +unsigned long timer_read_counter(void) +{ + /* + * ARM 64bit Global Timer is too much for our purpose. + * We use only lower 32 bit of the timer counter. + */ + return readl(get_global_timer_base() + GTIMER_CNT_L); +} + +int timer_init(void) +{ + /* enable timer */ + writel(PRESCALER << 8 | 1, get_global_timer_base() + GTIMER_CTRL); + + return 0; +} |