summaryrefslogtreecommitdiff
path: root/packages/linux/linux-2.6.22+2.6.23-rc5/ts72xx/ep93xx-timer-accuracy.diff
diff options
context:
space:
mode:
Diffstat (limited to 'packages/linux/linux-2.6.22+2.6.23-rc5/ts72xx/ep93xx-timer-accuracy.diff')
-rw-r--r--packages/linux/linux-2.6.22+2.6.23-rc5/ts72xx/ep93xx-timer-accuracy.diff59
1 files changed, 59 insertions, 0 deletions
diff --git a/packages/linux/linux-2.6.22+2.6.23-rc5/ts72xx/ep93xx-timer-accuracy.diff b/packages/linux/linux-2.6.22+2.6.23-rc5/ts72xx/ep93xx-timer-accuracy.diff
new file mode 100644
index 0000000000..8a6de2e7da
--- /dev/null
+++ b/packages/linux/linux-2.6.22+2.6.23-rc5/ts72xx/ep93xx-timer-accuracy.diff
@@ -0,0 +1,59 @@
+
+The ep93xx has a weird timer tick base (983.04 kHz.) This experimental
+patch tries to increase time of day accuracy by keeping the number of
+ticks until the next jiffy in a fractional value representation.
+
+Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
+
+Index: linux-2.6.23-rc5/arch/arm/mach-ep93xx/core.c
+===================================================================
+--- linux-2.6.23-rc5.orig/arch/arm/mach-ep93xx/core.c 2007-09-04 02:26:38.000000000 +0200
++++ linux-2.6.23-rc5/arch/arm/mach-ep93xx/core.c 2007-09-04 02:26:48.000000000 +0200
+@@ -94,19 +94,32 @@
+ * track of lost jiffies.
+ */
+ static unsigned int last_jiffy_time;
++static unsigned int next_jiffy_time;
++static unsigned int accumulator;
+
+-#define TIMER4_TICKS_PER_JIFFY ((CLOCK_TICK_RATE + (HZ/2)) / HZ)
++#define TIMER4_TICKS_PER_JIFFY (983040 / HZ)
++#define TIMER4_TICKS_MOD_JIFFY (983040 % HZ)
++
++static int after_eq(unsigned long a, unsigned long b)
++{
++ return ((signed long)(a - b)) >= 0;
++}
+
+ static int ep93xx_timer_interrupt(int irq, void *dev_id)
+ {
+ write_seqlock(&xtime_lock);
+
+ __raw_writel(1, EP93XX_TIMER1_CLEAR);
+- while ((signed long)
+- (__raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time)
+- >= TIMER4_TICKS_PER_JIFFY) {
+- last_jiffy_time += TIMER4_TICKS_PER_JIFFY;
++ while (after_eq(__raw_readl(EP93XX_TIMER4_VALUE_LOW), next_jiffy_time)) {
+ timer_tick();
++
++ last_jiffy_time = next_jiffy_time;
++ next_jiffy_time += TIMER4_TICKS_PER_JIFFY;
++ accumulator += TIMER4_TICKS_MOD_JIFFY;
++ if (accumulator >= HZ) {
++ next_jiffy_time++;
++ accumulator -= HZ;
++ }
+ }
+
+ write_sequnlock(&xtime_lock);
+Index: linux-2.6.23-rc5/include/asm-arm/arch-ep93xx/timex.h
+===================================================================
+--- linux-2.6.23-rc5.orig/include/asm-arm/arch-ep93xx/timex.h 2007-09-04 02:25:36.000000000 +0200
++++ linux-2.6.23-rc5/include/asm-arm/arch-ep93xx/timex.h 2007-09-04 02:26:48.000000000 +0200
+@@ -2,4 +2,4 @@
+ * linux/include/asm-arm/arch-ep93xx/timex.h
+ */
+
+-#define CLOCK_TICK_RATE 983040
++#define CLOCK_TICK_RATE (1000 * HZ)