Skip to contentSkip to conversation

ARM: mach-shmobile: introduce shmobile_setup_delay()

PATCH New Magnus Damm 1 participant 1 message Mar 7, 2012

Subsystems (4)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

PATCH 1/3 ARM: mach-shmobile: introduce shmobile_setup_delay()

From: Magnus Damm <[email protected]>

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.

---

 arch/arm/mach-shmobile/include/mach/common.h |    2 ++
 arch/arm/mach-shmobile/timer.c               |   17 +++++++++++++++++
 2 files changed, 19 insertions(+)
arch/arm/mach-shmobile/include/mach/common.h +2 -0
@@ -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);
 extern int shmobile_platform_cpu_kill(unsigned int cpu);
arch/arm/mach-shmobile/timer.c +17 -0
@@ -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)
 {
 	/*