]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: EXYNOS4: Add support MCT PPI for EXYNOS4212
authorChanghwan Youn <chaos.youn@samsung.com>
Tue, 4 Oct 2011 08:02:58 +0000 (17:02 +0900)
committerKukjin Kim <kgene.kim@samsung.com>
Tue, 4 Oct 2011 09:35:00 +0000 (18:35 +0900)
This patch implements clock event timer using MCT PPI
and make EXYNOS4212 use MCT PPI instead of MCT SPI.

Signed-off-by: Changhwan Youn <chaos.youn@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
arch/arm/mach-exynos4/include/mach/entry-macro.S
arch/arm/mach-exynos4/include/mach/irqs.h
arch/arm/mach-exynos4/mct.c

index d7a1e281ce7a98f437b65da2f33328b1629b5458..61393dcf55597371173e7447dcd908759d0d5330 100644 (file)
                /* As above, this assumes that irqstat and base are preserved.. */
 
                .macro test_for_ltirq, irqnr, irqstat, base, tmp
+               bic     \irqnr, \irqstat, #0x1c00
+               mov     \tmp, #0
+               cmp     \irqnr, #28
+               moveq   \tmp, #1
+               streq   \irqstat, [\base, #GIC_CPU_EOI]
+               cmp     \tmp, #0
                .endm
index f8952f8f3757760029e7d95d077ed99cd6e119f4..2d3f6bcd9bc0fa44d8960198df38526d53d52144 100644 (file)
@@ -19,6 +19,8 @@
 
 #define IRQ_PPI(x)             S5P_IRQ(x+16)
 
+#define IRQ_MCT_LOCALTIMER     IRQ_PPI(12)
+
 /* SPI: Shared Peripheral Interrupt */
 
 #define IRQ_SPI(x)             S5P_IRQ(x+32)
index ddd86864fb8313846428ba75c3ef523ce0508f56..f43f3faa6495e8fc8a09b9b0afdd50730cc4d4c3 100644 (file)
 #include <linux/delay.h>
 #include <linux/percpu.h>
 
+#include <asm/hardware/gic.h>
+
+#include <plat/cpu.h>
+
 #include <mach/map.h>
+#include <mach/irqs.h>
 #include <mach/regs-mct.h>
 #include <asm/mach/time.h>
 
+enum {
+       MCT_INT_SPI,
+       MCT_INT_PPI
+};
+
 static unsigned long clk_cnt_per_tick;
 static unsigned long clk_rate;
+static unsigned int mct_int_type;
 
 struct mct_clock_event_device {
        struct clock_event_device *evt;
@@ -321,9 +332,8 @@ static inline void exynos4_tick_set_mode(enum clock_event_mode mode,
        }
 }
 
-static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
+static inline int exynos4_mct_tick_clear(struct mct_clock_event_device *mevt)
 {
-       struct mct_clock_event_device *mevt = dev_id;
        struct clock_event_device *evt = mevt->evt;
 
        /*
@@ -335,7 +345,20 @@ static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
                exynos4_mct_tick_stop(mevt);
 
        /* Clear the MCT tick interrupt */
-       exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET);
+       if (__raw_readl(mevt->base + MCT_L_INT_CSTAT_OFFSET) & 1) {
+               exynos4_mct_write(0x1, mevt->base + MCT_L_INT_CSTAT_OFFSET);
+               return 1;
+       } else {
+               return 0;
+       }
+}
+
+static irqreturn_t exynos4_mct_tick_isr(int irq, void *dev_id)
+{
+       struct mct_clock_event_device *mevt = dev_id;
+       struct clock_event_device *evt = mevt->evt;
+
+       exynos4_mct_tick_clear(mevt);
 
        evt->event_handler(evt);
 
@@ -384,13 +407,17 @@ static void exynos4_mct_tick_init(struct clock_event_device *evt)
 
        exynos4_mct_write(0x1, mct_tick[cpu].base + MCT_L_TCNTB_OFFSET);
 
-       if (cpu == 0) {
-               mct_tick0_event_irq.dev_id = &mct_tick[cpu];
-               setup_irq(IRQ_MCT_L0, &mct_tick0_event_irq);
+       if (mct_int_type == MCT_INT_SPI) {
+               if (cpu == 0) {
+                       mct_tick0_event_irq.dev_id = &mct_tick[cpu];
+                       setup_irq(IRQ_MCT_L0, &mct_tick0_event_irq);
+               } else {
+                       mct_tick1_event_irq.dev_id = &mct_tick[cpu];
+                       setup_irq(IRQ_MCT_L1, &mct_tick1_event_irq);
+                       irq_set_affinity(IRQ_MCT_L1, cpumask_of(1));
+               }
        } else {
-               mct_tick1_event_irq.dev_id = &mct_tick[cpu];
-               setup_irq(IRQ_MCT_L1, &mct_tick1_event_irq);
-               irq_set_affinity(IRQ_MCT_L1, cpumask_of(1));
+               gic_enable_ppi(IRQ_MCT_LOCALTIMER);
        }
 }
 
@@ -404,7 +431,10 @@ int __cpuinit local_timer_setup(struct clock_event_device *evt)
 
 int local_timer_ack(void)
 {
-       return 0;
+       unsigned int cpu = smp_processor_id();
+       struct mct_clock_event_device *mevt = &mct_tick[cpu];
+
+       return exynos4_mct_tick_clear(mevt);
 }
 
 #endif /* CONFIG_LOCAL_TIMERS */
@@ -419,6 +449,11 @@ static void __init exynos4_timer_resources(void)
 
 static void __init exynos4_timer_init(void)
 {
+       if (soc_is_exynos4210())
+               mct_int_type = MCT_INT_SPI;
+       else
+               mct_int_type = MCT_INT_PPI;
+
        exynos4_timer_resources();
        exynos4_clocksource_init();
        exynos4_clockevent_init();