blob: df4fe7b07a513500c89cdcbf89a26df67010361e [file] [log] [blame]
From 4db83a8c2af822cc5ae76ea212c7a77b20a637b5 Mon Sep 17 00:00:00 2001
From: Magnus Damm <damm@opensource.se>
Date: Wed, 28 Mar 2012 19:22:30 +0900
Subject: ARM: mach-shmobile: Introduce shmobile_setup_delay()
Add the function shmobile_setup_delay() to let platforms
configure their maximum loops per jiffy delay. With this
jiffies calculation done the dependency on early timer
is removed.
In the future this allows us to assign timers
using the regular driver model via the device tree.
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
(cherry picked from commit 0f2c9f20e4e339de30cfd5613dfa9505e7b9c58b)
Conflicts:
arch/arm/mach-shmobile/include/mach/common.h
Signed-off-by: Simon Horman <horms@verge.net.au>
---
arch/arm/mach-shmobile/include/mach/common.h | 2 ++
arch/arm/mach-shmobile/timer.c | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index c77b3a1..bc3aa3e 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -3,6 +3,8 @@
extern void shmobile_earlytimer_init(void);
extern struct sys_timer shmobile_timer;
+extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
+ unsigned int mult, unsigned int div);
extern void shmobile_setup_console(void);
extern void shmobile_secondary_vector(void);
struct clk;
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index be1ad70..b323e3c 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -19,8 +19,25 @@
*
*/
#include <linux/platform_device.h>
+#include <linux/delay.h>
#include <asm/mach/time.h>
+void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz,
+ unsigned int mult, unsigned int div)
+{
+ /* calculate a worst-case loops-per-jiffy value
+ * based on maximum cpu core mhz setting and the
+ * __delay() implementation in arch/arm/lib/delay.S
+ *
+ * this will result in a longer delay than expected
+ * when the cpu core runs on lower frequencies.
+ */
+
+ unsigned int value = (1000000 * mult) / (HZ * div);
+
+ lpj_fine = max_cpu_core_mhz * value;
+}
+
static void __init shmobile_late_time_init(void)
{
/*
--
1.7.10.1.362.g242cab3