summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-iop33x/time.c
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2006-09-18 23:10:26 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-09-25 10:25:36 +0100
commit3f7e5815f4b774270e6506962de37af85aa9c830 (patch)
tree7e4a2b0d6f8b9f1a21ba7a4eb8baf1a1ec04d4f9 /arch/arm/mach-iop33x/time.c
parent98954df6917cb8f7e65f4f0f79ed641112fcf6b6 (diff)
downloadblackbird-op-linux-3f7e5815f4b774270e6506962de37af85aa9c830.tar.gz
blackbird-op-linux-3f7e5815f4b774270e6506962de37af85aa9c830.zip
[ARM] 3817/1: iop3xx: split the iop3xx mach into iop32x and iop33x
Split the iop3xx mach type into iop32x and iop33x -- split the config symbols, and move the code in the mach-iop3xx directory to the mach-iop32x and mach-iop33x directories. Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-iop33x/time.c')
-rw-r--r--arch/arm/mach-iop33x/time.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/arch/arm/mach-iop33x/time.c b/arch/arm/mach-iop33x/time.c
new file mode 100644
index 000000000000..d839cd0d926e
--- /dev/null
+++ b/arch/arm/mach-iop33x/time.c
@@ -0,0 +1,106 @@
+/*
+ * arch/arm/mach-iop33x/time.c
+ *
+ * Timer code for IOP331 based systems
+ *
+ * Author: Dave Jiang <dave.jiang@intel.com>
+ *
+ * Copyright 2003 Intel Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/time.h>
+#include <linux/init.h>
+#include <linux/timex.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include <asm/mach/irq.h>
+#include <asm/mach/time.h>
+
+static inline unsigned long get_elapsed(void)
+{
+ return LATCH - *IOP331_TU_TCR0;
+}
+
+static unsigned long iop331_gettimeoffset(void)
+{
+ unsigned long elapsed, usec;
+ u32 tisr1, tisr2;
+
+ /*
+ * If an interrupt was pending before we read the timer,
+ * we've already wrapped. Factor this into the time.
+ * If an interrupt was pending after we read the timer,
+ * it may have wrapped between checking the interrupt
+ * status and reading the timer. Re-read the timer to
+ * be sure its value is after the wrap.
+ */
+
+ asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr1));
+ elapsed = get_elapsed();
+ asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr2));
+
+ if(tisr1 & 1)
+ elapsed += LATCH;
+ else if (tisr2 & 1)
+ elapsed = LATCH + get_elapsed();
+
+ /*
+ * Now convert them to usec.
+ */
+ usec = (unsigned long)(elapsed / (CLOCK_TICK_RATE/1000000));
+
+ return usec;
+}
+
+static irqreturn_t
+iop331_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ u32 tisr;
+
+ write_seqlock(&xtime_lock);
+
+ asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr));
+ tisr |= 1;
+ asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
+
+ timer_tick(regs);
+
+ write_sequnlock(&xtime_lock);
+ return IRQ_HANDLED;
+}
+
+static struct irqaction iop331_timer_irq = {
+ .name = "IOP331 Timer Tick",
+ .handler = iop331_timer_interrupt,
+ .flags = IRQF_DISABLED | IRQF_TIMER,
+};
+
+static void __init iop331_timer_init(void)
+{
+ u32 timer_ctl;
+
+ setup_irq(IRQ_IOP331_TIMER0, &iop331_timer_irq);
+
+ timer_ctl = IOP331_TMR_EN | IOP331_TMR_PRIVILEGED | IOP331_TMR_RELOAD |
+ IOP331_TMR_RATIO_1_1;
+
+ asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (LATCH));
+
+ asm volatile("mcr p6, 0, %0, c0, c1, 0" : : "r" (timer_ctl));
+
+}
+
+struct sys_timer iop331_timer = {
+ .init = iop331_timer_init,
+ .offset = iop331_gettimeoffset,
+};
OpenPOWER on IntegriCloud