Skip to contentSkip to conversation

Consolidation: move SMP local timers to driver/clocksource

RFC PATCH New Marc Zyngier 10 participants 46 messages Jun 16, 2011 – Jun 27, 2011

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

The arch/arm tree contains several SMP local timer implementations (smp_twd, Exynos4 mct, and the msm timer, with more to come), and the word these days is that they should be moved to the driver directory.

Furthermore, the current core implementation makes it impossible to compile a kernel with several SMP local timer implementations, as the core code directly calls into the driver code.

This series moves these three drivers to driver/clocksource, with the following changes:
- They are converted to platform devices, and registered as early devices.
- CPU notifiers are used to start/stop the timers on secondary cores.

Each platform registers an early platform device with the associated resources (memory, interrupts). At the core level, an early device probe hook is installed, and binds devices and drivers if possible. The broadcast timer is always registered by the core code, and is used by the kernel if no other timer is available.

Small side effect on the mpcode_wdt watchdog driver, who used to share an include file with smp_twd, and now has a private copy of the definition of few registers it needs.

It should be relatively easy to move other (non SMP) timers/clocksources the same way, as it's already been done for shmobile. Furthermore, it is now straightforward to convert these platform devices to OF devices, and plug everything into the device tree.

Patches against next-20110615 + my earlier GIC-PPI series. Tested on VExpress, PB11MP, Pandaboard, Tegra Harmony and Exynos4 SMDK-v310.

Thomas and Arnd cc-ed on the whole series, as this could be consolidation material.

As always, comments welcome.

Marc Zyngier (16):
ARM: local timers: early device probing hooks
ARM: local timers: add arm_smp_twd driver to driver/clocksource
ARM: local timers: move realview to LOCAL_TIMER_DEVICES/ARM_SMP_TWD
ARM: local timers: move vexpress to LOCAL_TIMER_DEVICES/ARM_SMP_TWD
ARM: local timers: remove localtimer.c from plat-versatile
ARM: local timers: move Tegra to LOCAL_TIMER_DEVICES/ARM_SMP_TWD
ARM: local timers: move OMAP4 to LOCAL_TIMER_DEVICES/ARM_SMP_TWD
ARM: local timers: move shmobile to LOCAL_TIMER_DEVICES/ARM_SMP_TWD
ARM: local timers: move ux500 to LOCAL_TIMER_DEVICES/ARM_SMP_TWD
ARM: local timers: add exynos_mct driver to driver/clocksource
ARM: local timers: move exynos4 to
LOCAL_TIMER_DEVICES/EXYNOS_MCT/ARM_SMP_TWD
ARM: watchdog: make mpcore_wdt independant from asm/smp_twd.h
ARM: local timers: remove smp_twd from arch/arm
ARM: local timers: add msm_timer driver to driver/clocksource
ARM: local timers: move msm to LOCAL_TIMER_DEVICES/MSM_TIMER
ARM: local timers: remove local timer support from arch/arm

 arch/arm/Kconfig                         |   19 +--
 arch/arm/include/asm/localtimer.h        |   58 -----
 arch/arm/include/asm/mach/time.h         |    1 +
 arch/arm/include/asm/smp_twd.h           |   28 ---
 arch/arm/kernel/Makefile                 |    1 -
 arch/arm/kernel/smp.c                    |   70 ++-----
 arch/arm/kernel/smp_twd.c                |  163 --------------
 arch/arm/kernel/time.c                   |   15 ++
 arch/arm/mach-exynos4/Kconfig            |    2 +
 arch/arm/mach-exynos4/Makefile           |    1 -
 arch/arm/mach-exynos4/localtimer.c       |   27 ---
 arch/arm/mach-exynos4/mct.c              |  197 +----------------
 arch/arm/mach-exynos4/time.c             |   33 +++-
 arch/arm/mach-msm/Kconfig                |   10 +
 arch/arm/mach-msm/timer.c                |  290 +------------------------
 arch/arm/mach-omap2/Kconfig              |    3 +-
 arch/arm/mach-omap2/Makefile             |    1 -
 arch/arm/mach-omap2/timer-gp.c           |   40 +++-
 arch/arm/mach-omap2/timer-mpu.c          |   40 ----
 arch/arm/mach-realview/Kconfig           |    8 +
 arch/arm/mach-realview/realview_eb.c     |   31 +++-
 arch/arm/mach-realview/realview_pb11mp.c |   30 +++-
 arch/arm/mach-realview/realview_pbx.c    |   31 +++-
 arch/arm/mach-shmobile/Kconfig           |    2 +
 arch/arm/mach-shmobile/Makefile          |    1 -
 arch/arm/mach-shmobile/localtimer.c      |   27 ---
 arch/arm/mach-shmobile/platsmp.c         |    1 -
 arch/arm/mach-shmobile/setup-sh73a0.c    |   21 ++
 arch/arm/mach-shmobile/smp-sh73a0.c      |    6 -
 arch/arm/mach-shmobile/timer.c           |    2 +-
 arch/arm/mach-tegra/Kconfig              |    2 +
 arch/arm/mach-tegra/Makefile             |    2 +-
 arch/arm/mach-tegra/localtimer.c         |   27 ---
 arch/arm/mach-tegra/timer.c              |   32 +++-
 arch/arm/mach-ux500/Kconfig              |    2 +
 arch/arm/mach-ux500/Makefile             |    1 -
 arch/arm/mach-ux500/cpu-db5500.c         |    1 -
 arch/arm/mach-ux500/cpu-db8500.c         |    1 -
 arch/arm/mach-ux500/cpu.c                |   38 +++-
 arch/arm/mach-ux500/localtimer.c         |   30 ---
 arch/arm/mach-vexpress/Kconfig           |    2 +
 arch/arm/mach-vexpress/ct-ca9x4.c        |   30 +++-
 arch/arm/plat-s5p/s5p-time.c             |    1 -
 arch/arm/plat-versatile/Makefile         |    1 -
 arch/arm/plat-versatile/localtimer.c     |   28 ---
 drivers/clocksource/Kconfig              |    6 +
 drivers/clocksource/Makefile             |    3 +
 drivers/clocksource/arm_smp_twd.c        |  265 +++++++++++++++++++++++
 drivers/clocksource/exynos4_mct.c        |  283 ++++++++++++++++++++++++
 drivers/clocksource/msm_timer.c          |  345 ++++++++++++++++++++++++++++++
 drivers/watchdog/Kconfig                 |    2 +-
 drivers/watchdog/mpcore_wdt.c            |    7 +-
 52 files changed, 1239 insertions(+), 1029 deletions(-)
 delete mode 100644 arch/arm/include/asm/localtimer.h
 delete mode 100644 arch/arm/include/asm/smp_twd.h
 delete mode 100644 arch/arm/kernel/smp_twd.c
 delete mode 100644 arch/arm/mach-exynos4/localtimer.c
 delete mode 100644 arch/arm/mach-omap2/timer-mpu.c
 delete mode 100644 arch/arm/mach-shmobile/localtimer.c
 delete mode 100644 arch/arm/mach-tegra/localtimer.c
 delete mode 100644 arch/arm/mach-ux500/localtimer.c
 delete mode 100644 arch/arm/plat-versatile/localtimer.c
 create mode 100644 drivers/clocksource/arm_smp_twd.c
 create mode 100644 drivers/clocksource/exynos4_mct.c
 create mode 100644 drivers/clocksource/msm_timer.c
#1 lore raw

RFC PATCH 1/16 ARM: local timers: early device probing hooks

Introduce hooks to probe local timers registered as early devices. Use the late_time_init hook to perform the probing. Since shmobile is already using this hook, add an ARM specific arm_late_time_init hook that platforms can use instead.

This is controlled by a new config option (LOCAL_TIMER_DEVICES) which prevents LOCAL_TIMERS from being selected, as the two clearly conflict.

Cc Paul Mundt <[email protected]>
Cc Magnus Damm <[email protected]>
---
 arch/arm/Kconfig                 |    5 ++++-
 arch/arm/include/asm/mach/time.h |    1 +
 arch/arm/kernel/time.c           |   15 +++++++++++++++
 arch/arm/mach-shmobile/timer.c   |    2 +-
 4 files changed, 21 insertions(+), 2 deletions(-)
arch/arm/Kconfig +4 -1
index cdc89ed..dafb20a 100644
@@ -1415,7 +1415,7 @@ config HOTPLUG_CPU
 
 config LOCAL_TIMERS
 	bool "Use local timer interrupts"
-	depends on SMP
+	depends on SMP && !LOCAL_TIMER_DEVICES
 	default y
 	select HAVE_ARM_TWD if (!ARCH_MSM_SCORPIONMP && !EXYNOS4_MCT)
 	help
@@ -1424,6 +1424,9 @@ config LOCAL_TIMERS
 	  accounting to be spread across the timer interval, preventing a
 	  "thundering herd" at every timer tick.
 
+config LOCAL_TIMER_DEVICES
+	bool
+
 source kernel/Kconfig.preempt
 
 config HZ
arch/arm/include/asm/mach/time.h +1 -0
index d5adaae..f46ca39 100644
@@ -43,5 +43,6 @@ struct sys_timer {
 };
 
 extern void timer_tick(void);
+extern void (* __initdata arm_late_time_init)(void);
 
 #endif
arch/arm/kernel/time.c +15 -0
index cb634c3..32d0df8 100644
@@ -24,6 +24,7 @@
 #include <linux/syscore_ops.h>
 #include <linux/timer.h>
 #include <linux/irq.h>
+#include <linux/platform_device.h>
 
 #include <linux/mc146818rtc.h>
 
@@ -147,6 +148,19 @@ static int __init timer_init_syscore_ops(void)
 
 device_initcall(timer_init_syscore_ops);
 
+void (* __initdata arm_late_time_init)(void);
+
+static void __init __arm_late_time_init(void)
+{
+	if (arm_late_time_init)
+		arm_late_time_init();
+
+#ifdef CONFIG_LOCAL_TIMER_DEVICES
+	early_platform_driver_register_all("localtimer");
+	early_platform_driver_probe("localtimer", 1, 0);
+#endif
+}
+
 void __init time_init(void)
 {
 	system_timer = machine_desc->timer;
@@ -154,5 +168,6 @@ void __init time_init(void)
 #ifdef CONFIG_HAVE_SCHED_CLOCK
 	sched_clock_postinit();
 #endif
+	late_time_init = __arm_late_time_init;
 }
 
arch/arm/mach-shmobile/timer.c +1 -1
index 895794b..835baa4 100644
@@ -38,7 +38,7 @@ static void __init shmobile_late_time_init(void)
 
 static void __init shmobile_timer_init(void)
 {
-	late_time_init = shmobile_late_time_init;
+	arm_late_time_init = shmobile_late_time_init;
 }
 
 struct sys_timer shmobile_timer = {
Signature · 1 line
1.7.0.4
#2 lore raw

RFC PATCH 1/16 ARM: local timers: early device probing hooks

Quoted 10 lines · Marc Zyngier
arch/arm/kernel/time.c +6 -0
@@ -147,6 +148,19 @@ static int __init timer_init_syscore_ops(void)
 
 device_initcall(timer_init_syscore_ops);
 
+void (* __initdata arm_late_time_init)(void);
+
+static void __init __arm_late_time_init(void)
+{
+       if (arm_late_time_init)
+               arm_late_time_init();

arch/arm/kernel/time.c static int __init timer_init_syscore_ops(void) · line 166

Quoted 10 lines
arch/arm/kernel/time.c +7 -0
+
+#ifdef CONFIG_LOCAL_TIMER_DEVICES
+       early_platform_driver_register_all("localtimer");
+       early_platform_driver_probe("localtimer", 1, 0);
+#endif
+}
+
 void __init time_init(void)
 {
        system_timer = machine_desc->timer;

Instead of having two separate global pointers, should we make the ARM specific callback a machine_desc callback?

Arnd

#3 lore raw

RFC PATCH 1/16 ARM: local timers: early device probing hooks

Quoted 16 lines · Arnd Bergmann
Quoted 15 lines · Marc Zyngier
arch/arm/kernel/time.c +11 -0
@@ -147,6 +148,19 @@ static int __init timer_init_syscore_ops(void)
 
 device_initcall(timer_init_syscore_ops);
 
+void (* __initdata arm_late_time_init)(void);
+
+static void __init __arm_late_time_init(void)
+{
+       if (arm_late_time_init)
+               arm_late_time_init();
+
+#ifdef CONFIG_LOCAL_TIMER_DEVICES
+       early_platform_driver_register_all("localtimer");
+       early_platform_driver_probe("localtimer", 1, 0);
+#endif
Quoted 8 lines

arch/arm/kernel/time.c static int __init timer_init_syscore_ops(void) · line 166

Quoted 5 lines
arch/arm/kernel/time.c +2 -0
+}
+
 void __init time_init(void)
 {
        system_timer = machine_desc->timer;

Instead of having two separate global pointers, should we make the ARM specific callback a machine_desc callback?

Probably not. I only see this arm_late_time_init pointer as a temporary measure. The only user (shmobile) uses this hook to install its own early timers, and there is a patch floating around to move that code to time.c. Unless we have other uses for such a callback, of course.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#4 lore raw

RFC PATCH 1/16 ARM: local timers: early device probing hooks

Quoted 8 lines · Marc Zyngier
Quoted 3 lines

Instead of having two separate global pointers, should we make the ARM specific callback a machine_desc callback?

Probably not. I only see this arm_late_time_init pointer as a temporary measure. The only user (shmobile) uses this hook to install its own early timers, and there is a patch floating around to move that code to time.c. Unless we have other uses for such a callback, of course.

Ok, fair enough.

Arnd

#5 lore raw

RFC PATCH 2/16 ARM: local timers: add arm_smp_twd driver to driver/clocksource

In reply to Marc Zyngier

Add a "new" driver to driver/clocksource to support the ARM TWD hardware. This is basically a copy of arch/arm/kernel/smp_twd.c, turned into a platform driver, with a CPU notifier being used to start/stop timers on secondary cores.

---
 drivers/clocksource/Kconfig       |    3 +
 drivers/clocksource/Makefile      |    1 +
 drivers/clocksource/arm_smp_twd.c |  265 +++++++++++++++++++++++++++++++++++++
 3 files changed, 269 insertions(+), 0 deletions(-)
 create mode 100644 drivers/clocksource/arm_smp_twd.c
drivers/clocksource/Kconfig +3 -0
index 330343b..a436dd4 100644
@@ -9,3 +9,6 @@ config CLKBLD_I8253
 
 config CLKSRC_MMIO
 	bool
+
+config ARM_SMP_TWD
+       bool
drivers/clocksource/Makefile +1 -0
index 7922a0c..b7e6397 100644
@@ -8,3 +8,4 @@ obj-$(CONFIG_SH_TIMER_MTU2)	+= sh_mtu2.o
 obj-$(CONFIG_SH_TIMER_TMU)	+= sh_tmu.o
 obj-$(CONFIG_CLKBLD_I8253)	+= i8253.o
 obj-$(CONFIG_CLKSRC_MMIO)	+= mmio.o
+obj-$(CONFIG_ARM_SMP_TWD)	+= arm_smp_twd.o
drivers/clocksource/arm_smp_twd.c new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#6 lore raw

RFC PATCH 3/16 ARM: local timers: move realview to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

In reply to Marc Zyngier

Convert the RealView platforms to use the new arm_smp_twd driver. Add the platform devices and register them as early platform devices.

Tested on a PB11MP.

---
 arch/arm/mach-realview/Kconfig           |    8 +++++++
 arch/arm/mach-realview/realview_eb.c     |   31 ++++++++++++++++++++++++++---
 arch/arm/mach-realview/realview_pb11mp.c |   30 +++++++++++++++++++++++++---
 arch/arm/mach-realview/realview_pbx.c    |   31 +++++++++++++++++++++++++----
 4 files changed, 87 insertions(+), 13 deletions(-)
arch/arm/mach-realview/Kconfig +8 -0
index b9a9805..7eec270 100644
@@ -12,6 +12,8 @@ config REALVIEW_EB_A9MP
 	bool "Support Multicore Cortex-A9 Tile"
 	depends on MACH_REALVIEW_EB
 	select CPU_V7
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 	help
 	  Enable support for the Cortex-A9MPCore tile fitted to the
 	  Realview(R) Emulation Baseboard platform.
@@ -21,6 +23,8 @@ config REALVIEW_EB_ARM11MP
 	depends on MACH_REALVIEW_EB
 	select CPU_V6K
 	select ARCH_HAS_BARRIERS if SMP
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 	help
 	  Enable support for the ARM11MPCore tile fitted to the Realview(R)
 	  Emulation Baseboard platform.
@@ -40,6 +44,8 @@ config MACH_REALVIEW_PB11MP
 	select ARM_GIC
 	select HAVE_PATA_PLATFORM
 	select ARCH_HAS_BARRIERS if SMP
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 	help
 	  Include support for the ARM(R) RealView(R) Platform Baseboard for
 	  the ARM11MPCore.  This platform has an on-board ARM11MPCore and has
@@ -79,6 +85,8 @@ config MACH_REALVIEW_PBX
 	select HAVE_PATA_PLATFORM
 	select ARCH_SPARSEMEM_ENABLE if CPU_V7 && !REALVIEW_HIGH_PHYS_OFFSET
 	select ZONE_DMA if SPARSEMEM
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 	help
 	  Include support for the ARM(R) RealView(R) Platform Baseboard
 	  Explore.
arch/arm/mach-realview/realview_eb.c +27 -4
index 10e75fa..fbc941c 100644
@@ -36,7 +36,6 @@
 #include <asm/pgtable.h>
 #include <asm/hardware/gic.h>
 #include <asm/hardware/cache-l2x0.h>
-#include <asm/localtimer.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -330,6 +329,31 @@ static struct platform_device char_lcd_device = {
 	.resource	=	char_lcd_resources,
 };
 
+static struct resource eb_twd_resources[] = {
+	{
+		.start	= REALVIEW_EB11MP_TWD_BASE,
+		.end	= REALVIEW_EB11MP_TWD_BASE + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_LOCALTIMER,
+		.end	= IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device eb_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= eb_twd_resources,
+	.num_resources	= ARRAY_SIZE(eb_twd_resources),
+};
+
+static struct platform_device *eb_early_devices[] = {
+	&eb_twd_device,
+};
+
+
 static void __init gic_init_irq(void)
 {
 	if (core_tile_eb11mp() || core_tile_a9mp()) {
@@ -401,14 +425,13 @@ static void __init realview_eb_timer_init(void)
 	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
 		timer_irq = IRQ_EB11MP_TIMER0_1;
 	} else
 		timer_irq = IRQ_EB_TIMER0_1;
 
 	realview_timer_init(timer_irq);
+	early_platform_add_devices(eb_early_devices,
+				   ARRAY_SIZE(eb_early_devices));
 }
 
 static struct sys_timer realview_eb_timer = {
arch/arm/mach-realview/realview_pb11mp.c +26 -4
index b2985fc..9ed17c1 100644
@@ -36,7 +36,6 @@
 #include <asm/pgtable.h>
 #include <asm/hardware/gic.h>
 #include <asm/hardware/cache-l2x0.h>
-#include <asm/localtimer.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
@@ -276,6 +275,30 @@ static struct platform_device pmu_device = {
 	.resource		= pmu_resources,
 };
 
+static struct resource realview_pb11mp_twd_resources[] = {
+	{
+		.start	= REALVIEW_TC11MP_TWD_BASE,
+		.end	= REALVIEW_TC11MP_TWD_BASE + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_LOCALTIMER,
+		.end	= IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device realview_pb11mp_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= realview_pb11mp_twd_resources,
+	.num_resources	= ARRAY_SIZE(realview_pb11mp_twd_resources),
+};
+
+static struct platform_device *realview_pb11mp_early_devices[] = {
+	&realview_pb11mp_twd_device,
+};
+
 static void __init gic_init_irq(void)
 {
 	unsigned int pldctrl;
@@ -305,10 +328,9 @@ 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);
+	early_platform_add_devices(realview_pb11mp_early_devices,
+				   ARRAY_SIZE(realview_pb11mp_early_devices));
 }
 
 static struct sys_timer realview_pb11mp_timer = {
arch/arm/mach-realview/realview_pbx.c +26 -5
index 92ace2c..768faec 100644
@@ -31,7 +31,6 @@
 #include <asm/leds.h>
 #include <asm/mach-types.h>
 #include <asm/pmu.h>
-#include <asm/smp_twd.h>
 #include <asm/pgtable.h>
 #include <asm/hardware/gic.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -288,6 +287,30 @@ static struct platform_device pmu_device = {
 	.resource		= pmu_resources,
 };
 
+static struct resource realview_pbx_twd_resources[] = {
+	{
+		.start	= REALVIEW_PBX_TILE_TWD_BASE,
+		.end	= REALVIEW_PBX_TILE_TWD_BASE + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_LOCALTIMER,
+		.end	= IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device realview_pbx_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= realview_pbx_twd_resources,
+	.num_resources	= ARRAY_SIZE(realview_pbx_twd_resources),
+};
+
+static struct platform_device *realview_pbx_early_devices[] = {
+	&realview_pbx_twd_device,
+};
+
 static void __init gic_init_irq(void)
 {
 	/* ARM PBX on-board GIC */
@@ -308,11 +331,9 @@ 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);
+	early_platform_add_devices(realview_pbx_early_devices,
+				   ARRAY_SIZE(realview_pbx_early_devices));
 }
 
 static struct sys_timer realview_pbx_timer = {
Signature · 1 line
1.7.0.4
#7 lore raw

RFC PATCH 4/16 ARM: local timers: move vexpress to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

In reply to Marc Zyngier

Convert the vexpress platform (actually the CA9x4 tile) to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Tested on a VExpress.

---
 arch/arm/mach-vexpress/Kconfig    |    2 ++
 arch/arm/mach-vexpress/ct-ca9x4.c |   30 ++++++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
arch/arm/mach-vexpress/Kconfig +2 -0
index 6f59932..c26a5ec 100644
@@ -28,6 +28,8 @@ config ARCH_VEXPRESS_CA9X4
 	depends on VEXPRESS_ORIGINAL_MEMORY_MAP
 	select CPU_V7
 	select ARM_GIC
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 	select ARM_ERRATA_720789
 	select ARM_ERRATA_751472
 	select ARM_ERRATA_753970
arch/arm/mach-vexpress/ct-ca9x4.c +26 -4
index b06d056..4977e09 100644
@@ -15,7 +15,6 @@
 #include <asm/hardware/gic.h>
 #include <asm/pmu.h>
 #include <asm/smp_scu.h>
-#include <asm/smp_twd.h>
 
 #include <mach/ct-ca9x4.h>
 
@@ -49,11 +48,32 @@ static struct map_desc ct_ca9x4_io_desc[] __initdata = {
 	},
 };
 
+static struct resource ct_ca9x4_twd_resources[] = {
+	{
+		.start	= A9_MPCORE_TWD,
+		.end	= A9_MPCORE_TWD + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_LOCALTIMER,
+		.end	= IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device ct_ca9x4_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= ct_ca9x4_twd_resources,
+	.num_resources	= ARRAY_SIZE(ct_ca9x4_twd_resources),
+};
+
+static struct platform_device *ct_ca9x4_early_devices[] = {
+	&ct_ca9x4_twd_device,
+};
+
 static void __init ct_ca9x4_map_io(void)
 {
-#ifdef CONFIG_LOCAL_TIMERS
-	twd_base = MMIO_P2V(A9_MPCORE_TWD);
-#endif
 	iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
 }
 
@@ -192,6 +212,8 @@ static struct platform_device pmu_device = {
 static void __init ct_ca9x4_init_early(void)
 {
 	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
+	early_platform_add_devices(ct_ca9x4_early_devices,
+				   ARRAY_SIZE(ct_ca9x4_early_devices));
 }
 
 static void __init ct_ca9x4_init(void)
Signature · 1 line
1.7.0.4
#8 lore raw

RFC PATCH 5/16 ARM: local timers: remove localtimer.c from plat-versatile

In reply to Marc Zyngier

As the localtimer infrastructure is not use anymore by any of the Versatile platforms, remove localtimer.c.

---
 arch/arm/plat-versatile/Makefile     |    1 -
 arch/arm/plat-versatile/localtimer.c |   28 ----------------------------
 2 files changed, 0 insertions(+), 29 deletions(-)
 delete mode 100644 arch/arm/plat-versatile/localtimer.c
arch/arm/plat-versatile/Makefile +0 -1
index 69714db..a5cb194 100644
@@ -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
arch/arm/plat-versatile/localtimer.c deleted +0 -28
deleted file mode 100644
index a76daf4..0000000
@@ -1,28 +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 <asm/smp_twd.h>
-#include <asm/localtimer.h>
-#include <asm/hardware/gic.h>
-#include <mach/irqs.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)
-{
-	evt->irq = gic_ppi_to_vppi(IRQ_LOCALTIMER);
-	twd_timer_setup(evt);
-	return 0;
-}
Signature · 1 line
1.7.0.4
#9 lore raw

RFC PATCH 6/16 ARM: local timers: move Tegra to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

In reply to Marc Zyngier

Convert the Tegra platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Tested on a Harmony board.

Cc Colin Cross <[email protected]>
Cc Erik Gilling <[email protected]>
Cc Olof Johansson <[email protected]>
---
 arch/arm/mach-tegra/Kconfig      |    2 ++
 arch/arm/mach-tegra/Makefile     |    2 +-
 arch/arm/mach-tegra/localtimer.c |   27 ---------------------------
 arch/arm/mach-tegra/timer.c      |   32 +++++++++++++++++++++++++++-----
 4 files changed, 30 insertions(+), 33 deletions(-)
 delete mode 100644 arch/arm/mach-tegra/localtimer.c
arch/arm/mach-tegra/Kconfig +2 -0
index 5ec1846..4b05f02 100644
@@ -9,6 +9,8 @@ config ARCH_TEGRA_2x_SOC
 	bool "Tegra 2 family"
 	select CPU_V7
 	select ARM_GIC
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 	select ARCH_REQUIRE_GPIOLIB
 	select USB_ARCH_HAS_EHCI if USB_SUPPORT
 	select USB_ULPI if USB_SUPPORT
arch/arm/mach-tegra/Makefile +1 -1
index 823c703..efbddfc 100644
@@ -12,7 +12,7 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += clock.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)         += tegra2_clocks.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)		+= tegra2_emc.o
 obj-$(CONFIG_ARCH_TEGRA_2x_SOC)		+= pinmux-t2-tables.o
-obj-$(CONFIG_SMP)                       += platsmp.o localtimer.o headsmp.o
+obj-$(CONFIG_SMP)                       += platsmp.o headsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)               += hotplug.o
 obj-$(CONFIG_TEGRA_SYSTEM_DMA)		+= dma.o
 obj-$(CONFIG_CPU_FREQ)                  += cpu-tegra.o
arch/arm/mach-tegra/localtimer.c deleted +0 -27
deleted file mode 100644
index 97cd0a9..0000000
@@ -1,27 +0,0 @@
-/*
- *  arch/arm/mach-tegra/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 <asm/irq.h>
-#include <asm/smp_twd.h>
-#include <asm/localtimer.h>
-#include <asm/hardware/gic.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)
-{
-	evt->irq = gic_ppi_to_vppi(IRQ_LOCALTIMER);
-	twd_timer_setup(evt);
-	return 0;
-}
arch/arm/mach-tegra/timer.c +27 -5
index 9035042..4e1ecd0 100644
@@ -27,9 +27,9 @@
 #include <linux/clocksource.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/platform_device.h>
 
 #include <asm/mach/time.h>
-#include <asm/localtimer.h>
 #include <asm/sched_clock.h>
 
 #include <mach/iomap.h>
@@ -179,6 +179,30 @@ static struct irqaction tegra_timer_irq = {
 	.irq		= INT_TMR3,
 };
 
+static struct resource tegra_twd_resources[] = {
+	{
+		.start	= TEGRA_ARM_PERIF_BASE + 0x600,
+		.end	= TEGRA_ARM_PERIF_BASE + 0x600 + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_LOCALTIMER,
+		.end	= IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device tegra_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= tegra_twd_resources,
+	.num_resources	= ARRAY_SIZE(tegra_twd_resources),
+};
+
+static struct platform_device *tegra_early_devices[] = {
+	&tegra_twd_device,
+};
+
 static void __init tegra_init_timer(void)
 {
 	struct clk *clk;
@@ -197,10 +221,6 @@ static void __init tegra_init_timer(void)
 	BUG_ON(IS_ERR(clk));
 	clk_enable(clk);
 
-#ifdef CONFIG_HAVE_ARM_TWD
-	twd_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x600);
-#endif
-
 	switch (rate) {
 	case 12000000:
 		timer_writel(0x000b, TIMERUS_USEC_CFG);
@@ -241,6 +261,8 @@ static void __init tegra_init_timer(void)
 	tegra_clockevent.cpumask = cpu_all_mask;
 	tegra_clockevent.irq = tegra_timer_irq.irq;
 	clockevents_register_device(&tegra_clockevent);
+	early_platform_add_devices(tegra_early_devices,
+				   ARRAY_SIZE(tegra_early_devices));
 }
 
 struct sys_timer tegra_timer = {
Signature · 1 line
1.7.0.4
#10 lore raw

RFC PATCH 6/16 ARM: local timers: move Tegra to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

Marc Zyngier wrote at Thursday, June 16, 2011 1:07 PM:

Quoted 2 lines

Convert the Tegra platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

...

Quoted 4 lines
arch/arm/mach-tegra/timer.c +0 -0
index 9035042..4e1ecd0 100644

...

arch/arm/mach-tegra/timer.c static struct irqaction tegra_timer_irq = { · line 204

Quoted 3 lines
arch/arm/mach-tegra/timer.c +3 -0
+static struct platform_device *tegra_early_devices[] = {
+	&tegra_twd_device,
+};

In the cases where the timer device is registered within a timer-specific file, as here, and hence is likely the only device to be registered, does it make sense to elide the platform_device array above, and ...

...

arch/arm/mach-tegra/timer.c static void __init tegra_init_timer(void) · line 266

Quoted 7 lines
arch/arm/mach-tegra/timer.c +2 -0
@@ -241,6 +261,8 @@ static void __init tegra_init_timer(void)
 	tegra_clockevent.cpumask = cpu_all_mask;
 	tegra_clockevent.irq = tegra_timer_irq.irq;
 	clockevents_register_device(&tegra_clockevent);
+	early_platform_add_devices(tegra_early_devices,
+				   ARRAY_SIZE(tegra_early_devices));
 }

... and just refer to the single device directly here:

early_platform_add_devices(&tegra_twd_device, 1);

?

Or, is there likelihood that more devices would have to be added to that array in the near future, or that such a change would make moving the registration somewhere common later more complex?

Signature · 1 line
nvpublic
#11 lore raw

RFC PATCH 6/16 ARM: local timers: move Tegra to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

Quoted 30 lines · Stephen Warren

Marc Zyngier wrote at Thursday, June 16, 2011 1:07 PM:

Quoted 2 lines

Convert the Tegra platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

...

Quoted 4 lines
arch/arm/mach-tegra/timer.c +0 -0
index 9035042..4e1ecd0 100644

...

arch/arm/mach-tegra/timer.c static struct irqaction tegra_timer_irq = { · line 204

Quoted 3 lines
arch/arm/mach-tegra/timer.c +3 -0
+static struct platform_device *tegra_early_devices[] = {
+	&tegra_twd_device,
+};

In the cases where the timer device is registered within a timer-specific file, as here, and hence is likely the only device to be registered, does it make sense to elide the platform_device array above, and ...

...

arch/arm/mach-tegra/timer.c static void __init tegra_init_timer(void) · line 266

Quoted 7 lines
arch/arm/mach-tegra/timer.c +2 -0
@@ -241,6 +261,8 @@ static void __init tegra_init_timer(void)
 	tegra_clockevent.cpumask = cpu_all_mask;
 	tegra_clockevent.irq = tegra_timer_irq.irq;
 	clockevents_register_device(&tegra_clockevent);
+	early_platform_add_devices(tegra_early_devices,
+				   ARRAY_SIZE(tegra_early_devices));
 }

... and just refer to the single device directly here:

Quoted 3 lines

early_platform_add_devices(&tegra_twd_device, 1);

?

Unfortunately not. From include/linux/platform_device.h:
void early_platform_add_devices(struct platform_device **devs, int num);

There is no equivalent of platform_device_register() for early devices, so the array is mandatory.

Cheers,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#12 lore raw

RFC PATCH 7/16 ARM: local timers: move OMAP4 to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

In reply to Marc Zyngier

Convert the OMAP4 platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Tested on a Pandaboard.

Cc Tony Lindgren <[email protected]>
Cc Santosh Shilimkar <[email protected]>
---
 arch/arm/mach-omap2/Kconfig     |    3 +-
 arch/arm/mach-omap2/Makefile    |    1 -
 arch/arm/mach-omap2/timer-gp.c  |   40 ++++++++++++++++++++++++++++++++------
 arch/arm/mach-omap2/timer-mpu.c |   40 ---------------------------------------
 4 files changed, 35 insertions(+), 49 deletions(-)
 delete mode 100644 arch/arm/mach-omap2/timer-mpu.c
arch/arm/mach-omap2/Kconfig +2 -1
index 19d5891..805d7b9 100644
@@ -44,7 +44,8 @@ config ARCH_OMAP4
 	depends on ARCH_OMAP2PLUS
 	select CPU_V7
 	select ARM_GIC
-	select LOCAL_TIMERS if SMP
+	select LOCAL_TIMER_DEVICES if SMP
+	select ARM_SMP_TWD
 	select PL310_ERRATA_588369
 	select PL310_ERRATA_727915
 	select ARM_ERRATA_720789
arch/arm/mach-omap2/Makefile +0 -1
index b148077..f48c989 100644
@@ -22,7 +22,6 @@ obj-$(CONFIG_TWL4030_CORE) += omap_twl.o
 
 # SMP support ONLY available for OMAP4
 obj-$(CONFIG_SMP)			+= omap-smp.o omap-headsmp.o
-obj-$(CONFIG_LOCAL_TIMERS)		+= timer-mpu.o
 obj-$(CONFIG_HOTPLUG_CPU)		+= omap-hotplug.o
 obj-$(CONFIG_ARCH_OMAP4)		+= omap44xx-smc.o omap4-common.o
 
arch/arm/mach-omap2/timer-gp.c +33 -7
index 3b9cf85..f2f0db6 100644
@@ -35,10 +35,10 @@
 #include <linux/irq.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
+#include <linux/platform_device.h>
 
 #include <asm/mach/time.h>
 #include <plat/dmtimer.h>
-#include <asm/localtimer.h>
 #include <asm/sched_clock.h>
 #include <plat/common.h>
 #include <plat/omap_hwmod.h>
@@ -247,18 +247,44 @@ static void __init omap2_gp_clocksource_init(void)
 }
 #endif
 
+#ifdef CONFIG_ARM_SMP_TWD
+static struct resource omap2_gp_twd_resources[] = {
+	{
+		.start	= OMAP44XX_LOCAL_TWD_BASE,
+		.end	= OMAP44XX_LOCAL_TWD_BASE + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= OMAP44XX_IRQ_LOCALTIMER,
+		.end	= OMAP44XX_IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device omap2_gp_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= omap2_gp_twd_resources,
+	.num_resources	= ARRAY_SIZE(omap2_gp_twd_resources),
+};
+
+static struct platform_device *omap2_gp_early_devices[] = {
+	&omap2_gp_twd_device,
+};
+#endif
+
 static void __init omap2_gp_timer_init(void)
 {
-#ifdef CONFIG_LOCAL_TIMERS
-	if (cpu_is_omap44xx()) {
-		twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256);
-		BUG_ON(!twd_base);
-	}
-#endif
 	omap_dm_timer_init();
 
 	omap2_gp_clockevent_init();
 	omap2_gp_clocksource_init();
+#ifdef CONFIG_ARM_SMP_TWD
+	/* Local timers are not supprted on OMAP4430 ES1.0 */
+	if (omap_rev() != OMAP4430_REV_ES1_0)
+		early_platform_add_devices(omap2_gp_early_devices,
+					   ARRAY_SIZE(omap2_gp_early_devices));
+#endif
 }
 
 struct sys_timer omap_timer = {
arch/arm/mach-omap2/timer-mpu.c deleted +0 -40
deleted file mode 100644
index 1fd5ca5..0000000
@@ -1,40 +0,0 @@
-/*
- * The MPU local timer source file. In OMAP4, both cortex-a9 cores have
- * own timer in it's MPU domain. These timers will be driving the
- * linux kernel SMP tick framework when active. These timers are not
- * part of the wake up domain.
- *
- * Copyright (C) 2009 Texas Instruments, Inc.
- *
- * Author:
- *      Santosh Shilimkar <[email protected]>
- *
- * This file is based on arm realview smp platform file.
- * Copyright (C) 2002 ARM Ltd.
- *
- * 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 <asm/irq.h>
-#include <asm/smp_twd.h>
-#include <asm/localtimer.h>
-#include <asm/hardware/gic.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)
-{
-	/* Local timers are not supprted on OMAP4430 ES1.0 */
-	if (omap_rev() == OMAP4430_REV_ES1_0)
-		return -ENXIO;
-
-	evt->irq = gic_ppi_to_vppi(OMAP44XX_IRQ_LOCALTIMER);
-	twd_timer_setup(evt);
-	return 0;
-}
-
Signature · 1 line
1.7.0.4
#13 lore raw

RFC PATCH 7/16 ARM: local timers: move OMAP4 to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

Quoted 69 lines · Marc Zyngier

Convert the OMAP4 platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Tested on a Pandaboard.

Cc Tony Lindgren<[email protected]>
Cc Santosh Shilimkar<[email protected]>
---
  arch/arm/mach-omap2/Kconfig     |    3 +-
  arch/arm/mach-omap2/Makefile    |    1 -
  arch/arm/mach-omap2/timer-gp.c  |   40 ++++++++++++++++++++++++++++++++------
  arch/arm/mach-omap2/timer-mpu.c |   40 ---------------------------------------
  4 files changed, 35 insertions(+), 49 deletions(-)

delete mode 100644 arch/arm/mach-omap2/timer-mpu.c

arch/arm/mach-omap2/Kconfig +2 -1
index 19d5891..805d7b9 100644
@@ -44,7 +44,8 @@ config ARCH_OMAP4
  	depends on ARCH_OMAP2PLUS
  	select CPU_V7
  	select ARM_GIC
-	select LOCAL_TIMERS if SMP
+	select LOCAL_TIMER_DEVICES if SMP
+	select ARM_SMP_TWD
  	select PL310_ERRATA_588369
  	select PL310_ERRATA_727915
  	select ARM_ERRATA_720789
arch/arm/mach-omap2/Makefile +0 -1
index b148077..f48c989 100644
@@ -22,7 +22,6 @@ obj-$(CONFIG_TWL4030_CORE) += omap_twl.o
 
  # SMP support ONLY available for OMAP4
  obj-$(CONFIG_SMP)			+= omap-smp.o omap-headsmp.o
-obj-$(CONFIG_LOCAL_TIMERS)		+= timer-mpu.o
  obj-$(CONFIG_HOTPLUG_CPU)		+= omap-hotplug.o
  obj-$(CONFIG_ARCH_OMAP4)		+= omap44xx-smc.o omap4-common.o
 
arch/arm/mach-omap2/timer-gp.c +8 -1
index 3b9cf85..f2f0db6 100644
@@ -35,10 +35,10 @@
  #include<linux/irq.h>
  #include<linux/clocksource.h>
  #include<linux/clockchips.h>
+#include<linux/platform_device.h>
 
  #include<asm/mach/time.h>
  #include<plat/dmtimer.h>
-#include<asm/localtimer.h>
  #include<asm/sched_clock.h>
  #include<plat/common.h>
  #include<plat/omap_hwmod.h>
@@ -247,18 +247,44 @@ static void __init omap2_gp_clocksource_init(void)
  }
  #endif
 
+#ifdef CONFIG_ARM_SMP_TWD
+static struct resource omap2_gp_twd_resources[] = {
+	{
+		.start	= OMAP44XX_LOCAL_TWD_BASE,
+		.end	= OMAP44XX_LOCAL_TWD_BASE + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},

arch/arm/mach-omap2/timer-gp.c static void __init omap2_gp_clocksource_init(void) · line 266

Quoted 10 lines
arch/arm/mach-omap2/timer-gp.c +10 -0
+	{
+		.start	= OMAP44XX_IRQ_LOCALTIMER,
+		.end	= OMAP44XX_IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device omap2_gp_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,

Why is the id set to -1 ?

Quoted 19 lines
arch/arm/mach-omap2/timer-gp.c +9 -6
+	.resource	= omap2_gp_twd_resources,
+	.num_resources	= ARRAY_SIZE(omap2_gp_twd_resources),
+};
+
+static struct platform_device *omap2_gp_early_devices[] = {
+	&omap2_gp_twd_device,
+};
+#endif
+
  static void __init omap2_gp_timer_init(void)
  {
-#ifdef CONFIG_LOCAL_TIMERS
-	if (cpu_is_omap44xx()) {
-		twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256);
-		BUG_ON(!twd_base);
-	}
-#endif
  	omap_dm_timer_init();
 

arch/arm/mach-omap2/timer-gp.c static void __init omap2_gp_clocksource_init(void) · line 289

Quoted 10 lines
arch/arm/mach-omap2/timer-gp.c +6 -0
  	omap2_gp_clockevent_init();
  	omap2_gp_clocksource_init();
+#ifdef CONFIG_ARM_SMP_TWD
+	/* Local timers are not supprted on OMAP4430 ES1.0 */
+	if (omap_rev() != OMAP4430_REV_ES1_0)
+		early_platform_add_devices(omap2_gp_early_devices,
+					   ARRAY_SIZE(omap2_gp_early_devices));
+#endif
  }
 

These changes looks good.

Quoted 37 lines
arch/arm/mach-omap2/timer-gp.c +0 -0
  struct sys_timer omap_timer = {
arch/arm/mach-omap2/timer-mpu.c deleted +0 -30
deleted file mode 100644
index 1fd5ca5..0000000
@@ -1,40 +0,0 @@
-/*
- * The MPU local timer source file. In OMAP4, both cortex-a9 cores have
- * own timer in it's MPU domain. These timers will be driving the
- * linux kernel SMP tick framework when active. These timers are not
- * part of the wake up domain.
- *
- * Copyright (C) 2009 Texas Instruments, Inc.
- *
- * Author:
- *      Santosh Shilimkar<[email protected]>
- *
- * This file is based on arm realview smp platform file.
- * Copyright (C) 2002 ARM Ltd.
- *
- * 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<asm/irq.h>
-#include<asm/smp_twd.h>
-#include<asm/localtimer.h>
-#include<asm/hardware/gic.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)

arch/arm/mach-omap2/timer-mpu.c line 40

Quoted 10 lines
arch/arm/mach-omap2/timer-mpu.c deleted +0 -10
-{
-	/* Local timers are not supprted on OMAP4430 ES1.0 */
-	if (omap_rev() == OMAP4430_REV_ES1_0)
-		return -ENXIO;
-
-	evt->irq = gic_ppi_to_vppi(OMAP44XX_IRQ_LOCALTIMER);
-	twd_timer_setup(evt);
-	return 0;
-}
-

And this one is even better. -40 lines from arch/arm/*omap*/

I am fine with all changes except the id value. With that clarified,

Regards
Santosh

#14 lore raw

RFC PATCH 7/16 ARM: local timers: move OMAP4 to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

Hi Santosh,

Quoted 73 lines · Santosh Shilimkar
Quoted 72 lines · Marc Zyngier

Convert the OMAP4 platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Tested on a Pandaboard.

Cc Tony Lindgren<[email protected]>
Cc Santosh Shilimkar<[email protected]>
---
  arch/arm/mach-omap2/Kconfig     |    3 +-
  arch/arm/mach-omap2/Makefile    |    1 -
  arch/arm/mach-omap2/timer-gp.c  |   40 ++++++++++++++++++++++++++++++++------
  arch/arm/mach-omap2/timer-mpu.c |   40 ---------------------------------------
  4 files changed, 35 insertions(+), 49 deletions(-)

delete mode 100644 arch/arm/mach-omap2/timer-mpu.c

arch/arm/mach-omap2/Kconfig +2 -1
index 19d5891..805d7b9 100644
@@ -44,7 +44,8 @@ config ARCH_OMAP4
  	depends on ARCH_OMAP2PLUS
  	select CPU_V7
  	select ARM_GIC
-	select LOCAL_TIMERS if SMP
+	select LOCAL_TIMER_DEVICES if SMP
+	select ARM_SMP_TWD
  	select PL310_ERRATA_588369
  	select PL310_ERRATA_727915
  	select ARM_ERRATA_720789
arch/arm/mach-omap2/Makefile +0 -1
index b148077..f48c989 100644
@@ -22,7 +22,6 @@ obj-$(CONFIG_TWL4030_CORE) += omap_twl.o
 
  # SMP support ONLY available for OMAP4
  obj-$(CONFIG_SMP)			+= omap-smp.o omap-headsmp.o
-obj-$(CONFIG_LOCAL_TIMERS)		+= timer-mpu.o
  obj-$(CONFIG_HOTPLUG_CPU)		+= omap-hotplug.o
  obj-$(CONFIG_ARCH_OMAP4)		+= omap44xx-smc.o omap4-common.o
 
arch/arm/mach-omap2/timer-gp.c +11 -1
index 3b9cf85..f2f0db6 100644
@@ -35,10 +35,10 @@
  #include<linux/irq.h>
  #include<linux/clocksource.h>
  #include<linux/clockchips.h>
+#include<linux/platform_device.h>
 
  #include<asm/mach/time.h>
  #include<plat/dmtimer.h>
-#include<asm/localtimer.h>
  #include<asm/sched_clock.h>
  #include<plat/common.h>
  #include<plat/omap_hwmod.h>
@@ -247,18 +247,44 @@ static void __init omap2_gp_clocksource_init(void)
  }
  #endif
 
+#ifdef CONFIG_ARM_SMP_TWD
+static struct resource omap2_gp_twd_resources[] = {
+	{
+		.start	= OMAP44XX_LOCAL_TWD_BASE,
+		.end	= OMAP44XX_LOCAL_TWD_BASE + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= OMAP44XX_IRQ_LOCALTIMER,
+		.end	= OMAP44XX_IRQ_LOCALTIMER,
Quoted 8 lines

arch/arm/mach-omap2/timer-gp.c static void __init omap2_gp_clocksource_init(void) · line 266

Quoted 7 lines
arch/arm/mach-omap2/timer-gp.c +7 -0
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device omap2_gp_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,

Why is the id set to -1 ?

This is the normal way of indicating that there is only one such device in the system. The device ends being called "arm_smp_twd" instead of "arm_smp_twd.0". See Documentation/driver-model/platform.txt for details.

Quoted 80 lines
Quoted 19 lines
arch/arm/mach-omap2/timer-gp.c +9 -6
+	.resource	= omap2_gp_twd_resources,
+	.num_resources	= ARRAY_SIZE(omap2_gp_twd_resources),
+};
+
+static struct platform_device *omap2_gp_early_devices[] = {
+	&omap2_gp_twd_device,
+};
+#endif
+
  static void __init omap2_gp_timer_init(void)
  {
-#ifdef CONFIG_LOCAL_TIMERS
-	if (cpu_is_omap44xx()) {
-		twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256);
-		BUG_ON(!twd_base);
-	}
-#endif
  	omap_dm_timer_init();
 

arch/arm/mach-omap2/timer-gp.c static void __init omap2_gp_clocksource_init(void) · line 289

Quoted 10 lines
arch/arm/mach-omap2/timer-gp.c +6 -0
  	omap2_gp_clockevent_init();
  	omap2_gp_clocksource_init();
+#ifdef CONFIG_ARM_SMP_TWD
+	/* Local timers are not supprted on OMAP4430 ES1.0 */
+	if (omap_rev() != OMAP4430_REV_ES1_0)
+		early_platform_add_devices(omap2_gp_early_devices,
+					   ARRAY_SIZE(omap2_gp_early_devices));
+#endif
  }
 

These changes looks good.

Quoted 37 lines
arch/arm/mach-omap2/timer-gp.c +0 -0
  struct sys_timer omap_timer = {
arch/arm/mach-omap2/timer-mpu.c deleted +0 -30
deleted file mode 100644
index 1fd5ca5..0000000
@@ -1,40 +0,0 @@
-/*
- * The MPU local timer source file. In OMAP4, both cortex-a9 cores have
- * own timer in it's MPU domain. These timers will be driving the
- * linux kernel SMP tick framework when active. These timers are not
- * part of the wake up domain.
- *
- * Copyright (C) 2009 Texas Instruments, Inc.
- *
- * Author:
- *      Santosh Shilimkar<[email protected]>
- *
- * This file is based on arm realview smp platform file.
- * Copyright (C) 2002 ARM Ltd.
- *
- * 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<asm/irq.h>
-#include<asm/smp_twd.h>
-#include<asm/localtimer.h>
-#include<asm/hardware/gic.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)

arch/arm/mach-omap2/timer-mpu.c line 40

Quoted 10 lines
arch/arm/mach-omap2/timer-mpu.c deleted +0 -10
-{
-	/* Local timers are not supprted on OMAP4430 ES1.0 */
-	if (omap_rev() == OMAP4430_REV_ES1_0)
-		return -ENXIO;
-
-	evt->irq = gic_ppi_to_vppi(OMAP44XX_IRQ_LOCALTIMER);
-	twd_timer_setup(evt);
-	return 0;
-}
-

And this one is even better. -40 lines from arch/arm/*omap*/

Quoted 3 lines

I am fine with all changes except the id value. With that clarified,

Thanks for reviewing.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#15 lore raw

RFC PATCH 7/16 ARM: local timers: move OMAP4 to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

Quoted 85 lines · Marc Zyngier

Hi Santosh,

Quoted 73 lines · Santosh Shilimkar
Quoted 72 lines · Marc Zyngier

Convert the OMAP4 platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Tested on a Pandaboard.

Cc Tony Lindgren<[email protected]>
Cc Santosh Shilimkar<[email protected]>
---
   arch/arm/mach-omap2/Kconfig     |    3 +-
   arch/arm/mach-omap2/Makefile    |    1 -
   arch/arm/mach-omap2/timer-gp.c  |   40 ++++++++++++++++++++++++++++++++------
   arch/arm/mach-omap2/timer-mpu.c |   40 ---------------------------------------
   4 files changed, 35 insertions(+), 49 deletions(-)

delete mode 100644 arch/arm/mach-omap2/timer-mpu.c

arch/arm/mach-omap2/Kconfig +2 -1
index 19d5891..805d7b9 100644
@@ -44,7 +44,8 @@ config ARCH_OMAP4
   	depends on ARCH_OMAP2PLUS
   	select CPU_V7
   	select ARM_GIC
-	select LOCAL_TIMERS if SMP
+	select LOCAL_TIMER_DEVICES if SMP
+	select ARM_SMP_TWD
   	select PL310_ERRATA_588369
   	select PL310_ERRATA_727915
   	select ARM_ERRATA_720789
arch/arm/mach-omap2/Makefile +0 -1
index b148077..f48c989 100644
@@ -22,7 +22,6 @@ obj-$(CONFIG_TWL4030_CORE) += omap_twl.o
 
   # SMP support ONLY available for OMAP4
   obj-$(CONFIG_SMP)			+= omap-smp.o omap-headsmp.o
-obj-$(CONFIG_LOCAL_TIMERS)		+= timer-mpu.o
   obj-$(CONFIG_HOTPLUG_CPU)		+= omap-hotplug.o
   obj-$(CONFIG_ARCH_OMAP4)		+= omap44xx-smc.o omap4-common.o
 
arch/arm/mach-omap2/timer-gp.c +11 -1
index 3b9cf85..f2f0db6 100644
@@ -35,10 +35,10 @@
   #include<linux/irq.h>
   #include<linux/clocksource.h>
   #include<linux/clockchips.h>
+#include<linux/platform_device.h>
 
   #include<asm/mach/time.h>
   #include<plat/dmtimer.h>
-#include<asm/localtimer.h>
   #include<asm/sched_clock.h>
   #include<plat/common.h>
   #include<plat/omap_hwmod.h>
@@ -247,18 +247,44 @@ static void __init omap2_gp_clocksource_init(void)
   }
   #endif
 
+#ifdef CONFIG_ARM_SMP_TWD
+static struct resource omap2_gp_twd_resources[] = {
+	{
+		.start	= OMAP44XX_LOCAL_TWD_BASE,
+		.end	= OMAP44XX_LOCAL_TWD_BASE + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= OMAP44XX_IRQ_LOCALTIMER,
+		.end	= OMAP44XX_IRQ_LOCALTIMER,
Quoted 8 lines

arch/arm/mach-omap2/timer-gp.c static void __init omap2_gp_clocksource_init(void) · line 266

Quoted 7 lines
arch/arm/mach-omap2/timer-gp.c +7 -0
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device omap2_gp_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,

Why is the id set to -1 ?

Quoted 4 lines

This is the normal way of indicating that there is only one such device in the system. The device ends being called "arm_smp_twd" instead of "arm_smp_twd.0". See Documentation/driver-model/platform.txt for details.

Thanks. It's clear to me.

Regards
Santosh

#16 lore raw

RFC PATCH 8/16 ARM: local timers: move shmobile to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

In reply to Marc Zyngier

Convert the shmobile platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Cc Paul Mundt <[email protected]>
Cc Magnus Damm <[email protected]>
---
 arch/arm/mach-shmobile/Kconfig        |    2 ++
 arch/arm/mach-shmobile/Makefile       |    1 -
 arch/arm/mach-shmobile/localtimer.c   |   27 ---------------------------
 arch/arm/mach-shmobile/platsmp.c      |    1 -
 arch/arm/mach-shmobile/setup-sh73a0.c |   21 +++++++++++++++++++++
 arch/arm/mach-shmobile/smp-sh73a0.c   |    6 ------
 6 files changed, 23 insertions(+), 35 deletions(-)
 delete mode 100644 arch/arm/mach-shmobile/localtimer.c
arch/arm/mach-shmobile/Kconfig +2 -0
index 0c8f6cf..86befbc 100644
@@ -26,6 +26,8 @@ config ARCH_SH73A0
 	select SH_CLK_CPG
 	select ARCH_WANT_OPTIONAL_GPIOLIB
 	select ARM_GIC
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 
 comment "SH-Mobile Board Type"
 
arch/arm/mach-shmobile/Makefile +0 -1
index 612b270..82ec6e9 100644
@@ -14,7 +14,6 @@ obj-$(CONFIG_ARCH_SH73A0)	+= setup-sh73a0.o clock-sh73a0.o intc-sh73a0.o
 # SMP objects
 smp-y				:= platsmp.o headsmp.o
 smp-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
-smp-$(CONFIG_LOCAL_TIMERS)	+= localtimer.o
 smp-$(CONFIG_ARCH_SH73A0)	+= smp-sh73a0.o
 
 # Pinmux setup
arch/arm/mach-shmobile/localtimer.c deleted +0 -27
deleted file mode 100644
index 8a67b1c..0000000
@@ -1,27 +0,0 @@
-/*
- * SMP support for R-Mobile / SH-Mobile - local timer portion
- *
- * Copyright (C) 2010  Magnus Damm
- *
- * Based on vexpress, 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 <asm/smp_twd.h>
-#include <asm/localtimer.h>
-#include <asm/hardware/gic.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)
-{
-	evt->irq = gic_ppi_to_vppi(29);
-	twd_timer_setup(evt);
-	return 0;
-}
arch/arm/mach-shmobile/platsmp.c +0 -1
index f3888fe..5ac3b71 100644
@@ -17,7 +17,6 @@
 #include <linux/smp.h>
 #include <linux/io.h>
 #include <asm/hardware/gic.h>
-#include <asm/localtimer.h>
 #include <asm/mach-types.h>
 #include <mach/common.h>
 
arch/arm/mach-shmobile/setup-sh73a0.c +21 -0
index e46821c..8d26607 100644
@@ -630,6 +630,26 @@ static struct platform_device dma0_device = {
 	},
 };
 
+static struct resource twd_resources[] = {
+	{
+		.start	= 0xf0000600,
+		.end	= 0xf0000600 + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= 29,
+		.end	= 29,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= twd_resources,
+	.num_resources	= ARRAY_SIZE(twd_resources),
+};
+
 static struct platform_device *sh73a0_early_devices[] __initdata = {
 	&scif0_device,
 	&scif1_device,
@@ -643,6 +663,7 @@ static struct platform_device *sh73a0_early_devices[] __initdata = {
 	&cmt10_device,
 	&tmu00_device,
 	&tmu01_device,
+	&twd_device,
 };
 
 static struct platform_device *sh73a0_late_devices[] __initdata = {
arch/arm/mach-shmobile/smp-sh73a0.c +0 -6
index 3ffdbc9..d52c771 100644
@@ -24,7 +24,6 @@
 #include <linux/io.h>
 #include <mach/common.h>
 #include <asm/smp_scu.h>
-#include <asm/smp_twd.h>
 #include <asm/hardware/gic.h>
 
 #define WUPCR		0xe6151010
@@ -59,11 +58,6 @@ unsigned int __init sh73a0_get_core_count(void)
 {
 	void __iomem *scu_base = scu_base_addr();
 
-#ifdef CONFIG_HAVE_ARM_TWD
-	/* twd_base needs to be initialized before percpu_timer_setup() */
-	twd_base = (void __iomem *)0xf0000600;
-#endif
-
 	return scu_get_core_count(scu_base);
 }
 
Signature · 1 line
1.7.0.4
#17 lore raw

RFC PATCH 9/16 ARM: local timers: move ux500 to LOCAL_TIMER_DEVICES/ARM_SMP_TWD

In reply to Marc Zyngier

Convert the ux500 platforms to use the new arm_smp_twd driver. Add the platform device and register it as early platform device.

Cc Srinidhi Kasagar <[email protected]>
Cc Linus Walleij <[email protected]>
---
 arch/arm/mach-ux500/Kconfig      |    2 ++
 arch/arm/mach-ux500/Makefile     |    1 -
 arch/arm/mach-ux500/cpu-db5500.c |    1 -
 arch/arm/mach-ux500/cpu-db8500.c |    1 -
 arch/arm/mach-ux500/cpu.c        |   38 +++++++++++++++++++++++++++++++++-----
 arch/arm/mach-ux500/localtimer.c |   30 ------------------------------
 6 files changed, 35 insertions(+), 38 deletions(-)
 delete mode 100644 arch/arm/mach-ux500/localtimer.c
arch/arm/mach-ux500/Kconfig +2 -0
index 96d546c..aa21fc0 100644
@@ -5,6 +5,8 @@ config UX500_SOC_COMMON
 	default y
 	select ARM_GIC
 	select HAS_MTU
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD
 	select ARM_ERRATA_753970
 
 menu "Ux500 SoC"
arch/arm/mach-ux500/Makefile +0 -1
index 1694916..2e30a80 100644
@@ -14,7 +14,6 @@ obj-$(CONFIG_MACH_U8500)	+= board-mop500.o board-mop500-sdi.o \
 obj-$(CONFIG_MACH_U5500)	+= board-u5500.o board-u5500-sdi.o
 obj-$(CONFIG_SMP)		+= platsmp.o headsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
-obj-$(CONFIG_LOCAL_TIMERS)	+= localtimer.o
 obj-$(CONFIG_U5500_MODEM_IRQ)	+= modem-irq-db5500.o
 obj-$(CONFIG_U5500_MBOX)	+= mbox-db5500.o
 
arch/arm/mach-ux500/cpu-db5500.c +0 -1
index 22705d2..63eaa98 100644
@@ -33,7 +33,6 @@ static struct map_desc u5500_io_desc[] __initdata = {
 	__IO_DEV_DESC(U5500_GIC_CPU_BASE, SZ_4K),
 	__IO_DEV_DESC(U5500_GIC_DIST_BASE, SZ_4K),
 	__IO_DEV_DESC(U5500_L2CC_BASE, SZ_4K),
-	__IO_DEV_DESC(U5500_TWD_BASE, SZ_4K),
 	__IO_DEV_DESC(U5500_MTU0_BASE, SZ_4K),
 	__IO_DEV_DESC(U5500_SCU_BASE, SZ_4K),
 	__IO_DEV_DESC(U5500_BACKUPRAM0_BASE, SZ_8K),
arch/arm/mach-ux500/cpu-db8500.c +0 -1
index 4598b06..dfad7c8 100644
@@ -38,7 +38,6 @@ static struct map_desc u8500_io_desc[] __initdata = {
 	__IO_DEV_DESC(U8500_GIC_CPU_BASE, SZ_4K),
 	__IO_DEV_DESC(U8500_GIC_DIST_BASE, SZ_4K),
 	__IO_DEV_DESC(U8500_L2CC_BASE, SZ_4K),
-	__IO_DEV_DESC(U8500_TWD_BASE, SZ_4K),
 	__IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
 	__IO_DEV_DESC(U8500_SCU_BASE, SZ_4K),
 	__IO_DEV_DESC(U8500_BACKUPRAM0_BASE, SZ_8K),
arch/arm/mach-ux500/cpu.c +33 -5
index 1da23bb..1dac06f 100644
@@ -15,7 +15,6 @@
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/hardware/gic.h>
 #include <asm/mach/map.h>
-#include <asm/localtimer.h>
 
 #include <plat/mtu.h>
 #include <mach/hardware.h>
@@ -120,17 +119,44 @@ static int ux500_l2x0_init(void)
 early_initcall(ux500_l2x0_init);
 #endif
 
+static struct resource ux500_twd_resources[] = {
+	{
+		.start	= 0,
+		.end	= 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_LOCALTIMER,
+		.end	= IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device ux500_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= ux500_twd_resources,
+	.num_resources	= ARRAY_SIZE(ux500_twd_resources),
+};
+
+static struct platform_device *ux500_early_devices[] = {
+	&ux500_twd_device,
+};
+
 static void __init ux500_timer_init(void)
 {
-#ifdef CONFIG_LOCAL_TIMERS
+	unsigned long iobase = 0;
 	/* Setup the local timer base */
 	if (cpu_is_u5500())
-		twd_base = __io_address(U5500_TWD_BASE);
+		iobase = U5500_TWD_BASE;
 	else if (cpu_is_u8500())
-		twd_base = __io_address(U8500_TWD_BASE);
+		iobase = U8500_TWD_BASE;
 	else
 		ux500_unknown_soc();
-#endif
+
+	ux500_twd_resources[0].start += iobase;
+	ux500_twd_resources[0].end   += iobase;
+
 	if (cpu_is_u5500())
 		mtu_base = __io_address(U5500_MTU0_BASE);
 	else if (cpu_is_u8500ed())
@@ -141,6 +167,8 @@ static void __init ux500_timer_init(void)
 		ux500_unknown_soc();
 
 	nmdk_timer_init();
+	early_platform_add_devices(ux500_early_devices,
+				   ARRAY_SIZE(ux500_early_devices));
 }
 
 struct sys_timer ux500_timer = {
arch/arm/mach-ux500/localtimer.c deleted +0 -30
deleted file mode 100644
index f027cef..0000000
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2008-2009 ST-Ericsson
- * Srinidhi Kasagar <[email protected]>
- *
- * This file is heavily based on relaview platform, almost a copy.
- *
- * Copyright (C) 2002 ARM Ltd.
- *
- * 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 <asm/irq.h>
-#include <asm/smp_twd.h>
-#include <asm/localtimer.h>
-#include <asm/hardware/gic.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)
-{
-	evt->irq = gic_ppi_to_vppi(IRQ_LOCALTIMER);
-	twd_timer_setup(evt);
-	return 0;
-}
Signature · 1 line
1.7.0.4
#18 lore raw

RFC PATCH 10/16 ARM: local timers: add exynos_mct driver to driver/clocksource

In reply to Marc Zyngier

Add a "new" driver to driver/clocksource to support the Samsung MCT hardware. This is basically the local timer part of arch/arm/mach-exynos4/mct.c, turned into a platform driver, and with a CPU notifier being used to start/stop timers on secondary cores.

---
 drivers/clocksource/Makefile      |    1 +
 drivers/clocksource/exynos4_mct.c |  283 +++++++++++++++++++++++++++++++++++++
 2 files changed, 284 insertions(+), 0 deletions(-)
 create mode 100644 drivers/clocksource/exynos4_mct.c
drivers/clocksource/Makefile +1 -0
index b7e6397..7b30585 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_SH_TIMER_TMU)	+= sh_tmu.o
 obj-$(CONFIG_CLKBLD_I8253)	+= i8253.o
 obj-$(CONFIG_CLKSRC_MMIO)	+= mmio.o
 obj-$(CONFIG_ARM_SMP_TWD)	+= arm_smp_twd.o
+obj-$(CONFIG_EXYNOS4_MCT)	+= exynos4_mct.o
drivers/clocksource/exynos4_mct.c new file +283 -0

283 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#19 lore raw

RFC PATCH 10/16 ARM: local timers: add exynos_mct driver to driver/clocksource

Quoted 9 lines · Marc Zyngier

Add a "new" driver to driver/clocksource to support the Samsung MCT hardware. This is basically the local timer part of arch/arm/mach-exynos4/mct.c, turned into a platform driver, and with a CPU notifier being used to start/stop timers on secondary cores.

My feeling is that it would be nicer to do this as an atomic change together with the removal of the existing code, rather than two patches.

Arnd

#20 lore raw

RFC PATCH 10/16 ARM: local timers: add exynos_mct driver to driver/clocksource

Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Marc Zyngier

Add a "new" driver to driver/clocksource to support the Samsung MCT hardware. This is basically the local timer part of arch/arm/mach-exynos4/mct.c, turned into a platform driver, and with a CPU notifier being used to start/stop timers on secondary cores.

Quoted 5 lines
Quoted 2 lines

My feeling is that it would be nicer to do this as an atomic change together with the removal of the existing code, rather than two patches.

Happy either way.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#21 lore raw

RFC PATCH 11/16 ARM: local timers: move exynos4 to LOCAL_TIMER_DEVICES/EXYNOS_MCT/ARM_SMP_TWD

In reply to Marc Zyngier

Convert the exynos4 platforms to use the new arm_smp_twd or exynos4_mct drivers, depending on the configuration. arch/arm/mach-exynos4/mct.c takes a major hit in the process.

Add the platform devices and register them as early platform devices.

Tested on a SMDK-v310 with TWD only.

---
 arch/arm/mach-exynos4/Kconfig      |    2 +
 arch/arm/mach-exynos4/Makefile     |    1 -
 arch/arm/mach-exynos4/localtimer.c |   27 -----
 arch/arm/mach-exynos4/mct.c        |  197 ++---------------------------------
 arch/arm/mach-exynos4/time.c       |   33 +++++-
 arch/arm/plat-s5p/s5p-time.c       |    1 -
 6 files changed, 41 insertions(+), 220 deletions(-)
 delete mode 100644 arch/arm/mach-exynos4/localtimer.c
arch/arm/mach-exynos4/Kconfig +2 -0
index 1435fc3..0db7aa3 100644
@@ -12,6 +12,8 @@ if ARCH_EXYNOS4
 config CPU_EXYNOS4210
 	bool
 	select S3C_PL330_DMA
+	select LOCAL_TIMER_DEVICES
+	select ARM_SMP_TWD if !EXYNOS4_MCT
 	help
 	  Enable EXYNOS4210 CPU support
 
arch/arm/mach-exynos4/Makefile +0 -1
index 1366995..b223972 100644
@@ -23,7 +23,6 @@ ifeq ($(CONFIG_EXYNOS4_MCT),y)
 obj-y				+= mct.o
 else
 obj-y				+= time.o
-obj-$(CONFIG_LOCAL_TIMERS)	+= localtimer.o
 endif
 
 obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
arch/arm/mach-exynos4/localtimer.c deleted +0 -27
deleted file mode 100644
index 315de6f..0000000
@@ -1,27 +0,0 @@
-/* linux/arch/arm/mach-exynos4/localtimer.c
- *
- * Cloned from linux/arch/arm/mach-realview/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/clockchips.h>
-
-#include <asm/irq.h>
-#include <asm/localtimer.h>
-#include <asm/hardware/gic.h>
-
-/*
- * Setup the local clock events for a CPU.
- */
-int __cpuinit local_timer_setup(struct clock_event_device *evt)
-{
-	evt->irq = gic_ppi_to_vppi(IRQ_LOCALTIMER);
-	twd_timer_setup(evt);
-	return 0;
-}
arch/arm/mach-exynos4/mct.c +12 -185

238 lines not on this page · raw message

arch/arm/mach-exynos4/time.c +27 -6
index ebb8f38..be674d5 100644
@@ -19,8 +19,6 @@
 #include <linux/clockchips.h>
 #include <linux/platform_device.h>
 
-#include <asm/smp_twd.h>
-
 #include <mach/map.h>
 #include <plat/regs-timer.h>
 #include <asm/mach/time.h>
@@ -285,15 +283,38 @@ static void __init exynos4_timer_resources(void)
 	clk_enable(tin4);
 }
 
+static struct resource exynos4_twd_resources[] = {
+	{
+		.start	= EXYNOS4_PA_COREPERI + 0x600,
+		.end	= EXYNOS4_PA_COREPERI + 0x600 + 0x10,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_LOCALTIMER,
+		.end	= IRQ_LOCALTIMER,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device exynos4_twd_device = {
+	.name		= "arm_smp_twd",
+	.id		= -1,
+	.resource	= exynos4_twd_resources,
+	.num_resources	= ARRAY_SIZE(exynos4_twd_resources),
+};
+
+static struct platform_device *exynos4_early_devices[] = {
+	&exynos4_twd_device,
+};
+
 static void __init exynos4_timer_init(void)
 {
-#ifdef CONFIG_LOCAL_TIMERS
-	twd_base = S5P_VA_TWD;
-#endif
-
 	exynos4_timer_resources();
 	exynos4_clockevent_init();
 	exynos4_clocksource_init();
+
+	early_platform_add_devices(exynos4_early_devices,
+				   ARRAY_SIZE(exynos4_early_devices));
 }
 
 struct sys_timer exynos4_timer = {
arch/arm/plat-s5p/s5p-time.c +0 -1
index 899a8cc..f2a0915 100644
@@ -18,7 +18,6 @@
 #include <linux/clockchips.h>
 #include <linux/platform_device.h>
 
-#include <asm/smp_twd.h>
 #include <asm/mach/time.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
Signature · 1 line
1.7.0.4
#22 lore raw

RFC PATCH 12/16 ARM: watchdog: make mpcore_wdt independant from asm/smp_twd.h

In reply to Marc Zyngier

As the life expectancy of asm/smp_twd.h seems rather limited, move the few defines concerning mpcore_wdt to the driver itself.

Change the dependency to ARM_SMP_TWD as well.

Cc Wim Van Sebroeck <[email protected]>
---
 drivers/watchdog/Kconfig      |    2 +-
 drivers/watchdog/mpcore_wdt.c |    7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/watchdog/Kconfig +1 -1
index c70f82b..55647ac 100644
@@ -197,7 +197,7 @@ config DW_WATCHDOG
 
 config MPCORE_WATCHDOG
 	tristate "MPcore watchdog"
-	depends on HAVE_ARM_TWD
+	depends on ARM_SMP_TWD
 	help
 	  Watchdog timer embedded into the MPcore system.
 
drivers/watchdog/mpcore_wdt.c +6 -1
index 2b4af22..f638206 100644
@@ -33,7 +33,12 @@
 #include <linux/slab.h>
 #include <linux/io.h>
 
-#include <asm/smp_twd.h>
+#define TWD_WDOG_LOAD			0x20
+#define TWD_WDOG_COUNTER		0x24
+#define TWD_WDOG_CONTROL		0x28
+#define TWD_WDOG_INTSTAT		0x2C
+#define TWD_WDOG_RESETSTAT		0x30
+#define TWD_WDOG_DISABLE		0x34
 
 struct mpcore_wdt {
 	unsigned long	timer_alive;
Signature · 1 line
1.7.0.4
#23 lore raw

RFC PATCH 12/16 ARM: watchdog: make mpcore_wdt independant from asm/smp_twd.h

Hi Marc,

Quoted 7 lines

As the life expectancy of asm/smp_twd.h seems rather limited, move the few defines concerning mpcore_wdt to the driver itself.

Change the dependency to ARM_SMP_TWD as well.

Cc Wim Van Sebroeck <[email protected]>

I presume you Will keep this patch together with the other patches?

Kind regards,
Wim.

#24 lore raw

RFC PATCH 12/16 ARM: watchdog: make mpcore_wdt independant from asm/smp_twd.h

Quoted 5 lines · Wim Van Sebroeck

Hi Marc,

Quoted 3 lines

As the life expectancy of asm/smp_twd.h seems rather limited, move the few defines concerning mpcore_wdt to the driver itself.

Quoted 8 lines
Quoted 4 lines

Change the dependency to ARM_SMP_TWD as well.

Cc Wim Van Sebroeck <[email protected]>

I presume you Will keep this patch together with the other patches?

Most probably, though it is fairly independent from the whole series.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#25 lore raw

RFC PATCH 13/16 ARM: local timers: remove smp_twd from arch/arm

In reply to Marc Zyngier

There is no in-tree user of arch/arm/kernel/smp_twd.c, as they've been all converted to driver/clocksource/arm_smp_twd.c.

Shed a tear, and get rid of it.

---
 arch/arm/Kconfig                  |    8 --
 arch/arm/include/asm/localtimer.h |   10 ---
 arch/arm/include/asm/smp_twd.h    |   28 -------
 arch/arm/kernel/Makefile          |    1 -
 arch/arm/kernel/smp_twd.c         |  163 -------------------------------------
 5 files changed, 0 insertions(+), 210 deletions(-)
 delete mode 100644 arch/arm/include/asm/smp_twd.h
 delete mode 100644 arch/arm/kernel/smp_twd.c
arch/arm/Kconfig +0 -8
index dafb20a..f3c1124 100644
@@ -1370,13 +1370,6 @@ config HAVE_ARM_SCU
 	help
 	  This option enables support for the ARM system coherency unit
 
-config HAVE_ARM_TWD
-	bool
-	depends on SMP
-	select TICK_ONESHOT
-	help
-	  This options enables support for the ARM timer and watchdog unit
-
 choice
 	prompt "Memory split"
 	default VMSPLIT_3G
@@ -1417,7 +1410,6 @@ config LOCAL_TIMERS
 	bool "Use local timer interrupts"
 	depends on SMP && !LOCAL_TIMER_DEVICES
 	default y
-	select HAVE_ARM_TWD if (!ARCH_MSM_SCORPIONMP && !EXYNOS4_MCT)
 	help
 	  Enable support for local timers on SMP platforms, rather then the
 	  legacy IPI broadcast method.  Local timers allows the system
arch/arm/include/asm/localtimer.h +0 -10
index 5c8acb4..74af2cd 100644
@@ -26,22 +26,12 @@ irqreturn_t percpu_timer_handler(int irq, void *dev_id);
 
 #ifdef CONFIG_LOCAL_TIMERS
 
-#ifdef CONFIG_HAVE_ARM_TWD
-
-#include "smp_twd.h"
-
-#define local_timer_ack()	twd_timer_ack()
-
-#else
-
 /*
  * Platform provides this to acknowledge a local timer IRQ.
  * Returns true if the local timer IRQ is to be processed.
  */
 int local_timer_ack(void);
 
-#endif
-
 /*
  * Setup a local timer interrupt for a CPU.
  */
arch/arm/include/asm/smp_twd.h deleted +0 -28
deleted file mode 100644
index fed9981..0000000
@@ -1,28 +0,0 @@
-#ifndef __ASMARM_SMP_TWD_H
-#define __ASMARM_SMP_TWD_H
-
-#define TWD_TIMER_LOAD			0x00
-#define TWD_TIMER_COUNTER		0x04
-#define TWD_TIMER_CONTROL		0x08
-#define TWD_TIMER_INTSTAT		0x0C
-
-#define TWD_WDOG_LOAD			0x20
-#define TWD_WDOG_COUNTER		0x24
-#define TWD_WDOG_CONTROL		0x28
-#define TWD_WDOG_INTSTAT		0x2C
-#define TWD_WDOG_RESETSTAT		0x30
-#define TWD_WDOG_DISABLE		0x34
-
-#define TWD_TIMER_CONTROL_ENABLE	(1 << 0)
-#define TWD_TIMER_CONTROL_ONESHOT	(0 << 1)
-#define TWD_TIMER_CONTROL_PERIODIC	(1 << 1)
-#define TWD_TIMER_CONTROL_IT_ENABLE	(1 << 2)
-
-struct clock_event_device;
-
-extern void __iomem *twd_base;
-
-int twd_timer_ack(void);
-void twd_timer_setup(struct clock_event_device *);
-
-#endif
arch/arm/kernel/Makefile +0 -1
index a5b31af..c6c6d8b 100644
@@ -33,7 +33,6 @@ obj-$(CONFIG_PM_SLEEP)		+= sleep.o
 obj-$(CONFIG_HAVE_SCHED_CLOCK)	+= sched_clock.o
 obj-$(CONFIG_SMP)		+= smp.o smp_tlb.o
 obj-$(CONFIG_HAVE_ARM_SCU)	+= smp_scu.o
-obj-$(CONFIG_HAVE_ARM_TWD)	+= smp_twd.o
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
arch/arm/kernel/smp_twd.c deleted +0 -163

163 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#26 lore raw

RFC PATCH 14/16 ARM: local timers: add msm_timer driver to driver/clocksource

In reply to Marc Zyngier

Add a "new" driver to driver/clocksource to support the MSM timer hardware. This is basically a copy of arch/arm/mach-msm/timer.c turned into a platform driver, with a CPU notifier being used to start/stop the timer on secondary core.

Cc David Brown <[email protected]>
Cc Daniel Walker <[email protected]>
Cc Bryan Huntsman <[email protected]>
Cc Stephen Boyd <[email protected]>
---
 drivers/clocksource/Kconfig     |    3 +
 drivers/clocksource/Makefile    |    1 +
 drivers/clocksource/msm_timer.c |  345 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 349 insertions(+), 0 deletions(-)
 create mode 100644 drivers/clocksource/msm_timer.c
drivers/clocksource/Kconfig +3 -0
index a436dd4..c4cf8bc 100644
@@ -12,3 +12,6 @@ config CLKSRC_MMIO
 
 config ARM_SMP_TWD
        bool
+
+config MSM_TIMER
+       bool
drivers/clocksource/Makefile +1 -0
index 7b30585..ffb4186 100644
@@ -10,3 +10,4 @@ obj-$(CONFIG_CLKBLD_I8253)	+= i8253.o
 obj-$(CONFIG_CLKSRC_MMIO)	+= mmio.o
 obj-$(CONFIG_ARM_SMP_TWD)	+= arm_smp_twd.o
 obj-$(CONFIG_EXYNOS4_MCT)	+= exynos4_mct.o
+obj-$(CONFIG_MSM_TIMER)		+= msm_timer.o
drivers/clocksource/msm_timer.c new file +345 -0

345 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#27 lore raw

RFC PATCH 15/16 ARM: local timers: move msm to LOCAL_TIMER_DEVICES/MSM_TIMER

In reply to Marc Zyngier

Convert the MSM platforms to use the new msm_timer driver. Add the platform device and register it as early platform device. In the process, timer.c is reduced to... erm... not a lot.

Cc David Brown <[email protected]>
Cc Daniel Walker <[email protected]>
Cc Bryan Huntsman <[email protected]>
Cc Stephen Boyd <[email protected]>
---
 arch/arm/mach-msm/Kconfig |   10 ++
 arch/arm/mach-msm/timer.c |  290 ++-------------------------------------------
 2 files changed, 18 insertions(+), 282 deletions(-)
arch/arm/mach-msm/Kconfig +10 -0
index 1516896..65530ae 100644
@@ -13,6 +13,8 @@ config ARCH_MSM7X00A
 	select CPU_V6
 	select MSM_PROC_COMM
 	select HAS_MSM_DEBUG_UART_PHYS
+	select LOCAL_TIMER_DEVICES
+	select MSM_TIMER
 
 config ARCH_MSM7X30
 	bool "MSM7x30"
@@ -24,6 +26,8 @@ config ARCH_MSM7X30
 	select MSM_GPIOMUX
 	select MSM_PROC_COMM
 	select HAS_MSM_DEBUG_UART_PHYS
+	select LOCAL_TIMER_DEVICES
+	select MSM_TIMER
 
 config ARCH_QSD8X50
 	bool "QSD8X50"
@@ -35,6 +39,8 @@ config ARCH_QSD8X50
 	select MSM_GPIOMUX
 	select MSM_PROC_COMM
 	select HAS_MSM_DEBUG_UART_PHYS
+	select LOCAL_TIMER_DEVICES
+	select MSM_TIMER
 
 config ARCH_MSM8X60
 	bool "MSM8X60"
@@ -46,6 +52,8 @@ config ARCH_MSM8X60
 	select MSM_V2_TLMM
 	select MSM_GPIOMUX
 	select MSM_SCM if SMP
+	select LOCAL_TIMER_DEVICES
+	select MSM_TIMER
 
 config ARCH_MSM8960
 	bool "MSM8960"
@@ -56,6 +64,8 @@ config ARCH_MSM8960
 	select MSM_V2_TLMM
 	select MSM_GPIOMUX
 	select MSM_SCM if SMP
+	select LOCAL_TIMER_DEVICES
+	select MSM_TIMER
 
 endchoice
 
arch/arm/mach-msm/timer.c +8 -282

307 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#28 lore raw

RFC PATCH 16/16 ARM: local timers: remove local timer support from arch/arm

In reply to Marc Zyngier

Local timer support in arch/arm is now completely unused, as all in-tree platforms are using LOCAL_TIMER_DEVICES.

It allows us to simplify the code, only preserving the broadcast timer.

---
 arch/arm/Kconfig                  |   10 -----
 arch/arm/include/asm/localtimer.h |   48 -------------------------
 arch/arm/kernel/smp.c             |   70 +++++++-----------------------------
 3 files changed, 14 insertions(+), 114 deletions(-)
 delete mode 100644 arch/arm/include/asm/localtimer.h
arch/arm/Kconfig +0 -10
index f3c1124..3f4eecd 100644
@@ -1406,16 +1406,6 @@ config HOTPLUG_CPU
 	  Say Y here to experiment with turning CPUs off and on.  CPUs
 	  can be controlled through /sys/devices/system/cpu.
 
-config LOCAL_TIMERS
-	bool "Use local timer interrupts"
-	depends on SMP && !LOCAL_TIMER_DEVICES
-	default y
-	help
-	  Enable support for local timers on SMP platforms, rather then the
-	  legacy IPI broadcast method.  Local timers allows the system
-	  accounting to be spread across the timer interval, preventing a
-	  "thundering herd" at every timer tick.
-
 config LOCAL_TIMER_DEVICES
 	bool
 
arch/arm/include/asm/localtimer.h deleted +0 -48

48 lines not on this page · raw message

arch/arm/kernel/smp.c +14 -56

137 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#29 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

In reply to Marc Zyngier

Thanks for an excellent patch set Marc, take that as an Acked-by from me FWIW.

Quoted 2 lines · Marc Zyngier

Patches against next-20110615 + my earlier GIC-PPI series. Tested on VExpress, PB11MP, Pandaboard, Tegra Harmony and Exynos4 SMDK-v310.

This is making it hopeless for me to test on a plain -rc3 kernel, do you have a public git branch I can just pull in to get all this?

I would like to test on U8500 and also rebase Colins TWD CPUfreq patch on top of this so it can go in on top of the consolidations.

Thanks,
Linus Walleij

#30 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Hi Linus,

Quoted 7 lines · Linus Walleij

Thanks for an excellent patch set Marc, take that as an Acked-by from me FWIW.

Quoted 2 lines · Marc Zyngier

Patches against next-20110615 + my earlier GIC-PPI series. Tested on VExpress, PB11MP, Pandaboard, Tegra Harmony and Exynos4 SMDK-v310.

Quoted 6 lines

This is making it hopeless for me to test on a plain -rc3 kernel, do you have a public git branch I can just pull in to get all this?

I would like to test on U8500 and also rebase Colins TWD CPUfreq patch on top of this so it can go in on top of the consolidations.

I've created a new repository on git.kernel.org:
git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git
and rebased my stuff on top of -rc3 in the "local_timer_devices" branch. Tested on a PB11MP.

It may take some time for the mirrors to catch up...

Cheers,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#31 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 8 lines · Marc Zyngier

[Me]

Quoted 3 lines

I would like to test on U8500 and also rebase Colins TWD CPUfreq patch on top of this so it can go in on top of the consolidations.

I've created a new repository on git.kernel.org:
git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git
and rebased my stuff on top of -rc3 in the "local_timer_devices" branch.

I pulled it into my tree and booted on U8500, and it works like a charm. The GIC PPI stuff seems to be working too atleast from looking in /proc/interrupts:

689:        933          0   GIC-PPI  arm_smp_twd
692:          0        434   GIC-PPI  arm_smp_twd
IPI0:          0          0  Timer broadcast interrupts
IPI1:        586        695  Rescheduling interrupts
IPI2:          0          0  Function call interrupts
IPI3:          4          5  Single function call interrupts
IPI4:          0          0  CPU stop interrupts

So:

For the general stuff and the Ux500 patch.

Thanks,
Linus Walleij

#32 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

In reply to Marc Zyngier
Quoted 5 lines · Marc Zyngier

Patches against next-20110615 + my earlier GIC-PPI series. Tested on VExpress, PB11MP, Pandaboard, Tegra Harmony and Exynos4 SMDK-v310.

Thomas and Arnd cc-ed on the whole series, as this could be consolidation material.

Very nice stuff. Should we take this all in one branch in the arm-soc tree, pending Acks from the subarch maintainers?

We could also push it through the individual subarch branches, but my feeling is that would be more work.

Arnd

#33 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 4 lines · Arnd Bergmann
Quoted 3 lines · Marc Zyngier

Patches against next-20110615 + my earlier GIC-PPI series. Tested on VExpress, PB11MP, Pandaboard, Tegra Harmony and Exynos4 SMDK-v310.

Quoted 8 lines
Quoted 2 lines

Thomas and Arnd cc-ed on the whole series, as this could be consolidation material.

Very nice stuff. Should we take this all in one branch in the arm-soc tree, pending Acks from the subarch maintainers?

We could also push it through the individual subarch branches, but my feeling is that would be more work.

It seems far more work than it's worth, really. As long as the individual maintainers are happy with it, the single branch option seem nicer.

Cheers,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#34 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

In reply to Arnd Bergmann

Arnd,

Quoted 4 lines · Arnd Bergmann
Quoted 3 lines · Marc Zyngier

Patches against next-20110615 + my earlier GIC-PPI series. Tested on VExpress, PB11MP, Pandaboard, Tegra Harmony and Exynos4 SMDK-v310.

Quoted 9 lines
Quoted 2 lines

Thomas and Arnd cc-ed on the whole series, as this could be consolidation material.

Very nice stuff. Should we take this all in one branch in the arm-soc tree, pending Acks from the subarch maintainers?

We could also push it through the individual subarch branches, but my feeling is that would be more work.

If this is the direction to go, then there are a lot of other timers that can be moved besides just local timers. But Russell didn't really like the shmobile patches for early platform devices which this relies on. So we should get agreement on the small bit of infrastructure needed first, then start moving individual timers.

Also, device tree support for early platform devices would be useful for this.

Rob

#35 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 17 lines · Rob Herring

Arnd,

Quoted 4 lines · Arnd Bergmann
Quoted 3 lines · Marc Zyngier

Patches against next-20110615 + my earlier GIC-PPI series. Tested on VExpress, PB11MP, Pandaboard, Tegra Harmony and Exynos4 SMDK-v310.

Quoted 9 lines
Quoted 2 lines

Thomas and Arnd cc-ed on the whole series, as this could be consolidation material.

Very nice stuff. Should we take this all in one branch in the arm-soc tree, pending Acks from the subarch maintainers?

We could also push it through the individual subarch branches, but my feeling is that would be more work.

Quoted 5 lines

If this is the direction to go, then there are a lot of other timers that can be moved besides just local timers. But Russell didn't really like the shmobile patches for early platform devices which this relies on. So we should get agreement on the small bit of infrastructure needed first, then start moving individual timers.

I'm open to suggestions. Should the early platform infrastructure be flagged as unsuitable, I'd be happy to switch to something else, as long as it is minimal, and does not create another ARM-specific API (been there, done that...).

Quoted 2 lines

Also, device tree support for early platform devices would be useful for this.

Indeed.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#36 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 11 lines · Marc Zyngier
Quoted 5 lines · Rob Herring

If this is the direction to go, then there are a lot of other timers that can be moved besides just local timers. But Russell didn't really like the shmobile patches for early platform devices which this relies on. So we should get agreement on the small bit of infrastructure needed first, then start moving individual timers.

I'm open to suggestions. Should the early platform infrastructure be flagged as unsuitable, I'd be happy to switch to something else, as long as it is minimal, and does not create another ARM-specific API (been there, done that...).

I am most certainly not a fan of the early platform device stuff as I've said in the past.

It looks to me like:

1. it's overcomplex and fragile.
2. it abuses the early command line system.
3. it abuses platform devices etc.
4. it requires more initialization calls.

Lastly, and probably more importantly for the direction we're going, I can't see how it would hook into DT other than using the DT provided command line, which also appears to be an abuse there too.

Surely there's a better solution.

maintainer
#37 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 23 lines · Russell King - ARM Linux
Quoted 11 lines · Marc Zyngier
Quoted 5 lines · Rob Herring

If this is the direction to go, then there are a lot of other timers that can be moved besides just local timers. But Russell didn't really like the shmobile patches for early platform devices which this relies on. So we should get agreement on the small bit of infrastructure needed first, then start moving individual timers.

I'm open to suggestions. Should the early platform infrastructure be flagged as unsuitable, I'd be happy to switch to something else, as long as it is minimal, and does not create another ARM-specific API (been there, done that...).

I am most certainly not a fan of the early platform device stuff as I've said in the past.

It looks to me like:

1. it's overcomplex and fragile.
2. it abuses the early command line system.
3. it abuses platform devices etc.
4. it requires more initialization calls.

Quoted 5 lines

Lastly, and probably more importantly for the direction we're going, I can't see how it would hook into DT other than using the DT provided command line, which also appears to be an abuse there too.

Surely there's a better solution.

Which is?

#38 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

In reply to Russell King - ARM Linux
Quoted 18 lines · Russell King - ARM Linux
Quoted 11 lines · Marc Zyngier
Quoted 5 lines · Rob Herring

If this is the direction to go, then there are a lot of other timers that can be moved besides just local timers. But Russell didn't really like the shmobile patches for early platform devices which this relies on. So we should get agreement on the small bit of infrastructure needed first, then start moving individual timers.

I'm open to suggestions. Should the early platform infrastructure be flagged as unsuitable, I'd be happy to switch to something else, as long as it is minimal, and does not create another ARM-specific API (been there, done that...).

I am most certainly not a fan of the early platform device stuff as I've said in the past.

It looks to me like:

Quoted 8 lines

1. it's overcomplex and fragile.
2. it abuses the early command line system.
3. it abuses platform devices etc.
4. it requires more initialization calls.

Lastly, and probably more importantly for the direction we're going, I can't see how it would hook into DT other than using the DT provided command line, which also appears to be an abuse there too.

I'm going to second that opinion. I just looked through the early platform stuff, and I'm not thrilled with the model.

Setting up timers does not need to plug into the device model. Unless I'm completely reading the ARM code wrong, these timers are pretty fundamental to the operating system, and thus aren't really like other devices. I don't see any problem with individual timer init functions populated in machine_desc assuming that multiple boards with the same SoC will not require different timer initialization.

g.

maintainer
#39 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 32 lines · Grant Likely
Quoted 18 lines · Russell King - ARM Linux
Quoted 11 lines · Marc Zyngier
Quoted 5 lines · Rob Herring

If this is the direction to go, then there are a lot of other timers that can be moved besides just local timers. But Russell didn't really like the shmobile patches for early platform devices which this relies on. So we should get agreement on the small bit of infrastructure needed first, then start moving individual timers.

I'm open to suggestions. Should the early platform infrastructure be flagged as unsuitable, I'd be happy to switch to something else, as long as it is minimal, and does not create another ARM-specific API (been there, done that...).

I am most certainly not a fan of the early platform device stuff as I've said in the past.

It looks to me like:

Quoted 8 lines

1. it's overcomplex and fragile.
2. it abuses the early command line system.
3. it abuses platform devices etc.
4. it requires more initialization calls.

Lastly, and probably more importantly for the direction we're going, I can't see how it would hook into DT other than using the DT provided command line, which also appears to be an abuse there too.

I'm going to second that opinion. ?I just looked through the early platform stuff, and I'm not thrilled with the model.

Quoted 6 lines

Setting up timers does not need to plug into the device model. ?Unless I'm completely reading the ARM code wrong, these timers are pretty fundamental to the operating system, and thus aren't really like other devices. ?I don't see any problem with individual timer init functions populated in machine_desc assuming that multiple boards with the same SoC will not require different timer initialization.

Perhaps that's the case for some ARM platforms, but at least the sh7372 ARM platform is using general purpose timers as system timers. We have to since there are not other timers dedicated as system timers. Same for the SH architecture. I suspect that's the case for most other SoCs too actually, with the exception of platforms making use of ARM IP such as the TWD found in for instance Cortex-A9.

On most SoCs there are a wide range of SoC-specific timer channels to choose from. We want to reuse the same driver for multiple SoCs so separating the device configuration parameters (such as I/O base and IRQ) from the actual driver is desired.

The reason why we want to select timer channel is that some timer channels are tied to GPIO pins, and those GPIO pins may be used to driver board-specific hardware. So timer channel #2 may be great as clock source for board X but on board Y channel #2 is used to drive the PWM for the LCD backlight.

I fail to see what is wrong with separating device configuration from the actual driver.

Thanks,

/ magnus

#40 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

In reply to Rob Herring
Quoted 2 lines · Rob Herring

Also, device tree support for early platform devices would be useful for this.

What about the attached patch? I've used it to boot a VExpress board with the following DT snippet (and the corresponding support in the amp_smp_twd driver):

	localtimer at 2c000600 {
		device_type = "localtimer";
		compatible = "arm,smp-twd";
		reg = <0x2c000600 0x1000>;
		interrupts = <29>;
	};

Cheers,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#41 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Marc,

Quoted 10 lines · Marc Zyngier
Quoted 2 lines · Rob Herring

Also, device tree support for early platform devices would be useful for this.

What about the attached patch? I've used it to boot a VExpress board with the following DT snippet (and the corresponding support in the amp_smp_twd driver):

	localtimer at 2c000600 {
		device_type = "localtimer";

My understanding is device_type is only supposed to be used for devices with real OpenFirmware. You could just add localtimer or timer as a 2nd compatible string. I think localtimer is a bit of a Linux name, so just timer may be better.

Rob

Quoted 8 lines
		compatible = "arm,smp-twd";
		reg = <0x2c000600 0x1000>;
		interrupts = <29>;
	};

Cheers,

	M.
#42 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 11 lines · Rob Herring

Marc,

Quoted 8 lines · Marc Zyngier
Quoted 2 lines · Rob Herring

Also, device tree support for early platform devices would be useful for this.

What about the attached patch? I've used it to boot a VExpress board with the following DT snippet (and the corresponding support in the amp_smp_twd driver):

Quoted 7 lines
Quoted 2 lines
	localtimer at 2c000600 {
		device_type = "localtimer";

My understanding is device_type is only supposed to be used for devices with real OpenFirmware. You could just add localtimer or timer as a 2nd compatible string. I think localtimer is a bit of a Linux name, so just timer may be better.

Using "compatible" would not work. You'd have to add the same compatible string to all drivers, and get drivers probing the wrong device. Any other property we could use instead?

As for the "localtimer" string, this is to differentiate the per-cpu timers versus the global timers, and they may need to be probed in a specific order (global first, and then local).

The reason for this is that TWD needs to be calibrated, hence the need for a global timer running. Colin's patch could help getting rid of this restriction though.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#43 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 15 lines · Marc Zyngier
Quoted 14 lines · Rob Herring

Marc,

Quoted 10 lines · Marc Zyngier
Quoted 2 lines · Rob Herring

Also, device tree support for early platform devices would be useful for this.

What about the attached patch? I've used it to boot a VExpress board with the following DT snippet (and the corresponding support in the amp_smp_twd driver):

	localtimer at 2c000600 {
		device_type = "localtimer";
Quoted 8 lines
Quoted 4 lines

My understanding is device_type is only supposed to be used for devices with real OpenFirmware. You could just add localtimer or timer as a 2nd compatible string. I think localtimer is a bit of a Linux name, so just timer may be better.

Using "compatible" would not work. You'd have to add the same compatible string to all drivers, and get drivers probing the wrong device. Any other property we could use instead?

No, I'm saying you have a compatible property like this:

compatible = "arm,smp-twd", "timer";

You create the early platform device(s) based on matches with "timer", but match the driver based on "arm,smp-twd".

Quoted 8 lines

As for the "localtimer" string, this is to differentiate the per-cpu timers versus the global timers, and they may need to be probed in a specific order (global first, and then local).

The reason for this is that TWD needs to be calibrated, hence the need for a global timer running. Colin's patch could help getting rid of this restriction though.

Yes, my original patch adding clock api allowed just that.

Rob

Quoted 2 lines
	M.
#44 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

Quoted 25 lines · Rob Herring
Quoted 15 lines · Marc Zyngier
Quoted 14 lines · Rob Herring

Marc,

Quoted 10 lines · Marc Zyngier
Quoted 2 lines · Rob Herring

Also, device tree support for early platform devices would be useful for this.

What about the attached patch? I've used it to boot a VExpress board with the following DT snippet (and the corresponding support in the amp_smp_twd driver):

	localtimer at 2c000600 {
		device_type = "localtimer";
Quoted 8 lines
Quoted 4 lines

My understanding is device_type is only supposed to be used for devices with real OpenFirmware. You could just add localtimer or timer as a 2nd compatible string. I think localtimer is a bit of a Linux name, so just timer may be better.

Using "compatible" would not work. You'd have to add the same compatible string to all drivers, and get drivers probing the wrong device. Any other property we could use instead?

Quoted 6 lines

No, I'm saying you have a compatible property like this:

compatible = "arm,smp-twd", "timer";

You create the early platform device(s) based on matches with "timer", but match the driver based on "arm,smp-twd".

Right. What about the attached patch? Test-booted on the same VE with the above "compatible" property.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#45 lore raw

cover Consolidation: move SMP local timers to driver/clocksource

In reply to Arnd Bergmann
Quoted 2 lines · Arnd Bergmann

Very nice stuff. Should we take this all in one branch in the arm-soc tree, pending Acks from the subarch maintainers?

Yes please. If Marc feels the patch set is ready I suggest you bring it into arm-soc so it gets some testing in linux-next and any conflicts smoked out.

Quoted 2 lines

We could also push it through the individual subarch branches, but my feeling is that would be more work.

I agree.

Thanks,
Linus Walleij