ARM: plat-versatile: convert to twd_local_timer_register() interface
authorMarc Zyngier <marc.zyngier@arm.com>
Thu, 4 Aug 2011 10:57:04 +0000 (11:57 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Tue, 13 Mar 2012 13:29:58 +0000 (13:29 +0000)
Add support for the new smp_twd runtime registration interface
to the RealView/VE platforms, and remove the old compile-time support.
Tested on EB11MP.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm/mach-realview/realview_eb.c
arch/arm/mach-realview/realview_pb11mp.c
arch/arm/mach-realview/realview_pbx.c
arch/arm/mach-vexpress/ct-ca9x4.c
arch/arm/plat-versatile/Makefile
arch/arm/plat-versatile/localtimer.c [deleted file]

index 9578145..a2e9590 100644 (file)
@@ -36,7 +36,7 @@
 #include <asm/pgtable.h>
 #include <asm/hardware/gic.h>
 #include <asm/hardware/cache-l2x0.h>
-#include <asm/localtimer.h>
+#include <asm/smp_twd.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -383,6 +383,23 @@ static void realview_eb11mp_fixup(void)
        realview_eb_isp1761_resources[1].end    = IRQ_EB11MP_USB;
 }
 
+#ifdef CONFIG_HAVE_ARM_TWD
+static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
+                             REALVIEW_EB11MP_TWD_BASE,
+                             IRQ_LOCALTIMER);
+
+static void __init realview_eb_twd_init(void)
+{
+       if (core_tile_eb11mp() || core_tile_a9mp()) {
+               int err = twd_local_timer_register(&twd_local_timer);
+               if (err)
+                       pr_err("twd_local_timer_register failed %d\n", err);
+       }
+}
+#else
+#define realview_eb_twd_init() do { } while(0)
+#endif
+
 static void __init realview_eb_timer_init(void)
 {
        unsigned int timer_irq;
@@ -392,15 +409,13 @@ static void __init realview_eb_timer_init(void)
        timer2_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE);
        timer3_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE) + 0x20;
 
-       if (core_tile_eb11mp() || core_tile_a9mp()) {
-#ifdef CONFIG_LOCAL_TIMERS
-               twd_base = __io_address(REALVIEW_EB11MP_TWD_BASE);
-#endif
+       if (core_tile_eb11mp() || core_tile_a9mp())
                timer_irq = IRQ_EB11MP_TIMER0_1;
-       else
+       else
                timer_irq = IRQ_EB_TIMER0_1;
 
        realview_timer_init(timer_irq);
+       realview_eb_twd_init();
 }
 
 static struct sys_timer realview_eb_timer = {
index 2147335..3bea5bd 100644 (file)
@@ -36,7 +36,7 @@
 #include <asm/pgtable.h>
 #include <asm/hardware/gic.h>
 #include <asm/hardware/cache-l2x0.h>
-#include <asm/localtimer.h>
+#include <asm/smp_twd.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
@@ -290,6 +290,21 @@ static void __init gic_init_irq(void)
        gic_cascade_irq(1, IRQ_TC11MP_PB_IRQ1);
 }
 
+#ifdef CONFIG_HAVE_ARM_TWD
+static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
+                             REALVIEW_TC11MP_TWD_BASE,
+                             IRQ_LOCALTIMER);
+
+static void __init realview_pb11mp_twd_init(void)
+{
+       int err = twd_local_timer_register(&twd_local_timer);
+       if (err)
+               pr_err("twd_local_timer_register failed %d\n", err);
+}
+#else
+#define realview_pb11mp_twd_init()     do {} while(0)
+#endif
+
 static void __init realview_pb11mp_timer_init(void)
 {
        timer0_va_base = __io_address(REALVIEW_PB11MP_TIMER0_1_BASE);
@@ -297,10 +312,8 @@ static void __init realview_pb11mp_timer_init(void)
        timer2_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE);
        timer3_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE) + 0x20;
 
-#ifdef CONFIG_LOCAL_TIMERS
-       twd_base = __io_address(REALVIEW_TC11MP_TWD_BASE);
-#endif
        realview_timer_init(IRQ_TC11MP_TIMER0_1);
+       realview_pb11mp_twd_init();
 }
 
 static struct sys_timer realview_pb11mp_timer = {
index ac71564..6ddcc61 100644 (file)
@@ -298,6 +298,21 @@ static void __init gic_init_irq(void)
        }
 }
 
+#ifdef CONFIG_HAVE_ARM_TWD
+static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
+                             REALVIEW_PBX_TILE_TWD_BASE,
+                             IRQ_LOCALTIMER);
+
+static void __init realview_pbx_twd_init(void)
+{
+       int err = twd_local_timer_register(&twd_local_timer);
+       if (err)
+               pr_err("twd_local_timer_register failed %d\n", err);
+}
+#else
+#define realview_pbx_twd_init()        do { } while(0)
+#endif
+
 static void __init realview_pbx_timer_init(void)
 {
        timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE);
@@ -305,11 +320,8 @@ static void __init realview_pbx_timer_init(void)
        timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE);
        timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20;
 
-#ifdef CONFIG_LOCAL_TIMERS
-       if (core_tile_pbx11mp() || core_tile_pbxa9mp())
-               twd_base = __io_address(REALVIEW_PBX_TILE_TWD_BASE);
-#endif
        realview_timer_init(IRQ_PBX_TIMER0_1);
+       realview_pbx_twd_init();
 }
 
 static struct sys_timer realview_pbx_timer = {
index a2f7d5d..e5abe85 100644 (file)
@@ -42,15 +42,26 @@ static struct map_desc ct_ca9x4_io_desc[] __initdata = {
 static void __init ct_ca9x4_map_io(void)
 {
        iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
-#ifdef CONFIG_LOCAL_TIMERS
-       twd_base = ioremap(A9_MPCORE_TWD, SZ_32);
-#endif
 }
 
+#ifdef CONFIG_HAVE_ARM_TWD
+static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER);
+
+static void __init ca9x4_twd_init(void)
+{
+       int err = twd_local_timer_register(&twd_local_timer);
+       if (err)
+               pr_err("twd_local_timer_register failed %d\n", err);
+}
+#else
+#define ca9x4_twd_init()       do {} while(0)
+#endif
+
 static void __init ct_ca9x4_init_irq(void)
 {
        gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K),
                 ioremap(A9_MPCORE_GIC_CPU, SZ_256));
+       ca9x4_twd_init();
 }
 
 static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
index 69714db..a5cb194 100644 (file)
@@ -1,5 +1,4 @@
 obj-y  := clock.o
-obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
 obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o
 obj-$(CONFIG_PLAT_VERSATILE_FPGA_IRQ) += fpga-irq.o
 obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o
diff --git a/arch/arm/plat-versatile/localtimer.c b/arch/arm/plat-versatile/localtimer.c
deleted file mode 100644 (file)
index e156687..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  linux/arch/arm/plat-versatile/localtimer.c
- *
- *  Copyright (C) 2002 ARM Ltd.
- *  All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/init.h>
-#include <linux/smp.h>
-#include <linux/clockchips.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
-
-#include <asm/smp_twd.h>
-#include <asm/localtimer.h>
-#include <mach/irqs.h>
-
-const static struct of_device_id twd_of_match[] __initconst = {
-       { .compatible = "arm,cortex-a9-twd-timer",      },
-       { .compatible = "arm,cortex-a5-twd-timer",      },
-       { .compatible = "arm,arm11mp-twd-timer",        },
-       { },
-};
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)
-{
-#if defined(CONFIG_OF)
-       static int dt_node_probed;
-
-       /* Look for TWD node only once */
-       if (!dt_node_probed) {
-               struct device_node *node = of_find_matching_node(NULL,
-                               twd_of_match);
-
-               if (node)
-                       twd_base = of_iomap(node, 0);
-
-               dt_node_probed = 1;
-       }
-#endif
-       if (!twd_base)
-               return -ENXIO;
-
-       evt->irq = IRQ_LOCALTIMER;
-       twd_timer_setup(evt);
-       return 0;
-}