VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / arch / arm / mach-epxa10db / time.c
index 0c8b9cf..7d72a43 100644 (file)
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
 
 #include <asm/hardware.h>
+#include <asm/system.h>
+#include <asm/leds.h>
 
+#include <asm/mach/time.h>
 
-extern int (*set_rtc)(void);
+#define TIMER00_TYPE (volatile unsigned int*)
+#include <asm/arch/timer00.h>
 
 static int epxa10db_set_rtc(void)
 {
@@ -29,3 +35,39 @@ static int epxa10db_rtc_init(void)
 }
 
 __initcall(epxa10db_rtc_init);
+
+
+/*
+ * IRQ handler for the timer
+ */
+static irqreturn_t
+epxa10db_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+
+       // ...clear the interrupt
+       *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))|=TIMER0_CR_CI_MSK;
+
+       timer_tick(regs);
+
+       return IRQ_HANDLED;
+}
+
+static struct irqaction epxa10db_timer_irq = {
+       .name           = "Excalibur Timer Tick",
+       .flags          = SA_INTERRUPT,
+       .handler        = epxa10db_timer_interrupt
+};
+
+/*
+ * Set up timer interrupt, and return the current time in seconds.
+ */
+void __init epxa10db_init_time(void)
+{
+       /* Start the timer */
+       *TIMER0_LIMIT(IO_ADDRESS(EXC_TIMER00_BASE))=(unsigned int)(EXC_AHB2_CLK_FREQUENCY/200);
+       *TIMER0_PRESCALE(IO_ADDRESS(EXC_TIMER00_BASE))=1;
+       *TIMER0_CR(IO_ADDRESS(EXC_TIMER00_BASE))=TIMER0_CR_IE_MSK | TIMER0_CR_S_MSK;
+
+       setup_irq(IRQ_TIMER0, &epxa10db_timer_irq);
+}
+