All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support
@ 2013-04-01 22:21 Rob Herring
  2013-04-01 22:21 ` [PATCH v2 01/13] ARM: make machine_desc->init_time default to clocksource_of_init Rob Herring
                   ` (12 more replies)
  0 siblings, 13 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

This series add device-tree support using CLKSRC_OF for initialization
of arm/arm64 architected timers, integrator ap and cp timers, and sp804
timers. The timer code for integrator and sp804 is moved to
drivers/clocksource. The common DT based initialization of sp804 is
supported on highbank, versatile-ab and vexpress. The DT init support is
newly added for versatile-ab.

This series is dependent on my CLKSRC_OF clean-up in arm-soc and my
sched_clock selection series[1]. The full series is available here:

git://sources.calxeda.com/kernel/linux.git arm-timers
http://sources.calxeda.com/gitweb/?p=kernel/linux.git;a=shortlog;h=refs/heads/arm-timers

Changes in v2:
- Rework sp804 init to be more readable as to which timer is initialized
  for which function (clksrc or clkevt).
- Drop patch removing TIMER_CTRL clearing which is still needed for non-DT
  init cases.
- Add TIMER_CTRL to DT init functions. Even if the timer is unused as
  clksrc or clkevt, it is disabled.
- Extract only clocksource_of_init call from Arnd's default machine desc
  patch

Rob

[1] http://www.spinics.net/lists/arm-kernel/msg234566.html


Arnd Bergmann (1):
  ARM: make machine_desc->init_time default to clocksource_of_init

Haojian Zhuang (1):
  devtree: add binding documentation for sp804

Rob Herring (11):
  ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
  OF: add empty of_device_is_available for !OF
  ARM: timer-sp: convert to use CLKSRC_OF init
  ARM: highbank: use OF init for sp804 timer
  ARM: vexpress: remove sp804 OF init
  ARM: dts: vexpress: disable CA9 core tile sp804 timer
  ARM: vexpress: remove extra timer-sp control register clearing
  ARM: versatile: add versatile dtbs to dtbs target
  ARM: versatile: use OF init for sp804 timer
  ARM: integrator-cp: convert use CLKSRC_OF for timer init
  ARM: move sp804 and integrator timers to drivers/clocksource

 .../devicetree/bindings/timer/arm,sp804.txt        |   29 +++
 arch/arm/Kconfig                                   |    5 -
 arch/arm/boot/dts/Makefile                         |    2 +
 arch/arm/boot/dts/integratorcp.dts                 |    6 +-
 arch/arm/boot/dts/versatile-ab.dts                 |   12 ++
 arch/arm/boot/dts/vexpress-v2p-ca9.dts             |    1 +
 arch/arm/common/Makefile                           |    1 -
 arch/arm/include/asm/arch_timer.h                  |   13 +-
 arch/arm/include/asm/hardware/timer-sp.h           |   15 --
 arch/arm/kernel/arch_timer.c                       |   17 +-
 arch/arm/kernel/time.c                             |    7 +-
 arch/arm/mach-exynos/mach-exynos5-dt.c             |    1 -
 arch/arm/mach-exynos/mct.c                         |    6 -
 arch/arm/mach-highbank/highbank.c                  |   24 +--
 arch/arm/mach-integrator/Kconfig                   |    1 +
 arch/arm/mach-integrator/integrator_ap.c           |  170 +-----------------
 arch/arm/mach-integrator/integrator_cp.c           |   39 +---
 arch/arm/mach-omap2/timer.c                        |    5 +-
 arch/arm/mach-realview/core.c                      |    5 +-
 arch/arm/mach-shmobile/board-kzm9d.c               |    1 -
 arch/arm/mach-shmobile/include/mach/common.h       |    1 -
 arch/arm/mach-shmobile/setup-emev2.c               |    1 -
 arch/arm/mach-shmobile/setup-r8a7740.c             |    1 -
 arch/arm/mach-shmobile/setup-sh7372.c              |    1 -
 arch/arm/mach-shmobile/setup-sh73a0.c              |    1 -
 arch/arm/mach-shmobile/timer.c                     |    6 -
 arch/arm/mach-versatile/core.c                     |   30 ++--
 arch/arm/mach-versatile/versatile_dt.c             |    1 -
 arch/arm/mach-vexpress/ct-ca9x4.c                  |    4 +-
 arch/arm/mach-vexpress/v2m.c                       |   25 +--
 arch/arm/mach-virt/virt.c                          |    9 -
 arch/arm64/include/asm/arch_timer.h                |    5 +
 arch/arm64/kernel/time.c                           |    6 +-
 drivers/clocksource/Kconfig                        |   13 ++
 drivers/clocksource/Makefile                       |    2 +
 drivers/clocksource/arm_arch_timer.c               |   23 +--
 drivers/clocksource/integrator_ap_timer.c          |  189 ++++++++++++++++++++
 .../arm/common => drivers/clocksource}/timer-sp.c  |  144 +++++++++++++--
 include/clocksource/arm_arch_timer.h               |    6 -
 .../hardware => include/clocksource}/arm_timer.h   |    4 +-
 include/clocksource/integrator_ap_timer.h          |    7 +
 include/clocksource/timer-sp.h                     |   23 +++
 include/linux/of.h                                 |    5 +
 43 files changed, 470 insertions(+), 397 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/arm,sp804.txt
 delete mode 100644 arch/arm/include/asm/hardware/timer-sp.h
 create mode 100644 drivers/clocksource/integrator_ap_timer.c
 rename {arch/arm/common => drivers/clocksource}/timer-sp.c (58%)
 rename {arch/arm/include/asm/hardware => include/clocksource}/arm_timer.h (93%)
 create mode 100644 include/clocksource/integrator_ap_timer.h
 create mode 100644 include/clocksource/timer-sp.h

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 01/13] ARM: make machine_desc->init_time default to clocksource_of_init
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-01 22:21   ` Rob Herring
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

Originally from a default machine descriptor patch from Arnd, pull out
just the default call to clocksource_of_init part. This is needed so that
platforms can simply remove .init_time calls as they are converted to use
clocksource_of_init.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Nicolas Pitre <nico@linaro.org>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/kernel/time.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 955d92d..abff4e9 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -22,6 +22,7 @@
 #include <linux/errno.h>
 #include <linux/profile.h>
 #include <linux/timer.h>
+#include <linux/clocksource.h>
 #include <linux/irq.h>
 
 #include <asm/thread_info.h>
@@ -115,6 +116,10 @@ int __init register_persistent_clock(clock_access_fn read_boot,
 
 void __init time_init(void)
 {
-	machine_desc->init_time();
+	if (machine_desc->init_time)
+		machine_desc->init_time();
+	else
+		clocksource_of_init();
+
 	sched_clock_postinit();
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
  2013-04-01 22:21 ` [PATCH v2 01/13] ARM: make machine_desc->init_time default to clocksource_of_init Rob Herring
@ 2013-04-01 22:21   ` Rob Herring
  2013-04-01 22:21 ` [PATCH v2 03/13] OF: add empty of_device_is_available for !OF Rob Herring
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

This converts arm and arm64 to use CLKSRC_OF DT based initialization for
the arch timer. A new function arch_timer_arch_init is added to allow for
arch specific setup.

This has a side effect of enabling sched_clock on omap5 and exynos5. There
should not be any reason not to use the arch timers for sched_clock.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-omap@vger.kernel.org
Cc: linux-sh@vger.kernel.org
---
 arch/arm/include/asm/arch_timer.h            |   13 +------------
 arch/arm/kernel/arch_timer.c                 |   17 +++--------------
 arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
 arch/arm/mach-exynos/mct.c                   |    6 ------
 arch/arm/mach-highbank/highbank.c            |    5 +----
 arch/arm/mach-omap2/timer.c                  |    5 +----
 arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
 arch/arm/mach-shmobile/include/mach/common.h |    1 -
 arch/arm/mach-shmobile/setup-emev2.c         |    1 -
 arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
 arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
 arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
 arch/arm/mach-shmobile/timer.c               |    6 ------
 arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
 arch/arm/mach-virt/virt.c                    |    9 ---------
 arch/arm64/include/asm/arch_timer.h          |    5 +++++
 arch/arm64/kernel/time.c                     |    6 ++++--
 drivers/clocksource/Kconfig                  |    1 +
 drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
 include/clocksource/arm_arch_timer.h         |    6 ------
 20 files changed, 27 insertions(+), 89 deletions(-)

diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index 7ade91d..7c1bfc0 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -10,8 +10,7 @@
 #include <clocksource/arm_arch_timer.h>
 
 #ifdef CONFIG_ARM_ARCH_TIMER
-int arch_timer_of_register(void);
-int arch_timer_sched_clock_init(void);
+int arch_timer_arch_init(void);
 
 /*
  * These register accessors are marked inline so the compiler can
@@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
 
 	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
 }
-#else
-static inline int arch_timer_of_register(void)
-{
-	return -ENXIO;
-}
-
-static inline int arch_timer_sched_clock_init(void)
-{
-	return -ENXIO;
-}
 #endif
 
 #endif
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index a7536d4..dc74048 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
 	register_current_timer_delay(&arch_delay_timer);
 }
 
-int __init arch_timer_of_register(void)
-{
-	int ret;
-
-	ret = arch_timer_init();
-	if (ret)
-		return ret;
-
-	arch_timer_delay_timer_register();
-
-	return 0;
-}
-
-int __init arch_timer_sched_clock_init(void)
+int __init arch_timer_arch_init(void)
 {
         u32 arch_timer_rate = arch_timer_get_rate();
 
 	if (arch_timer_rate = 0)
 		return -ENXIO;
 
+	arch_timer_delay_timer_register();
+
 	/* Cache the sched_clock multiplier to save a divide in the hot path. */
 	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
 	sched_clock_func = arch_timer_sched_clock;
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
index acaeb14..4d97b43 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
 	.map_io		= exynos5_dt_map_io,
 	.init_machine	= exynos5_dt_machine_init,
 	.init_late	= exynos_init_late,
-	.init_time	= exynos4_timer_init,
 	.dt_compat	= exynos5_dt_compat,
 	.restart        = exynos5_restart,
 	.reserve	= exynos5_reserve,
diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
index c9d6650..04aff6a 100644
--- a/arch/arm/mach-exynos/mct.c
+++ b/arch/arm/mach-exynos/mct.c
@@ -21,7 +21,6 @@
 #include <linux/percpu.h>
 #include <linux/of.h>
 
-#include <asm/arch_timer.h>
 #include <asm/localtimer.h>
 
 #include <plat/cpu.h>
@@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
 
 void __init exynos4_timer_init(void)
 {
-	if (soc_is_exynos5440()) {
-		arch_timer_of_register();
-		return;
-	}
-
 	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
 		mct_int_type = MCT_INT_SPI;
 	else
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 76c1170..758150e 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -15,6 +15,7 @@
  */
 #include <linux/clk.h>
 #include <linux/clkdev.h>
+#include <linux/clocksource.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -28,7 +29,6 @@
 #include <linux/amba/bus.h>
 #include <linux/clk-provider.h>
 
-#include <asm/arch_timer.h>
 #include <asm/cacheflush.h>
 #include <asm/cputype.h>
 #include <asm/smp_plat.h>
@@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
 	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
 	sp804_clockevents_init(timer_base, irq, "timer0");
 
-	arch_timer_of_register();
-	arch_timer_sched_clock_init();
-
 	clocksource_of_init();
 }
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 4fd8025..7dd6453 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -46,7 +46,6 @@
 #include <asm/smp_twd.h>
 #include <asm/sched_clock.h>
 
-#include <asm/arch_timer.h>
 #include "omap_hwmod.h"
 #include "omap_device.h"
 #include <plat/counter-32k.h>
@@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
 	omap5_sync32k_timer_init();
 	realtime_counter_init();
 
-	err = arch_timer_of_register();
-	if (err)
-		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
+        clocksource_of_init();
 }
 #endif /* CONFIG_SOC_OMAP5 */
 
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
index c254782..c016ccd 100644
--- a/arch/arm/mach-shmobile/board-kzm9d.c
+++ b/arch/arm/mach-shmobile/board-kzm9d.c
@@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
 	.init_irq	= emev2_init_irq,
 	.init_machine	= kzm9d_add_standard_devices,
 	.init_late	= shmobile_init_late,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= kzm9d_boards_compat_dt,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index e48606d..5efc0f0 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -2,7 +2,6 @@
 #define __ARCH_MACH_COMMON_H
 
 extern void shmobile_earlytimer_init(void);
-extern void shmobile_timer_init(void);
 extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
 			 unsigned int mult, unsigned int div);
 struct twd_local_timer;
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
index 47662a5..4e38a66 100644
--- a/arch/arm/mach-shmobile/setup-emev2.c
+++ b/arch/arm/mach-shmobile/setup-emev2.c
@@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= irqchip_init,
 	.init_machine	= emev2_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= emev2_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index 8b85d4d..104b474 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
 	.init_irq	= r8a7740_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_machine	= r8a7740_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= r8a7740_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index 59c7146..5502d62 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_machine	= sh7372_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= sh7372_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index bdab575..ea66316 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= sh73a0_init_irq_dt,
 	.init_machine	= sh73a0_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= sh73a0_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index 3d16d4d..add2f15 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
 {
 	late_time_init = shmobile_late_time_init;
 }
-
-void __init shmobile_timer_init(void)
-{
-	arch_timer_of_register();
-	arch_timer_sched_clock_init();
-}
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index d0ad789..6215717 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -1,6 +1,7 @@
 /*
  * Versatile Express V2M Motherboard Support
  */
+#include <linux/clocksource.h>
 #include <linux/device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/mmci.h>
@@ -23,7 +24,6 @@
 #include <linux/regulator/machine.h>
 #include <linux/vexpress.h>
 
-#include <asm/arch_timer.h>
 #include <asm/mach-types.h>
 #include <asm/sizes.h>
 #include <asm/mach/arch.h>
@@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
 				irq_of_parse_and_map(node, 0));
 	}
 
-	arch_timer_of_register();
-
-	if (arch_timer_sched_clock_init() != 0)
-		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
+	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
 				24000000);
 }
 
diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
index 31666f6..adc0945 100644
--- a/arch/arm/mach-virt/virt.c
+++ b/arch/arm/mach-virt/virt.c
@@ -23,21 +23,13 @@
 #include <linux/of_platform.h>
 #include <linux/smp.h>
 
-#include <asm/arch_timer.h>
 #include <asm/mach/arch.h>
-#include <asm/mach/time.h>
 
 static void __init virt_init(void)
 {
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-static void __init virt_timer_init(void)
-{
-	WARN_ON(arch_timer_of_register() != 0);
-	WARN_ON(arch_timer_sched_clock_init() != 0);
-}
-
 static const char *virt_dt_match[] = {
 	"linux,dummy-virt",
 	NULL
@@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
 
 DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
 	.init_irq	= irqchip_init,
-	.init_time	= virt_timer_init,
 	.init_machine	= virt_init,
 	.smp		= smp_ops(virt_smp_ops),
 	.dt_compat	= virt_dt_match,
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index 91e2a6a..bf6ab242 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
 	return cval;
 }
 
+static inline int arch_timer_arch_init(void)
+{
+	return 0;
+}
+
 #endif
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
index b0ef18d..a551f88 100644
--- a/arch/arm64/kernel/time.c
+++ b/arch/arm64/kernel/time.c
@@ -32,6 +32,7 @@
 #include <linux/timer.h>
 #include <linux/irq.h>
 #include <linux/delay.h>
+#include <linux/clocksource.h>
 
 #include <clocksource/arm_arch_timer.h>
 
@@ -77,10 +78,11 @@ void __init time_init(void)
 {
 	u32 arch_timer_rate;
 
-	if (arch_timer_init())
-		panic("Unable to initialise architected timer.\n");
+	clocksource_of_init();
 
 	arch_timer_rate = arch_timer_get_rate();
+	if (!arch_timer_rate)
+		panic("Unable to initialise architected timer.\n");
 
 	/* Cache the sched_clock multiplier to save a divide in the hot path. */
 	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index e507ab7..d98e7e1 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
 
 config ARM_ARCH_TIMER
 	bool
+	select CLKSRC_OF if OF
 
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index d7ad425..122ff05 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -337,22 +337,14 @@ out:
 	return err;
 }
 
-static const struct of_device_id arch_timer_of_match[] __initconst = {
-	{ .compatible	= "arm,armv7-timer",	},
-	{ .compatible	= "arm,armv8-timer",	},
-	{},
-};
-
-int __init arch_timer_init(void)
+static void __init arch_timer_init(struct device_node *np)
 {
-	struct device_node *np;
 	u32 freq;
 	int i;
 
-	np = of_find_matching_node(NULL, arch_timer_of_match);
-	if (!np) {
-		pr_err("arch_timer: can't find DT node\n");
-		return -ENODEV;
+	if (arch_timer_get_rate()) {
+		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
+		return;
 	}
 
 	/* Try to determine the frequency from the device tree or CNTFRQ */
@@ -378,7 +370,7 @@ int __init arch_timer_init(void)
 		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
 		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
 			pr_warn("arch_timer: No interrupt available, giving up\n");
-			return -EINVAL;
+			return;
 		}
 	}
 
@@ -387,5 +379,8 @@ int __init arch_timer_init(void)
 	else
 		arch_timer_read_counter = arch_counter_get_cntpct;
 
-	return arch_timer_register();
+	arch_timer_register();
+	arch_timer_arch_init();
 }
+CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
+CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
index 2603267..e6c9c4c 100644
--- a/include/clocksource/arm_arch_timer.h
+++ b/include/clocksource/arm_arch_timer.h
@@ -31,18 +31,12 @@
 
 #ifdef CONFIG_ARM_ARCH_TIMER
 
-extern int arch_timer_init(void);
 extern u32 arch_timer_get_rate(void);
 extern u64 (*arch_timer_read_counter)(void);
 extern struct timecounter *arch_timer_get_timecounter(void);
 
 #else
 
-static inline int arch_timer_init(void)
-{
-	return -ENXIO;
-}
-
 static inline u32 arch_timer_get_rate(void)
 {
 	return 0;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-01 22:21   ` Rob Herring
  0 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Thomas Gleixner, Mark Rutland, Russell King, John Stultz, arm,
	Marc Zyngier, Linus Walleij, Rob Herring, Kukjin Kim,
	Tony Lindgren, Simon Horman, Magnus Damm, Catalin Marinas,
	Will Deacon, linux-samsung-soc, linux-omap, linux-sh

From: Rob Herring <rob.herring@calxeda.com>

This converts arm and arm64 to use CLKSRC_OF DT based initialization for
the arch timer. A new function arch_timer_arch_init is added to allow for
arch specific setup.

This has a side effect of enabling sched_clock on omap5 and exynos5. There
should not be any reason not to use the arch timers for sched_clock.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-samsung-soc@vger.kernel.org
Cc: linux-omap@vger.kernel.org
Cc: linux-sh@vger.kernel.org
---
 arch/arm/include/asm/arch_timer.h            |   13 +------------
 arch/arm/kernel/arch_timer.c                 |   17 +++--------------
 arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
 arch/arm/mach-exynos/mct.c                   |    6 ------
 arch/arm/mach-highbank/highbank.c            |    5 +----
 arch/arm/mach-omap2/timer.c                  |    5 +----
 arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
 arch/arm/mach-shmobile/include/mach/common.h |    1 -
 arch/arm/mach-shmobile/setup-emev2.c         |    1 -
 arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
 arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
 arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
 arch/arm/mach-shmobile/timer.c               |    6 ------
 arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
 arch/arm/mach-virt/virt.c                    |    9 ---------
 arch/arm64/include/asm/arch_timer.h          |    5 +++++
 arch/arm64/kernel/time.c                     |    6 ++++--
 drivers/clocksource/Kconfig                  |    1 +
 drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
 include/clocksource/arm_arch_timer.h         |    6 ------
 20 files changed, 27 insertions(+), 89 deletions(-)

diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index 7ade91d..7c1bfc0 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -10,8 +10,7 @@
 #include <clocksource/arm_arch_timer.h>
 
 #ifdef CONFIG_ARM_ARCH_TIMER
-int arch_timer_of_register(void);
-int arch_timer_sched_clock_init(void);
+int arch_timer_arch_init(void);
 
 /*
  * These register accessors are marked inline so the compiler can
@@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
 
 	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
 }
-#else
-static inline int arch_timer_of_register(void)
-{
-	return -ENXIO;
-}
-
-static inline int arch_timer_sched_clock_init(void)
-{
-	return -ENXIO;
-}
 #endif
 
 #endif
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index a7536d4..dc74048 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
 	register_current_timer_delay(&arch_delay_timer);
 }
 
-int __init arch_timer_of_register(void)
-{
-	int ret;
-
-	ret = arch_timer_init();
-	if (ret)
-		return ret;
-
-	arch_timer_delay_timer_register();
-
-	return 0;
-}
-
-int __init arch_timer_sched_clock_init(void)
+int __init arch_timer_arch_init(void)
 {
         u32 arch_timer_rate = arch_timer_get_rate();
 
 	if (arch_timer_rate == 0)
 		return -ENXIO;
 
+	arch_timer_delay_timer_register();
+
 	/* Cache the sched_clock multiplier to save a divide in the hot path. */
 	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
 	sched_clock_func = arch_timer_sched_clock;
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
index acaeb14..4d97b43 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
 	.map_io		= exynos5_dt_map_io,
 	.init_machine	= exynos5_dt_machine_init,
 	.init_late	= exynos_init_late,
-	.init_time	= exynos4_timer_init,
 	.dt_compat	= exynos5_dt_compat,
 	.restart        = exynos5_restart,
 	.reserve	= exynos5_reserve,
diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
index c9d6650..04aff6a 100644
--- a/arch/arm/mach-exynos/mct.c
+++ b/arch/arm/mach-exynos/mct.c
@@ -21,7 +21,6 @@
 #include <linux/percpu.h>
 #include <linux/of.h>
 
-#include <asm/arch_timer.h>
 #include <asm/localtimer.h>
 
 #include <plat/cpu.h>
@@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
 
 void __init exynos4_timer_init(void)
 {
-	if (soc_is_exynos5440()) {
-		arch_timer_of_register();
-		return;
-	}
-
 	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
 		mct_int_type = MCT_INT_SPI;
 	else
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 76c1170..758150e 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -15,6 +15,7 @@
  */
 #include <linux/clk.h>
 #include <linux/clkdev.h>
+#include <linux/clocksource.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -28,7 +29,6 @@
 #include <linux/amba/bus.h>
 #include <linux/clk-provider.h>
 
-#include <asm/arch_timer.h>
 #include <asm/cacheflush.h>
 #include <asm/cputype.h>
 #include <asm/smp_plat.h>
@@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
 	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
 	sp804_clockevents_init(timer_base, irq, "timer0");
 
-	arch_timer_of_register();
-	arch_timer_sched_clock_init();
-
 	clocksource_of_init();
 }
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 4fd8025..7dd6453 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -46,7 +46,6 @@
 #include <asm/smp_twd.h>
 #include <asm/sched_clock.h>
 
-#include <asm/arch_timer.h>
 #include "omap_hwmod.h"
 #include "omap_device.h"
 #include <plat/counter-32k.h>
@@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
 	omap5_sync32k_timer_init();
 	realtime_counter_init();
 
-	err = arch_timer_of_register();
-	if (err)
-		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
+        clocksource_of_init();
 }
 #endif /* CONFIG_SOC_OMAP5 */
 
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
index c254782..c016ccd 100644
--- a/arch/arm/mach-shmobile/board-kzm9d.c
+++ b/arch/arm/mach-shmobile/board-kzm9d.c
@@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
 	.init_irq	= emev2_init_irq,
 	.init_machine	= kzm9d_add_standard_devices,
 	.init_late	= shmobile_init_late,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= kzm9d_boards_compat_dt,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index e48606d..5efc0f0 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -2,7 +2,6 @@
 #define __ARCH_MACH_COMMON_H
 
 extern void shmobile_earlytimer_init(void);
-extern void shmobile_timer_init(void);
 extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
 			 unsigned int mult, unsigned int div);
 struct twd_local_timer;
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
index 47662a5..4e38a66 100644
--- a/arch/arm/mach-shmobile/setup-emev2.c
+++ b/arch/arm/mach-shmobile/setup-emev2.c
@@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= irqchip_init,
 	.init_machine	= emev2_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= emev2_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index 8b85d4d..104b474 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
 	.init_irq	= r8a7740_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_machine	= r8a7740_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= r8a7740_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index 59c7146..5502d62 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_machine	= sh7372_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= sh7372_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index bdab575..ea66316 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= sh73a0_init_irq_dt,
 	.init_machine	= sh73a0_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= sh73a0_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index 3d16d4d..add2f15 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
 {
 	late_time_init = shmobile_late_time_init;
 }
-
-void __init shmobile_timer_init(void)
-{
-	arch_timer_of_register();
-	arch_timer_sched_clock_init();
-}
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index d0ad789..6215717 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -1,6 +1,7 @@
 /*
  * Versatile Express V2M Motherboard Support
  */
+#include <linux/clocksource.h>
 #include <linux/device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/mmci.h>
@@ -23,7 +24,6 @@
 #include <linux/regulator/machine.h>
 #include <linux/vexpress.h>
 
-#include <asm/arch_timer.h>
 #include <asm/mach-types.h>
 #include <asm/sizes.h>
 #include <asm/mach/arch.h>
@@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
 				irq_of_parse_and_map(node, 0));
 	}
 
-	arch_timer_of_register();
-
-	if (arch_timer_sched_clock_init() != 0)
-		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
+	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
 				24000000);
 }
 
diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
index 31666f6..adc0945 100644
--- a/arch/arm/mach-virt/virt.c
+++ b/arch/arm/mach-virt/virt.c
@@ -23,21 +23,13 @@
 #include <linux/of_platform.h>
 #include <linux/smp.h>
 
-#include <asm/arch_timer.h>
 #include <asm/mach/arch.h>
-#include <asm/mach/time.h>
 
 static void __init virt_init(void)
 {
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-static void __init virt_timer_init(void)
-{
-	WARN_ON(arch_timer_of_register() != 0);
-	WARN_ON(arch_timer_sched_clock_init() != 0);
-}
-
 static const char *virt_dt_match[] = {
 	"linux,dummy-virt",
 	NULL
@@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
 
 DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
 	.init_irq	= irqchip_init,
-	.init_time	= virt_timer_init,
 	.init_machine	= virt_init,
 	.smp		= smp_ops(virt_smp_ops),
 	.dt_compat	= virt_dt_match,
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index 91e2a6a..bf6ab242 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
 	return cval;
 }
 
+static inline int arch_timer_arch_init(void)
+{
+	return 0;
+}
+
 #endif
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
index b0ef18d..a551f88 100644
--- a/arch/arm64/kernel/time.c
+++ b/arch/arm64/kernel/time.c
@@ -32,6 +32,7 @@
 #include <linux/timer.h>
 #include <linux/irq.h>
 #include <linux/delay.h>
+#include <linux/clocksource.h>
 
 #include <clocksource/arm_arch_timer.h>
 
@@ -77,10 +78,11 @@ void __init time_init(void)
 {
 	u32 arch_timer_rate;
 
-	if (arch_timer_init())
-		panic("Unable to initialise architected timer.\n");
+	clocksource_of_init();
 
 	arch_timer_rate = arch_timer_get_rate();
+	if (!arch_timer_rate)
+		panic("Unable to initialise architected timer.\n");
 
 	/* Cache the sched_clock multiplier to save a divide in the hot path. */
 	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index e507ab7..d98e7e1 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
 
 config ARM_ARCH_TIMER
 	bool
+	select CLKSRC_OF if OF
 
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index d7ad425..122ff05 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -337,22 +337,14 @@ out:
 	return err;
 }
 
-static const struct of_device_id arch_timer_of_match[] __initconst = {
-	{ .compatible	= "arm,armv7-timer",	},
-	{ .compatible	= "arm,armv8-timer",	},
-	{},
-};
-
-int __init arch_timer_init(void)
+static void __init arch_timer_init(struct device_node *np)
 {
-	struct device_node *np;
 	u32 freq;
 	int i;
 
-	np = of_find_matching_node(NULL, arch_timer_of_match);
-	if (!np) {
-		pr_err("arch_timer: can't find DT node\n");
-		return -ENODEV;
+	if (arch_timer_get_rate()) {
+		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
+		return;
 	}
 
 	/* Try to determine the frequency from the device tree or CNTFRQ */
@@ -378,7 +370,7 @@ int __init arch_timer_init(void)
 		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
 		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
 			pr_warn("arch_timer: No interrupt available, giving up\n");
-			return -EINVAL;
+			return;
 		}
 	}
 
@@ -387,5 +379,8 @@ int __init arch_timer_init(void)
 	else
 		arch_timer_read_counter = arch_counter_get_cntpct;
 
-	return arch_timer_register();
+	arch_timer_register();
+	arch_timer_arch_init();
 }
+CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
+CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
index 2603267..e6c9c4c 100644
--- a/include/clocksource/arm_arch_timer.h
+++ b/include/clocksource/arm_arch_timer.h
@@ -31,18 +31,12 @@
 
 #ifdef CONFIG_ARM_ARCH_TIMER
 
-extern int arch_timer_init(void);
 extern u32 arch_timer_get_rate(void);
 extern u64 (*arch_timer_read_counter)(void);
 extern struct timecounter *arch_timer_get_timecounter(void);
 
 #else
 
-static inline int arch_timer_init(void)
-{
-	return -ENXIO;
-}
-
 static inline u32 arch_timer_get_rate(void)
 {
 	return 0;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-01 22:21   ` Rob Herring
  0 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

This converts arm and arm64 to use CLKSRC_OF DT based initialization for
the arch timer. A new function arch_timer_arch_init is added to allow for
arch specific setup.

This has a side effect of enabling sched_clock on omap5 and exynos5. There
should not be any reason not to use the arch timers for sched_clock.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-samsung-soc at vger.kernel.org
Cc: linux-omap at vger.kernel.org
Cc: linux-sh at vger.kernel.org
---
 arch/arm/include/asm/arch_timer.h            |   13 +------------
 arch/arm/kernel/arch_timer.c                 |   17 +++--------------
 arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
 arch/arm/mach-exynos/mct.c                   |    6 ------
 arch/arm/mach-highbank/highbank.c            |    5 +----
 arch/arm/mach-omap2/timer.c                  |    5 +----
 arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
 arch/arm/mach-shmobile/include/mach/common.h |    1 -
 arch/arm/mach-shmobile/setup-emev2.c         |    1 -
 arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
 arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
 arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
 arch/arm/mach-shmobile/timer.c               |    6 ------
 arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
 arch/arm/mach-virt/virt.c                    |    9 ---------
 arch/arm64/include/asm/arch_timer.h          |    5 +++++
 arch/arm64/kernel/time.c                     |    6 ++++--
 drivers/clocksource/Kconfig                  |    1 +
 drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
 include/clocksource/arm_arch_timer.h         |    6 ------
 20 files changed, 27 insertions(+), 89 deletions(-)

diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index 7ade91d..7c1bfc0 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -10,8 +10,7 @@
 #include <clocksource/arm_arch_timer.h>
 
 #ifdef CONFIG_ARM_ARCH_TIMER
-int arch_timer_of_register(void);
-int arch_timer_sched_clock_init(void);
+int arch_timer_arch_init(void);
 
 /*
  * These register accessors are marked inline so the compiler can
@@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
 
 	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
 }
-#else
-static inline int arch_timer_of_register(void)
-{
-	return -ENXIO;
-}
-
-static inline int arch_timer_sched_clock_init(void)
-{
-	return -ENXIO;
-}
 #endif
 
 #endif
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index a7536d4..dc74048 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
 	register_current_timer_delay(&arch_delay_timer);
 }
 
-int __init arch_timer_of_register(void)
-{
-	int ret;
-
-	ret = arch_timer_init();
-	if (ret)
-		return ret;
-
-	arch_timer_delay_timer_register();
-
-	return 0;
-}
-
-int __init arch_timer_sched_clock_init(void)
+int __init arch_timer_arch_init(void)
 {
         u32 arch_timer_rate = arch_timer_get_rate();
 
 	if (arch_timer_rate == 0)
 		return -ENXIO;
 
+	arch_timer_delay_timer_register();
+
 	/* Cache the sched_clock multiplier to save a divide in the hot path. */
 	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
 	sched_clock_func = arch_timer_sched_clock;
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
index acaeb14..4d97b43 100644
--- a/arch/arm/mach-exynos/mach-exynos5-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
 	.map_io		= exynos5_dt_map_io,
 	.init_machine	= exynos5_dt_machine_init,
 	.init_late	= exynos_init_late,
-	.init_time	= exynos4_timer_init,
 	.dt_compat	= exynos5_dt_compat,
 	.restart        = exynos5_restart,
 	.reserve	= exynos5_reserve,
diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
index c9d6650..04aff6a 100644
--- a/arch/arm/mach-exynos/mct.c
+++ b/arch/arm/mach-exynos/mct.c
@@ -21,7 +21,6 @@
 #include <linux/percpu.h>
 #include <linux/of.h>
 
-#include <asm/arch_timer.h>
 #include <asm/localtimer.h>
 
 #include <plat/cpu.h>
@@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
 
 void __init exynos4_timer_init(void)
 {
-	if (soc_is_exynos5440()) {
-		arch_timer_of_register();
-		return;
-	}
-
 	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
 		mct_int_type = MCT_INT_SPI;
 	else
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 76c1170..758150e 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -15,6 +15,7 @@
  */
 #include <linux/clk.h>
 #include <linux/clkdev.h>
+#include <linux/clocksource.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -28,7 +29,6 @@
 #include <linux/amba/bus.h>
 #include <linux/clk-provider.h>
 
-#include <asm/arch_timer.h>
 #include <asm/cacheflush.h>
 #include <asm/cputype.h>
 #include <asm/smp_plat.h>
@@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
 	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
 	sp804_clockevents_init(timer_base, irq, "timer0");
 
-	arch_timer_of_register();
-	arch_timer_sched_clock_init();
-
 	clocksource_of_init();
 }
 
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 4fd8025..7dd6453 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -46,7 +46,6 @@
 #include <asm/smp_twd.h>
 #include <asm/sched_clock.h>
 
-#include <asm/arch_timer.h>
 #include "omap_hwmod.h"
 #include "omap_device.h"
 #include <plat/counter-32k.h>
@@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
 	omap5_sync32k_timer_init();
 	realtime_counter_init();
 
-	err = arch_timer_of_register();
-	if (err)
-		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
+        clocksource_of_init();
 }
 #endif /* CONFIG_SOC_OMAP5 */
 
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
index c254782..c016ccd 100644
--- a/arch/arm/mach-shmobile/board-kzm9d.c
+++ b/arch/arm/mach-shmobile/board-kzm9d.c
@@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
 	.init_irq	= emev2_init_irq,
 	.init_machine	= kzm9d_add_standard_devices,
 	.init_late	= shmobile_init_late,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= kzm9d_boards_compat_dt,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index e48606d..5efc0f0 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -2,7 +2,6 @@
 #define __ARCH_MACH_COMMON_H
 
 extern void shmobile_earlytimer_init(void);
-extern void shmobile_timer_init(void);
 extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
 			 unsigned int mult, unsigned int div);
 struct twd_local_timer;
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
index 47662a5..4e38a66 100644
--- a/arch/arm/mach-shmobile/setup-emev2.c
+++ b/arch/arm/mach-shmobile/setup-emev2.c
@@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= irqchip_init,
 	.init_machine	= emev2_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= emev2_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index 8b85d4d..104b474 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
 	.init_irq	= r8a7740_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_machine	= r8a7740_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= r8a7740_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index 59c7146..5502d62 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_machine	= sh7372_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= sh7372_boards_compat_dt,
 MACHINE_END
 
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index bdab575..ea66316 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
 	.nr_irqs	= NR_IRQS_LEGACY,
 	.init_irq	= sh73a0_init_irq_dt,
 	.init_machine	= sh73a0_add_standard_devices_dt,
-	.init_time	= shmobile_timer_init,
 	.dt_compat	= sh73a0_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index 3d16d4d..add2f15 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
 {
 	late_time_init = shmobile_late_time_init;
 }
-
-void __init shmobile_timer_init(void)
-{
-	arch_timer_of_register();
-	arch_timer_sched_clock_init();
-}
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index d0ad789..6215717 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -1,6 +1,7 @@
 /*
  * Versatile Express V2M Motherboard Support
  */
+#include <linux/clocksource.h>
 #include <linux/device.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/mmci.h>
@@ -23,7 +24,6 @@
 #include <linux/regulator/machine.h>
 #include <linux/vexpress.h>
 
-#include <asm/arch_timer.h>
 #include <asm/mach-types.h>
 #include <asm/sizes.h>
 #include <asm/mach/arch.h>
@@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
 				irq_of_parse_and_map(node, 0));
 	}
 
-	arch_timer_of_register();
-
-	if (arch_timer_sched_clock_init() != 0)
-		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
+	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
 				24000000);
 }
 
diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
index 31666f6..adc0945 100644
--- a/arch/arm/mach-virt/virt.c
+++ b/arch/arm/mach-virt/virt.c
@@ -23,21 +23,13 @@
 #include <linux/of_platform.h>
 #include <linux/smp.h>
 
-#include <asm/arch_timer.h>
 #include <asm/mach/arch.h>
-#include <asm/mach/time.h>
 
 static void __init virt_init(void)
 {
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }
 
-static void __init virt_timer_init(void)
-{
-	WARN_ON(arch_timer_of_register() != 0);
-	WARN_ON(arch_timer_sched_clock_init() != 0);
-}
-
 static const char *virt_dt_match[] = {
 	"linux,dummy-virt",
 	NULL
@@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
 
 DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
 	.init_irq	= irqchip_init,
-	.init_time	= virt_timer_init,
 	.init_machine	= virt_init,
 	.smp		= smp_ops(virt_smp_ops),
 	.dt_compat	= virt_dt_match,
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index 91e2a6a..bf6ab242 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
 	return cval;
 }
 
+static inline int arch_timer_arch_init(void)
+{
+	return 0;
+}
+
 #endif
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
index b0ef18d..a551f88 100644
--- a/arch/arm64/kernel/time.c
+++ b/arch/arm64/kernel/time.c
@@ -32,6 +32,7 @@
 #include <linux/timer.h>
 #include <linux/irq.h>
 #include <linux/delay.h>
+#include <linux/clocksource.h>
 
 #include <clocksource/arm_arch_timer.h>
 
@@ -77,10 +78,11 @@ void __init time_init(void)
 {
 	u32 arch_timer_rate;
 
-	if (arch_timer_init())
-		panic("Unable to initialise architected timer.\n");
+	clocksource_of_init();
 
 	arch_timer_rate = arch_timer_get_rate();
+	if (!arch_timer_rate)
+		panic("Unable to initialise architected timer.\n");
 
 	/* Cache the sched_clock multiplier to save a divide in the hot path. */
 	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index e507ab7..d98e7e1 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
 
 config ARM_ARCH_TIMER
 	bool
+	select CLKSRC_OF if OF
 
 config CLKSRC_METAG_GENERIC
 	def_bool y if METAG
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index d7ad425..122ff05 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -337,22 +337,14 @@ out:
 	return err;
 }
 
-static const struct of_device_id arch_timer_of_match[] __initconst = {
-	{ .compatible	= "arm,armv7-timer",	},
-	{ .compatible	= "arm,armv8-timer",	},
-	{},
-};
-
-int __init arch_timer_init(void)
+static void __init arch_timer_init(struct device_node *np)
 {
-	struct device_node *np;
 	u32 freq;
 	int i;
 
-	np = of_find_matching_node(NULL, arch_timer_of_match);
-	if (!np) {
-		pr_err("arch_timer: can't find DT node\n");
-		return -ENODEV;
+	if (arch_timer_get_rate()) {
+		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
+		return;
 	}
 
 	/* Try to determine the frequency from the device tree or CNTFRQ */
@@ -378,7 +370,7 @@ int __init arch_timer_init(void)
 		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
 		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
 			pr_warn("arch_timer: No interrupt available, giving up\n");
-			return -EINVAL;
+			return;
 		}
 	}
 
@@ -387,5 +379,8 @@ int __init arch_timer_init(void)
 	else
 		arch_timer_read_counter = arch_counter_get_cntpct;
 
-	return arch_timer_register();
+	arch_timer_register();
+	arch_timer_arch_init();
 }
+CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
+CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
index 2603267..e6c9c4c 100644
--- a/include/clocksource/arm_arch_timer.h
+++ b/include/clocksource/arm_arch_timer.h
@@ -31,18 +31,12 @@
 
 #ifdef CONFIG_ARM_ARCH_TIMER
 
-extern int arch_timer_init(void);
 extern u32 arch_timer_get_rate(void);
 extern u64 (*arch_timer_read_counter)(void);
 extern struct timecounter *arch_timer_get_timecounter(void);
 
 #else
 
-static inline int arch_timer_init(void)
-{
-	return -ENXIO;
-}
-
 static inline u32 arch_timer_get_rate(void)
 {
 	return 0;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 03/13] OF: add empty of_device_is_available for !OF
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
  2013-04-01 22:21 ` [PATCH v2 01/13] ARM: make machine_desc->init_time default to clocksource_of_init Rob Herring
  2013-04-01 22:21   ` Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-01 22:21 ` [PATCH v2 04/13] ARM: timer-sp: convert to use CLKSRC_OF init Rob Herring
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Add an empty version of of_device_is_available.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 include/linux/of.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/of.h b/include/linux/of.h
index a0f1292..95c8583 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -379,6 +379,11 @@ static inline int of_device_is_compatible(const struct device_node *device,
 	return 0;
 }
 
+static inline int of_device_is_available(const struct device_node *device)
+{
+	return 0;
+}
+
 static inline struct property *of_find_property(const struct device_node *np,
 						const char *name,
 						int *lenp)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 04/13] ARM: timer-sp: convert to use CLKSRC_OF init
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (2 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 03/13] OF: add empty of_device_is_available for !OF Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-19 16:30   ` Russell King - ARM Linux
  2013-04-01 22:21 ` [PATCH v2 05/13] ARM: highbank: use OF init for sp804 timer Rob Herring
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

This adds CLKSRC_OF based init for sp804 timer. The clock initialization is
refactored to support retrieving the clock(s) from the DT.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/Kconfig                         |    1 +
 arch/arm/common/timer-sp.c               |  105 +++++++++++++++++++++++++-----
 arch/arm/include/asm/hardware/timer-sp.h |   16 +++--
 3 files changed, 102 insertions(+), 20 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5bfd584..10e3053 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1173,6 +1173,7 @@ config PLAT_VERSATILE
 config ARM_TIMER_SP804
 	bool
 	select CLKSRC_MMIO
+	select CLKSRC_OF if OF
 	select HAVE_SCHED_CLOCK
 
 source arch/arm/mm/Kconfig
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index 9d2d3ba..ded926f 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -25,33 +25,28 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 
 #include <asm/sched_clock.h>
 #include <asm/hardware/arm_timer.h>
 
-static long __init sp804_get_clock_rate(const char *name)
+static long __init sp804_get_clock_rate(struct clk *clk)
 {
-	struct clk *clk;
 	long rate;
 	int err;
 
-	clk = clk_get_sys("sp804", name);
-	if (IS_ERR(clk)) {
-		pr_err("sp804: %s clock not found: %d\n", name,
-			(int)PTR_ERR(clk));
-		return PTR_ERR(clk);
-	}
-
 	err = clk_prepare(clk);
 	if (err) {
-		pr_err("sp804: %s clock failed to prepare: %d\n", name, err);
+		pr_err("sp804: clock failed to prepare: %d\n", err);
 		clk_put(clk);
 		return err;
 	}
 
 	err = clk_enable(clk);
 	if (err) {
-		pr_err("sp804: %s clock failed to enable: %d\n", name, err);
+		pr_err("sp804: clock failed to enable: %d\n", err);
 		clk_unprepare(clk);
 		clk_put(clk);
 		return err;
@@ -59,7 +54,7 @@ static long __init sp804_get_clock_rate(const char *name)
 
 	rate = clk_get_rate(clk);
 	if (rate < 0) {
-		pr_err("sp804: %s clock failed to get rate: %ld\n", name, rate);
+		pr_err("sp804: clock failed to get rate: %ld\n", rate);
 		clk_disable(clk);
 		clk_unprepare(clk);
 		clk_put(clk);
@@ -77,9 +72,21 @@ static u32 sp804_read(void)
 
 void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
 						     const char *name,
+						     struct clk *clk,
 						     int use_sched_clock)
 {
-	long rate = sp804_get_clock_rate(name);
+	long rate;
+
+	if (!clk) {
+		clk = clk_get_sys("sp804", name);
+		if (IS_ERR(clk)) {
+			pr_err("sp804: clock not found: %d\n",
+			       (int)PTR_ERR(clk));
+			return;
+		}
+	}
+
+	rate = sp804_get_clock_rate(clk);
 
 	if (rate < 0)
 		return;
@@ -171,12 +178,20 @@ static struct irqaction sp804_timer_irq = {
 	.dev_id		= &sp804_clockevent,
 };
 
-void __init sp804_clockevents_init(void __iomem *base, unsigned int irq,
-	const char *name)
+void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct clk *clk, const char *name)
 {
 	struct clock_event_device *evt = &sp804_clockevent;
-	long rate = sp804_get_clock_rate(name);
+	long rate;
+
+	if (!clk)
+		clk = clk_get_sys("sp804", name);
+	if (IS_ERR(clk)) {
+		pr_err("sp804: %s clock not found: %d\n", name,
+			(int)PTR_ERR(clk));
+		return;
+	}
 
+	rate = sp804_get_clock_rate(clk);
 	if (rate < 0)
 		return;
 
@@ -186,6 +201,64 @@ void __init sp804_clockevents_init(void __iomem *base, unsigned int irq,
 	evt->irq = irq;
 	evt->cpumask = cpu_possible_mask;
 
+	writel(0, base + TIMER_CTRL);
+
 	setup_irq(irq, &sp804_timer_irq);
 	clockevents_config_and_register(evt, rate, 0xf, 0xffffffff);
 }
+
+static void __init sp804_of_init(struct device_node *np)
+{
+	static bool initialized = false;
+	void __iomem *base;
+	int irq;
+	u32 irq_num = 0;
+	struct clk *clk1, *clk2;
+	const char *name = of_get_property(np, "compatible", NULL);
+
+	base = of_iomap(np, 0);
+	if (WARN_ON(!base))
+		return;
+
+	/* Ensure timers are disabled */
+	writel(0, base + TIMER_CTRL);
+	writel(0, base + TIMER_2_BASE + TIMER_CTRL);
+
+	if (initialized || !of_device_is_available(np))
+		goto err;
+
+	clk1 = of_clk_get(np, 0);
+	if (IS_ERR(clk1))
+		clk1 = NULL;
+
+	/* Get the 2nd clock if the timer has 2 timer clocks */
+	if (of_count_phandle_with_args(np, "clocks", "#clock-cells") == 3) {
+		clk2 = of_clk_get(np, 1);
+		if (IS_ERR(clk2)) {
+			pr_err("sp804: %s clock not found: %d\n", np->name,
+				(int)PTR_ERR(clk2));
+			goto err;
+		}
+	} else
+		clk2 = clk1;
+
+	irq = irq_of_parse_and_map(np, 0);
+	if (irq <= 0)
+		goto err;
+
+	of_property_read_u32(np, "arm,sp804-has-irq", &irq_num);
+	if (irq_num == 2) {
+		__sp804_clockevents_init(base + TIMER_2_BASE, irq, clk2, name);
+		__sp804_clocksource_and_sched_clock_init(base, name, clk1, 1);
+	} else {
+		__sp804_clockevents_init(base, irq, clk1 , name);
+		__sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE,
+							 name, clk2, 1);
+	}
+	initialized = true;
+
+	return;
+err:
+	iounmap(base);
+}
+CLOCKSOURCE_OF_DECLARE(sp804, "arm,sp804", sp804_of_init);
diff --git a/arch/arm/include/asm/hardware/timer-sp.h b/arch/arm/include/asm/hardware/timer-sp.h
index 2dd9d3f..bb28af7 100644
--- a/arch/arm/include/asm/hardware/timer-sp.h
+++ b/arch/arm/include/asm/hardware/timer-sp.h
@@ -1,15 +1,23 @@
+struct clk;
+
 void __sp804_clocksource_and_sched_clock_init(void __iomem *,
-					      const char *, int);
+					      const char *, struct clk *, int);
+void __sp804_clockevents_init(void __iomem *, unsigned int,
+			      struct clk *, const char *);
 
 static inline void sp804_clocksource_init(void __iomem *base, const char *name)
 {
-	__sp804_clocksource_and_sched_clock_init(base, name, 0);
+	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 0);
 }
 
 static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base,
 							  const char *name)
 {
-	__sp804_clocksource_and_sched_clock_init(base, name, 1);
+	__sp804_clocksource_and_sched_clock_init(base, name, NULL, 1);
 }
 
-void sp804_clockevents_init(void __iomem *, unsigned int, const char *);
+static inline void sp804_clockevents_init(void __iomem *base, unsigned int irq, const char *name)
+{
+	__sp804_clockevents_init(base, irq, NULL, name);
+
+}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 05/13] ARM: highbank: use OF init for sp804 timer
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (3 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 04/13] ARM: timer-sp: convert to use CLKSRC_OF init Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-01 22:21 ` [PATCH v2 06/13] ARM: vexpress: remove sp804 OF init Rob Herring
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Remove the highbank specific setup for the sp804 timer now that
clocksource_of_init will do it.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-highbank/highbank.c |   19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 758150e..e7df2dd 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -32,8 +32,6 @@
 #include <asm/cacheflush.h>
 #include <asm/cputype.h>
 #include <asm/smp_plat.h>
-#include <asm/hardware/arm_timer.h>
-#include <asm/hardware/timer-sp.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -90,33 +88,16 @@ static void __init highbank_init_irq(void)
 #endif
 }
 
-static struct clk_lookup lookup = {
-	.dev_id = "sp804",
-	.con_id = NULL,
-};
-
 static void __init highbank_timer_init(void)
 {
-	int irq;
 	struct device_node *np;
-	void __iomem *timer_base;
 
 	/* Map system registers */
 	np = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs");
 	sregs_base = of_iomap(np, 0);
 	WARN_ON(!sregs_base);
 
-	np = of_find_compatible_node(NULL, NULL, "arm,sp804");
-	timer_base = of_iomap(np, 0);
-	WARN_ON(!timer_base);
-	irq = irq_of_parse_and_map(np, 0);
-
 	of_clk_init(NULL);
-	lookup.clk = of_clk_get(np, 0);
-	clkdev_add(&lookup);
-
-	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
-	sp804_clockevents_init(timer_base, irq, "timer0");
 
 	clocksource_of_init();
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 06/13] ARM: vexpress: remove sp804 OF init
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (4 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 05/13] ARM: highbank: use OF init for sp804 timer Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-02 16:41   ` Pawel Moll
  2013-04-01 22:21 ` [PATCH v2 07/13] ARM: dts: vexpress: disable CA9 core tile sp804 timer Rob Herring
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Remove the vexpress specific setup for the sp804 timer now that
clocksource_of_init will do it.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-vexpress/v2m.c |   11 -----------
 1 file changed, 11 deletions(-)

diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 6215717..cdc29d8 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -431,20 +431,9 @@ void __init v2m_dt_init_early(void)
 
 static void __init v2m_dt_timer_init(void)
 {
-	struct device_node *node = NULL;
-
 	vexpress_clk_of_init();
 
 	clocksource_of_init();
-	do {
-		node = of_find_compatible_node(node, NULL, "arm,sp804");
-	} while (node && vexpress_get_site_by_node(node) != VEXPRESS_SITE_MB);
-	if (node) {
-		pr_info("Using SP804 '%s' as a clock & events source\n",
-				node->full_name);
-		v2m_sp804_init(of_iomap(node, 0),
-				irq_of_parse_and_map(node, 0));
-	}
 
 	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
 				24000000);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 07/13] ARM: dts: vexpress: disable CA9 core tile sp804 timer
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (5 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 06/13] ARM: vexpress: remove sp804 OF init Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-02 16:47   ` Pawel Moll
  2013-04-01 22:21 ` [PATCH v2 08/13] ARM: vexpress: remove extra timer-sp control register clearing Rob Herring
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

The motherboard sp804 timer is used, but core tile sp804 timer is not.
According to Russell King, the clock configuration is undocumented and
defaults to 32kHz which is not desireable. So mark core tile sp804 timer
as disabled.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/boot/dts/vexpress-v2p-ca9.dts |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/vexpress-v2p-ca9.dts b/arch/arm/boot/dts/vexpress-v2p-ca9.dts
index 1420bb1..62d9b22 100644
--- a/arch/arm/boot/dts/vexpress-v2p-ca9.dts
+++ b/arch/arm/boot/dts/vexpress-v2p-ca9.dts
@@ -98,6 +98,7 @@
 			     <0 49 4>;
 		clocks = <&oscclk2>, <&oscclk2>;
 		clock-names = "timclk", "apb_pclk";
+		status = "disabled";
 	};
 
 	watchdog at 100e5000 {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 08/13] ARM: vexpress: remove extra timer-sp control register clearing
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (6 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 07/13] ARM: dts: vexpress: disable CA9 core tile sp804 timer Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-02 16:48   ` Pawel Moll
  2013-04-01 22:21 ` [PATCH v2 09/13] ARM: versatile: add versatile dtbs to dtbs target Rob Herring
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

The timer-sp initialization code clears the control register before
initializing the timers, so every platform doing this is redundant.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-vexpress/v2m.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index cdc29d8..09e571d 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -61,9 +61,6 @@ static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
 	if (WARN_ON(!base || irq == NO_IRQ))
 		return;
 
-	writel(0, base + TIMER_1_BASE + TIMER_CTRL);
-	writel(0, base + TIMER_2_BASE + TIMER_CTRL);
-
 	sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
 	sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 09/13] ARM: versatile: add versatile dtbs to dtbs target
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (7 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 08/13] ARM: vexpress: remove extra timer-sp control register clearing Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-01 22:21 ` [PATCH v2 10/13] ARM: versatile: use OF init for sp804 timer Rob Herring
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Add the versatile platform dtbs to the dtbs make rule.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/boot/dts/Makefile |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 9c62558..08d298d 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -165,6 +165,8 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \
 	tegra30-cardhu-a04.dtb \
 	tegra114-dalmore.dtb \
 	tegra114-pluto.dtb
+dtb-$(CONFIG_ARCH_VERSATILE) += versatile-ab.dtb \
+	versatile-pb.dtb
 dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \
 	vexpress-v2p-ca9.dtb \
 	vexpress-v2p-ca15-tc1.dtb \
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 10/13] ARM: versatile: use OF init for sp804 timer
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (8 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 09/13] ARM: versatile: add versatile dtbs to dtbs target Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-01 22:21 ` [PATCH v2 11/13] ARM: integrator-cp: convert use CLKSRC_OF for timer init Rob Herring
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Enable DT based init for the sp804 timers on versatile DT platform.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/boot/dts/versatile-ab.dts     |   12 ++++++++++++
 arch/arm/mach-versatile/core.c         |   26 +++++++++++++-------------
 arch/arm/mach-versatile/versatile_dt.c |    1 -
 3 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/versatile-ab.dts b/arch/arm/boot/dts/versatile-ab.dts
index e2fe319..dde75ae 100644
--- a/arch/arm/boot/dts/versatile-ab.dts
+++ b/arch/arm/boot/dts/versatile-ab.dts
@@ -121,6 +121,18 @@
 			interrupts = <0>;
 		};
 
+		timer at 101e2000 {
+			compatible = "arm,sp804", "arm,primecell";
+			reg = <0x101e2000 0x1000>;
+			interrupts = <4>;
+		};
+
+		timer at 101e3000 {
+			compatible = "arm,sp804", "arm,primecell";
+			reg = <0x101e3000 0x1000>;
+			interrupts = <5>;
+		};
+
 		gpio0: gpio at 101e4000 {
 			compatible = "arm,pl061", "arm,primecell";
 			reg = <0x101e4000 0x1000>;
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 25160ae..54bb80b 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -749,12 +749,25 @@ void versatile_restart(char mode, const char *cmd)
 /* Early initializations */
 void __init versatile_init_early(void)
 {
+	u32 val;
 	void __iomem *sys = __io_address(VERSATILE_SYS_BASE);
 
 	osc4_clk.vcoreg	= sys + VERSATILE_SYS_OSCCLCD_OFFSET;
 	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
 	versatile_sched_clock_init(sys + VERSATILE_SYS_24MHz_OFFSET, 24000000);
+
+	/*
+	 * set clock frequency:
+	 *	VERSATILE_REFCLK is 32KHz
+	 *	VERSATILE_TIMCLK is 1MHz
+	 */
+	val = readl(__io_address(VERSATILE_SCTL_BASE));
+	writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) |
+	       (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) |
+	       (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) |
+	       (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val,
+	       __io_address(VERSATILE_SCTL_BASE));
 }
 
 void __init versatile_init(void)
@@ -785,19 +798,6 @@ void __init versatile_init(void)
  */
 void __init versatile_timer_init(void)
 {
-	u32 val;
-
-	/* 
-	 * set clock frequency: 
-	 *	VERSATILE_REFCLK is 32KHz
-	 *	VERSATILE_TIMCLK is 1MHz
-	 */
-	val = readl(__io_address(VERSATILE_SCTL_BASE));
-	writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) |
-	       (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | 
-	       (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) |
-	       (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val,
-	       __io_address(VERSATILE_SCTL_BASE));
 
 	/*
 	 * Initialise to a known state (all timers off)
diff --git a/arch/arm/mach-versatile/versatile_dt.c b/arch/arm/mach-versatile/versatile_dt.c
index 2558f2e..3621b00 100644
--- a/arch/arm/mach-versatile/versatile_dt.c
+++ b/arch/arm/mach-versatile/versatile_dt.c
@@ -45,7 +45,6 @@ DT_MACHINE_START(VERSATILE_PB, "ARM-Versatile (Device Tree Support)")
 	.map_io		= versatile_map_io,
 	.init_early	= versatile_init_early,
 	.init_irq	= versatile_init_irq,
-	.init_time	= versatile_timer_init,
 	.init_machine	= versatile_dt_init,
 	.dt_compat	= versatile_dt_match,
 	.restart	= versatile_restart,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 11/13] ARM: integrator-cp: convert use CLKSRC_OF for timer init
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (9 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 10/13] ARM: versatile: use OF init for sp804 timer Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-01 22:21 ` [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource Rob Herring
  2013-04-01 22:21 ` [PATCH v2 13/13] devtree: add binding documentation for sp804 Rob Herring
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Move the integrator-cp timer init to timer-sp.c and use CLKSRC_OF. There is
no reason to use the aliases, so drop them from the init code.

The integrator-cp timers are mistakenly called sp804 timers in the dts, but
in fact they are not sp804 dual timers, but single timers with the same
programming model. Fix the dts to reflect this.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/boot/dts/integratorcp.dts       |    6 ++---
 arch/arm/common/timer-sp.c               |   35 ++++++++++++++++++++++++++++++
 arch/arm/mach-integrator/integrator_cp.c |   34 -----------------------------
 3 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/arch/arm/boot/dts/integratorcp.dts b/arch/arm/boot/dts/integratorcp.dts
index 8b11939..ff1aea0 100644
--- a/arch/arm/boot/dts/integratorcp.dts
+++ b/arch/arm/boot/dts/integratorcp.dts
@@ -24,15 +24,15 @@
 	};
 
 	timer0: timer at 13000000 {
-		compatible = "arm,sp804", "arm,primecell";
+		compatible = "arm,integrator-cp-timer";
 	};
 
 	timer1: timer at 13000100 {
-		compatible = "arm,sp804", "arm,primecell";
+		compatible = "arm,integrator-cp-timer";
 	};
 
 	timer2: timer at 13000200 {
-		compatible = "arm,sp804", "arm,primecell";
+		compatible = "arm,integrator-cp-timer";
 	};
 
 	pic: pic at 14000000 {
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index ded926f..ddc7407 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -31,6 +31,7 @@
 
 #include <asm/sched_clock.h>
 #include <asm/hardware/arm_timer.h>
+#include <asm/hardware/timer-sp.h>
 
 static long __init sp804_get_clock_rate(struct clk *clk)
 {
@@ -262,3 +263,37 @@ err:
 	iounmap(base);
 }
 CLOCKSOURCE_OF_DECLARE(sp804, "arm,sp804", sp804_of_init);
+
+static void __init integrator_cp_of_init(struct device_node *np)
+{
+	static int init_count = 0;
+	void __iomem *base;
+	int irq;
+	const char *name = of_get_property(np, "compatible", NULL);
+
+	base = of_iomap(np, 0);
+	if (WARN_ON(!base))
+		return;
+
+	/* Ensure timer is disabled */
+	writel(0, base + TIMER_CTRL);
+
+	if (init_count == 2 || !of_device_is_available(np))
+		goto err;
+
+	if (!init_count)
+		sp804_clocksource_init(base, name);
+	else {
+		irq = irq_of_parse_and_map(np, 0);
+		if (irq <= 0)
+			goto err;
+
+		sp804_clockevents_init(base, irq, name);
+	}
+
+	init_count++;
+	return;
+err:
+	iounmap(base);
+}
+CLOCKSOURCE_OF_DECLARE(intcp, "arm,integrator-cp-timer", integrator_cp_of_init);
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 2b0db82..5781f3c 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -250,39 +250,6 @@ static void __init intcp_init_early(void)
 }
 
 #ifdef CONFIG_OF
-
-static void __init cp_of_timer_init(void)
-{
-	struct device_node *node;
-	const char *path;
-	void __iomem *base;
-	int err;
-	int irq;
-
-	err = of_property_read_string(of_aliases,
-				"arm,timer-primary", &path);
-	if (WARN_ON(err))
-		return;
-	node = of_find_node_by_path(path);
-	base = of_iomap(node, 0);
-	if (WARN_ON(!base))
-		return;
-	writel(0, base + TIMER_CTRL);
-	sp804_clocksource_init(base, node->name);
-
-	err = of_property_read_string(of_aliases,
-				"arm,timer-secondary", &path);
-	if (WARN_ON(err))
-		return;
-	node = of_find_node_by_path(path);
-	base = of_iomap(node, 0);
-	if (WARN_ON(!base))
-		return;
-	irq = irq_of_parse_and_map(node, 0);
-	writel(0, base + TIMER_CTRL);
-	sp804_clockevents_init(base, irq, node->name);
-}
-
 static const struct of_device_id fpga_irq_of_match[] __initconst = {
 	{ .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, },
 	{ /* Sentinel */ }
@@ -386,7 +353,6 @@ DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)")
 	.init_early	= intcp_init_early,
 	.init_irq	= intcp_init_irq_of,
 	.handle_irq	= fpga_handle_irq,
-	.init_time	= cp_of_timer_init,
 	.init_machine	= intcp_init_of,
 	.restart	= integrator_restart,
 	.dt_compat      = intcp_dt_board_compat,
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (10 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 11/13] ARM: integrator-cp: convert use CLKSRC_OF for timer init Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  2013-04-01 23:26   ` John Stultz
  2013-04-01 22:21 ` [PATCH v2 13/13] devtree: add binding documentation for sp804 Rob Herring
  12 siblings, 1 reply; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Move timer-sp and integrator-ap timer code to drivers/clocksource and
update timer-sp.h and arm_timer.h includes.

This adds CLKSRC_OF support for the integrator-ap timer and removes the
use of "arm,timer-primary" and "arm,timer-secondary" aliases. The timer
selection should not be important as all 3 timers are equal capability.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 arch/arm/Kconfig                                   |    6 -
 arch/arm/common/Makefile                           |    1 -
 arch/arm/mach-integrator/Kconfig                   |    1 +
 arch/arm/mach-integrator/integrator_ap.c           |  170 +-----------------
 arch/arm/mach-integrator/integrator_cp.c           |    5 +-
 arch/arm/mach-realview/core.c                      |    5 +-
 arch/arm/mach-versatile/core.c                     |    4 +-
 arch/arm/mach-vexpress/ct-ca9x4.c                  |    4 +-
 arch/arm/mach-vexpress/v2m.c                       |    4 +-
 drivers/clocksource/Kconfig                        |   12 ++
 drivers/clocksource/Makefile                       |    2 +
 drivers/clocksource/integrator_ap_timer.c          |  189 ++++++++++++++++++++
 .../arm/common => drivers/clocksource}/timer-sp.c  |    6 +-
 .../hardware => include/clocksource}/arm_timer.h   |    4 +-
 include/clocksource/integrator_ap_timer.h          |    7 +
 .../hardware => include/clocksource}/timer-sp.h    |    0
 16 files changed, 226 insertions(+), 194 deletions(-)
 create mode 100644 drivers/clocksource/integrator_ap_timer.c
 rename {arch/arm/common => drivers/clocksource}/timer-sp.c (98%)
 rename {arch/arm/include/asm/hardware => include/clocksource}/arm_timer.h (93%)
 create mode 100644 include/clocksource/integrator_ap_timer.h
 rename {arch/arm/include/asm/hardware => include/clocksource}/timer-sp.h (100%)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 10e3053..982076c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1170,12 +1170,6 @@ config PLAT_PXA
 config PLAT_VERSATILE
 	bool
 
-config ARM_TIMER_SP804
-	bool
-	select CLKSRC_MMIO
-	select CLKSRC_OF if OF
-	select HAVE_SCHED_CLOCK
-
 source arch/arm/mm/Kconfig
 
 config ARM_NR_BANKS
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index dc8dd0d..5a4cc1a 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -10,4 +10,3 @@ obj-$(CONFIG_SHARP_LOCOMO)	+= locomo.o
 obj-$(CONFIG_SHARP_PARAM)	+= sharpsl_param.o
 obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
-obj-$(CONFIG_ARM_TIMER_SP804)	+= timer-sp.o
diff --git a/arch/arm/mach-integrator/Kconfig b/arch/arm/mach-integrator/Kconfig
index abeff25..c5e4ff3 100644
--- a/arch/arm/mach-integrator/Kconfig
+++ b/arch/arm/mach-integrator/Kconfig
@@ -5,6 +5,7 @@ menu "Integrator Options"
 config ARCH_INTEGRATOR_AP
 	bool "Support Integrator/AP and Integrator/PP2 platforms"
 	select CLKSRC_MMIO
+	select INTEGRATOR_AP_TIMER
 	select MIGHT_HAVE_PCI
 	select SERIAL_AMBA_PL010
 	select SERIAL_AMBA_PL010_CONSOLE
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index ea96144..c364e8e 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -27,8 +27,6 @@
 #include <linux/syscore_ops.h>
 #include <linux/amba/bus.h>
 #include <linux/amba/kmi.h>
-#include <linux/clocksource.h>
-#include <linux/clockchips.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irqchip/versatile-fpga.h>
@@ -41,15 +39,15 @@
 #include <linux/stat.h>
 #include <linux/sys_soc.h>
 #include <linux/termios.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/integrator_ap_timer.h>
 #include <video/vga.h>
 
 #include <mach/hardware.h>
 #include <mach/platform.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/setup.h>
 #include <asm/param.h>		/* HZ */
 #include <asm/mach-types.h>
-#include <asm/sched_clock.h>
 
 #include <mach/lm.h>
 #include <mach/irqs.h>
@@ -58,7 +56,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 #include <asm/mach/pci.h>
-#include <asm/mach/time.h>
 
 #include "common.h"
 
@@ -296,174 +293,12 @@ struct amba_pl010_data ap_uart_data = {
 #define TIMER1_VA_BASE __io_address(INTEGRATOR_TIMER1_BASE)
 #define TIMER2_VA_BASE __io_address(INTEGRATOR_TIMER2_BASE)
 
-static unsigned long timer_reload;
-
-static u32 notrace integrator_read_sched_clock(void)
-{
-	return -readl((void __iomem *) TIMER2_VA_BASE + TIMER_VALUE);
-}
-
-static void integrator_clocksource_init(unsigned long inrate,
-					void __iomem *base)
-{
-	u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
-	unsigned long rate = inrate;
-
-	if (rate >= 1500000) {
-		rate /= 16;
-		ctrl |= TIMER_CTRL_DIV16;
-	}
-
-	writel(0xffff, base + TIMER_LOAD);
-	writel(ctrl, base + TIMER_CTRL);
-
-	clocksource_mmio_init(base + TIMER_VALUE, "timer2",
-			rate, 200, 16, clocksource_mmio_readl_down);
-	setup_sched_clock(integrator_read_sched_clock, 16, rate);
-}
-
-static void __iomem * clkevt_base;
-
-/*
- * IRQ handler for the timer
- */
-static irqreturn_t integrator_timer_interrupt(int irq, void *dev_id)
-{
-	struct clock_event_device *evt = dev_id;
-
-	/* clear the interrupt */
-	writel(1, clkevt_base + TIMER_INTCLR);
-
-	evt->event_handler(evt);
-
-	return IRQ_HANDLED;
-}
-
-static void clkevt_set_mode(enum clock_event_mode mode, struct clock_event_device *evt)
-{
-	u32 ctrl = readl(clkevt_base + TIMER_CTRL) & ~TIMER_CTRL_ENABLE;
-
-	/* Disable timer */
-	writel(ctrl, clkevt_base + TIMER_CTRL);
-
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		/* Enable the timer and start the periodic tick */
-		writel(timer_reload, clkevt_base + TIMER_LOAD);
-		ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE;
-		writel(ctrl, clkevt_base + TIMER_CTRL);
-		break;
-	case CLOCK_EVT_MODE_ONESHOT:
-		/* Leave the timer disabled, .set_next_event will enable it */
-		ctrl &= ~TIMER_CTRL_PERIODIC;
-		writel(ctrl, clkevt_base + TIMER_CTRL);
-		break;
-	case CLOCK_EVT_MODE_UNUSED:
-	case CLOCK_EVT_MODE_SHUTDOWN:
-	case CLOCK_EVT_MODE_RESUME:
-	default:
-		/* Just leave in disabled state */
-		break;
-	}
-
-}
-
-static int clkevt_set_next_event(unsigned long next, struct clock_event_device *evt)
-{
-	unsigned long ctrl = readl(clkevt_base + TIMER_CTRL);
-
-	writel(ctrl & ~TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
-	writel(next, clkevt_base + TIMER_LOAD);
-	writel(ctrl | TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
-
-	return 0;
-}
-
-static struct clock_event_device integrator_clockevent = {
-	.name		= "timer1",
-	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-	.set_mode	= clkevt_set_mode,
-	.set_next_event	= clkevt_set_next_event,
-	.rating		= 300,
-};
-
-static struct irqaction integrator_timer_irq = {
-	.name		= "timer",
-	.flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
-	.handler	= integrator_timer_interrupt,
-	.dev_id		= &integrator_clockevent,
-};
-
-static void integrator_clockevent_init(unsigned long inrate,
-				void __iomem *base, int irq)
-{
-	unsigned long rate = inrate;
-	unsigned int ctrl = 0;
-
-	clkevt_base = base;
-	/* Calculate and program a divisor */
-	if (rate > 0x100000 * HZ) {
-		rate /= 256;
-		ctrl |= TIMER_CTRL_DIV256;
-	} else if (rate > 0x10000 * HZ) {
-		rate /= 16;
-		ctrl |= TIMER_CTRL_DIV16;
-	}
-	timer_reload = rate / HZ;
-	writel(ctrl, clkevt_base + TIMER_CTRL);
-
-	setup_irq(irq, &integrator_timer_irq);
-	clockevents_config_and_register(&integrator_clockevent,
-					rate,
-					1,
-					0xffffU);
-}
-
 void __init ap_init_early(void)
 {
 }
 
 #ifdef CONFIG_OF
 
-static void __init ap_of_timer_init(void)
-{
-	struct device_node *node;
-	const char *path;
-	void __iomem *base;
-	int err;
-	int irq;
-	struct clk *clk;
-	unsigned long rate;
-
-	clk = clk_get_sys("ap_timer", NULL);
-	BUG_ON(IS_ERR(clk));
-	clk_prepare_enable(clk);
-	rate = clk_get_rate(clk);
-
-	err = of_property_read_string(of_aliases,
-				"arm,timer-primary", &path);
-	if (WARN_ON(err))
-		return;
-	node = of_find_node_by_path(path);
-	base = of_iomap(node, 0);
-	if (WARN_ON(!base))
-		return;
-	writel(0, base + TIMER_CTRL);
-	integrator_clocksource_init(rate, base);
-
-	err = of_property_read_string(of_aliases,
-				"arm,timer-secondary", &path);
-	if (WARN_ON(err))
-		return;
-	node = of_find_node_by_path(path);
-	base = of_iomap(node, 0);
-	if (WARN_ON(!base))
-		return;
-	irq = irq_of_parse_and_map(node, 0);
-	writel(0, base + TIMER_CTRL);
-	integrator_clockevent_init(rate, base, irq);
-}
-
 static const struct of_device_id fpga_irq_of_match[] __initconst = {
 	{ .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, },
 	{ /* Sentinel */ }
@@ -582,7 +417,6 @@ DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)")
 	.init_early	= ap_init_early,
 	.init_irq	= ap_init_irq_of,
 	.handle_irq	= fpga_handle_irq,
-	.init_time	= ap_of_timer_init,
 	.init_machine	= ap_init_of,
 	.restart	= integrator_restart,
 	.dt_compat      = ap_dt_board_compat,
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 5781f3c..19e2497 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -28,12 +28,13 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/sys_soc.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <mach/hardware.h>
 #include <mach/platform.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/icst.h>
 
 #include <mach/cm.h>
@@ -45,8 +46,6 @@
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 
-#include <asm/hardware/timer-sp.h>
-
 #include <plat/clcd.h>
 #include <plat/sched_clock.h>
 
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 1d5ee5c..ac59770 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -31,21 +31,20 @@
 #include <linux/amba/mmci.h>
 #include <linux/gfp.h>
 #include <linux/mtd/physmap.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
 #include <asm/mach-types.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/icst.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 
-
 #include <mach/platform.h>
 #include <mach/irqs.h>
-#include <asm/hardware/timer-sp.h>
 
 #include <plat/clcd.h>
 #include <plat/sched_clock.h>
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 54bb80b..84f26c7 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -38,9 +38,10 @@
 #include <linux/clkdev.h>
 #include <linux/mtd/physmap.h>
 #include <linux/bitops.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <asm/irq.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/icst.h>
 #include <asm/mach-types.h>
 
@@ -50,7 +51,6 @@
 #include <asm/mach/map.h>
 #include <mach/hardware.h>
 #include <mach/platform.h>
-#include <asm/hardware/timer-sp.h>
 
 #include <plat/clcd.h>
 #include <plat/sched_clock.h>
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index 6f34497..8cce326 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -11,16 +11,14 @@
 #include <linux/clkdev.h>
 #include <linux/vexpress.h>
 #include <linux/irqchip/arm-gic.h>
+#include <clocksource/timer-sp.h>
 
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/smp_scu.h>
 #include <asm/smp_twd.h>
 
 #include <mach/ct-ca9x4.h>
 
-#include <asm/hardware/timer-sp.h>
-
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 09e571d..dc15485 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -23,15 +23,15 @@
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 #include <linux/vexpress.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <asm/mach-types.h>
 #include <asm/sizes.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
-#include <asm/hardware/arm_timer.h>
 #include <asm/hardware/cache-l2x0.h>
-#include <asm/hardware/timer-sp.h>
 
 #include <mach/ct-ca9x4.h>
 #include <mach/motherboard.h>
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index d98e7e1..00aa4cd 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -25,6 +25,18 @@ config DW_APB_TIMER_OF
 config ARMADA_370_XP_TIMER
 	bool
 
+config ARM_TIMER_SP804
+	bool
+	depends on ARM
+	select CLKSRC_MMIO
+	select CLKSRC_OF if OF
+	select HAVE_SCHED_CLOCK
+
+config INTEGRATOR_AP_TIMER
+	bool
+	depends on ARM
+	select CLKSRC_OF if OF
+
 config SUNXI_TIMER
 	bool
 
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 4d8283a..9f3b62b 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -14,8 +14,10 @@ obj-$(CONFIG_DW_APB_TIMER)	+= dw_apb_timer.o
 obj-$(CONFIG_DW_APB_TIMER_OF)	+= dw_apb_timer_of.o
 obj-$(CONFIG_CLKSRC_NOMADIK_MTU)	+= nomadik-mtu.o
 obj-$(CONFIG_CLKSRC_DBX500_PRCMU)	+= clksrc-dbx500-prcmu.o
+obj-$(CONFIG_ARM_TIMER_SP804)	+= timer-sp.o
 obj-$(CONFIG_ARMADA_370_XP_TIMER)	+= time-armada-370-xp.o
 obj-$(CONFIG_ARCH_BCM2835)	+= bcm2835_timer.o
+obj-$(CONFIG_INTEGRATOR_AP_TIMER)	+= integrator_ap_timer.o
 obj-$(CONFIG_SUNXI_TIMER)	+= sunxi_timer.o
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra20_timer.o
 obj-$(CONFIG_VT8500_TIMER)	+= vt8500_timer.o
diff --git a/drivers/clocksource/integrator_ap_timer.c b/drivers/clocksource/integrator_ap_timer.c
new file mode 100644
index 0000000..05e6204
--- /dev/null
+++ b/drivers/clocksource/integrator_ap_timer.c
@@ -0,0 +1,189 @@
+/*
+ *  Copyright (C) 2000-2003 Deep Blue Solutions Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/clocksource.h>
+#include <linux/clockchips.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/clk.h>
+#include <linux/of_irq.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <clocksource/timer-sp.h>
+#include <clocksource/arm_timer.h>
+
+#include <asm/sched_clock.h>
+
+static unsigned long timer_reload;
+static void __iomem *clksrc_base;
+
+static u32 notrace integrator_read_sched_clock(void)
+{
+	return -readl(clksrc_base + TIMER_VALUE);
+}
+
+void __init integrator_clocksource_init(unsigned long inrate,
+					void __iomem *base)
+{
+	u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
+	unsigned long rate = inrate;
+
+	clksrc_base = base;
+
+	if (rate >= 1500000) {
+		rate /= 16;
+		ctrl |= TIMER_CTRL_DIV16;
+	}
+
+	writel(0xffff, base + TIMER_LOAD);
+	writel(ctrl, base + TIMER_CTRL);
+
+	clocksource_mmio_init(base + TIMER_VALUE, "timer2",
+			rate, 200, 16, clocksource_mmio_readl_down);
+	setup_sched_clock(integrator_read_sched_clock, 16, rate);
+}
+
+static void __iomem * clkevt_base;
+
+/*
+ * IRQ handler for the timer
+ */
+static irqreturn_t integrator_timer_interrupt(int irq, void *dev_id)
+{
+	struct clock_event_device *evt = dev_id;
+
+	/* clear the interrupt */
+	writel(1, clkevt_base + TIMER_INTCLR);
+
+	evt->event_handler(evt);
+
+	return IRQ_HANDLED;
+}
+
+static void clkevt_set_mode(enum clock_event_mode mode, struct clock_event_device *evt)
+{
+	u32 ctrl = readl(clkevt_base + TIMER_CTRL) & ~TIMER_CTRL_ENABLE;
+
+	/* Disable timer */
+	writel(ctrl, clkevt_base + TIMER_CTRL);
+
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		/* Enable the timer and start the periodic tick */
+		writel(timer_reload, clkevt_base + TIMER_LOAD);
+		ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE;
+		writel(ctrl, clkevt_base + TIMER_CTRL);
+		break;
+	case CLOCK_EVT_MODE_ONESHOT:
+		/* Leave the timer disabled, .set_next_event will enable it */
+		ctrl &= ~TIMER_CTRL_PERIODIC;
+		writel(ctrl, clkevt_base + TIMER_CTRL);
+		break;
+	case CLOCK_EVT_MODE_UNUSED:
+	case CLOCK_EVT_MODE_SHUTDOWN:
+	case CLOCK_EVT_MODE_RESUME:
+	default:
+		/* Just leave in disabled state */
+		break;
+	}
+
+}
+
+static int clkevt_set_next_event(unsigned long next, struct clock_event_device *evt)
+{
+	unsigned long ctrl = readl(clkevt_base + TIMER_CTRL);
+
+	writel(ctrl & ~TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
+	writel(next, clkevt_base + TIMER_LOAD);
+	writel(ctrl | TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
+
+	return 0;
+}
+
+static struct clock_event_device integrator_clockevent = {
+	.name		= "timer1",
+	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
+	.set_mode	= clkevt_set_mode,
+	.set_next_event	= clkevt_set_next_event,
+	.rating		= 300,
+};
+
+static struct irqaction integrator_timer_irq = {
+	.name		= "timer",
+	.flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
+	.handler	= integrator_timer_interrupt,
+	.dev_id		= &integrator_clockevent,
+};
+
+void __init integrator_clockevent_init(unsigned long inrate,
+				       void __iomem *base, int irq)
+{
+	unsigned long rate = inrate;
+	unsigned int ctrl = 0;
+
+	clkevt_base = base;
+	/* Calculate and program a divisor */
+	if (rate > 0x100000 * HZ) {
+		rate /= 256;
+		ctrl |= TIMER_CTRL_DIV256;
+	} else if (rate > 0x10000 * HZ) {
+		rate /= 16;
+		ctrl |= TIMER_CTRL_DIV16;
+	}
+	timer_reload = rate / HZ;
+	writel(ctrl, clkevt_base + TIMER_CTRL);
+
+	setup_irq(irq, &integrator_timer_irq);
+	clockevents_config_and_register(&integrator_clockevent,
+					rate,
+					1,
+					0xffffU);
+}
+
+static void __init ap_of_timer_init(struct device_node *node)
+{
+	void __iomem *base;
+	int irq;
+	struct clk *clk;
+	unsigned long rate;
+
+	clk = clk_get_sys("ap_timer", NULL);
+	BUG_ON(IS_ERR(clk));
+	clk_prepare_enable(clk);
+	rate = clk_get_rate(clk);
+
+	base = of_iomap(node, 0);
+	if (WARN_ON(!base))
+		return;
+
+	writel(0, base + TIMER_CTRL);
+
+	if ((clksrc_base && clkevt_base) || !of_device_is_available(node)) {
+		iounmap(base);
+		return;
+	}
+
+	irq = irq_of_parse_and_map(node, 0);
+	if (!clkevt_base && (irq > 0))
+		integrator_clockevent_init(rate, base, irq);
+	else
+		integrator_clocksource_init(rate, base);
+}
+CLOCKSOURCE_OF_DECLARE(integrator_ap, "integrator-timer", ap_of_timer_init);
diff --git a/arch/arm/common/timer-sp.c b/drivers/clocksource/timer-sp.c
similarity index 98%
rename from arch/arm/common/timer-sp.c
rename to drivers/clocksource/timer-sp.c
index ddc7407..b0fc7f0 100644
--- a/arch/arm/common/timer-sp.c
+++ b/drivers/clocksource/timer-sp.c
@@ -1,6 +1,4 @@
 /*
- *  linux/arch/arm/common/timer-sp.c
- *
  *  Copyright (C) 1999 - 2003 ARM Limited
  *  Copyright (C) 2000 Deep Blue Solutions Ltd
  *
@@ -28,10 +26,10 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <clocksource/arm_timer.h>
+#include <clocksource/timer-sp.h>
 
 #include <asm/sched_clock.h>
-#include <asm/hardware/arm_timer.h>
-#include <asm/hardware/timer-sp.h>
 
 static long __init sp804_get_clock_rate(struct clk *clk)
 {
diff --git a/arch/arm/include/asm/hardware/arm_timer.h b/include/clocksource/arm_timer.h
similarity index 93%
rename from arch/arm/include/asm/hardware/arm_timer.h
rename to include/clocksource/arm_timer.h
index d6030ff..f4a443a 100644
--- a/arch/arm/include/asm/hardware/arm_timer.h
+++ b/include/clocksource/arm_timer.h
@@ -1,5 +1,5 @@
-#ifndef __ASM_ARM_HARDWARE_ARM_TIMER_H
-#define __ASM_ARM_HARDWARE_ARM_TIMER_H
+#ifndef __CLOCKSOURCE_ARM_TIMER_H
+#define __CLOCKSOURCE_ARM_TIMER_H
 
 /*
  * ARM timer implementation, found in Integrator, Versatile and Realview
diff --git a/include/clocksource/integrator_ap_timer.h b/include/clocksource/integrator_ap_timer.h
new file mode 100644
index 0000000..2f585fc
--- /dev/null
+++ b/include/clocksource/integrator_ap_timer.h
@@ -0,0 +1,7 @@
+#ifndef __CLOCKSOURCE_INTEGRATOR_AP_TIMER
+#define __CLOCKSOURCE_INTEGRATOR_AP_TIMER
+
+void integrator_clocksource_init(unsigned long inrate, void __iomem *base);
+void integrator_clockevent_init(unsigned long inrate, void __iomem *base, int irq);
+
+#endif
diff --git a/arch/arm/include/asm/hardware/timer-sp.h b/include/clocksource/timer-sp.h
similarity index 100%
rename from arch/arm/include/asm/hardware/timer-sp.h
rename to include/clocksource/timer-sp.h
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 13/13] devtree: add binding documentation for sp804
  2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
                   ` (11 preceding siblings ...)
  2013-04-01 22:21 ` [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource Rob Herring
@ 2013-04-01 22:21 ` Rob Herring
  12 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-01 22:21 UTC (permalink / raw)
  To: linux-arm-kernel

From: Haojian Zhuang <haojian.zhuang@linaro.org>

The sp804 binding is already in use by several platforms. This adds missing
documentation for the binding and also extends the binding to handle some
additional possible interrupt configurations.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 .../devicetree/bindings/timer/arm,sp804.txt        |   29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/arm,sp804.txt

diff --git a/Documentation/devicetree/bindings/timer/arm,sp804.txt b/Documentation/devicetree/bindings/timer/arm,sp804.txt
new file mode 100644
index 0000000..5cd8eee
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/arm,sp804.txt
@@ -0,0 +1,29 @@
+ARM sp804 Dual Timers
+---------------------------------------
+
+Required properties:
+- compatible: Should be "arm,sp804" & "arm,primecell"
+- interrupts: Should contain the list of Dual Timer interrupts. This is the
+	interrupt for timer 1 and timer 2. In the case of a single entry, it is
+	the combined interrupt or if "arm,sp804-has-irq" is present that
+	specifies which timer interrupt is connected.
+- reg: Should contain location and length for dual timer register.
+- clocks: clocks driving the dual timer hardware. This list should be 1 or 3
+	clocks.	With 3 clocks, the order is timer0 clock, timer1 clock,
+	apb_pclk. A single clock can also be specified if the same clock is
+	used for all clock inputs.
+
+Optional properties:
+- arm,sp804-has-irq = <#>: In the case of only 1 timer irq line connected, this
+	specifies if the irq connection is for timer 1 or timer 2. A value of 1
+	or 2 should be used.
+
+Example:
+
+	timer0: timer at fc800000 {
+		compatible = "arm,sp804", "arm,primecell";
+		reg = <0xfc800000 0x1000>;
+		interrupts = <0 0 4>, <0 1 4>;
+		clocks = <&timclk1 &timclk2 &pclk>;
+		clock-names = "timer1", "timer2", "apb_pclk";
+	};
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-01 22:21 ` [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource Rob Herring
@ 2013-04-01 23:26   ` John Stultz
  2013-04-02 19:49     ` Rob Herring
  0 siblings, 1 reply; 44+ messages in thread
From: John Stultz @ 2013-04-01 23:26 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/01/2013 03:21 PM, Rob Herring wrote:
> diff --git a/drivers/clocksource/integrator_ap_timer.c b/drivers/clocksource/integrator_ap_timer.c
> new file mode 100644
> index 0000000..05e6204
> --- /dev/null
> +++ b/drivers/clocksource/integrator_ap_timer.c
[snip]
> +static void __iomem * clkevt_base;
> +
> +/*
> + * IRQ handler for the timer
> + */
> +static irqreturn_t integrator_timer_interrupt(int irq, void *dev_id)
> +{
> +	struct clock_event_device *evt = dev_id;
> +
> +	/* clear the interrupt */
> +	writel(1, clkevt_base + TIMER_INTCLR);
> +
> +	evt->event_handler(evt);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static void clkevt_set_mode(enum clock_event_mode mode, struct clock_event_device *evt)
> +{
> +	u32 ctrl = readl(clkevt_base + TIMER_CTRL) & ~TIMER_CTRL_ENABLE;
> +
> +	/* Disable timer */
> +	writel(ctrl, clkevt_base + TIMER_CTRL);
> +
> +	switch (mode) {
> +	case CLOCK_EVT_MODE_PERIODIC:
> +		/* Enable the timer and start the periodic tick */
> +		writel(timer_reload, clkevt_base + TIMER_LOAD);
> +		ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE;
> +		writel(ctrl, clkevt_base + TIMER_CTRL);
> +		break;
> +	case CLOCK_EVT_MODE_ONESHOT:
> +		/* Leave the timer disabled, .set_next_event will enable it */
> +		ctrl &= ~TIMER_CTRL_PERIODIC;
> +		writel(ctrl, clkevt_base + TIMER_CTRL);
> +		break;
> +	case CLOCK_EVT_MODE_UNUSED:
> +	case CLOCK_EVT_MODE_SHUTDOWN:
> +	case CLOCK_EVT_MODE_RESUME:
> +	default:
> +		/* Just leave in disabled state */
> +		break;
> +	}
> +
> +}
> +
> +static int clkevt_set_next_event(unsigned long next, struct clock_event_device *evt)
> +{
> +	unsigned long ctrl = readl(clkevt_base + TIMER_CTRL);
> +
> +	writel(ctrl & ~TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
> +	writel(next, clkevt_base + TIMER_LOAD);
> +	writel(ctrl | TIMER_CTRL_ENABLE, clkevt_base + TIMER_CTRL);
> +
> +	return 0;
> +}
> +
> +static struct clock_event_device integrator_clockevent = {
> +	.name		= "timer1",
> +	.features	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
> +	.set_mode	= clkevt_set_mode,
> +	.set_next_event	= clkevt_set_next_event,
> +	.rating		= 300,
> +};
> +
> +static struct irqaction integrator_timer_irq = {
> +	.name		= "timer",
> +	.flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
> +	.handler	= integrator_timer_interrupt,
> +	.dev_id		= &integrator_clockevent,
> +};
> +
> +void __init integrator_clockevent_init(unsigned long inrate,
> +				       void __iomem *base, int irq)
> +{
> +	unsigned long rate = inrate;
> +	unsigned int ctrl = 0;
> +
> +	clkevt_base = base;
> +	/* Calculate and program a divisor */
> +	if (rate > 0x100000 * HZ) {
> +		rate /= 256;
> +		ctrl |= TIMER_CTRL_DIV256;
> +	} else if (rate > 0x10000 * HZ) {
> +		rate /= 16;
> +		ctrl |= TIMER_CTRL_DIV16;
> +	}
> +	timer_reload = rate / HZ;
> +	writel(ctrl, clkevt_base + TIMER_CTRL);
> +
> +	setup_irq(irq, &integrator_timer_irq);
> +	clockevents_config_and_register(&integrator_clockevent,
> +					rate,
> +					1,
> +					0xffffU);
> +}
> +
> +static void __init ap_of_timer_init(struct device_node *node)
> +{
> +	void __iomem *base;
> +	int irq;
> +	struct clk *clk;
> +	unsigned long rate;
> +
> +	clk = clk_get_sys("ap_timer", NULL);
> +	BUG_ON(IS_ERR(clk));
> +	clk_prepare_enable(clk);
> +	rate = clk_get_rate(clk);
> +
> +	base = of_iomap(node, 0);
> +	if (WARN_ON(!base))
> +		return;
> +
> +	writel(0, base + TIMER_CTRL);
> +
> +	if ((clksrc_base && clkevt_base) || !of_device_is_available(node)) {
> +		iounmap(base);
> +		return;
> +	}
> +
> +	irq = irq_of_parse_and_map(node, 0);
> +	if (!clkevt_base && (irq > 0))
> +		integrator_clockevent_init(rate, base, irq);
> +	else
> +		integrator_clocksource_init(rate, base);
> +}
> +CLOCKSOURCE_OF_DECLARE(integrator_ap, "integrator-timer", ap_of_timer_init);

So, most of the code here is really clockevent code and not clocksource 
code. I realize they were combined in the mach directory you're copying 
them from, but if we're going to move all this code out of the arch 
directory and into drivers/, I'd like to propose we not dump it all into 
drivers/clocksource.

For more context here see:
http://www.spinics.net/lists/arm-kernel/msg234074.html

So unless Thomas objects, would you be willing to break this change up 
adding the relevant irq related bits to a new drivers/clockevents 
directory? You can leave the sched_clock bits to clocksource for now, 
since I think that logic should eventually be integrated with the 
clocksource core.

When you resubmit, please also add Daniel Lezcano 
<daniel.lezcano@linaro.org> to the cc.

thanks
-john

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
  2013-04-01 22:21   ` Rob Herring
  (?)
@ 2013-04-02  3:23     ` Santosh Shilimkar
  -1 siblings, 0 replies; 44+ messages in thread
From: Santosh Shilimkar @ 2013-04-02  3:23 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-arm-kernel, Thomas Gleixner, Mark Rutland, Russell King,
	John Stultz, arm, Marc Zyngier, Linus Walleij, Rob Herring,
	Kukjin Kim, Tony Lindgren, Simon Horman, Magnus Damm,
	Catalin Marinas, Will Deacon, linux-samsung-soc, linux-omap,
	linux-sh

On Tuesday 02 April 2013 03:51 AM, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.
> 
Absolutely.

> Signed-off-by: Rob Herring <rob.herring@calxeda.com>

[..]

>  arch/arm/mach-omap2/timer.c                  |    5 +----

Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-02  3:23     ` Santosh Shilimkar
  0 siblings, 0 replies; 44+ messages in thread
From: Santosh Shilimkar @ 2013-04-02  3:23 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 02 April 2013 03:51 AM, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.
> 
Absolutely.

> Signed-off-by: Rob Herring <rob.herring@calxeda.com>

[..]

>  arch/arm/mach-omap2/timer.c                  |    5 +----

Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-02  3:23     ` Santosh Shilimkar
  0 siblings, 0 replies; 44+ messages in thread
From: Santosh Shilimkar @ 2013-04-02  3:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 02 April 2013 03:51 AM, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.
> 
Absolutely.

> Signed-off-by: Rob Herring <rob.herring@calxeda.com>

[..]

>  arch/arm/mach-omap2/timer.c                  |    5 +----

Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 06/13] ARM: vexpress: remove sp804 OF init
  2013-04-01 22:21 ` [PATCH v2 06/13] ARM: vexpress: remove sp804 OF init Rob Herring
@ 2013-04-02 16:41   ` Pawel Moll
  0 siblings, 0 replies; 44+ messages in thread
From: Pawel Moll @ 2013-04-02 16:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2013-04-01 at 23:21 +0100, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> Remove the vexpress specific setup for the sp804 timer now that
> clocksource_of_init will do it.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> ---
>  arch/arm/mach-vexpress/v2m.c |   11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> index 6215717..cdc29d8 100644
> --- a/arch/arm/mach-vexpress/v2m.c
> +++ b/arch/arm/mach-vexpress/v2m.c
> @@ -431,20 +431,9 @@ void __init v2m_dt_init_early(void)
>  
>  static void __init v2m_dt_timer_init(void)
>  {
> -	struct device_node *node = NULL;
> -
>  	vexpress_clk_of_init();
>  
>  	clocksource_of_init();
> -	do {
> -		node = of_find_compatible_node(node, NULL, "arm,sp804");
> -	} while (node && vexpress_get_site_by_node(node) != VEXPRESS_SITE_MB);
> -	if (node) {
> -		pr_info("Using SP804 '%s' as a clock & events source\n",
> -				node->full_name);
> -		v2m_sp804_init(of_iomap(node, 0),
> -				irq_of_parse_and_map(node, 0));
> -	}
>  
>  	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>  				24000000);

Acked-by: Pawel Moll <pawel.moll@arm.com>

Thanks!

Pawel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 07/13] ARM: dts: vexpress: disable CA9 core tile sp804 timer
  2013-04-01 22:21 ` [PATCH v2 07/13] ARM: dts: vexpress: disable CA9 core tile sp804 timer Rob Herring
@ 2013-04-02 16:47   ` Pawel Moll
  0 siblings, 0 replies; 44+ messages in thread
From: Pawel Moll @ 2013-04-02 16:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2013-04-01 at 23:21 +0100, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> The motherboard sp804 timer is used, but core tile sp804 timer is not.
> According to Russell King, the clock configuration is undocumented and
> defaults to 32kHz which is not desireable. So mark core tile sp804 timer
> as disabled.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> ---
>  arch/arm/boot/dts/vexpress-v2p-ca9.dts |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/boot/dts/vexpress-v2p-ca9.dts b/arch/arm/boot/dts/vexpress-v2p-ca9.dts
> index 1420bb1..62d9b22 100644
> --- a/arch/arm/boot/dts/vexpress-v2p-ca9.dts
> +++ b/arch/arm/boot/dts/vexpress-v2p-ca9.dts
> @@ -98,6 +98,7 @@
>  			     <0 49 4>;
>  		clocks = <&oscclk2>, <&oscclk2>;
>  		clock-names = "timclk", "apb_pclk";
> +		status = "disabled";
>  	};
>  
>  	watchdog at 100e5000 {

I'm not sure if this is necessary. The parent oscclk2 (frequency
33-100MHz) should provide enough information for SP804 to work. One
thing that worries me is that it may be not available (not registered
yet) at the time of SP804 initialisation, but then the driver would
simply give up (I hope) on this instance so we would be us back in the
situation where it's not used. I'll try to give this stuff a spin soon.

Pawe?

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 08/13] ARM: vexpress: remove extra timer-sp control register clearing
  2013-04-01 22:21 ` [PATCH v2 08/13] ARM: vexpress: remove extra timer-sp control register clearing Rob Herring
@ 2013-04-02 16:48   ` Pawel Moll
  0 siblings, 0 replies; 44+ messages in thread
From: Pawel Moll @ 2013-04-02 16:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2013-04-01 at 23:21 +0100, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> The timer-sp initialization code clears the control register before
> initializing the timers, so every platform doing this is redundant.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> ---
>  arch/arm/mach-vexpress/v2m.c |    3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> index cdc29d8..09e571d 100644
> --- a/arch/arm/mach-vexpress/v2m.c
> +++ b/arch/arm/mach-vexpress/v2m.c
> @@ -61,9 +61,6 @@ static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
>  	if (WARN_ON(!base || irq == NO_IRQ))
>  		return;
>  
> -	writel(0, base + TIMER_1_BASE + TIMER_CTRL);
> -	writel(0, base + TIMER_2_BASE + TIMER_CTRL);
> -
>  	sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
>  	sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
>  }

Acked-by: Pawel Moll <pawel.moll@arm.com>

Thanks!

Pawel

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-01 23:26   ` John Stultz
@ 2013-04-02 19:49     ` Rob Herring
  2013-04-03  0:41       ` John Stultz
  2013-04-03 16:52       ` Linus Walleij
  0 siblings, 2 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-02 19:49 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/01/2013 06:26 PM, John Stultz wrote:
> On 04/01/2013 03:21 PM, Rob Herring wrote:
>> diff --git a/drivers/clocksource/integrator_ap_timer.c
>> b/drivers/clocksource/integrator_ap_timer.c
>> new file mode 100644
>> index 0000000..05e6204
>> --- /dev/null
>> +++ b/drivers/clocksource/integrator_ap_timer.c
> [snip]


>> +CLOCKSOURCE_OF_DECLARE(integrator_ap, "integrator-timer",
>> ap_of_timer_init);
> 
> So, most of the code here is really clockevent code and not clocksource
> code. I realize they were combined in the mach directory you're copying
> them from, but if we're going to move all this code out of the arch
> directory and into drivers/, I'd like to propose we not dump it all into
> drivers/clocksource.

Arguably, half the h/w is used for clocksource and half for clockevent
so it is equal. :) The sp804 and integrator are somewhat separated that
carving them up may be possible, but there are examples like i.MX timers
where the implementations are tied more closely together (the clockevent
compare value is the clocksource counter + delta).

Where do I put the init functions which need to know about both?

What about all the other timers that are already in drivers/clocksource?

> 
> For more context here see:
> http://www.spinics.net/lists/arm-kernel/msg234074.html

Seems like this is more a maintainer issue than necessarily what is the
right split of code (not that those are completely unrelated). Perhaps
splitting maintainership between core and drivers is needed. It
definitely seems Thomas cannot keep up with the plethora of ARM related
timers and irqchips getting moved into drivers/.

Rob

> So unless Thomas objects, would you be willing to break this change up
> adding the relevant irq related bits to a new drivers/clockevents
> directory? You can leave the sched_clock bits to clocksource for now,
> since I think that logic should eventually be integrated with the
> clocksource core.
> 
> When you resubmit, please also add Daniel Lezcano
> <daniel.lezcano@linaro.org> to the cc.
> 
> thanks
> -john

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-02 19:49     ` Rob Herring
@ 2013-04-03  0:41       ` John Stultz
  2013-04-03  2:31         ` Rob Herring
  2013-04-10 23:23         ` Rob Herring
  2013-04-03 16:52       ` Linus Walleij
  1 sibling, 2 replies; 44+ messages in thread
From: John Stultz @ 2013-04-03  0:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/02/2013 12:49 PM, Rob Herring wrote:
> On 04/01/2013 06:26 PM, John Stultz wrote:
>> On 04/01/2013 03:21 PM, Rob Herring wrote:
>>> diff --git a/drivers/clocksource/integrator_ap_timer.c
>>> b/drivers/clocksource/integrator_ap_timer.c
>>> new file mode 100644
>>> index 0000000..05e6204
>>> --- /dev/null
>>> +++ b/drivers/clocksource/integrator_ap_timer.c
>> [snip]
>
>>> +CLOCKSOURCE_OF_DECLARE(integrator_ap, "integrator-timer",
>>> ap_of_timer_init);
>> So, most of the code here is really clockevent code and not clocksource
>> code. I realize they were combined in the mach directory you're copying
>> them from, but if we're going to move all this code out of the arch
>> directory and into drivers/, I'd like to propose we not dump it all into
>> drivers/clocksource.
> Arguably, half the h/w is used for clocksource and half for clockevent
> so it is equal. :) The sp804 and integrator are somewhat separated that
> carving them up may be possible, but there are examples like i.MX timers
> where the implementations are tied more closely together (the clockevent
> compare value is the clocksource counter + delta).
>
> Where do I put the init functions which need to know about both?

Either have them init themselves via *_initcall, or call out from one to 
the other?

> What about all the other timers that are already in drivers/clocksource?

I'm hoping to start moving those out soon.


>> For more context here see:
>> http://www.spinics.net/lists/arm-kernel/msg234074.html
> Seems like this is more a maintainer issue than necessarily what is the
> right split of code (not that those are completely unrelated). Perhaps
> splitting maintainership between core and drivers is needed. It
> definitely seems Thomas cannot keep up with the plethora of ARM related
> timers and irqchips getting moved into drivers/.

Well, I'm hoping Daniel can help offload Thomas, but I've still not 
heard back if Thomas is ok with this whole proposal or not.

thanks
-john

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-03  0:41       ` John Stultz
@ 2013-04-03  2:31         ` Rob Herring
  2013-04-10 23:23         ` Rob Herring
  1 sibling, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-03  2:31 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/02/2013 07:41 PM, John Stultz wrote:
> On 04/02/2013 12:49 PM, Rob Herring wrote:
>> On 04/01/2013 06:26 PM, John Stultz wrote:
>>> On 04/01/2013 03:21 PM, Rob Herring wrote:
>>>> diff --git a/drivers/clocksource/integrator_ap_timer.c
>>>> b/drivers/clocksource/integrator_ap_timer.c
>>>> new file mode 100644
>>>> index 0000000..05e6204
>>>> --- /dev/null
>>>> +++ b/drivers/clocksource/integrator_ap_timer.c
>>> [snip]
>>
>>>> +CLOCKSOURCE_OF_DECLARE(integrator_ap, "integrator-timer",
>>>> ap_of_timer_init);
>>> So, most of the code here is really clockevent code and not clocksource
>>> code. I realize they were combined in the mach directory you're copying
>>> them from, but if we're going to move all this code out of the arch
>>> directory and into drivers/, I'd like to propose we not dump it all into
>>> drivers/clocksource.
>> Arguably, half the h/w is used for clocksource and half for clockevent
>> so it is equal. :) The sp804 and integrator are somewhat separated that
>> carving them up may be possible, but there are examples like i.MX timers
>> where the implementations are tied more closely together (the clockevent
>> compare value is the clocksource counter + delta).
>>
>> Where do I put the init functions which need to know about both?
> 
> Either have them init themselves via *_initcall, or call out from one to
> the other?

initcalls are too late on ARM. This is why CLOCKSOURCE_OF_DECLARE was
created, but it is tied to 1 init callback per matched DT node. The nice
thing about it is we avoid any headers with arbitrary timer init
functions and data and calls from the platform code in the DT case.

We could also create a CLOCKEVENT_OF_DECLARE and match twice, but then
that is 2 searches thru the DT.

I don't think an undefined interface of shared data that's different for
every timer is a good idea. This is typically the mapped address(es),
clocks, spinlocks, register access functions, misc flags, etc.

>> What about all the other timers that are already in drivers/clocksource?
> 
> I'm hoping to start moving those out soon.

I count 3 clkevt only, 4 clocksource only and 13 drivers with both. How
intertwined the 13 are, I don't know. I think we should get things moved
to a common spot first and look at all the various h/w first before
deciding how to best split things up.

Rob

>>> For more context here see:
>>> http://www.spinics.net/lists/arm-kernel/msg234074.html
>> Seems like this is more a maintainer issue than necessarily what is the
>> right split of code (not that those are completely unrelated). Perhaps
>> splitting maintainership between core and drivers is needed. It
>> definitely seems Thomas cannot keep up with the plethora of ARM related
>> timers and irqchips getting moved into drivers/.
> 
> Well, I'm hoping Daniel can help offload Thomas, but I've still not
> heard back if Thomas is ok with this whole proposal or not.
> 
> thanks
> -john

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-02 19:49     ` Rob Herring
  2013-04-03  0:41       ` John Stultz
@ 2013-04-03 16:52       ` Linus Walleij
  2013-04-04 11:06         ` Daniel Lezcano
  1 sibling, 1 reply; 44+ messages in thread
From: Linus Walleij @ 2013-04-03 16:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 2, 2013 at 9:49 PM, Rob Herring <robherring2@gmail.com> wrote:
> On 04/01/2013 06:26 PM, John Stultz wrote:

>> So, most of the code here is really clockevent code and not clocksource
>> code. I realize they were combined in the mach directory you're copying
>> them from, but if we're going to move all this code out of the arch
>> directory and into drivers/, I'd like to propose we not dump it all into
>> drivers/clocksource.
>
> Arguably, half the h/w is used for clocksource and half for clockevent
> so it is equal. :) The sp804 and integrator are somewhat separated that
> carving them up may be possible, but there are examples like i.MX timers
> where the implementations are tied more closely together (the clockevent
> compare value is the clocksource counter + delta).
>
> Where do I put the init functions which need to know about both?
>
> What about all the other timers that are already in drivers/clocksource?

The other day I thought about this because I remembered discussing
it with John, and thinking about how some drivers (like ours) combine
clock source, clock event, sched_clock() hook and delay timers. The
same hardware is incidentally used for all four.

Driver writers really like to think about a driver pertaining to a certain
memory segment in the hardware, and that's causing some strain
here and there in the kernel.

Anyway, I was thinking that the four classes of drivers were somehow
related but not the same thing.

So what about renaming
drivers/clocksource -> drivers/timer

Then create a subdirectory drivers/timer/clocksource
for the pure clocksource code and any drivers falling into that
category.

Thus drivers/timer/clockevent, drivers/timer/schedclock
and drivers/timer/delay can be created to handle specialized
hardware blocks.

But the best thing with that scheme would be that combined
drivers doing several things at once could live directly in
drivers/timer/* and not pollute drivers/clocksource.

Yes/No/Insane?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
  2013-04-01 22:21   ` Rob Herring
  (?)
@ 2013-04-04  5:56     ` Simon Horman
  -1 siblings, 0 replies; 44+ messages in thread
From: Simon Horman @ 2013-04-04  5:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.

Would it be possible for you to either delay the removal of
shmobile_timer_init. In general I am in favour of the following
approach to wide changes such as this one:

1. Add new feature
2. Convert users to new feature
3. Remove old feature.

If it is not possible to delay the removal of shmobile_timer_init could you
update your base such that you also remove its usage from the following
files:

arch/arm/mach-shmobile/board-kzm9g-reference.c
arch/arm/mach-shmobile/setup-r8a73a4.c
arch/arm/mach-shmobile/setup-r8a7779.c
arch/arm/mach-shmobile/board-lager.c
arch/arm/mach-shmobile/board-ape6evm.c
arch/arm/mach-shmobile/setup-r8a7778.c
arch/arm/mach-shmobile/board-marzen-reference.c
arch/arm/mach-shmobile/setup-r8a7790.c
arch/arm/mach-shmobile/board-bockw.c

The above files are all present in the arm-soc/next/boards2 branch
of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
I am happy for you use the later as a base if you wish.

> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-samsung-soc@vger.kernel.org
> Cc: linux-omap@vger.kernel.org
> Cc: linux-sh@vger.kernel.org
> ---
>  arch/arm/include/asm/arch_timer.h            |   13 +------------
>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
>  arch/arm/mach-exynos/mct.c                   |    6 ------
>  arch/arm/mach-highbank/highbank.c            |    5 +----
>  arch/arm/mach-omap2/timer.c                  |    5 +----
>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -

I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.

>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -

I am not able to test the setup-emev2 portion properly at this time,
booting the kzm9d board without the board-kzm9d file seems broken without
your patch. However, your change seems reasonable to me.

>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -

I am not able to test the setup-r8a7740 portion properly at this time,
booting the armadillo800eva board without the board-armadillo800eva file
seems broken without your patch. However, your change seems reasonable to
me.

>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -

I am not able to test the setup-sh7372 portion properly at this time,
booting the mackerel board without the board-mackerel file seems broken without
your patch. However, your change seems reasonable to me.

>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -

I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.


The tests above were made by merging

git://sources.calxeda.com/kernel/linux.git arm-timers
head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
	     ("devtree: add binding documentation for sp804")

and the renesas-next-20130403 tag of the renesas tree (URL above).

>  arch/arm/mach-shmobile/timer.c               |    6 ------
>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
>  arch/arm/mach-virt/virt.c                    |    9 ---------
>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
>  arch/arm64/kernel/time.c                     |    6 ++++--
>  drivers/clocksource/Kconfig                  |    1 +
>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
>  include/clocksource/arm_arch_timer.h         |    6 ------
>  20 files changed, 27 insertions(+), 89 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
> index 7ade91d..7c1bfc0 100644
> --- a/arch/arm/include/asm/arch_timer.h
> +++ b/arch/arm/include/asm/arch_timer.h
> @@ -10,8 +10,7 @@
>  #include <clocksource/arm_arch_timer.h>
>  
>  #ifdef CONFIG_ARM_ARCH_TIMER
> -int arch_timer_of_register(void);
> -int arch_timer_sched_clock_init(void);
> +int arch_timer_arch_init(void);
>  
>  /*
>   * These register accessors are marked inline so the compiler can
> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
>  
>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
>  }
> -#else
> -static inline int arch_timer_of_register(void)
> -{
> -	return -ENXIO;
> -}
> -
> -static inline int arch_timer_sched_clock_init(void)
> -{
> -	return -ENXIO;
> -}
>  #endif
>  
>  #endif
> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
> index a7536d4..dc74048 100644
> --- a/arch/arm/kernel/arch_timer.c
> +++ b/arch/arm/kernel/arch_timer.c
> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
>  	register_current_timer_delay(&arch_delay_timer);
>  }
>  
> -int __init arch_timer_of_register(void)
> -{
> -	int ret;
> -
> -	ret = arch_timer_init();
> -	if (ret)
> -		return ret;
> -
> -	arch_timer_delay_timer_register();
> -
> -	return 0;
> -}
> -
> -int __init arch_timer_sched_clock_init(void)
> +int __init arch_timer_arch_init(void)
>  {
>          u32 arch_timer_rate = arch_timer_get_rate();
>  
>  	if (arch_timer_rate = 0)
>  		return -ENXIO;
>  
> +	arch_timer_delay_timer_register();
> +
>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>  	sched_clock_func = arch_timer_sched_clock;
> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
> index acaeb14..4d97b43 100644
> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
>  	.map_io		= exynos5_dt_map_io,
>  	.init_machine	= exynos5_dt_machine_init,
>  	.init_late	= exynos_init_late,
> -	.init_time	= exynos4_timer_init,
>  	.dt_compat	= exynos5_dt_compat,
>  	.restart        = exynos5_restart,
>  	.reserve	= exynos5_reserve,
> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
> index c9d6650..04aff6a 100644
> --- a/arch/arm/mach-exynos/mct.c
> +++ b/arch/arm/mach-exynos/mct.c
> @@ -21,7 +21,6 @@
>  #include <linux/percpu.h>
>  #include <linux/of.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/localtimer.h>
>  
>  #include <plat/cpu.h>
> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
>  
>  void __init exynos4_timer_init(void)
>  {
> -	if (soc_is_exynos5440()) {
> -		arch_timer_of_register();
> -		return;
> -	}
> -
>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
>  		mct_int_type = MCT_INT_SPI;
>  	else
> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> index 76c1170..758150e 100644
> --- a/arch/arm/mach-highbank/highbank.c
> +++ b/arch/arm/mach-highbank/highbank.c
> @@ -15,6 +15,7 @@
>   */
>  #include <linux/clk.h>
>  #include <linux/clkdev.h>
> +#include <linux/clocksource.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/io.h>
>  #include <linux/irq.h>
> @@ -28,7 +29,6 @@
>  #include <linux/amba/bus.h>
>  #include <linux/clk-provider.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/cacheflush.h>
>  #include <asm/cputype.h>
>  #include <asm/smp_plat.h>
> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
>  	sp804_clockevents_init(timer_base, irq, "timer0");
>  
> -	arch_timer_of_register();
> -	arch_timer_sched_clock_init();
> -
>  	clocksource_of_init();
>  }
>  
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index 4fd8025..7dd6453 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -46,7 +46,6 @@
>  #include <asm/smp_twd.h>
>  #include <asm/sched_clock.h>
>  
> -#include <asm/arch_timer.h>
>  #include "omap_hwmod.h"
>  #include "omap_device.h"
>  #include <plat/counter-32k.h>
> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
>  	omap5_sync32k_timer_init();
>  	realtime_counter_init();
>  
> -	err = arch_timer_of_register();
> -	if (err)
> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
> +        clocksource_of_init();
>  }
>  #endif /* CONFIG_SOC_OMAP5 */
>  
> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
> index c254782..c016ccd 100644
> --- a/arch/arm/mach-shmobile/board-kzm9d.c
> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
>  	.init_irq	= emev2_init_irq,
>  	.init_machine	= kzm9d_add_standard_devices,
>  	.init_late	= shmobile_init_late,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= kzm9d_boards_compat_dt,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> index e48606d..5efc0f0 100644
> --- a/arch/arm/mach-shmobile/include/mach/common.h
> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> @@ -2,7 +2,6 @@
>  #define __ARCH_MACH_COMMON_H
>  
>  extern void shmobile_earlytimer_init(void);
> -extern void shmobile_timer_init(void);
>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
>  			 unsigned int mult, unsigned int div);
>  struct twd_local_timer;
> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
> index 47662a5..4e38a66 100644
> --- a/arch/arm/mach-shmobile/setup-emev2.c
> +++ b/arch/arm/mach-shmobile/setup-emev2.c
> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
>  	.nr_irqs	= NR_IRQS_LEGACY,
>  	.init_irq	= irqchip_init,
>  	.init_machine	= emev2_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= emev2_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
> index 8b85d4d..104b474 100644
> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
>  	.init_irq	= r8a7740_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_machine	= r8a7740_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= r8a7740_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
> index 59c7146..5502d62 100644
> --- a/arch/arm/mach-shmobile/setup-sh7372.c
> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
>  	.init_irq	= sh7372_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_machine	= sh7372_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= sh7372_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> index bdab575..ea66316 100644
> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
>  	.nr_irqs	= NR_IRQS_LEGACY,
>  	.init_irq	= sh73a0_init_irq_dt,
>  	.init_machine	= sh73a0_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= sh73a0_boards_compat_dt,
>  MACHINE_END
>  #endif /* CONFIG_USE_OF */
> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
> index 3d16d4d..add2f15 100644
> --- a/arch/arm/mach-shmobile/timer.c
> +++ b/arch/arm/mach-shmobile/timer.c
> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
>  {
>  	late_time_init = shmobile_late_time_init;
>  }
> -
> -void __init shmobile_timer_init(void)
> -{
> -	arch_timer_of_register();
> -	arch_timer_sched_clock_init();
> -}
> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> index d0ad789..6215717 100644
> --- a/arch/arm/mach-vexpress/v2m.c
> +++ b/arch/arm/mach-vexpress/v2m.c
> @@ -1,6 +1,7 @@
>  /*
>   * Versatile Express V2M Motherboard Support
>   */
> +#include <linux/clocksource.h>
>  #include <linux/device.h>
>  #include <linux/amba/bus.h>
>  #include <linux/amba/mmci.h>
> @@ -23,7 +24,6 @@
>  #include <linux/regulator/machine.h>
>  #include <linux/vexpress.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/mach-types.h>
>  #include <asm/sizes.h>
>  #include <asm/mach/arch.h>
> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
>  				irq_of_parse_and_map(node, 0));
>  	}
>  
> -	arch_timer_of_register();
> -
> -	if (arch_timer_sched_clock_init() != 0)
> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>  				24000000);
>  }
>  
> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
> index 31666f6..adc0945 100644
> --- a/arch/arm/mach-virt/virt.c
> +++ b/arch/arm/mach-virt/virt.c
> @@ -23,21 +23,13 @@
>  #include <linux/of_platform.h>
>  #include <linux/smp.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/mach/arch.h>
> -#include <asm/mach/time.h>
>  
>  static void __init virt_init(void)
>  {
>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>  }
>  
> -static void __init virt_timer_init(void)
> -{
> -	WARN_ON(arch_timer_of_register() != 0);
> -	WARN_ON(arch_timer_sched_clock_init() != 0);
> -}
> -
>  static const char *virt_dt_match[] = {
>  	"linux,dummy-virt",
>  	NULL
> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
>  
>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
>  	.init_irq	= irqchip_init,
> -	.init_time	= virt_timer_init,
>  	.init_machine	= virt_init,
>  	.smp		= smp_ops(virt_smp_ops),
>  	.dt_compat	= virt_dt_match,
> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> index 91e2a6a..bf6ab242 100644
> --- a/arch/arm64/include/asm/arch_timer.h
> +++ b/arch/arm64/include/asm/arch_timer.h
> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
>  	return cval;
>  }
>  
> +static inline int arch_timer_arch_init(void)
> +{
> +	return 0;
> +}
> +
>  #endif
> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
> index b0ef18d..a551f88 100644
> --- a/arch/arm64/kernel/time.c
> +++ b/arch/arm64/kernel/time.c
> @@ -32,6 +32,7 @@
>  #include <linux/timer.h>
>  #include <linux/irq.h>
>  #include <linux/delay.h>
> +#include <linux/clocksource.h>
>  
>  #include <clocksource/arm_arch_timer.h>
>  
> @@ -77,10 +78,11 @@ void __init time_init(void)
>  {
>  	u32 arch_timer_rate;
>  
> -	if (arch_timer_init())
> -		panic("Unable to initialise architected timer.\n");
> +	clocksource_of_init();
>  
>  	arch_timer_rate = arch_timer_get_rate();
> +	if (!arch_timer_rate)
> +		panic("Unable to initialise architected timer.\n");
>  
>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index e507ab7..d98e7e1 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
>  
>  config ARM_ARCH_TIMER
>  	bool
> +	select CLKSRC_OF if OF
>  
>  config CLKSRC_METAG_GENERIC
>  	def_bool y if METAG
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index d7ad425..122ff05 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -337,22 +337,14 @@ out:
>  	return err;
>  }
>  
> -static const struct of_device_id arch_timer_of_match[] __initconst = {
> -	{ .compatible	= "arm,armv7-timer",	},
> -	{ .compatible	= "arm,armv8-timer",	},
> -	{},
> -};
> -
> -int __init arch_timer_init(void)
> +static void __init arch_timer_init(struct device_node *np)
>  {
> -	struct device_node *np;
>  	u32 freq;
>  	int i;
>  
> -	np = of_find_matching_node(NULL, arch_timer_of_match);
> -	if (!np) {
> -		pr_err("arch_timer: can't find DT node\n");
> -		return -ENODEV;
> +	if (arch_timer_get_rate()) {
> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> +		return;
>  	}
>  
>  	/* Try to determine the frequency from the device tree or CNTFRQ */
> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
>  			pr_warn("arch_timer: No interrupt available, giving up\n");
> -			return -EINVAL;
> +			return;
>  		}
>  	}
>  
> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
>  	else
>  		arch_timer_read_counter = arch_counter_get_cntpct;
>  
> -	return arch_timer_register();
> +	arch_timer_register();
> +	arch_timer_arch_init();
>  }
> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> index 2603267..e6c9c4c 100644
> --- a/include/clocksource/arm_arch_timer.h
> +++ b/include/clocksource/arm_arch_timer.h
> @@ -31,18 +31,12 @@
>  
>  #ifdef CONFIG_ARM_ARCH_TIMER
>  
> -extern int arch_timer_init(void);
>  extern u32 arch_timer_get_rate(void);
>  extern u64 (*arch_timer_read_counter)(void);
>  extern struct timecounter *arch_timer_get_timecounter(void);
>  
>  #else
>  
> -static inline int arch_timer_init(void)
> -{
> -	return -ENXIO;
> -}
> -
>  static inline u32 arch_timer_get_rate(void)
>  {
>  	return 0;
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-04  5:56     ` Simon Horman
  0 siblings, 0 replies; 44+ messages in thread
From: Simon Horman @ 2013-04-04  5:56 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-arm-kernel, Thomas Gleixner, Mark Rutland, Russell King,
	John Stultz, arm, Marc Zyngier, Linus Walleij, Rob Herring,
	Kukjin Kim, Tony Lindgren, Magnus Damm, Catalin Marinas,
	Will Deacon, linux-samsung-soc, linux-omap, linux-sh

On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.

Would it be possible for you to either delay the removal of
shmobile_timer_init. In general I am in favour of the following
approach to wide changes such as this one:

1. Add new feature
2. Convert users to new feature
3. Remove old feature.

If it is not possible to delay the removal of shmobile_timer_init could you
update your base such that you also remove its usage from the following
files:

arch/arm/mach-shmobile/board-kzm9g-reference.c
arch/arm/mach-shmobile/setup-r8a73a4.c
arch/arm/mach-shmobile/setup-r8a7779.c
arch/arm/mach-shmobile/board-lager.c
arch/arm/mach-shmobile/board-ape6evm.c
arch/arm/mach-shmobile/setup-r8a7778.c
arch/arm/mach-shmobile/board-marzen-reference.c
arch/arm/mach-shmobile/setup-r8a7790.c
arch/arm/mach-shmobile/board-bockw.c

The above files are all present in the arm-soc/next/boards2 branch
of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
I am happy for you use the later as a base if you wish.

> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-samsung-soc@vger.kernel.org
> Cc: linux-omap@vger.kernel.org
> Cc: linux-sh@vger.kernel.org
> ---
>  arch/arm/include/asm/arch_timer.h            |   13 +------------
>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
>  arch/arm/mach-exynos/mct.c                   |    6 ------
>  arch/arm/mach-highbank/highbank.c            |    5 +----
>  arch/arm/mach-omap2/timer.c                  |    5 +----
>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -

I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.

>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -

I am not able to test the setup-emev2 portion properly at this time,
booting the kzm9d board without the board-kzm9d file seems broken without
your patch. However, your change seems reasonable to me.

>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -

I am not able to test the setup-r8a7740 portion properly at this time,
booting the armadillo800eva board without the board-armadillo800eva file
seems broken without your patch. However, your change seems reasonable to
me.

>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -

I am not able to test the setup-sh7372 portion properly at this time,
booting the mackerel board without the board-mackerel file seems broken without
your patch. However, your change seems reasonable to me.

>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -

I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.


The tests above were made by merging

git://sources.calxeda.com/kernel/linux.git arm-timers
head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
	     ("devtree: add binding documentation for sp804")

and the renesas-next-20130403 tag of the renesas tree (URL above).

>  arch/arm/mach-shmobile/timer.c               |    6 ------
>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
>  arch/arm/mach-virt/virt.c                    |    9 ---------
>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
>  arch/arm64/kernel/time.c                     |    6 ++++--
>  drivers/clocksource/Kconfig                  |    1 +
>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
>  include/clocksource/arm_arch_timer.h         |    6 ------
>  20 files changed, 27 insertions(+), 89 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
> index 7ade91d..7c1bfc0 100644
> --- a/arch/arm/include/asm/arch_timer.h
> +++ b/arch/arm/include/asm/arch_timer.h
> @@ -10,8 +10,7 @@
>  #include <clocksource/arm_arch_timer.h>
>  
>  #ifdef CONFIG_ARM_ARCH_TIMER
> -int arch_timer_of_register(void);
> -int arch_timer_sched_clock_init(void);
> +int arch_timer_arch_init(void);
>  
>  /*
>   * These register accessors are marked inline so the compiler can
> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
>  
>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
>  }
> -#else
> -static inline int arch_timer_of_register(void)
> -{
> -	return -ENXIO;
> -}
> -
> -static inline int arch_timer_sched_clock_init(void)
> -{
> -	return -ENXIO;
> -}
>  #endif
>  
>  #endif
> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
> index a7536d4..dc74048 100644
> --- a/arch/arm/kernel/arch_timer.c
> +++ b/arch/arm/kernel/arch_timer.c
> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
>  	register_current_timer_delay(&arch_delay_timer);
>  }
>  
> -int __init arch_timer_of_register(void)
> -{
> -	int ret;
> -
> -	ret = arch_timer_init();
> -	if (ret)
> -		return ret;
> -
> -	arch_timer_delay_timer_register();
> -
> -	return 0;
> -}
> -
> -int __init arch_timer_sched_clock_init(void)
> +int __init arch_timer_arch_init(void)
>  {
>          u32 arch_timer_rate = arch_timer_get_rate();
>  
>  	if (arch_timer_rate == 0)
>  		return -ENXIO;
>  
> +	arch_timer_delay_timer_register();
> +
>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>  	sched_clock_func = arch_timer_sched_clock;
> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
> index acaeb14..4d97b43 100644
> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
>  	.map_io		= exynos5_dt_map_io,
>  	.init_machine	= exynos5_dt_machine_init,
>  	.init_late	= exynos_init_late,
> -	.init_time	= exynos4_timer_init,
>  	.dt_compat	= exynos5_dt_compat,
>  	.restart        = exynos5_restart,
>  	.reserve	= exynos5_reserve,
> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
> index c9d6650..04aff6a 100644
> --- a/arch/arm/mach-exynos/mct.c
> +++ b/arch/arm/mach-exynos/mct.c
> @@ -21,7 +21,6 @@
>  #include <linux/percpu.h>
>  #include <linux/of.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/localtimer.h>
>  
>  #include <plat/cpu.h>
> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
>  
>  void __init exynos4_timer_init(void)
>  {
> -	if (soc_is_exynos5440()) {
> -		arch_timer_of_register();
> -		return;
> -	}
> -
>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
>  		mct_int_type = MCT_INT_SPI;
>  	else
> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> index 76c1170..758150e 100644
> --- a/arch/arm/mach-highbank/highbank.c
> +++ b/arch/arm/mach-highbank/highbank.c
> @@ -15,6 +15,7 @@
>   */
>  #include <linux/clk.h>
>  #include <linux/clkdev.h>
> +#include <linux/clocksource.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/io.h>
>  #include <linux/irq.h>
> @@ -28,7 +29,6 @@
>  #include <linux/amba/bus.h>
>  #include <linux/clk-provider.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/cacheflush.h>
>  #include <asm/cputype.h>
>  #include <asm/smp_plat.h>
> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
>  	sp804_clockevents_init(timer_base, irq, "timer0");
>  
> -	arch_timer_of_register();
> -	arch_timer_sched_clock_init();
> -
>  	clocksource_of_init();
>  }
>  
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index 4fd8025..7dd6453 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -46,7 +46,6 @@
>  #include <asm/smp_twd.h>
>  #include <asm/sched_clock.h>
>  
> -#include <asm/arch_timer.h>
>  #include "omap_hwmod.h"
>  #include "omap_device.h"
>  #include <plat/counter-32k.h>
> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
>  	omap5_sync32k_timer_init();
>  	realtime_counter_init();
>  
> -	err = arch_timer_of_register();
> -	if (err)
> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
> +        clocksource_of_init();
>  }
>  #endif /* CONFIG_SOC_OMAP5 */
>  
> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
> index c254782..c016ccd 100644
> --- a/arch/arm/mach-shmobile/board-kzm9d.c
> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
>  	.init_irq	= emev2_init_irq,
>  	.init_machine	= kzm9d_add_standard_devices,
>  	.init_late	= shmobile_init_late,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= kzm9d_boards_compat_dt,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> index e48606d..5efc0f0 100644
> --- a/arch/arm/mach-shmobile/include/mach/common.h
> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> @@ -2,7 +2,6 @@
>  #define __ARCH_MACH_COMMON_H
>  
>  extern void shmobile_earlytimer_init(void);
> -extern void shmobile_timer_init(void);
>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
>  			 unsigned int mult, unsigned int div);
>  struct twd_local_timer;
> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
> index 47662a5..4e38a66 100644
> --- a/arch/arm/mach-shmobile/setup-emev2.c
> +++ b/arch/arm/mach-shmobile/setup-emev2.c
> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
>  	.nr_irqs	= NR_IRQS_LEGACY,
>  	.init_irq	= irqchip_init,
>  	.init_machine	= emev2_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= emev2_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
> index 8b85d4d..104b474 100644
> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
>  	.init_irq	= r8a7740_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_machine	= r8a7740_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= r8a7740_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
> index 59c7146..5502d62 100644
> --- a/arch/arm/mach-shmobile/setup-sh7372.c
> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
>  	.init_irq	= sh7372_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_machine	= sh7372_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= sh7372_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> index bdab575..ea66316 100644
> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
>  	.nr_irqs	= NR_IRQS_LEGACY,
>  	.init_irq	= sh73a0_init_irq_dt,
>  	.init_machine	= sh73a0_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= sh73a0_boards_compat_dt,
>  MACHINE_END
>  #endif /* CONFIG_USE_OF */
> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
> index 3d16d4d..add2f15 100644
> --- a/arch/arm/mach-shmobile/timer.c
> +++ b/arch/arm/mach-shmobile/timer.c
> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
>  {
>  	late_time_init = shmobile_late_time_init;
>  }
> -
> -void __init shmobile_timer_init(void)
> -{
> -	arch_timer_of_register();
> -	arch_timer_sched_clock_init();
> -}
> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> index d0ad789..6215717 100644
> --- a/arch/arm/mach-vexpress/v2m.c
> +++ b/arch/arm/mach-vexpress/v2m.c
> @@ -1,6 +1,7 @@
>  /*
>   * Versatile Express V2M Motherboard Support
>   */
> +#include <linux/clocksource.h>
>  #include <linux/device.h>
>  #include <linux/amba/bus.h>
>  #include <linux/amba/mmci.h>
> @@ -23,7 +24,6 @@
>  #include <linux/regulator/machine.h>
>  #include <linux/vexpress.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/mach-types.h>
>  #include <asm/sizes.h>
>  #include <asm/mach/arch.h>
> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
>  				irq_of_parse_and_map(node, 0));
>  	}
>  
> -	arch_timer_of_register();
> -
> -	if (arch_timer_sched_clock_init() != 0)
> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>  				24000000);
>  }
>  
> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
> index 31666f6..adc0945 100644
> --- a/arch/arm/mach-virt/virt.c
> +++ b/arch/arm/mach-virt/virt.c
> @@ -23,21 +23,13 @@
>  #include <linux/of_platform.h>
>  #include <linux/smp.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/mach/arch.h>
> -#include <asm/mach/time.h>
>  
>  static void __init virt_init(void)
>  {
>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>  }
>  
> -static void __init virt_timer_init(void)
> -{
> -	WARN_ON(arch_timer_of_register() != 0);
> -	WARN_ON(arch_timer_sched_clock_init() != 0);
> -}
> -
>  static const char *virt_dt_match[] = {
>  	"linux,dummy-virt",
>  	NULL
> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
>  
>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
>  	.init_irq	= irqchip_init,
> -	.init_time	= virt_timer_init,
>  	.init_machine	= virt_init,
>  	.smp		= smp_ops(virt_smp_ops),
>  	.dt_compat	= virt_dt_match,
> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> index 91e2a6a..bf6ab242 100644
> --- a/arch/arm64/include/asm/arch_timer.h
> +++ b/arch/arm64/include/asm/arch_timer.h
> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
>  	return cval;
>  }
>  
> +static inline int arch_timer_arch_init(void)
> +{
> +	return 0;
> +}
> +
>  #endif
> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
> index b0ef18d..a551f88 100644
> --- a/arch/arm64/kernel/time.c
> +++ b/arch/arm64/kernel/time.c
> @@ -32,6 +32,7 @@
>  #include <linux/timer.h>
>  #include <linux/irq.h>
>  #include <linux/delay.h>
> +#include <linux/clocksource.h>
>  
>  #include <clocksource/arm_arch_timer.h>
>  
> @@ -77,10 +78,11 @@ void __init time_init(void)
>  {
>  	u32 arch_timer_rate;
>  
> -	if (arch_timer_init())
> -		panic("Unable to initialise architected timer.\n");
> +	clocksource_of_init();
>  
>  	arch_timer_rate = arch_timer_get_rate();
> +	if (!arch_timer_rate)
> +		panic("Unable to initialise architected timer.\n");
>  
>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index e507ab7..d98e7e1 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
>  
>  config ARM_ARCH_TIMER
>  	bool
> +	select CLKSRC_OF if OF
>  
>  config CLKSRC_METAG_GENERIC
>  	def_bool y if METAG
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index d7ad425..122ff05 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -337,22 +337,14 @@ out:
>  	return err;
>  }
>  
> -static const struct of_device_id arch_timer_of_match[] __initconst = {
> -	{ .compatible	= "arm,armv7-timer",	},
> -	{ .compatible	= "arm,armv8-timer",	},
> -	{},
> -};
> -
> -int __init arch_timer_init(void)
> +static void __init arch_timer_init(struct device_node *np)
>  {
> -	struct device_node *np;
>  	u32 freq;
>  	int i;
>  
> -	np = of_find_matching_node(NULL, arch_timer_of_match);
> -	if (!np) {
> -		pr_err("arch_timer: can't find DT node\n");
> -		return -ENODEV;
> +	if (arch_timer_get_rate()) {
> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> +		return;
>  	}
>  
>  	/* Try to determine the frequency from the device tree or CNTFRQ */
> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
>  			pr_warn("arch_timer: No interrupt available, giving up\n");
> -			return -EINVAL;
> +			return;
>  		}
>  	}
>  
> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
>  	else
>  		arch_timer_read_counter = arch_counter_get_cntpct;
>  
> -	return arch_timer_register();
> +	arch_timer_register();
> +	arch_timer_arch_init();
>  }
> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> index 2603267..e6c9c4c 100644
> --- a/include/clocksource/arm_arch_timer.h
> +++ b/include/clocksource/arm_arch_timer.h
> @@ -31,18 +31,12 @@
>  
>  #ifdef CONFIG_ARM_ARCH_TIMER
>  
> -extern int arch_timer_init(void);
>  extern u32 arch_timer_get_rate(void);
>  extern u64 (*arch_timer_read_counter)(void);
>  extern struct timecounter *arch_timer_get_timecounter(void);
>  
>  #else
>  
> -static inline int arch_timer_init(void)
> -{
> -	return -ENXIO;
> -}
> -
>  static inline u32 arch_timer_get_rate(void)
>  {
>  	return 0;
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-04  5:56     ` Simon Horman
  0 siblings, 0 replies; 44+ messages in thread
From: Simon Horman @ 2013-04-04  5:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.

Would it be possible for you to either delay the removal of
shmobile_timer_init. In general I am in favour of the following
approach to wide changes such as this one:

1. Add new feature
2. Convert users to new feature
3. Remove old feature.

If it is not possible to delay the removal of shmobile_timer_init could you
update your base such that you also remove its usage from the following
files:

arch/arm/mach-shmobile/board-kzm9g-reference.c
arch/arm/mach-shmobile/setup-r8a73a4.c
arch/arm/mach-shmobile/setup-r8a7779.c
arch/arm/mach-shmobile/board-lager.c
arch/arm/mach-shmobile/board-ape6evm.c
arch/arm/mach-shmobile/setup-r8a7778.c
arch/arm/mach-shmobile/board-marzen-reference.c
arch/arm/mach-shmobile/setup-r8a7790.c
arch/arm/mach-shmobile/board-bockw.c

The above files are all present in the arm-soc/next/boards2 branch
of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
I am happy for you use the later as a base if you wish.

> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-samsung-soc at vger.kernel.org
> Cc: linux-omap at vger.kernel.org
> Cc: linux-sh at vger.kernel.org
> ---
>  arch/arm/include/asm/arch_timer.h            |   13 +------------
>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
>  arch/arm/mach-exynos/mct.c                   |    6 ------
>  arch/arm/mach-highbank/highbank.c            |    5 +----
>  arch/arm/mach-omap2/timer.c                  |    5 +----
>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -

I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.

>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -

I am not able to test the setup-emev2 portion properly at this time,
booting the kzm9d board without the board-kzm9d file seems broken without
your patch. However, your change seems reasonable to me.

>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -

I am not able to test the setup-r8a7740 portion properly at this time,
booting the armadillo800eva board without the board-armadillo800eva file
seems broken without your patch. However, your change seems reasonable to
me.

>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -

I am not able to test the setup-sh7372 portion properly at this time,
booting the mackerel board without the board-mackerel file seems broken without
your patch. However, your change seems reasonable to me.

>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -

I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.


The tests above were made by merging

git://sources.calxeda.com/kernel/linux.git arm-timers
head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
	     ("devtree: add binding documentation for sp804")

and the renesas-next-20130403 tag of the renesas tree (URL above).

>  arch/arm/mach-shmobile/timer.c               |    6 ------
>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
>  arch/arm/mach-virt/virt.c                    |    9 ---------
>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
>  arch/arm64/kernel/time.c                     |    6 ++++--
>  drivers/clocksource/Kconfig                  |    1 +
>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
>  include/clocksource/arm_arch_timer.h         |    6 ------
>  20 files changed, 27 insertions(+), 89 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
> index 7ade91d..7c1bfc0 100644
> --- a/arch/arm/include/asm/arch_timer.h
> +++ b/arch/arm/include/asm/arch_timer.h
> @@ -10,8 +10,7 @@
>  #include <clocksource/arm_arch_timer.h>
>  
>  #ifdef CONFIG_ARM_ARCH_TIMER
> -int arch_timer_of_register(void);
> -int arch_timer_sched_clock_init(void);
> +int arch_timer_arch_init(void);
>  
>  /*
>   * These register accessors are marked inline so the compiler can
> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
>  
>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
>  }
> -#else
> -static inline int arch_timer_of_register(void)
> -{
> -	return -ENXIO;
> -}
> -
> -static inline int arch_timer_sched_clock_init(void)
> -{
> -	return -ENXIO;
> -}
>  #endif
>  
>  #endif
> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
> index a7536d4..dc74048 100644
> --- a/arch/arm/kernel/arch_timer.c
> +++ b/arch/arm/kernel/arch_timer.c
> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
>  	register_current_timer_delay(&arch_delay_timer);
>  }
>  
> -int __init arch_timer_of_register(void)
> -{
> -	int ret;
> -
> -	ret = arch_timer_init();
> -	if (ret)
> -		return ret;
> -
> -	arch_timer_delay_timer_register();
> -
> -	return 0;
> -}
> -
> -int __init arch_timer_sched_clock_init(void)
> +int __init arch_timer_arch_init(void)
>  {
>          u32 arch_timer_rate = arch_timer_get_rate();
>  
>  	if (arch_timer_rate == 0)
>  		return -ENXIO;
>  
> +	arch_timer_delay_timer_register();
> +
>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>  	sched_clock_func = arch_timer_sched_clock;
> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
> index acaeb14..4d97b43 100644
> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
>  	.map_io		= exynos5_dt_map_io,
>  	.init_machine	= exynos5_dt_machine_init,
>  	.init_late	= exynos_init_late,
> -	.init_time	= exynos4_timer_init,
>  	.dt_compat	= exynos5_dt_compat,
>  	.restart        = exynos5_restart,
>  	.reserve	= exynos5_reserve,
> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
> index c9d6650..04aff6a 100644
> --- a/arch/arm/mach-exynos/mct.c
> +++ b/arch/arm/mach-exynos/mct.c
> @@ -21,7 +21,6 @@
>  #include <linux/percpu.h>
>  #include <linux/of.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/localtimer.h>
>  
>  #include <plat/cpu.h>
> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
>  
>  void __init exynos4_timer_init(void)
>  {
> -	if (soc_is_exynos5440()) {
> -		arch_timer_of_register();
> -		return;
> -	}
> -
>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
>  		mct_int_type = MCT_INT_SPI;
>  	else
> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> index 76c1170..758150e 100644
> --- a/arch/arm/mach-highbank/highbank.c
> +++ b/arch/arm/mach-highbank/highbank.c
> @@ -15,6 +15,7 @@
>   */
>  #include <linux/clk.h>
>  #include <linux/clkdev.h>
> +#include <linux/clocksource.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/io.h>
>  #include <linux/irq.h>
> @@ -28,7 +29,6 @@
>  #include <linux/amba/bus.h>
>  #include <linux/clk-provider.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/cacheflush.h>
>  #include <asm/cputype.h>
>  #include <asm/smp_plat.h>
> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
>  	sp804_clockevents_init(timer_base, irq, "timer0");
>  
> -	arch_timer_of_register();
> -	arch_timer_sched_clock_init();
> -
>  	clocksource_of_init();
>  }
>  
> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> index 4fd8025..7dd6453 100644
> --- a/arch/arm/mach-omap2/timer.c
> +++ b/arch/arm/mach-omap2/timer.c
> @@ -46,7 +46,6 @@
>  #include <asm/smp_twd.h>
>  #include <asm/sched_clock.h>
>  
> -#include <asm/arch_timer.h>
>  #include "omap_hwmod.h"
>  #include "omap_device.h"
>  #include <plat/counter-32k.h>
> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
>  	omap5_sync32k_timer_init();
>  	realtime_counter_init();
>  
> -	err = arch_timer_of_register();
> -	if (err)
> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
> +        clocksource_of_init();
>  }
>  #endif /* CONFIG_SOC_OMAP5 */
>  
> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
> index c254782..c016ccd 100644
> --- a/arch/arm/mach-shmobile/board-kzm9d.c
> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
>  	.init_irq	= emev2_init_irq,
>  	.init_machine	= kzm9d_add_standard_devices,
>  	.init_late	= shmobile_init_late,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= kzm9d_boards_compat_dt,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> index e48606d..5efc0f0 100644
> --- a/arch/arm/mach-shmobile/include/mach/common.h
> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> @@ -2,7 +2,6 @@
>  #define __ARCH_MACH_COMMON_H
>  
>  extern void shmobile_earlytimer_init(void);
> -extern void shmobile_timer_init(void);
>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
>  			 unsigned int mult, unsigned int div);
>  struct twd_local_timer;
> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
> index 47662a5..4e38a66 100644
> --- a/arch/arm/mach-shmobile/setup-emev2.c
> +++ b/arch/arm/mach-shmobile/setup-emev2.c
> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
>  	.nr_irqs	= NR_IRQS_LEGACY,
>  	.init_irq	= irqchip_init,
>  	.init_machine	= emev2_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= emev2_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
> index 8b85d4d..104b474 100644
> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
>  	.init_irq	= r8a7740_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_machine	= r8a7740_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= r8a7740_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
> index 59c7146..5502d62 100644
> --- a/arch/arm/mach-shmobile/setup-sh7372.c
> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
>  	.init_irq	= sh7372_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_machine	= sh7372_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= sh7372_boards_compat_dt,
>  MACHINE_END
>  
> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> index bdab575..ea66316 100644
> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
>  	.nr_irqs	= NR_IRQS_LEGACY,
>  	.init_irq	= sh73a0_init_irq_dt,
>  	.init_machine	= sh73a0_add_standard_devices_dt,
> -	.init_time	= shmobile_timer_init,
>  	.dt_compat	= sh73a0_boards_compat_dt,
>  MACHINE_END
>  #endif /* CONFIG_USE_OF */
> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
> index 3d16d4d..add2f15 100644
> --- a/arch/arm/mach-shmobile/timer.c
> +++ b/arch/arm/mach-shmobile/timer.c
> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
>  {
>  	late_time_init = shmobile_late_time_init;
>  }
> -
> -void __init shmobile_timer_init(void)
> -{
> -	arch_timer_of_register();
> -	arch_timer_sched_clock_init();
> -}
> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> index d0ad789..6215717 100644
> --- a/arch/arm/mach-vexpress/v2m.c
> +++ b/arch/arm/mach-vexpress/v2m.c
> @@ -1,6 +1,7 @@
>  /*
>   * Versatile Express V2M Motherboard Support
>   */
> +#include <linux/clocksource.h>
>  #include <linux/device.h>
>  #include <linux/amba/bus.h>
>  #include <linux/amba/mmci.h>
> @@ -23,7 +24,6 @@
>  #include <linux/regulator/machine.h>
>  #include <linux/vexpress.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/mach-types.h>
>  #include <asm/sizes.h>
>  #include <asm/mach/arch.h>
> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
>  				irq_of_parse_and_map(node, 0));
>  	}
>  
> -	arch_timer_of_register();
> -
> -	if (arch_timer_sched_clock_init() != 0)
> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>  				24000000);
>  }
>  
> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
> index 31666f6..adc0945 100644
> --- a/arch/arm/mach-virt/virt.c
> +++ b/arch/arm/mach-virt/virt.c
> @@ -23,21 +23,13 @@
>  #include <linux/of_platform.h>
>  #include <linux/smp.h>
>  
> -#include <asm/arch_timer.h>
>  #include <asm/mach/arch.h>
> -#include <asm/mach/time.h>
>  
>  static void __init virt_init(void)
>  {
>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>  }
>  
> -static void __init virt_timer_init(void)
> -{
> -	WARN_ON(arch_timer_of_register() != 0);
> -	WARN_ON(arch_timer_sched_clock_init() != 0);
> -}
> -
>  static const char *virt_dt_match[] = {
>  	"linux,dummy-virt",
>  	NULL
> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
>  
>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
>  	.init_irq	= irqchip_init,
> -	.init_time	= virt_timer_init,
>  	.init_machine	= virt_init,
>  	.smp		= smp_ops(virt_smp_ops),
>  	.dt_compat	= virt_dt_match,
> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> index 91e2a6a..bf6ab242 100644
> --- a/arch/arm64/include/asm/arch_timer.h
> +++ b/arch/arm64/include/asm/arch_timer.h
> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
>  	return cval;
>  }
>  
> +static inline int arch_timer_arch_init(void)
> +{
> +	return 0;
> +}
> +
>  #endif
> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
> index b0ef18d..a551f88 100644
> --- a/arch/arm64/kernel/time.c
> +++ b/arch/arm64/kernel/time.c
> @@ -32,6 +32,7 @@
>  #include <linux/timer.h>
>  #include <linux/irq.h>
>  #include <linux/delay.h>
> +#include <linux/clocksource.h>
>  
>  #include <clocksource/arm_arch_timer.h>
>  
> @@ -77,10 +78,11 @@ void __init time_init(void)
>  {
>  	u32 arch_timer_rate;
>  
> -	if (arch_timer_init())
> -		panic("Unable to initialise architected timer.\n");
> +	clocksource_of_init();
>  
>  	arch_timer_rate = arch_timer_get_rate();
> +	if (!arch_timer_rate)
> +		panic("Unable to initialise architected timer.\n");
>  
>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index e507ab7..d98e7e1 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
>  
>  config ARM_ARCH_TIMER
>  	bool
> +	select CLKSRC_OF if OF
>  
>  config CLKSRC_METAG_GENERIC
>  	def_bool y if METAG
> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> index d7ad425..122ff05 100644
> --- a/drivers/clocksource/arm_arch_timer.c
> +++ b/drivers/clocksource/arm_arch_timer.c
> @@ -337,22 +337,14 @@ out:
>  	return err;
>  }
>  
> -static const struct of_device_id arch_timer_of_match[] __initconst = {
> -	{ .compatible	= "arm,armv7-timer",	},
> -	{ .compatible	= "arm,armv8-timer",	},
> -	{},
> -};
> -
> -int __init arch_timer_init(void)
> +static void __init arch_timer_init(struct device_node *np)
>  {
> -	struct device_node *np;
>  	u32 freq;
>  	int i;
>  
> -	np = of_find_matching_node(NULL, arch_timer_of_match);
> -	if (!np) {
> -		pr_err("arch_timer: can't find DT node\n");
> -		return -ENODEV;
> +	if (arch_timer_get_rate()) {
> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> +		return;
>  	}
>  
>  	/* Try to determine the frequency from the device tree or CNTFRQ */
> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
>  			pr_warn("arch_timer: No interrupt available, giving up\n");
> -			return -EINVAL;
> +			return;
>  		}
>  	}
>  
> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
>  	else
>  		arch_timer_read_counter = arch_counter_get_cntpct;
>  
> -	return arch_timer_register();
> +	arch_timer_register();
> +	arch_timer_arch_init();
>  }
> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> index 2603267..e6c9c4c 100644
> --- a/include/clocksource/arm_arch_timer.h
> +++ b/include/clocksource/arm_arch_timer.h
> @@ -31,18 +31,12 @@
>  
>  #ifdef CONFIG_ARM_ARCH_TIMER
>  
> -extern int arch_timer_init(void);
>  extern u32 arch_timer_get_rate(void);
>  extern u64 (*arch_timer_read_counter)(void);
>  extern struct timecounter *arch_timer_get_timecounter(void);
>  
>  #else
>  
> -static inline int arch_timer_init(void)
> -{
> -	return -ENXIO;
> -}
> -
>  static inline u32 arch_timer_get_rate(void)
>  {
>  	return 0;
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-03 16:52       ` Linus Walleij
@ 2013-04-04 11:06         ` Daniel Lezcano
  0 siblings, 0 replies; 44+ messages in thread
From: Daniel Lezcano @ 2013-04-04 11:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/03/2013 06:52 PM, Linus Walleij wrote:
> On Tue, Apr 2, 2013 at 9:49 PM, Rob Herring <robherring2@gmail.com> wrote:
>> On 04/01/2013 06:26 PM, John Stultz wrote:
> 
>>> So, most of the code here is really clockevent code and not clocksource
>>> code. I realize they were combined in the mach directory you're copying
>>> them from, but if we're going to move all this code out of the arch
>>> directory and into drivers/, I'd like to propose we not dump it all into
>>> drivers/clocksource.
>>
>> Arguably, half the h/w is used for clocksource and half for clockevent
>> so it is equal. :) The sp804 and integrator are somewhat separated that
>> carving them up may be possible, but there are examples like i.MX timers
>> where the implementations are tied more closely together (the clockevent
>> compare value is the clocksource counter + delta).
>>
>> Where do I put the init functions which need to know about both?
>>
>> What about all the other timers that are already in drivers/clocksource?
> 
> The other day I thought about this because I remembered discussing
> it with John, and thinking about how some drivers (like ours) combine
> clock source, clock event, sched_clock() hook and delay timers. The
> same hardware is incidentally used for all four.
> 
> Driver writers really like to think about a driver pertaining to a certain
> memory segment in the hardware, and that's causing some strain
> here and there in the kernel.
> 
> Anyway, I was thinking that the four classes of drivers were somehow
> related but not the same thing.
> 
> So what about renaming
> drivers/clocksource -> drivers/timer
> 
> Then create a subdirectory drivers/timer/clocksource
> for the pure clocksource code and any drivers falling into that
> category.
> 
> Thus drivers/timer/clockevent, drivers/timer/schedclock
> and drivers/timer/delay can be created to handle specialized
> hardware blocks.
> 
> But the best thing with that scheme would be that combined
> drivers doing several things at once could live directly in
> drivers/timer/* and not pollute drivers/clocksource.

That looks reasonable.

  -- Daniel


-- 
 <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
  2013-04-04  5:56     ` Simon Horman
  (?)
@ 2013-04-10 23:17       ` Rob Herring
  -1 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-10 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/04/2013 12:56 AM, Simon Horman wrote:
> On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
>> the arch timer. A new function arch_timer_arch_init is added to allow for
>> arch specific setup.
>>
>> This has a side effect of enabling sched_clock on omap5 and exynos5. There
>> should not be any reason not to use the arch timers for sched_clock.
> 
> Would it be possible for you to either delay the removal of
> shmobile_timer_init. In general I am in favour of the following
> approach to wide changes such as this one:

I will simply change shmobile_timer_init to call clocksource_of_init
rather than deleting it. That should keep the new users working and then
it can be deleted latter.

> 1. Add new feature
> 2. Convert users to new feature
> 3. Remove old feature.
> 
> If it is not possible to delay the removal of shmobile_timer_init could you
> update your base such that you also remove its usage from the following
> files:
> 
> arch/arm/mach-shmobile/board-kzm9g-reference.c
> arch/arm/mach-shmobile/setup-r8a73a4.c
> arch/arm/mach-shmobile/setup-r8a7779.c
> arch/arm/mach-shmobile/board-lager.c
> arch/arm/mach-shmobile/board-ape6evm.c
> arch/arm/mach-shmobile/setup-r8a7778.c
> arch/arm/mach-shmobile/board-marzen-reference.c
> arch/arm/mach-shmobile/setup-r8a7790.c
> arch/arm/mach-shmobile/board-bockw.c

Why so many boards? There's been prior discussions about whether to add
DT into existing board files or start with a minimal DT board file and
add to it. The fact that there are 14 mach desc's using
shmobile_timer_init which is a function only used for DT and 17 DT mach
descs total for shmobile tells me perhaps the latter approach is needed.

Either way, it is good to see progress on DT support in shmobile.

Rob

> The above files are all present in the arm-soc/next/boards2 branch
> of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
> of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
> I am happy for you use the later as a base if you wish.
> 
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: Kukjin Kim <kgene.kim@samsung.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Simon Horman <horms@verge.net.au>
>> Cc: Magnus Damm <magnus.damm@gmail.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: John Stultz <john.stultz@linaro.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: linux-samsung-soc@vger.kernel.org
>> Cc: linux-omap@vger.kernel.org
>> Cc: linux-sh@vger.kernel.org
>> ---
>>  arch/arm/include/asm/arch_timer.h            |   13 +------------
>>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
>>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
>>  arch/arm/mach-exynos/mct.c                   |    6 ------
>>  arch/arm/mach-highbank/highbank.c            |    5 +----
>>  arch/arm/mach-omap2/timer.c                  |    5 +----
>>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
> 
> I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.
> 
>>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
>>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -
> 
> I am not able to test the setup-emev2 portion properly at this time,
> booting the kzm9d board without the board-kzm9d file seems broken without
> your patch. However, your change seems reasonable to me.
> 
>>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
> 
> I am not able to test the setup-r8a7740 portion properly at this time,
> booting the armadillo800eva board without the board-armadillo800eva file
> seems broken without your patch. However, your change seems reasonable to
> me.
> 
>>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
> 
> I am not able to test the setup-sh7372 portion properly at this time,
> booting the mackerel board without the board-mackerel file seems broken without
> your patch. However, your change seems reasonable to me.
> 
>>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
> 
> I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.
> 
> 
> The tests above were made by merging
> 
> git://sources.calxeda.com/kernel/linux.git arm-timers
> head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
> 	     ("devtree: add binding documentation for sp804")
> 
> and the renesas-next-20130403 tag of the renesas tree (URL above).
> 
>>  arch/arm/mach-shmobile/timer.c               |    6 ------
>>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
>>  arch/arm/mach-virt/virt.c                    |    9 ---------
>>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
>>  arch/arm64/kernel/time.c                     |    6 ++++--
>>  drivers/clocksource/Kconfig                  |    1 +
>>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
>>  include/clocksource/arm_arch_timer.h         |    6 ------
>>  20 files changed, 27 insertions(+), 89 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
>> index 7ade91d..7c1bfc0 100644
>> --- a/arch/arm/include/asm/arch_timer.h
>> +++ b/arch/arm/include/asm/arch_timer.h
>> @@ -10,8 +10,7 @@
>>  #include <clocksource/arm_arch_timer.h>
>>  
>>  #ifdef CONFIG_ARM_ARCH_TIMER
>> -int arch_timer_of_register(void);
>> -int arch_timer_sched_clock_init(void);
>> +int arch_timer_arch_init(void);
>>  
>>  /*
>>   * These register accessors are marked inline so the compiler can
>> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
>>  
>>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
>>  }
>> -#else
>> -static inline int arch_timer_of_register(void)
>> -{
>> -	return -ENXIO;
>> -}
>> -
>> -static inline int arch_timer_sched_clock_init(void)
>> -{
>> -	return -ENXIO;
>> -}
>>  #endif
>>  
>>  #endif
>> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
>> index a7536d4..dc74048 100644
>> --- a/arch/arm/kernel/arch_timer.c
>> +++ b/arch/arm/kernel/arch_timer.c
>> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
>>  	register_current_timer_delay(&arch_delay_timer);
>>  }
>>  
>> -int __init arch_timer_of_register(void)
>> -{
>> -	int ret;
>> -
>> -	ret = arch_timer_init();
>> -	if (ret)
>> -		return ret;
>> -
>> -	arch_timer_delay_timer_register();
>> -
>> -	return 0;
>> -}
>> -
>> -int __init arch_timer_sched_clock_init(void)
>> +int __init arch_timer_arch_init(void)
>>  {
>>          u32 arch_timer_rate = arch_timer_get_rate();
>>  
>>  	if (arch_timer_rate = 0)
>>  		return -ENXIO;
>>  
>> +	arch_timer_delay_timer_register();
>> +
>>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>>  	sched_clock_func = arch_timer_sched_clock;
>> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
>> index acaeb14..4d97b43 100644
>> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
>> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
>> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
>>  	.map_io		= exynos5_dt_map_io,
>>  	.init_machine	= exynos5_dt_machine_init,
>>  	.init_late	= exynos_init_late,
>> -	.init_time	= exynos4_timer_init,
>>  	.dt_compat	= exynos5_dt_compat,
>>  	.restart        = exynos5_restart,
>>  	.reserve	= exynos5_reserve,
>> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
>> index c9d6650..04aff6a 100644
>> --- a/arch/arm/mach-exynos/mct.c
>> +++ b/arch/arm/mach-exynos/mct.c
>> @@ -21,7 +21,6 @@
>>  #include <linux/percpu.h>
>>  #include <linux/of.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/localtimer.h>
>>  
>>  #include <plat/cpu.h>
>> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
>>  
>>  void __init exynos4_timer_init(void)
>>  {
>> -	if (soc_is_exynos5440()) {
>> -		arch_timer_of_register();
>> -		return;
>> -	}
>> -
>>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
>>  		mct_int_type = MCT_INT_SPI;
>>  	else
>> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
>> index 76c1170..758150e 100644
>> --- a/arch/arm/mach-highbank/highbank.c
>> +++ b/arch/arm/mach-highbank/highbank.c
>> @@ -15,6 +15,7 @@
>>   */
>>  #include <linux/clk.h>
>>  #include <linux/clkdev.h>
>> +#include <linux/clocksource.h>
>>  #include <linux/dma-mapping.h>
>>  #include <linux/io.h>
>>  #include <linux/irq.h>
>> @@ -28,7 +29,6 @@
>>  #include <linux/amba/bus.h>
>>  #include <linux/clk-provider.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/cacheflush.h>
>>  #include <asm/cputype.h>
>>  #include <asm/smp_plat.h>
>> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
>>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
>>  	sp804_clockevents_init(timer_base, irq, "timer0");
>>  
>> -	arch_timer_of_register();
>> -	arch_timer_sched_clock_init();
>> -
>>  	clocksource_of_init();
>>  }
>>  
>> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
>> index 4fd8025..7dd6453 100644
>> --- a/arch/arm/mach-omap2/timer.c
>> +++ b/arch/arm/mach-omap2/timer.c
>> @@ -46,7 +46,6 @@
>>  #include <asm/smp_twd.h>
>>  #include <asm/sched_clock.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include "omap_hwmod.h"
>>  #include "omap_device.h"
>>  #include <plat/counter-32k.h>
>> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
>>  	omap5_sync32k_timer_init();
>>  	realtime_counter_init();
>>  
>> -	err = arch_timer_of_register();
>> -	if (err)
>> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
>> +        clocksource_of_init();
>>  }
>>  #endif /* CONFIG_SOC_OMAP5 */
>>  
>> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
>> index c254782..c016ccd 100644
>> --- a/arch/arm/mach-shmobile/board-kzm9d.c
>> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
>> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
>>  	.init_irq	= emev2_init_irq,
>>  	.init_machine	= kzm9d_add_standard_devices,
>>  	.init_late	= shmobile_init_late,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= kzm9d_boards_compat_dt,
>>  MACHINE_END
>> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
>> index e48606d..5efc0f0 100644
>> --- a/arch/arm/mach-shmobile/include/mach/common.h
>> +++ b/arch/arm/mach-shmobile/include/mach/common.h
>> @@ -2,7 +2,6 @@
>>  #define __ARCH_MACH_COMMON_H
>>  
>>  extern void shmobile_earlytimer_init(void);
>> -extern void shmobile_timer_init(void);
>>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
>>  			 unsigned int mult, unsigned int div);
>>  struct twd_local_timer;
>> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
>> index 47662a5..4e38a66 100644
>> --- a/arch/arm/mach-shmobile/setup-emev2.c
>> +++ b/arch/arm/mach-shmobile/setup-emev2.c
>> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
>>  	.nr_irqs	= NR_IRQS_LEGACY,
>>  	.init_irq	= irqchip_init,
>>  	.init_machine	= emev2_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= emev2_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
>> index 8b85d4d..104b474 100644
>> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
>> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
>> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
>>  	.init_irq	= r8a7740_init_irq,
>>  	.handle_irq	= shmobile_handle_irq_intc,
>>  	.init_machine	= r8a7740_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= r8a7740_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
>> index 59c7146..5502d62 100644
>> --- a/arch/arm/mach-shmobile/setup-sh7372.c
>> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
>> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
>>  	.init_irq	= sh7372_init_irq,
>>  	.handle_irq	= shmobile_handle_irq_intc,
>>  	.init_machine	= sh7372_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= sh7372_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
>> index bdab575..ea66316 100644
>> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
>> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
>> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
>>  	.nr_irqs	= NR_IRQS_LEGACY,
>>  	.init_irq	= sh73a0_init_irq_dt,
>>  	.init_machine	= sh73a0_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= sh73a0_boards_compat_dt,
>>  MACHINE_END
>>  #endif /* CONFIG_USE_OF */
>> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
>> index 3d16d4d..add2f15 100644
>> --- a/arch/arm/mach-shmobile/timer.c
>> +++ b/arch/arm/mach-shmobile/timer.c
>> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
>>  {
>>  	late_time_init = shmobile_late_time_init;
>>  }
>> -
>> -void __init shmobile_timer_init(void)
>> -{
>> -	arch_timer_of_register();
>> -	arch_timer_sched_clock_init();
>> -}
>> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
>> index d0ad789..6215717 100644
>> --- a/arch/arm/mach-vexpress/v2m.c
>> +++ b/arch/arm/mach-vexpress/v2m.c
>> @@ -1,6 +1,7 @@
>>  /*
>>   * Versatile Express V2M Motherboard Support
>>   */
>> +#include <linux/clocksource.h>
>>  #include <linux/device.h>
>>  #include <linux/amba/bus.h>
>>  #include <linux/amba/mmci.h>
>> @@ -23,7 +24,6 @@
>>  #include <linux/regulator/machine.h>
>>  #include <linux/vexpress.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/mach-types.h>
>>  #include <asm/sizes.h>
>>  #include <asm/mach/arch.h>
>> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
>>  				irq_of_parse_and_map(node, 0));
>>  	}
>>  
>> -	arch_timer_of_register();
>> -
>> -	if (arch_timer_sched_clock_init() != 0)
>> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>>  				24000000);
>>  }
>>  
>> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
>> index 31666f6..adc0945 100644
>> --- a/arch/arm/mach-virt/virt.c
>> +++ b/arch/arm/mach-virt/virt.c
>> @@ -23,21 +23,13 @@
>>  #include <linux/of_platform.h>
>>  #include <linux/smp.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/mach/arch.h>
>> -#include <asm/mach/time.h>
>>  
>>  static void __init virt_init(void)
>>  {
>>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>>  }
>>  
>> -static void __init virt_timer_init(void)
>> -{
>> -	WARN_ON(arch_timer_of_register() != 0);
>> -	WARN_ON(arch_timer_sched_clock_init() != 0);
>> -}
>> -
>>  static const char *virt_dt_match[] = {
>>  	"linux,dummy-virt",
>>  	NULL
>> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
>>  
>>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
>>  	.init_irq	= irqchip_init,
>> -	.init_time	= virt_timer_init,
>>  	.init_machine	= virt_init,
>>  	.smp		= smp_ops(virt_smp_ops),
>>  	.dt_compat	= virt_dt_match,
>> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
>> index 91e2a6a..bf6ab242 100644
>> --- a/arch/arm64/include/asm/arch_timer.h
>> +++ b/arch/arm64/include/asm/arch_timer.h
>> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
>>  	return cval;
>>  }
>>  
>> +static inline int arch_timer_arch_init(void)
>> +{
>> +	return 0;
>> +}
>> +
>>  #endif
>> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
>> index b0ef18d..a551f88 100644
>> --- a/arch/arm64/kernel/time.c
>> +++ b/arch/arm64/kernel/time.c
>> @@ -32,6 +32,7 @@
>>  #include <linux/timer.h>
>>  #include <linux/irq.h>
>>  #include <linux/delay.h>
>> +#include <linux/clocksource.h>
>>  
>>  #include <clocksource/arm_arch_timer.h>
>>  
>> @@ -77,10 +78,11 @@ void __init time_init(void)
>>  {
>>  	u32 arch_timer_rate;
>>  
>> -	if (arch_timer_init())
>> -		panic("Unable to initialise architected timer.\n");
>> +	clocksource_of_init();
>>  
>>  	arch_timer_rate = arch_timer_get_rate();
>> +	if (!arch_timer_rate)
>> +		panic("Unable to initialise architected timer.\n");
>>  
>>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
>> index e507ab7..d98e7e1 100644
>> --- a/drivers/clocksource/Kconfig
>> +++ b/drivers/clocksource/Kconfig
>> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
>>  
>>  config ARM_ARCH_TIMER
>>  	bool
>> +	select CLKSRC_OF if OF
>>  
>>  config CLKSRC_METAG_GENERIC
>>  	def_bool y if METAG
>> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
>> index d7ad425..122ff05 100644
>> --- a/drivers/clocksource/arm_arch_timer.c
>> +++ b/drivers/clocksource/arm_arch_timer.c
>> @@ -337,22 +337,14 @@ out:
>>  	return err;
>>  }
>>  
>> -static const struct of_device_id arch_timer_of_match[] __initconst = {
>> -	{ .compatible	= "arm,armv7-timer",	},
>> -	{ .compatible	= "arm,armv8-timer",	},
>> -	{},
>> -};
>> -
>> -int __init arch_timer_init(void)
>> +static void __init arch_timer_init(struct device_node *np)
>>  {
>> -	struct device_node *np;
>>  	u32 freq;
>>  	int i;
>>  
>> -	np = of_find_matching_node(NULL, arch_timer_of_match);
>> -	if (!np) {
>> -		pr_err("arch_timer: can't find DT node\n");
>> -		return -ENODEV;
>> +	if (arch_timer_get_rate()) {
>> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
>> +		return;
>>  	}
>>  
>>  	/* Try to determine the frequency from the device tree or CNTFRQ */
>> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
>>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
>>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
>>  			pr_warn("arch_timer: No interrupt available, giving up\n");
>> -			return -EINVAL;
>> +			return;
>>  		}
>>  	}
>>  
>> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
>>  	else
>>  		arch_timer_read_counter = arch_counter_get_cntpct;
>>  
>> -	return arch_timer_register();
>> +	arch_timer_register();
>> +	arch_timer_arch_init();
>>  }
>> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
>> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
>> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
>> index 2603267..e6c9c4c 100644
>> --- a/include/clocksource/arm_arch_timer.h
>> +++ b/include/clocksource/arm_arch_timer.h
>> @@ -31,18 +31,12 @@
>>  
>>  #ifdef CONFIG_ARM_ARCH_TIMER
>>  
>> -extern int arch_timer_init(void);
>>  extern u32 arch_timer_get_rate(void);
>>  extern u64 (*arch_timer_read_counter)(void);
>>  extern struct timecounter *arch_timer_get_timecounter(void);
>>  
>>  #else
>>  
>> -static inline int arch_timer_init(void)
>> -{
>> -	return -ENXIO;
>> -}
>> -
>>  static inline u32 arch_timer_get_rate(void)
>>  {
>>  	return 0;
>> -- 
>> 1.7.10.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-10 23:17       ` Rob Herring
  0 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-10 23:17 UTC (permalink / raw)
  To: Simon Horman
  Cc: linux-arm-kernel, Thomas Gleixner, Mark Rutland, Russell King,
	John Stultz, arm, Marc Zyngier, Linus Walleij, Rob Herring,
	Kukjin Kim, Tony Lindgren, Magnus Damm, Catalin Marinas,
	Will Deacon, linux-samsung-soc, linux-omap, linux-sh

On 04/04/2013 12:56 AM, Simon Horman wrote:
> On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
>> the arch timer. A new function arch_timer_arch_init is added to allow for
>> arch specific setup.
>>
>> This has a side effect of enabling sched_clock on omap5 and exynos5. There
>> should not be any reason not to use the arch timers for sched_clock.
> 
> Would it be possible for you to either delay the removal of
> shmobile_timer_init. In general I am in favour of the following
> approach to wide changes such as this one:

I will simply change shmobile_timer_init to call clocksource_of_init
rather than deleting it. That should keep the new users working and then
it can be deleted latter.

> 1. Add new feature
> 2. Convert users to new feature
> 3. Remove old feature.
> 
> If it is not possible to delay the removal of shmobile_timer_init could you
> update your base such that you also remove its usage from the following
> files:
> 
> arch/arm/mach-shmobile/board-kzm9g-reference.c
> arch/arm/mach-shmobile/setup-r8a73a4.c
> arch/arm/mach-shmobile/setup-r8a7779.c
> arch/arm/mach-shmobile/board-lager.c
> arch/arm/mach-shmobile/board-ape6evm.c
> arch/arm/mach-shmobile/setup-r8a7778.c
> arch/arm/mach-shmobile/board-marzen-reference.c
> arch/arm/mach-shmobile/setup-r8a7790.c
> arch/arm/mach-shmobile/board-bockw.c

Why so many boards? There's been prior discussions about whether to add
DT into existing board files or start with a minimal DT board file and
add to it. The fact that there are 14 mach desc's using
shmobile_timer_init which is a function only used for DT and 17 DT mach
descs total for shmobile tells me perhaps the latter approach is needed.

Either way, it is good to see progress on DT support in shmobile.

Rob

> The above files are all present in the arm-soc/next/boards2 branch
> of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
> of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
> I am happy for you use the later as a base if you wish.
> 
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: Kukjin Kim <kgene.kim@samsung.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Simon Horman <horms@verge.net.au>
>> Cc: Magnus Damm <magnus.damm@gmail.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: John Stultz <john.stultz@linaro.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: linux-samsung-soc@vger.kernel.org
>> Cc: linux-omap@vger.kernel.org
>> Cc: linux-sh@vger.kernel.org
>> ---
>>  arch/arm/include/asm/arch_timer.h            |   13 +------------
>>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
>>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
>>  arch/arm/mach-exynos/mct.c                   |    6 ------
>>  arch/arm/mach-highbank/highbank.c            |    5 +----
>>  arch/arm/mach-omap2/timer.c                  |    5 +----
>>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
> 
> I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.
> 
>>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
>>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -
> 
> I am not able to test the setup-emev2 portion properly at this time,
> booting the kzm9d board without the board-kzm9d file seems broken without
> your patch. However, your change seems reasonable to me.
> 
>>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
> 
> I am not able to test the setup-r8a7740 portion properly at this time,
> booting the armadillo800eva board without the board-armadillo800eva file
> seems broken without your patch. However, your change seems reasonable to
> me.
> 
>>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
> 
> I am not able to test the setup-sh7372 portion properly at this time,
> booting the mackerel board without the board-mackerel file seems broken without
> your patch. However, your change seems reasonable to me.
> 
>>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
> 
> I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.
> 
> 
> The tests above were made by merging
> 
> git://sources.calxeda.com/kernel/linux.git arm-timers
> head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
> 	     ("devtree: add binding documentation for sp804")
> 
> and the renesas-next-20130403 tag of the renesas tree (URL above).
> 
>>  arch/arm/mach-shmobile/timer.c               |    6 ------
>>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
>>  arch/arm/mach-virt/virt.c                    |    9 ---------
>>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
>>  arch/arm64/kernel/time.c                     |    6 ++++--
>>  drivers/clocksource/Kconfig                  |    1 +
>>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
>>  include/clocksource/arm_arch_timer.h         |    6 ------
>>  20 files changed, 27 insertions(+), 89 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
>> index 7ade91d..7c1bfc0 100644
>> --- a/arch/arm/include/asm/arch_timer.h
>> +++ b/arch/arm/include/asm/arch_timer.h
>> @@ -10,8 +10,7 @@
>>  #include <clocksource/arm_arch_timer.h>
>>  
>>  #ifdef CONFIG_ARM_ARCH_TIMER
>> -int arch_timer_of_register(void);
>> -int arch_timer_sched_clock_init(void);
>> +int arch_timer_arch_init(void);
>>  
>>  /*
>>   * These register accessors are marked inline so the compiler can
>> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
>>  
>>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
>>  }
>> -#else
>> -static inline int arch_timer_of_register(void)
>> -{
>> -	return -ENXIO;
>> -}
>> -
>> -static inline int arch_timer_sched_clock_init(void)
>> -{
>> -	return -ENXIO;
>> -}
>>  #endif
>>  
>>  #endif
>> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
>> index a7536d4..dc74048 100644
>> --- a/arch/arm/kernel/arch_timer.c
>> +++ b/arch/arm/kernel/arch_timer.c
>> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
>>  	register_current_timer_delay(&arch_delay_timer);
>>  }
>>  
>> -int __init arch_timer_of_register(void)
>> -{
>> -	int ret;
>> -
>> -	ret = arch_timer_init();
>> -	if (ret)
>> -		return ret;
>> -
>> -	arch_timer_delay_timer_register();
>> -
>> -	return 0;
>> -}
>> -
>> -int __init arch_timer_sched_clock_init(void)
>> +int __init arch_timer_arch_init(void)
>>  {
>>          u32 arch_timer_rate = arch_timer_get_rate();
>>  
>>  	if (arch_timer_rate == 0)
>>  		return -ENXIO;
>>  
>> +	arch_timer_delay_timer_register();
>> +
>>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>>  	sched_clock_func = arch_timer_sched_clock;
>> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
>> index acaeb14..4d97b43 100644
>> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
>> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
>> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
>>  	.map_io		= exynos5_dt_map_io,
>>  	.init_machine	= exynos5_dt_machine_init,
>>  	.init_late	= exynos_init_late,
>> -	.init_time	= exynos4_timer_init,
>>  	.dt_compat	= exynos5_dt_compat,
>>  	.restart        = exynos5_restart,
>>  	.reserve	= exynos5_reserve,
>> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
>> index c9d6650..04aff6a 100644
>> --- a/arch/arm/mach-exynos/mct.c
>> +++ b/arch/arm/mach-exynos/mct.c
>> @@ -21,7 +21,6 @@
>>  #include <linux/percpu.h>
>>  #include <linux/of.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/localtimer.h>
>>  
>>  #include <plat/cpu.h>
>> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
>>  
>>  void __init exynos4_timer_init(void)
>>  {
>> -	if (soc_is_exynos5440()) {
>> -		arch_timer_of_register();
>> -		return;
>> -	}
>> -
>>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
>>  		mct_int_type = MCT_INT_SPI;
>>  	else
>> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
>> index 76c1170..758150e 100644
>> --- a/arch/arm/mach-highbank/highbank.c
>> +++ b/arch/arm/mach-highbank/highbank.c
>> @@ -15,6 +15,7 @@
>>   */
>>  #include <linux/clk.h>
>>  #include <linux/clkdev.h>
>> +#include <linux/clocksource.h>
>>  #include <linux/dma-mapping.h>
>>  #include <linux/io.h>
>>  #include <linux/irq.h>
>> @@ -28,7 +29,6 @@
>>  #include <linux/amba/bus.h>
>>  #include <linux/clk-provider.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/cacheflush.h>
>>  #include <asm/cputype.h>
>>  #include <asm/smp_plat.h>
>> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
>>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
>>  	sp804_clockevents_init(timer_base, irq, "timer0");
>>  
>> -	arch_timer_of_register();
>> -	arch_timer_sched_clock_init();
>> -
>>  	clocksource_of_init();
>>  }
>>  
>> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
>> index 4fd8025..7dd6453 100644
>> --- a/arch/arm/mach-omap2/timer.c
>> +++ b/arch/arm/mach-omap2/timer.c
>> @@ -46,7 +46,6 @@
>>  #include <asm/smp_twd.h>
>>  #include <asm/sched_clock.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include "omap_hwmod.h"
>>  #include "omap_device.h"
>>  #include <plat/counter-32k.h>
>> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
>>  	omap5_sync32k_timer_init();
>>  	realtime_counter_init();
>>  
>> -	err = arch_timer_of_register();
>> -	if (err)
>> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
>> +        clocksource_of_init();
>>  }
>>  #endif /* CONFIG_SOC_OMAP5 */
>>  
>> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
>> index c254782..c016ccd 100644
>> --- a/arch/arm/mach-shmobile/board-kzm9d.c
>> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
>> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
>>  	.init_irq	= emev2_init_irq,
>>  	.init_machine	= kzm9d_add_standard_devices,
>>  	.init_late	= shmobile_init_late,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= kzm9d_boards_compat_dt,
>>  MACHINE_END
>> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
>> index e48606d..5efc0f0 100644
>> --- a/arch/arm/mach-shmobile/include/mach/common.h
>> +++ b/arch/arm/mach-shmobile/include/mach/common.h
>> @@ -2,7 +2,6 @@
>>  #define __ARCH_MACH_COMMON_H
>>  
>>  extern void shmobile_earlytimer_init(void);
>> -extern void shmobile_timer_init(void);
>>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
>>  			 unsigned int mult, unsigned int div);
>>  struct twd_local_timer;
>> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
>> index 47662a5..4e38a66 100644
>> --- a/arch/arm/mach-shmobile/setup-emev2.c
>> +++ b/arch/arm/mach-shmobile/setup-emev2.c
>> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
>>  	.nr_irqs	= NR_IRQS_LEGACY,
>>  	.init_irq	= irqchip_init,
>>  	.init_machine	= emev2_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= emev2_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
>> index 8b85d4d..104b474 100644
>> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
>> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
>> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
>>  	.init_irq	= r8a7740_init_irq,
>>  	.handle_irq	= shmobile_handle_irq_intc,
>>  	.init_machine	= r8a7740_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= r8a7740_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
>> index 59c7146..5502d62 100644
>> --- a/arch/arm/mach-shmobile/setup-sh7372.c
>> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
>> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
>>  	.init_irq	= sh7372_init_irq,
>>  	.handle_irq	= shmobile_handle_irq_intc,
>>  	.init_machine	= sh7372_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= sh7372_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
>> index bdab575..ea66316 100644
>> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
>> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
>> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
>>  	.nr_irqs	= NR_IRQS_LEGACY,
>>  	.init_irq	= sh73a0_init_irq_dt,
>>  	.init_machine	= sh73a0_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= sh73a0_boards_compat_dt,
>>  MACHINE_END
>>  #endif /* CONFIG_USE_OF */
>> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
>> index 3d16d4d..add2f15 100644
>> --- a/arch/arm/mach-shmobile/timer.c
>> +++ b/arch/arm/mach-shmobile/timer.c
>> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
>>  {
>>  	late_time_init = shmobile_late_time_init;
>>  }
>> -
>> -void __init shmobile_timer_init(void)
>> -{
>> -	arch_timer_of_register();
>> -	arch_timer_sched_clock_init();
>> -}
>> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
>> index d0ad789..6215717 100644
>> --- a/arch/arm/mach-vexpress/v2m.c
>> +++ b/arch/arm/mach-vexpress/v2m.c
>> @@ -1,6 +1,7 @@
>>  /*
>>   * Versatile Express V2M Motherboard Support
>>   */
>> +#include <linux/clocksource.h>
>>  #include <linux/device.h>
>>  #include <linux/amba/bus.h>
>>  #include <linux/amba/mmci.h>
>> @@ -23,7 +24,6 @@
>>  #include <linux/regulator/machine.h>
>>  #include <linux/vexpress.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/mach-types.h>
>>  #include <asm/sizes.h>
>>  #include <asm/mach/arch.h>
>> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
>>  				irq_of_parse_and_map(node, 0));
>>  	}
>>  
>> -	arch_timer_of_register();
>> -
>> -	if (arch_timer_sched_clock_init() != 0)
>> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>>  				24000000);
>>  }
>>  
>> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
>> index 31666f6..adc0945 100644
>> --- a/arch/arm/mach-virt/virt.c
>> +++ b/arch/arm/mach-virt/virt.c
>> @@ -23,21 +23,13 @@
>>  #include <linux/of_platform.h>
>>  #include <linux/smp.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/mach/arch.h>
>> -#include <asm/mach/time.h>
>>  
>>  static void __init virt_init(void)
>>  {
>>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>>  }
>>  
>> -static void __init virt_timer_init(void)
>> -{
>> -	WARN_ON(arch_timer_of_register() != 0);
>> -	WARN_ON(arch_timer_sched_clock_init() != 0);
>> -}
>> -
>>  static const char *virt_dt_match[] = {
>>  	"linux,dummy-virt",
>>  	NULL
>> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
>>  
>>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
>>  	.init_irq	= irqchip_init,
>> -	.init_time	= virt_timer_init,
>>  	.init_machine	= virt_init,
>>  	.smp		= smp_ops(virt_smp_ops),
>>  	.dt_compat	= virt_dt_match,
>> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
>> index 91e2a6a..bf6ab242 100644
>> --- a/arch/arm64/include/asm/arch_timer.h
>> +++ b/arch/arm64/include/asm/arch_timer.h
>> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
>>  	return cval;
>>  }
>>  
>> +static inline int arch_timer_arch_init(void)
>> +{
>> +	return 0;
>> +}
>> +
>>  #endif
>> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
>> index b0ef18d..a551f88 100644
>> --- a/arch/arm64/kernel/time.c
>> +++ b/arch/arm64/kernel/time.c
>> @@ -32,6 +32,7 @@
>>  #include <linux/timer.h>
>>  #include <linux/irq.h>
>>  #include <linux/delay.h>
>> +#include <linux/clocksource.h>
>>  
>>  #include <clocksource/arm_arch_timer.h>
>>  
>> @@ -77,10 +78,11 @@ void __init time_init(void)
>>  {
>>  	u32 arch_timer_rate;
>>  
>> -	if (arch_timer_init())
>> -		panic("Unable to initialise architected timer.\n");
>> +	clocksource_of_init();
>>  
>>  	arch_timer_rate = arch_timer_get_rate();
>> +	if (!arch_timer_rate)
>> +		panic("Unable to initialise architected timer.\n");
>>  
>>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
>> index e507ab7..d98e7e1 100644
>> --- a/drivers/clocksource/Kconfig
>> +++ b/drivers/clocksource/Kconfig
>> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
>>  
>>  config ARM_ARCH_TIMER
>>  	bool
>> +	select CLKSRC_OF if OF
>>  
>>  config CLKSRC_METAG_GENERIC
>>  	def_bool y if METAG
>> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
>> index d7ad425..122ff05 100644
>> --- a/drivers/clocksource/arm_arch_timer.c
>> +++ b/drivers/clocksource/arm_arch_timer.c
>> @@ -337,22 +337,14 @@ out:
>>  	return err;
>>  }
>>  
>> -static const struct of_device_id arch_timer_of_match[] __initconst = {
>> -	{ .compatible	= "arm,armv7-timer",	},
>> -	{ .compatible	= "arm,armv8-timer",	},
>> -	{},
>> -};
>> -
>> -int __init arch_timer_init(void)
>> +static void __init arch_timer_init(struct device_node *np)
>>  {
>> -	struct device_node *np;
>>  	u32 freq;
>>  	int i;
>>  
>> -	np = of_find_matching_node(NULL, arch_timer_of_match);
>> -	if (!np) {
>> -		pr_err("arch_timer: can't find DT node\n");
>> -		return -ENODEV;
>> +	if (arch_timer_get_rate()) {
>> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
>> +		return;
>>  	}
>>  
>>  	/* Try to determine the frequency from the device tree or CNTFRQ */
>> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
>>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
>>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
>>  			pr_warn("arch_timer: No interrupt available, giving up\n");
>> -			return -EINVAL;
>> +			return;
>>  		}
>>  	}
>>  
>> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
>>  	else
>>  		arch_timer_read_counter = arch_counter_get_cntpct;
>>  
>> -	return arch_timer_register();
>> +	arch_timer_register();
>> +	arch_timer_arch_init();
>>  }
>> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
>> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
>> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
>> index 2603267..e6c9c4c 100644
>> --- a/include/clocksource/arm_arch_timer.h
>> +++ b/include/clocksource/arm_arch_timer.h
>> @@ -31,18 +31,12 @@
>>  
>>  #ifdef CONFIG_ARM_ARCH_TIMER
>>  
>> -extern int arch_timer_init(void);
>>  extern u32 arch_timer_get_rate(void);
>>  extern u64 (*arch_timer_read_counter)(void);
>>  extern struct timecounter *arch_timer_get_timecounter(void);
>>  
>>  #else
>>  
>> -static inline int arch_timer_init(void)
>> -{
>> -	return -ENXIO;
>> -}
>> -
>>  static inline u32 arch_timer_get_rate(void)
>>  {
>>  	return 0;
>> -- 
>> 1.7.10.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-10 23:17       ` Rob Herring
  0 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-10 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/04/2013 12:56 AM, Simon Horman wrote:
> On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
>> the arch timer. A new function arch_timer_arch_init is added to allow for
>> arch specific setup.
>>
>> This has a side effect of enabling sched_clock on omap5 and exynos5. There
>> should not be any reason not to use the arch timers for sched_clock.
> 
> Would it be possible for you to either delay the removal of
> shmobile_timer_init. In general I am in favour of the following
> approach to wide changes such as this one:

I will simply change shmobile_timer_init to call clocksource_of_init
rather than deleting it. That should keep the new users working and then
it can be deleted latter.

> 1. Add new feature
> 2. Convert users to new feature
> 3. Remove old feature.
> 
> If it is not possible to delay the removal of shmobile_timer_init could you
> update your base such that you also remove its usage from the following
> files:
> 
> arch/arm/mach-shmobile/board-kzm9g-reference.c
> arch/arm/mach-shmobile/setup-r8a73a4.c
> arch/arm/mach-shmobile/setup-r8a7779.c
> arch/arm/mach-shmobile/board-lager.c
> arch/arm/mach-shmobile/board-ape6evm.c
> arch/arm/mach-shmobile/setup-r8a7778.c
> arch/arm/mach-shmobile/board-marzen-reference.c
> arch/arm/mach-shmobile/setup-r8a7790.c
> arch/arm/mach-shmobile/board-bockw.c

Why so many boards? There's been prior discussions about whether to add
DT into existing board files or start with a minimal DT board file and
add to it. The fact that there are 14 mach desc's using
shmobile_timer_init which is a function only used for DT and 17 DT mach
descs total for shmobile tells me perhaps the latter approach is needed.

Either way, it is good to see progress on DT support in shmobile.

Rob

> The above files are all present in the arm-soc/next/boards2 branch
> of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
> of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
> I am happy for you use the later as a base if you wish.
> 
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: Kukjin Kim <kgene.kim@samsung.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: Simon Horman <horms@verge.net.au>
>> Cc: Magnus Damm <magnus.damm@gmail.com>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Cc: Will Deacon <will.deacon@arm.com>
>> Cc: John Stultz <john.stultz@linaro.org>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: linux-samsung-soc at vger.kernel.org
>> Cc: linux-omap at vger.kernel.org
>> Cc: linux-sh at vger.kernel.org
>> ---
>>  arch/arm/include/asm/arch_timer.h            |   13 +------------
>>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
>>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
>>  arch/arm/mach-exynos/mct.c                   |    6 ------
>>  arch/arm/mach-highbank/highbank.c            |    5 +----
>>  arch/arm/mach-omap2/timer.c                  |    5 +----
>>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
> 
> I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.
> 
>>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
>>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -
> 
> I am not able to test the setup-emev2 portion properly at this time,
> booting the kzm9d board without the board-kzm9d file seems broken without
> your patch. However, your change seems reasonable to me.
> 
>>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
> 
> I am not able to test the setup-r8a7740 portion properly at this time,
> booting the armadillo800eva board without the board-armadillo800eva file
> seems broken without your patch. However, your change seems reasonable to
> me.
> 
>>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
> 
> I am not able to test the setup-sh7372 portion properly at this time,
> booting the mackerel board without the board-mackerel file seems broken without
> your patch. However, your change seems reasonable to me.
> 
>>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
> 
> I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.
> 
> 
> The tests above were made by merging
> 
> git://sources.calxeda.com/kernel/linux.git arm-timers
> head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
> 	     ("devtree: add binding documentation for sp804")
> 
> and the renesas-next-20130403 tag of the renesas tree (URL above).
> 
>>  arch/arm/mach-shmobile/timer.c               |    6 ------
>>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
>>  arch/arm/mach-virt/virt.c                    |    9 ---------
>>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
>>  arch/arm64/kernel/time.c                     |    6 ++++--
>>  drivers/clocksource/Kconfig                  |    1 +
>>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
>>  include/clocksource/arm_arch_timer.h         |    6 ------
>>  20 files changed, 27 insertions(+), 89 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
>> index 7ade91d..7c1bfc0 100644
>> --- a/arch/arm/include/asm/arch_timer.h
>> +++ b/arch/arm/include/asm/arch_timer.h
>> @@ -10,8 +10,7 @@
>>  #include <clocksource/arm_arch_timer.h>
>>  
>>  #ifdef CONFIG_ARM_ARCH_TIMER
>> -int arch_timer_of_register(void);
>> -int arch_timer_sched_clock_init(void);
>> +int arch_timer_arch_init(void);
>>  
>>  /*
>>   * These register accessors are marked inline so the compiler can
>> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
>>  
>>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
>>  }
>> -#else
>> -static inline int arch_timer_of_register(void)
>> -{
>> -	return -ENXIO;
>> -}
>> -
>> -static inline int arch_timer_sched_clock_init(void)
>> -{
>> -	return -ENXIO;
>> -}
>>  #endif
>>  
>>  #endif
>> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
>> index a7536d4..dc74048 100644
>> --- a/arch/arm/kernel/arch_timer.c
>> +++ b/arch/arm/kernel/arch_timer.c
>> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
>>  	register_current_timer_delay(&arch_delay_timer);
>>  }
>>  
>> -int __init arch_timer_of_register(void)
>> -{
>> -	int ret;
>> -
>> -	ret = arch_timer_init();
>> -	if (ret)
>> -		return ret;
>> -
>> -	arch_timer_delay_timer_register();
>> -
>> -	return 0;
>> -}
>> -
>> -int __init arch_timer_sched_clock_init(void)
>> +int __init arch_timer_arch_init(void)
>>  {
>>          u32 arch_timer_rate = arch_timer_get_rate();
>>  
>>  	if (arch_timer_rate == 0)
>>  		return -ENXIO;
>>  
>> +	arch_timer_delay_timer_register();
>> +
>>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>>  	sched_clock_func = arch_timer_sched_clock;
>> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
>> index acaeb14..4d97b43 100644
>> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
>> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
>> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
>>  	.map_io		= exynos5_dt_map_io,
>>  	.init_machine	= exynos5_dt_machine_init,
>>  	.init_late	= exynos_init_late,
>> -	.init_time	= exynos4_timer_init,
>>  	.dt_compat	= exynos5_dt_compat,
>>  	.restart        = exynos5_restart,
>>  	.reserve	= exynos5_reserve,
>> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
>> index c9d6650..04aff6a 100644
>> --- a/arch/arm/mach-exynos/mct.c
>> +++ b/arch/arm/mach-exynos/mct.c
>> @@ -21,7 +21,6 @@
>>  #include <linux/percpu.h>
>>  #include <linux/of.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/localtimer.h>
>>  
>>  #include <plat/cpu.h>
>> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
>>  
>>  void __init exynos4_timer_init(void)
>>  {
>> -	if (soc_is_exynos5440()) {
>> -		arch_timer_of_register();
>> -		return;
>> -	}
>> -
>>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
>>  		mct_int_type = MCT_INT_SPI;
>>  	else
>> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
>> index 76c1170..758150e 100644
>> --- a/arch/arm/mach-highbank/highbank.c
>> +++ b/arch/arm/mach-highbank/highbank.c
>> @@ -15,6 +15,7 @@
>>   */
>>  #include <linux/clk.h>
>>  #include <linux/clkdev.h>
>> +#include <linux/clocksource.h>
>>  #include <linux/dma-mapping.h>
>>  #include <linux/io.h>
>>  #include <linux/irq.h>
>> @@ -28,7 +29,6 @@
>>  #include <linux/amba/bus.h>
>>  #include <linux/clk-provider.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/cacheflush.h>
>>  #include <asm/cputype.h>
>>  #include <asm/smp_plat.h>
>> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
>>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
>>  	sp804_clockevents_init(timer_base, irq, "timer0");
>>  
>> -	arch_timer_of_register();
>> -	arch_timer_sched_clock_init();
>> -
>>  	clocksource_of_init();
>>  }
>>  
>> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
>> index 4fd8025..7dd6453 100644
>> --- a/arch/arm/mach-omap2/timer.c
>> +++ b/arch/arm/mach-omap2/timer.c
>> @@ -46,7 +46,6 @@
>>  #include <asm/smp_twd.h>
>>  #include <asm/sched_clock.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include "omap_hwmod.h"
>>  #include "omap_device.h"
>>  #include <plat/counter-32k.h>
>> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
>>  	omap5_sync32k_timer_init();
>>  	realtime_counter_init();
>>  
>> -	err = arch_timer_of_register();
>> -	if (err)
>> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
>> +        clocksource_of_init();
>>  }
>>  #endif /* CONFIG_SOC_OMAP5 */
>>  
>> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
>> index c254782..c016ccd 100644
>> --- a/arch/arm/mach-shmobile/board-kzm9d.c
>> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
>> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
>>  	.init_irq	= emev2_init_irq,
>>  	.init_machine	= kzm9d_add_standard_devices,
>>  	.init_late	= shmobile_init_late,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= kzm9d_boards_compat_dt,
>>  MACHINE_END
>> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
>> index e48606d..5efc0f0 100644
>> --- a/arch/arm/mach-shmobile/include/mach/common.h
>> +++ b/arch/arm/mach-shmobile/include/mach/common.h
>> @@ -2,7 +2,6 @@
>>  #define __ARCH_MACH_COMMON_H
>>  
>>  extern void shmobile_earlytimer_init(void);
>> -extern void shmobile_timer_init(void);
>>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
>>  			 unsigned int mult, unsigned int div);
>>  struct twd_local_timer;
>> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
>> index 47662a5..4e38a66 100644
>> --- a/arch/arm/mach-shmobile/setup-emev2.c
>> +++ b/arch/arm/mach-shmobile/setup-emev2.c
>> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
>>  	.nr_irqs	= NR_IRQS_LEGACY,
>>  	.init_irq	= irqchip_init,
>>  	.init_machine	= emev2_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= emev2_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
>> index 8b85d4d..104b474 100644
>> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
>> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
>> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
>>  	.init_irq	= r8a7740_init_irq,
>>  	.handle_irq	= shmobile_handle_irq_intc,
>>  	.init_machine	= r8a7740_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= r8a7740_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
>> index 59c7146..5502d62 100644
>> --- a/arch/arm/mach-shmobile/setup-sh7372.c
>> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
>> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
>>  	.init_irq	= sh7372_init_irq,
>>  	.handle_irq	= shmobile_handle_irq_intc,
>>  	.init_machine	= sh7372_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= sh7372_boards_compat_dt,
>>  MACHINE_END
>>  
>> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
>> index bdab575..ea66316 100644
>> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
>> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
>> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
>>  	.nr_irqs	= NR_IRQS_LEGACY,
>>  	.init_irq	= sh73a0_init_irq_dt,
>>  	.init_machine	= sh73a0_add_standard_devices_dt,
>> -	.init_time	= shmobile_timer_init,
>>  	.dt_compat	= sh73a0_boards_compat_dt,
>>  MACHINE_END
>>  #endif /* CONFIG_USE_OF */
>> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
>> index 3d16d4d..add2f15 100644
>> --- a/arch/arm/mach-shmobile/timer.c
>> +++ b/arch/arm/mach-shmobile/timer.c
>> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
>>  {
>>  	late_time_init = shmobile_late_time_init;
>>  }
>> -
>> -void __init shmobile_timer_init(void)
>> -{
>> -	arch_timer_of_register();
>> -	arch_timer_sched_clock_init();
>> -}
>> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
>> index d0ad789..6215717 100644
>> --- a/arch/arm/mach-vexpress/v2m.c
>> +++ b/arch/arm/mach-vexpress/v2m.c
>> @@ -1,6 +1,7 @@
>>  /*
>>   * Versatile Express V2M Motherboard Support
>>   */
>> +#include <linux/clocksource.h>
>>  #include <linux/device.h>
>>  #include <linux/amba/bus.h>
>>  #include <linux/amba/mmci.h>
>> @@ -23,7 +24,6 @@
>>  #include <linux/regulator/machine.h>
>>  #include <linux/vexpress.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/mach-types.h>
>>  #include <asm/sizes.h>
>>  #include <asm/mach/arch.h>
>> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
>>  				irq_of_parse_and_map(node, 0));
>>  	}
>>  
>> -	arch_timer_of_register();
>> -
>> -	if (arch_timer_sched_clock_init() != 0)
>> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
>>  				24000000);
>>  }
>>  
>> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
>> index 31666f6..adc0945 100644
>> --- a/arch/arm/mach-virt/virt.c
>> +++ b/arch/arm/mach-virt/virt.c
>> @@ -23,21 +23,13 @@
>>  #include <linux/of_platform.h>
>>  #include <linux/smp.h>
>>  
>> -#include <asm/arch_timer.h>
>>  #include <asm/mach/arch.h>
>> -#include <asm/mach/time.h>
>>  
>>  static void __init virt_init(void)
>>  {
>>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>>  }
>>  
>> -static void __init virt_timer_init(void)
>> -{
>> -	WARN_ON(arch_timer_of_register() != 0);
>> -	WARN_ON(arch_timer_sched_clock_init() != 0);
>> -}
>> -
>>  static const char *virt_dt_match[] = {
>>  	"linux,dummy-virt",
>>  	NULL
>> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
>>  
>>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
>>  	.init_irq	= irqchip_init,
>> -	.init_time	= virt_timer_init,
>>  	.init_machine	= virt_init,
>>  	.smp		= smp_ops(virt_smp_ops),
>>  	.dt_compat	= virt_dt_match,
>> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
>> index 91e2a6a..bf6ab242 100644
>> --- a/arch/arm64/include/asm/arch_timer.h
>> +++ b/arch/arm64/include/asm/arch_timer.h
>> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
>>  	return cval;
>>  }
>>  
>> +static inline int arch_timer_arch_init(void)
>> +{
>> +	return 0;
>> +}
>> +
>>  #endif
>> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
>> index b0ef18d..a551f88 100644
>> --- a/arch/arm64/kernel/time.c
>> +++ b/arch/arm64/kernel/time.c
>> @@ -32,6 +32,7 @@
>>  #include <linux/timer.h>
>>  #include <linux/irq.h>
>>  #include <linux/delay.h>
>> +#include <linux/clocksource.h>
>>  
>>  #include <clocksource/arm_arch_timer.h>
>>  
>> @@ -77,10 +78,11 @@ void __init time_init(void)
>>  {
>>  	u32 arch_timer_rate;
>>  
>> -	if (arch_timer_init())
>> -		panic("Unable to initialise architected timer.\n");
>> +	clocksource_of_init();
>>  
>>  	arch_timer_rate = arch_timer_get_rate();
>> +	if (!arch_timer_rate)
>> +		panic("Unable to initialise architected timer.\n");
>>  
>>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
>>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
>> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
>> index e507ab7..d98e7e1 100644
>> --- a/drivers/clocksource/Kconfig
>> +++ b/drivers/clocksource/Kconfig
>> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
>>  
>>  config ARM_ARCH_TIMER
>>  	bool
>> +	select CLKSRC_OF if OF
>>  
>>  config CLKSRC_METAG_GENERIC
>>  	def_bool y if METAG
>> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
>> index d7ad425..122ff05 100644
>> --- a/drivers/clocksource/arm_arch_timer.c
>> +++ b/drivers/clocksource/arm_arch_timer.c
>> @@ -337,22 +337,14 @@ out:
>>  	return err;
>>  }
>>  
>> -static const struct of_device_id arch_timer_of_match[] __initconst = {
>> -	{ .compatible	= "arm,armv7-timer",	},
>> -	{ .compatible	= "arm,armv8-timer",	},
>> -	{},
>> -};
>> -
>> -int __init arch_timer_init(void)
>> +static void __init arch_timer_init(struct device_node *np)
>>  {
>> -	struct device_node *np;
>>  	u32 freq;
>>  	int i;
>>  
>> -	np = of_find_matching_node(NULL, arch_timer_of_match);
>> -	if (!np) {
>> -		pr_err("arch_timer: can't find DT node\n");
>> -		return -ENODEV;
>> +	if (arch_timer_get_rate()) {
>> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
>> +		return;
>>  	}
>>  
>>  	/* Try to determine the frequency from the device tree or CNTFRQ */
>> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
>>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
>>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
>>  			pr_warn("arch_timer: No interrupt available, giving up\n");
>> -			return -EINVAL;
>> +			return;
>>  		}
>>  	}
>>  
>> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
>>  	else
>>  		arch_timer_read_counter = arch_counter_get_cntpct;
>>  
>> -	return arch_timer_register();
>> +	arch_timer_register();
>> +	arch_timer_arch_init();
>>  }
>> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
>> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
>> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
>> index 2603267..e6c9c4c 100644
>> --- a/include/clocksource/arm_arch_timer.h
>> +++ b/include/clocksource/arm_arch_timer.h
>> @@ -31,18 +31,12 @@
>>  
>>  #ifdef CONFIG_ARM_ARCH_TIMER
>>  
>> -extern int arch_timer_init(void);
>>  extern u32 arch_timer_get_rate(void);
>>  extern u64 (*arch_timer_read_counter)(void);
>>  extern struct timecounter *arch_timer_get_timecounter(void);
>>  
>>  #else
>>  
>> -static inline int arch_timer_init(void)
>> -{
>> -	return -ENXIO;
>> -}
>> -
>>  static inline u32 arch_timer_get_rate(void)
>>  {
>>  	return 0;
>> -- 
>> 1.7.10.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-03  0:41       ` John Stultz
  2013-04-03  2:31         ` Rob Herring
@ 2013-04-10 23:23         ` Rob Herring
  2013-04-11  8:33           ` Linus Walleij
  1 sibling, 1 reply; 44+ messages in thread
From: Rob Herring @ 2013-04-10 23:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/02/2013 07:41 PM, John Stultz wrote:
> On 04/02/2013 12:49 PM, Rob Herring wrote:
>> On 04/01/2013 06:26 PM, John Stultz wrote:
>>> On 04/01/2013 03:21 PM, Rob Herring wrote:
>>>> diff --git a/drivers/clocksource/integrator_ap_timer.c
>>>> b/drivers/clocksource/integrator_ap_timer.c
>>>> new file mode 100644
>>>> index 0000000..05e6204
>>>> --- /dev/null
>>>> +++ b/drivers/clocksource/integrator_ap_timer.c
>>> [snip]
>>
>>>> +CLOCKSOURCE_OF_DECLARE(integrator_ap, "integrator-timer",
>>>> ap_of_timer_init);
>>> So, most of the code here is really clockevent code and not clocksource
>>> code. I realize they were combined in the mach directory you're copying
>>> them from, but if we're going to move all this code out of the arch
>>> directory and into drivers/, I'd like to propose we not dump it all into
>>> drivers/clocksource.
>> Arguably, half the h/w is used for clocksource and half for clockevent
>> so it is equal. :) The sp804 and integrator are somewhat separated that
>> carving them up may be possible, but there are examples like i.MX timers
>> where the implementations are tied more closely together (the clockevent
>> compare value is the clocksource counter + delta).
>>
>> Where do I put the init functions which need to know about both?
> 
> Either have them init themselves via *_initcall, or call out from one to
> the other?
> 
>> What about all the other timers that are already in drivers/clocksource?
> 
> I'm hoping to start moving those out soon.
> 
> 
>>> For more context here see:
>>> http://www.spinics.net/lists/arm-kernel/msg234074.html
>> Seems like this is more a maintainer issue than necessarily what is the
>> right split of code (not that those are completely unrelated). Perhaps
>> splitting maintainership between core and drivers is needed. It
>> definitely seems Thomas cannot keep up with the plethora of ARM related
>> timers and irqchips getting moved into drivers/.
> 
> Well, I'm hoping Daniel can help offload Thomas, but I've still not
> heard back if Thomas is ok with this whole proposal or not.

I'm waiting until there is some clear direction on how or if to split up
clksrc and clkevt drivers. So I will drop this patch for 3.10 unless you
are okay with moving it to drivers/clocksource first and sorting out how
to split things later.

Rob

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
  2013-04-10 23:17       ` Rob Herring
  (?)
@ 2013-04-11  0:09         ` Simon Horman
  -1 siblings, 0 replies; 44+ messages in thread
From: Simon Horman @ 2013-04-11  0:09 UTC (permalink / raw)
  To: linux-arm-kernel

[ CC Magnus Damm ]

On Wed, Apr 10, 2013 at 06:17:31PM -0500, Rob Herring wrote:
> On 04/04/2013 12:56 AM, Simon Horman wrote:
> > On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
> >> From: Rob Herring <rob.herring@calxeda.com>
> >>
> >> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> >> the arch timer. A new function arch_timer_arch_init is added to allow for
> >> arch specific setup.
> >>
> >> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> >> should not be any reason not to use the arch timers for sched_clock.
> > 
> > Would it be possible for you to either delay the removal of
> > shmobile_timer_init. In general I am in favour of the following
> > approach to wide changes such as this one:
> 
> I will simply change shmobile_timer_init to call clocksource_of_init
> rather than deleting it. That should keep the new users working and then
> it can be deleted latter.

Thanks.

> > 1. Add new feature
> > 2. Convert users to new feature
> > 3. Remove old feature.
> > 
> > If it is not possible to delay the removal of shmobile_timer_init could you
> > update your base such that you also remove its usage from the following
> > files:
> > 
> > arch/arm/mach-shmobile/board-kzm9g-reference.c
> > arch/arm/mach-shmobile/setup-r8a73a4.c
> > arch/arm/mach-shmobile/setup-r8a7779.c
> > arch/arm/mach-shmobile/board-lager.c
> > arch/arm/mach-shmobile/board-ape6evm.c
> > arch/arm/mach-shmobile/setup-r8a7778.c
> > arch/arm/mach-shmobile/board-marzen-reference.c
> > arch/arm/mach-shmobile/setup-r8a7790.c
> > arch/arm/mach-shmobile/board-bockw.c
> 
> Why so many boards? There's been prior discussions about whether to add
> DT into existing board files or start with a minimal DT board file and
> add to it. The fact that there are 14 mach desc's using
> shmobile_timer_init which is a function only used for DT and 17 DT mach
> descs total for shmobile tells me perhaps the latter approach is needed.
> 
> Either way, it is good to see progress on DT support in shmobile.

I've CCed Magnus who can answer that question better than I.
But in general I believe the answer is that because DT support for
many of the drivers that the boards and SoCs rely on isn't quite (or
in some cases at all) ready yet we need to bring things up using C code.

I realise that there are other approaches to this problem, but
this is the one we're taking at this time.

> 
> Rob
> 
> > The above files are all present in the arm-soc/next/boards2 branch
> > of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
> > of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
> > I am happy for you use the later as a base if you wish.
> > 
> >> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> >> Cc: Russell King <linux@arm.linux.org.uk>
> >> Cc: Kukjin Kim <kgene.kim@samsung.com>
> >> Cc: Tony Lindgren <tony@atomide.com>
> >> Cc: Simon Horman <horms@verge.net.au>
> >> Cc: Magnus Damm <magnus.damm@gmail.com>
> >> Cc: Catalin Marinas <catalin.marinas@arm.com>
> >> Cc: Will Deacon <will.deacon@arm.com>
> >> Cc: John Stultz <john.stultz@linaro.org>
> >> Cc: Thomas Gleixner <tglx@linutronix.de>
> >> Cc: linux-samsung-soc@vger.kernel.org
> >> Cc: linux-omap@vger.kernel.org
> >> Cc: linux-sh@vger.kernel.org
> >> ---
> >>  arch/arm/include/asm/arch_timer.h            |   13 +------------
> >>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
> >>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
> >>  arch/arm/mach-exynos/mct.c                   |    6 ------
> >>  arch/arm/mach-highbank/highbank.c            |    5 +----
> >>  arch/arm/mach-omap2/timer.c                  |    5 +----
> >>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
> > 
> > I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.
> > 
> >>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
> >>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -
> > 
> > I am not able to test the setup-emev2 portion properly at this time,
> > booting the kzm9d board without the board-kzm9d file seems broken without
> > your patch. However, your change seems reasonable to me.
> > 
> >>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
> > 
> > I am not able to test the setup-r8a7740 portion properly at this time,
> > booting the armadillo800eva board without the board-armadillo800eva file
> > seems broken without your patch. However, your change seems reasonable to
> > me.
> > 
> >>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
> > 
> > I am not able to test the setup-sh7372 portion properly at this time,
> > booting the mackerel board without the board-mackerel file seems broken without
> > your patch. However, your change seems reasonable to me.
> > 
> >>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
> > 
> > I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.
> > 
> > 
> > The tests above were made by merging
> > 
> > git://sources.calxeda.com/kernel/linux.git arm-timers
> > head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
> > 	     ("devtree: add binding documentation for sp804")
> > 
> > and the renesas-next-20130403 tag of the renesas tree (URL above).
> > 
> >>  arch/arm/mach-shmobile/timer.c               |    6 ------
> >>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
> >>  arch/arm/mach-virt/virt.c                    |    9 ---------
> >>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
> >>  arch/arm64/kernel/time.c                     |    6 ++++--
> >>  drivers/clocksource/Kconfig                  |    1 +
> >>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
> >>  include/clocksource/arm_arch_timer.h         |    6 ------
> >>  20 files changed, 27 insertions(+), 89 deletions(-)
> >>
> >> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
> >> index 7ade91d..7c1bfc0 100644
> >> --- a/arch/arm/include/asm/arch_timer.h
> >> +++ b/arch/arm/include/asm/arch_timer.h
> >> @@ -10,8 +10,7 @@
> >>  #include <clocksource/arm_arch_timer.h>
> >>  
> >>  #ifdef CONFIG_ARM_ARCH_TIMER
> >> -int arch_timer_of_register(void);
> >> -int arch_timer_sched_clock_init(void);
> >> +int arch_timer_arch_init(void);
> >>  
> >>  /*
> >>   * These register accessors are marked inline so the compiler can
> >> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
> >>  
> >>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
> >>  }
> >> -#else
> >> -static inline int arch_timer_of_register(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >> -
> >> -static inline int arch_timer_sched_clock_init(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >>  #endif
> >>  
> >>  #endif
> >> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
> >> index a7536d4..dc74048 100644
> >> --- a/arch/arm/kernel/arch_timer.c
> >> +++ b/arch/arm/kernel/arch_timer.c
> >> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
> >>  	register_current_timer_delay(&arch_delay_timer);
> >>  }
> >>  
> >> -int __init arch_timer_of_register(void)
> >> -{
> >> -	int ret;
> >> -
> >> -	ret = arch_timer_init();
> >> -	if (ret)
> >> -		return ret;
> >> -
> >> -	arch_timer_delay_timer_register();
> >> -
> >> -	return 0;
> >> -}
> >> -
> >> -int __init arch_timer_sched_clock_init(void)
> >> +int __init arch_timer_arch_init(void)
> >>  {
> >>          u32 arch_timer_rate = arch_timer_get_rate();
> >>  
> >>  	if (arch_timer_rate = 0)
> >>  		return -ENXIO;
> >>  
> >> +	arch_timer_delay_timer_register();
> >> +
> >>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
> >>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> >>  	sched_clock_func = arch_timer_sched_clock;
> >> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> index acaeb14..4d97b43 100644
> >> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
> >>  	.map_io		= exynos5_dt_map_io,
> >>  	.init_machine	= exynos5_dt_machine_init,
> >>  	.init_late	= exynos_init_late,
> >> -	.init_time	= exynos4_timer_init,
> >>  	.dt_compat	= exynos5_dt_compat,
> >>  	.restart        = exynos5_restart,
> >>  	.reserve	= exynos5_reserve,
> >> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
> >> index c9d6650..04aff6a 100644
> >> --- a/arch/arm/mach-exynos/mct.c
> >> +++ b/arch/arm/mach-exynos/mct.c
> >> @@ -21,7 +21,6 @@
> >>  #include <linux/percpu.h>
> >>  #include <linux/of.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/localtimer.h>
> >>  
> >>  #include <plat/cpu.h>
> >> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
> >>  
> >>  void __init exynos4_timer_init(void)
> >>  {
> >> -	if (soc_is_exynos5440()) {
> >> -		arch_timer_of_register();
> >> -		return;
> >> -	}
> >> -
> >>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
> >>  		mct_int_type = MCT_INT_SPI;
> >>  	else
> >> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> >> index 76c1170..758150e 100644
> >> --- a/arch/arm/mach-highbank/highbank.c
> >> +++ b/arch/arm/mach-highbank/highbank.c
> >> @@ -15,6 +15,7 @@
> >>   */
> >>  #include <linux/clk.h>
> >>  #include <linux/clkdev.h>
> >> +#include <linux/clocksource.h>
> >>  #include <linux/dma-mapping.h>
> >>  #include <linux/io.h>
> >>  #include <linux/irq.h>
> >> @@ -28,7 +29,6 @@
> >>  #include <linux/amba/bus.h>
> >>  #include <linux/clk-provider.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/cacheflush.h>
> >>  #include <asm/cputype.h>
> >>  #include <asm/smp_plat.h>
> >> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
> >>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
> >>  	sp804_clockevents_init(timer_base, irq, "timer0");
> >>  
> >> -	arch_timer_of_register();
> >> -	arch_timer_sched_clock_init();
> >> -
> >>  	clocksource_of_init();
> >>  }
> >>  
> >> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> >> index 4fd8025..7dd6453 100644
> >> --- a/arch/arm/mach-omap2/timer.c
> >> +++ b/arch/arm/mach-omap2/timer.c
> >> @@ -46,7 +46,6 @@
> >>  #include <asm/smp_twd.h>
> >>  #include <asm/sched_clock.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include "omap_hwmod.h"
> >>  #include "omap_device.h"
> >>  #include <plat/counter-32k.h>
> >> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
> >>  	omap5_sync32k_timer_init();
> >>  	realtime_counter_init();
> >>  
> >> -	err = arch_timer_of_register();
> >> -	if (err)
> >> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
> >> +        clocksource_of_init();
> >>  }
> >>  #endif /* CONFIG_SOC_OMAP5 */
> >>  
> >> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
> >> index c254782..c016ccd 100644
> >> --- a/arch/arm/mach-shmobile/board-kzm9d.c
> >> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
> >> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
> >>  	.init_irq	= emev2_init_irq,
> >>  	.init_machine	= kzm9d_add_standard_devices,
> >>  	.init_late	= shmobile_init_late,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= kzm9d_boards_compat_dt,
> >>  MACHINE_END
> >> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> >> index e48606d..5efc0f0 100644
> >> --- a/arch/arm/mach-shmobile/include/mach/common.h
> >> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> >> @@ -2,7 +2,6 @@
> >>  #define __ARCH_MACH_COMMON_H
> >>  
> >>  extern void shmobile_earlytimer_init(void);
> >> -extern void shmobile_timer_init(void);
> >>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
> >>  			 unsigned int mult, unsigned int div);
> >>  struct twd_local_timer;
> >> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
> >> index 47662a5..4e38a66 100644
> >> --- a/arch/arm/mach-shmobile/setup-emev2.c
> >> +++ b/arch/arm/mach-shmobile/setup-emev2.c
> >> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
> >>  	.nr_irqs	= NR_IRQS_LEGACY,
> >>  	.init_irq	= irqchip_init,
> >>  	.init_machine	= emev2_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= emev2_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
> >> index 8b85d4d..104b474 100644
> >> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
> >> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
> >> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
> >>  	.init_irq	= r8a7740_init_irq,
> >>  	.handle_irq	= shmobile_handle_irq_intc,
> >>  	.init_machine	= r8a7740_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= r8a7740_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
> >> index 59c7146..5502d62 100644
> >> --- a/arch/arm/mach-shmobile/setup-sh7372.c
> >> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
> >> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
> >>  	.init_irq	= sh7372_init_irq,
> >>  	.handle_irq	= shmobile_handle_irq_intc,
> >>  	.init_machine	= sh7372_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= sh7372_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> >> index bdab575..ea66316 100644
> >> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> >> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> >> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
> >>  	.nr_irqs	= NR_IRQS_LEGACY,
> >>  	.init_irq	= sh73a0_init_irq_dt,
> >>  	.init_machine	= sh73a0_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= sh73a0_boards_compat_dt,
> >>  MACHINE_END
> >>  #endif /* CONFIG_USE_OF */
> >> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
> >> index 3d16d4d..add2f15 100644
> >> --- a/arch/arm/mach-shmobile/timer.c
> >> +++ b/arch/arm/mach-shmobile/timer.c
> >> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
> >>  {
> >>  	late_time_init = shmobile_late_time_init;
> >>  }
> >> -
> >> -void __init shmobile_timer_init(void)
> >> -{
> >> -	arch_timer_of_register();
> >> -	arch_timer_sched_clock_init();
> >> -}
> >> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> >> index d0ad789..6215717 100644
> >> --- a/arch/arm/mach-vexpress/v2m.c
> >> +++ b/arch/arm/mach-vexpress/v2m.c
> >> @@ -1,6 +1,7 @@
> >>  /*
> >>   * Versatile Express V2M Motherboard Support
> >>   */
> >> +#include <linux/clocksource.h>
> >>  #include <linux/device.h>
> >>  #include <linux/amba/bus.h>
> >>  #include <linux/amba/mmci.h>
> >> @@ -23,7 +24,6 @@
> >>  #include <linux/regulator/machine.h>
> >>  #include <linux/vexpress.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/mach-types.h>
> >>  #include <asm/sizes.h>
> >>  #include <asm/mach/arch.h>
> >> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
> >>  				irq_of_parse_and_map(node, 0));
> >>  	}
> >>  
> >> -	arch_timer_of_register();
> >> -
> >> -	if (arch_timer_sched_clock_init() != 0)
> >> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> >> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> >>  				24000000);
> >>  }
> >>  
> >> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
> >> index 31666f6..adc0945 100644
> >> --- a/arch/arm/mach-virt/virt.c
> >> +++ b/arch/arm/mach-virt/virt.c
> >> @@ -23,21 +23,13 @@
> >>  #include <linux/of_platform.h>
> >>  #include <linux/smp.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/mach/arch.h>
> >> -#include <asm/mach/time.h>
> >>  
> >>  static void __init virt_init(void)
> >>  {
> >>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> >>  }
> >>  
> >> -static void __init virt_timer_init(void)
> >> -{
> >> -	WARN_ON(arch_timer_of_register() != 0);
> >> -	WARN_ON(arch_timer_sched_clock_init() != 0);
> >> -}
> >> -
> >>  static const char *virt_dt_match[] = {
> >>  	"linux,dummy-virt",
> >>  	NULL
> >> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
> >>  
> >>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
> >>  	.init_irq	= irqchip_init,
> >> -	.init_time	= virt_timer_init,
> >>  	.init_machine	= virt_init,
> >>  	.smp		= smp_ops(virt_smp_ops),
> >>  	.dt_compat	= virt_dt_match,
> >> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> >> index 91e2a6a..bf6ab242 100644
> >> --- a/arch/arm64/include/asm/arch_timer.h
> >> +++ b/arch/arm64/include/asm/arch_timer.h
> >> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
> >>  	return cval;
> >>  }
> >>  
> >> +static inline int arch_timer_arch_init(void)
> >> +{
> >> +	return 0;
> >> +}
> >> +
> >>  #endif
> >> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
> >> index b0ef18d..a551f88 100644
> >> --- a/arch/arm64/kernel/time.c
> >> +++ b/arch/arm64/kernel/time.c
> >> @@ -32,6 +32,7 @@
> >>  #include <linux/timer.h>
> >>  #include <linux/irq.h>
> >>  #include <linux/delay.h>
> >> +#include <linux/clocksource.h>
> >>  
> >>  #include <clocksource/arm_arch_timer.h>
> >>  
> >> @@ -77,10 +78,11 @@ void __init time_init(void)
> >>  {
> >>  	u32 arch_timer_rate;
> >>  
> >> -	if (arch_timer_init())
> >> -		panic("Unable to initialise architected timer.\n");
> >> +	clocksource_of_init();
> >>  
> >>  	arch_timer_rate = arch_timer_get_rate();
> >> +	if (!arch_timer_rate)
> >> +		panic("Unable to initialise architected timer.\n");
> >>  
> >>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
> >>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> >> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> >> index e507ab7..d98e7e1 100644
> >> --- a/drivers/clocksource/Kconfig
> >> +++ b/drivers/clocksource/Kconfig
> >> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
> >>  
> >>  config ARM_ARCH_TIMER
> >>  	bool
> >> +	select CLKSRC_OF if OF
> >>  
> >>  config CLKSRC_METAG_GENERIC
> >>  	def_bool y if METAG
> >> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> >> index d7ad425..122ff05 100644
> >> --- a/drivers/clocksource/arm_arch_timer.c
> >> +++ b/drivers/clocksource/arm_arch_timer.c
> >> @@ -337,22 +337,14 @@ out:
> >>  	return err;
> >>  }
> >>  
> >> -static const struct of_device_id arch_timer_of_match[] __initconst = {
> >> -	{ .compatible	= "arm,armv7-timer",	},
> >> -	{ .compatible	= "arm,armv8-timer",	},
> >> -	{},
> >> -};
> >> -
> >> -int __init arch_timer_init(void)
> >> +static void __init arch_timer_init(struct device_node *np)
> >>  {
> >> -	struct device_node *np;
> >>  	u32 freq;
> >>  	int i;
> >>  
> >> -	np = of_find_matching_node(NULL, arch_timer_of_match);
> >> -	if (!np) {
> >> -		pr_err("arch_timer: can't find DT node\n");
> >> -		return -ENODEV;
> >> +	if (arch_timer_get_rate()) {
> >> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> >> +		return;
> >>  	}
> >>  
> >>  	/* Try to determine the frequency from the device tree or CNTFRQ */
> >> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
> >>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
> >>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
> >>  			pr_warn("arch_timer: No interrupt available, giving up\n");
> >> -			return -EINVAL;
> >> +			return;
> >>  		}
> >>  	}
> >>  
> >> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
> >>  	else
> >>  		arch_timer_read_counter = arch_counter_get_cntpct;
> >>  
> >> -	return arch_timer_register();
> >> +	arch_timer_register();
> >> +	arch_timer_arch_init();
> >>  }
> >> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
> >> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
> >> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> >> index 2603267..e6c9c4c 100644
> >> --- a/include/clocksource/arm_arch_timer.h
> >> +++ b/include/clocksource/arm_arch_timer.h
> >> @@ -31,18 +31,12 @@
> >>  
> >>  #ifdef CONFIG_ARM_ARCH_TIMER
> >>  
> >> -extern int arch_timer_init(void);
> >>  extern u32 arch_timer_get_rate(void);
> >>  extern u64 (*arch_timer_read_counter)(void);
> >>  extern struct timecounter *arch_timer_get_timecounter(void);
> >>  
> >>  #else
> >>  
> >> -static inline int arch_timer_init(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >> -
> >>  static inline u32 arch_timer_get_rate(void)
> >>  {
> >>  	return 0;
> >> -- 
> >> 1.7.10.4
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >>
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-11  0:09         ` Simon Horman
  0 siblings, 0 replies; 44+ messages in thread
From: Simon Horman @ 2013-04-11  0:09 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-arm-kernel, Thomas Gleixner, Mark Rutland, Russell King,
	John Stultz, arm, Marc Zyngier, Linus Walleij, Rob Herring,
	Kukjin Kim, Tony Lindgren, Magnus Damm, Catalin Marinas,
	Will Deacon, linux-samsung-soc, linux-omap, linux-sh

[ CC Magnus Damm ]

On Wed, Apr 10, 2013 at 06:17:31PM -0500, Rob Herring wrote:
> On 04/04/2013 12:56 AM, Simon Horman wrote:
> > On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
> >> From: Rob Herring <rob.herring@calxeda.com>
> >>
> >> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> >> the arch timer. A new function arch_timer_arch_init is added to allow for
> >> arch specific setup.
> >>
> >> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> >> should not be any reason not to use the arch timers for sched_clock.
> > 
> > Would it be possible for you to either delay the removal of
> > shmobile_timer_init. In general I am in favour of the following
> > approach to wide changes such as this one:
> 
> I will simply change shmobile_timer_init to call clocksource_of_init
> rather than deleting it. That should keep the new users working and then
> it can be deleted latter.

Thanks.

> > 1. Add new feature
> > 2. Convert users to new feature
> > 3. Remove old feature.
> > 
> > If it is not possible to delay the removal of shmobile_timer_init could you
> > update your base such that you also remove its usage from the following
> > files:
> > 
> > arch/arm/mach-shmobile/board-kzm9g-reference.c
> > arch/arm/mach-shmobile/setup-r8a73a4.c
> > arch/arm/mach-shmobile/setup-r8a7779.c
> > arch/arm/mach-shmobile/board-lager.c
> > arch/arm/mach-shmobile/board-ape6evm.c
> > arch/arm/mach-shmobile/setup-r8a7778.c
> > arch/arm/mach-shmobile/board-marzen-reference.c
> > arch/arm/mach-shmobile/setup-r8a7790.c
> > arch/arm/mach-shmobile/board-bockw.c
> 
> Why so many boards? There's been prior discussions about whether to add
> DT into existing board files or start with a minimal DT board file and
> add to it. The fact that there are 14 mach desc's using
> shmobile_timer_init which is a function only used for DT and 17 DT mach
> descs total for shmobile tells me perhaps the latter approach is needed.
> 
> Either way, it is good to see progress on DT support in shmobile.

I've CCed Magnus who can answer that question better than I.
But in general I believe the answer is that because DT support for
many of the drivers that the boards and SoCs rely on isn't quite (or
in some cases at all) ready yet we need to bring things up using C code.

I realise that there are other approaches to this problem, but
this is the one we're taking at this time.

> 
> Rob
> 
> > The above files are all present in the arm-soc/next/boards2 branch
> > of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
> > of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
> > I am happy for you use the later as a base if you wish.
> > 
> >> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> >> Cc: Russell King <linux@arm.linux.org.uk>
> >> Cc: Kukjin Kim <kgene.kim@samsung.com>
> >> Cc: Tony Lindgren <tony@atomide.com>
> >> Cc: Simon Horman <horms@verge.net.au>
> >> Cc: Magnus Damm <magnus.damm@gmail.com>
> >> Cc: Catalin Marinas <catalin.marinas@arm.com>
> >> Cc: Will Deacon <will.deacon@arm.com>
> >> Cc: John Stultz <john.stultz@linaro.org>
> >> Cc: Thomas Gleixner <tglx@linutronix.de>
> >> Cc: linux-samsung-soc@vger.kernel.org
> >> Cc: linux-omap@vger.kernel.org
> >> Cc: linux-sh@vger.kernel.org
> >> ---
> >>  arch/arm/include/asm/arch_timer.h            |   13 +------------
> >>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
> >>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
> >>  arch/arm/mach-exynos/mct.c                   |    6 ------
> >>  arch/arm/mach-highbank/highbank.c            |    5 +----
> >>  arch/arm/mach-omap2/timer.c                  |    5 +----
> >>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
> > 
> > I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.
> > 
> >>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
> >>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -
> > 
> > I am not able to test the setup-emev2 portion properly at this time,
> > booting the kzm9d board without the board-kzm9d file seems broken without
> > your patch. However, your change seems reasonable to me.
> > 
> >>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
> > 
> > I am not able to test the setup-r8a7740 portion properly at this time,
> > booting the armadillo800eva board without the board-armadillo800eva file
> > seems broken without your patch. However, your change seems reasonable to
> > me.
> > 
> >>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
> > 
> > I am not able to test the setup-sh7372 portion properly at this time,
> > booting the mackerel board without the board-mackerel file seems broken without
> > your patch. However, your change seems reasonable to me.
> > 
> >>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
> > 
> > I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.
> > 
> > 
> > The tests above were made by merging
> > 
> > git://sources.calxeda.com/kernel/linux.git arm-timers
> > head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
> > 	     ("devtree: add binding documentation for sp804")
> > 
> > and the renesas-next-20130403 tag of the renesas tree (URL above).
> > 
> >>  arch/arm/mach-shmobile/timer.c               |    6 ------
> >>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
> >>  arch/arm/mach-virt/virt.c                    |    9 ---------
> >>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
> >>  arch/arm64/kernel/time.c                     |    6 ++++--
> >>  drivers/clocksource/Kconfig                  |    1 +
> >>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
> >>  include/clocksource/arm_arch_timer.h         |    6 ------
> >>  20 files changed, 27 insertions(+), 89 deletions(-)
> >>
> >> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
> >> index 7ade91d..7c1bfc0 100644
> >> --- a/arch/arm/include/asm/arch_timer.h
> >> +++ b/arch/arm/include/asm/arch_timer.h
> >> @@ -10,8 +10,7 @@
> >>  #include <clocksource/arm_arch_timer.h>
> >>  
> >>  #ifdef CONFIG_ARM_ARCH_TIMER
> >> -int arch_timer_of_register(void);
> >> -int arch_timer_sched_clock_init(void);
> >> +int arch_timer_arch_init(void);
> >>  
> >>  /*
> >>   * These register accessors are marked inline so the compiler can
> >> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
> >>  
> >>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
> >>  }
> >> -#else
> >> -static inline int arch_timer_of_register(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >> -
> >> -static inline int arch_timer_sched_clock_init(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >>  #endif
> >>  
> >>  #endif
> >> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
> >> index a7536d4..dc74048 100644
> >> --- a/arch/arm/kernel/arch_timer.c
> >> +++ b/arch/arm/kernel/arch_timer.c
> >> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
> >>  	register_current_timer_delay(&arch_delay_timer);
> >>  }
> >>  
> >> -int __init arch_timer_of_register(void)
> >> -{
> >> -	int ret;
> >> -
> >> -	ret = arch_timer_init();
> >> -	if (ret)
> >> -		return ret;
> >> -
> >> -	arch_timer_delay_timer_register();
> >> -
> >> -	return 0;
> >> -}
> >> -
> >> -int __init arch_timer_sched_clock_init(void)
> >> +int __init arch_timer_arch_init(void)
> >>  {
> >>          u32 arch_timer_rate = arch_timer_get_rate();
> >>  
> >>  	if (arch_timer_rate == 0)
> >>  		return -ENXIO;
> >>  
> >> +	arch_timer_delay_timer_register();
> >> +
> >>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
> >>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> >>  	sched_clock_func = arch_timer_sched_clock;
> >> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> index acaeb14..4d97b43 100644
> >> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
> >>  	.map_io		= exynos5_dt_map_io,
> >>  	.init_machine	= exynos5_dt_machine_init,
> >>  	.init_late	= exynos_init_late,
> >> -	.init_time	= exynos4_timer_init,
> >>  	.dt_compat	= exynos5_dt_compat,
> >>  	.restart        = exynos5_restart,
> >>  	.reserve	= exynos5_reserve,
> >> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
> >> index c9d6650..04aff6a 100644
> >> --- a/arch/arm/mach-exynos/mct.c
> >> +++ b/arch/arm/mach-exynos/mct.c
> >> @@ -21,7 +21,6 @@
> >>  #include <linux/percpu.h>
> >>  #include <linux/of.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/localtimer.h>
> >>  
> >>  #include <plat/cpu.h>
> >> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
> >>  
> >>  void __init exynos4_timer_init(void)
> >>  {
> >> -	if (soc_is_exynos5440()) {
> >> -		arch_timer_of_register();
> >> -		return;
> >> -	}
> >> -
> >>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
> >>  		mct_int_type = MCT_INT_SPI;
> >>  	else
> >> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> >> index 76c1170..758150e 100644
> >> --- a/arch/arm/mach-highbank/highbank.c
> >> +++ b/arch/arm/mach-highbank/highbank.c
> >> @@ -15,6 +15,7 @@
> >>   */
> >>  #include <linux/clk.h>
> >>  #include <linux/clkdev.h>
> >> +#include <linux/clocksource.h>
> >>  #include <linux/dma-mapping.h>
> >>  #include <linux/io.h>
> >>  #include <linux/irq.h>
> >> @@ -28,7 +29,6 @@
> >>  #include <linux/amba/bus.h>
> >>  #include <linux/clk-provider.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/cacheflush.h>
> >>  #include <asm/cputype.h>
> >>  #include <asm/smp_plat.h>
> >> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
> >>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
> >>  	sp804_clockevents_init(timer_base, irq, "timer0");
> >>  
> >> -	arch_timer_of_register();
> >> -	arch_timer_sched_clock_init();
> >> -
> >>  	clocksource_of_init();
> >>  }
> >>  
> >> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> >> index 4fd8025..7dd6453 100644
> >> --- a/arch/arm/mach-omap2/timer.c
> >> +++ b/arch/arm/mach-omap2/timer.c
> >> @@ -46,7 +46,6 @@
> >>  #include <asm/smp_twd.h>
> >>  #include <asm/sched_clock.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include "omap_hwmod.h"
> >>  #include "omap_device.h"
> >>  #include <plat/counter-32k.h>
> >> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
> >>  	omap5_sync32k_timer_init();
> >>  	realtime_counter_init();
> >>  
> >> -	err = arch_timer_of_register();
> >> -	if (err)
> >> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
> >> +        clocksource_of_init();
> >>  }
> >>  #endif /* CONFIG_SOC_OMAP5 */
> >>  
> >> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
> >> index c254782..c016ccd 100644
> >> --- a/arch/arm/mach-shmobile/board-kzm9d.c
> >> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
> >> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
> >>  	.init_irq	= emev2_init_irq,
> >>  	.init_machine	= kzm9d_add_standard_devices,
> >>  	.init_late	= shmobile_init_late,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= kzm9d_boards_compat_dt,
> >>  MACHINE_END
> >> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> >> index e48606d..5efc0f0 100644
> >> --- a/arch/arm/mach-shmobile/include/mach/common.h
> >> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> >> @@ -2,7 +2,6 @@
> >>  #define __ARCH_MACH_COMMON_H
> >>  
> >>  extern void shmobile_earlytimer_init(void);
> >> -extern void shmobile_timer_init(void);
> >>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
> >>  			 unsigned int mult, unsigned int div);
> >>  struct twd_local_timer;
> >> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
> >> index 47662a5..4e38a66 100644
> >> --- a/arch/arm/mach-shmobile/setup-emev2.c
> >> +++ b/arch/arm/mach-shmobile/setup-emev2.c
> >> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
> >>  	.nr_irqs	= NR_IRQS_LEGACY,
> >>  	.init_irq	= irqchip_init,
> >>  	.init_machine	= emev2_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= emev2_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
> >> index 8b85d4d..104b474 100644
> >> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
> >> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
> >> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
> >>  	.init_irq	= r8a7740_init_irq,
> >>  	.handle_irq	= shmobile_handle_irq_intc,
> >>  	.init_machine	= r8a7740_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= r8a7740_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
> >> index 59c7146..5502d62 100644
> >> --- a/arch/arm/mach-shmobile/setup-sh7372.c
> >> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
> >> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
> >>  	.init_irq	= sh7372_init_irq,
> >>  	.handle_irq	= shmobile_handle_irq_intc,
> >>  	.init_machine	= sh7372_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= sh7372_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> >> index bdab575..ea66316 100644
> >> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> >> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> >> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
> >>  	.nr_irqs	= NR_IRQS_LEGACY,
> >>  	.init_irq	= sh73a0_init_irq_dt,
> >>  	.init_machine	= sh73a0_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= sh73a0_boards_compat_dt,
> >>  MACHINE_END
> >>  #endif /* CONFIG_USE_OF */
> >> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
> >> index 3d16d4d..add2f15 100644
> >> --- a/arch/arm/mach-shmobile/timer.c
> >> +++ b/arch/arm/mach-shmobile/timer.c
> >> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
> >>  {
> >>  	late_time_init = shmobile_late_time_init;
> >>  }
> >> -
> >> -void __init shmobile_timer_init(void)
> >> -{
> >> -	arch_timer_of_register();
> >> -	arch_timer_sched_clock_init();
> >> -}
> >> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> >> index d0ad789..6215717 100644
> >> --- a/arch/arm/mach-vexpress/v2m.c
> >> +++ b/arch/arm/mach-vexpress/v2m.c
> >> @@ -1,6 +1,7 @@
> >>  /*
> >>   * Versatile Express V2M Motherboard Support
> >>   */
> >> +#include <linux/clocksource.h>
> >>  #include <linux/device.h>
> >>  #include <linux/amba/bus.h>
> >>  #include <linux/amba/mmci.h>
> >> @@ -23,7 +24,6 @@
> >>  #include <linux/regulator/machine.h>
> >>  #include <linux/vexpress.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/mach-types.h>
> >>  #include <asm/sizes.h>
> >>  #include <asm/mach/arch.h>
> >> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
> >>  				irq_of_parse_and_map(node, 0));
> >>  	}
> >>  
> >> -	arch_timer_of_register();
> >> -
> >> -	if (arch_timer_sched_clock_init() != 0)
> >> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> >> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> >>  				24000000);
> >>  }
> >>  
> >> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
> >> index 31666f6..adc0945 100644
> >> --- a/arch/arm/mach-virt/virt.c
> >> +++ b/arch/arm/mach-virt/virt.c
> >> @@ -23,21 +23,13 @@
> >>  #include <linux/of_platform.h>
> >>  #include <linux/smp.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/mach/arch.h>
> >> -#include <asm/mach/time.h>
> >>  
> >>  static void __init virt_init(void)
> >>  {
> >>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> >>  }
> >>  
> >> -static void __init virt_timer_init(void)
> >> -{
> >> -	WARN_ON(arch_timer_of_register() != 0);
> >> -	WARN_ON(arch_timer_sched_clock_init() != 0);
> >> -}
> >> -
> >>  static const char *virt_dt_match[] = {
> >>  	"linux,dummy-virt",
> >>  	NULL
> >> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
> >>  
> >>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
> >>  	.init_irq	= irqchip_init,
> >> -	.init_time	= virt_timer_init,
> >>  	.init_machine	= virt_init,
> >>  	.smp		= smp_ops(virt_smp_ops),
> >>  	.dt_compat	= virt_dt_match,
> >> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> >> index 91e2a6a..bf6ab242 100644
> >> --- a/arch/arm64/include/asm/arch_timer.h
> >> +++ b/arch/arm64/include/asm/arch_timer.h
> >> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
> >>  	return cval;
> >>  }
> >>  
> >> +static inline int arch_timer_arch_init(void)
> >> +{
> >> +	return 0;
> >> +}
> >> +
> >>  #endif
> >> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
> >> index b0ef18d..a551f88 100644
> >> --- a/arch/arm64/kernel/time.c
> >> +++ b/arch/arm64/kernel/time.c
> >> @@ -32,6 +32,7 @@
> >>  #include <linux/timer.h>
> >>  #include <linux/irq.h>
> >>  #include <linux/delay.h>
> >> +#include <linux/clocksource.h>
> >>  
> >>  #include <clocksource/arm_arch_timer.h>
> >>  
> >> @@ -77,10 +78,11 @@ void __init time_init(void)
> >>  {
> >>  	u32 arch_timer_rate;
> >>  
> >> -	if (arch_timer_init())
> >> -		panic("Unable to initialise architected timer.\n");
> >> +	clocksource_of_init();
> >>  
> >>  	arch_timer_rate = arch_timer_get_rate();
> >> +	if (!arch_timer_rate)
> >> +		panic("Unable to initialise architected timer.\n");
> >>  
> >>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
> >>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> >> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> >> index e507ab7..d98e7e1 100644
> >> --- a/drivers/clocksource/Kconfig
> >> +++ b/drivers/clocksource/Kconfig
> >> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
> >>  
> >>  config ARM_ARCH_TIMER
> >>  	bool
> >> +	select CLKSRC_OF if OF
> >>  
> >>  config CLKSRC_METAG_GENERIC
> >>  	def_bool y if METAG
> >> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> >> index d7ad425..122ff05 100644
> >> --- a/drivers/clocksource/arm_arch_timer.c
> >> +++ b/drivers/clocksource/arm_arch_timer.c
> >> @@ -337,22 +337,14 @@ out:
> >>  	return err;
> >>  }
> >>  
> >> -static const struct of_device_id arch_timer_of_match[] __initconst = {
> >> -	{ .compatible	= "arm,armv7-timer",	},
> >> -	{ .compatible	= "arm,armv8-timer",	},
> >> -	{},
> >> -};
> >> -
> >> -int __init arch_timer_init(void)
> >> +static void __init arch_timer_init(struct device_node *np)
> >>  {
> >> -	struct device_node *np;
> >>  	u32 freq;
> >>  	int i;
> >>  
> >> -	np = of_find_matching_node(NULL, arch_timer_of_match);
> >> -	if (!np) {
> >> -		pr_err("arch_timer: can't find DT node\n");
> >> -		return -ENODEV;
> >> +	if (arch_timer_get_rate()) {
> >> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> >> +		return;
> >>  	}
> >>  
> >>  	/* Try to determine the frequency from the device tree or CNTFRQ */
> >> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
> >>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
> >>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
> >>  			pr_warn("arch_timer: No interrupt available, giving up\n");
> >> -			return -EINVAL;
> >> +			return;
> >>  		}
> >>  	}
> >>  
> >> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
> >>  	else
> >>  		arch_timer_read_counter = arch_counter_get_cntpct;
> >>  
> >> -	return arch_timer_register();
> >> +	arch_timer_register();
> >> +	arch_timer_arch_init();
> >>  }
> >> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
> >> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
> >> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> >> index 2603267..e6c9c4c 100644
> >> --- a/include/clocksource/arm_arch_timer.h
> >> +++ b/include/clocksource/arm_arch_timer.h
> >> @@ -31,18 +31,12 @@
> >>  
> >>  #ifdef CONFIG_ARM_ARCH_TIMER
> >>  
> >> -extern int arch_timer_init(void);
> >>  extern u32 arch_timer_get_rate(void);
> >>  extern u64 (*arch_timer_read_counter)(void);
> >>  extern struct timecounter *arch_timer_get_timecounter(void);
> >>  
> >>  #else
> >>  
> >> -static inline int arch_timer_init(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >> -
> >>  static inline u32 arch_timer_get_rate(void)
> >>  {
> >>  	return 0;
> >> -- 
> >> 1.7.10.4
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >>
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-11  0:09         ` Simon Horman
  0 siblings, 0 replies; 44+ messages in thread
From: Simon Horman @ 2013-04-11  0:09 UTC (permalink / raw)
  To: linux-arm-kernel

[ CC Magnus Damm ]

On Wed, Apr 10, 2013 at 06:17:31PM -0500, Rob Herring wrote:
> On 04/04/2013 12:56 AM, Simon Horman wrote:
> > On Mon, Apr 01, 2013 at 05:21:12PM -0500, Rob Herring wrote:
> >> From: Rob Herring <rob.herring@calxeda.com>
> >>
> >> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> >> the arch timer. A new function arch_timer_arch_init is added to allow for
> >> arch specific setup.
> >>
> >> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> >> should not be any reason not to use the arch timers for sched_clock.
> > 
> > Would it be possible for you to either delay the removal of
> > shmobile_timer_init. In general I am in favour of the following
> > approach to wide changes such as this one:
> 
> I will simply change shmobile_timer_init to call clocksource_of_init
> rather than deleting it. That should keep the new users working and then
> it can be deleted latter.

Thanks.

> > 1. Add new feature
> > 2. Convert users to new feature
> > 3. Remove old feature.
> > 
> > If it is not possible to delay the removal of shmobile_timer_init could you
> > update your base such that you also remove its usage from the following
> > files:
> > 
> > arch/arm/mach-shmobile/board-kzm9g-reference.c
> > arch/arm/mach-shmobile/setup-r8a73a4.c
> > arch/arm/mach-shmobile/setup-r8a7779.c
> > arch/arm/mach-shmobile/board-lager.c
> > arch/arm/mach-shmobile/board-ape6evm.c
> > arch/arm/mach-shmobile/setup-r8a7778.c
> > arch/arm/mach-shmobile/board-marzen-reference.c
> > arch/arm/mach-shmobile/setup-r8a7790.c
> > arch/arm/mach-shmobile/board-bockw.c
> 
> Why so many boards? There's been prior discussions about whether to add
> DT into existing board files or start with a minimal DT board file and
> add to it. The fact that there are 14 mach desc's using
> shmobile_timer_init which is a function only used for DT and 17 DT mach
> descs total for shmobile tells me perhaps the latter approach is needed.
> 
> Either way, it is good to see progress on DT support in shmobile.

I've CCed Magnus who can answer that question better than I.
But in general I believe the answer is that because DT support for
many of the drivers that the boards and SoCs rely on isn't quite (or
in some cases at all) ready yet we need to bring things up using C code.

I realise that there are other approaches to this problem, but
this is the one we're taking at this time.

> 
> Rob
> 
> > The above files are all present in the arm-soc/next/boards2 branch
> > of the arm-soc tree which has pulled the renesas-boards3-for-v3.10 tag
> > of git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git.
> > I am happy for you use the later as a base if you wish.
> > 
> >> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> >> Cc: Russell King <linux@arm.linux.org.uk>
> >> Cc: Kukjin Kim <kgene.kim@samsung.com>
> >> Cc: Tony Lindgren <tony@atomide.com>
> >> Cc: Simon Horman <horms@verge.net.au>
> >> Cc: Magnus Damm <magnus.damm@gmail.com>
> >> Cc: Catalin Marinas <catalin.marinas@arm.com>
> >> Cc: Will Deacon <will.deacon@arm.com>
> >> Cc: John Stultz <john.stultz@linaro.org>
> >> Cc: Thomas Gleixner <tglx@linutronix.de>
> >> Cc: linux-samsung-soc at vger.kernel.org
> >> Cc: linux-omap at vger.kernel.org
> >> Cc: linux-sh at vger.kernel.org
> >> ---
> >>  arch/arm/include/asm/arch_timer.h            |   13 +------------
> >>  arch/arm/kernel/arch_timer.c                 |   17 +++--------------
> >>  arch/arm/mach-exynos/mach-exynos5-dt.c       |    1 -
> >>  arch/arm/mach-exynos/mct.c                   |    6 ------
> >>  arch/arm/mach-highbank/highbank.c            |    5 +----
> >>  arch/arm/mach-omap2/timer.c                  |    5 +----
> >>  arch/arm/mach-shmobile/board-kzm9d.c         |    1 -
> > 
> > I have boot tested the board-kzm9d change on the kzm9d board, it seems fine.
> > 
> >>  arch/arm/mach-shmobile/include/mach/common.h |    1 -
> >>  arch/arm/mach-shmobile/setup-emev2.c         |    1 -
> > 
> > I am not able to test the setup-emev2 portion properly at this time,
> > booting the kzm9d board without the board-kzm9d file seems broken without
> > your patch. However, your change seems reasonable to me.
> > 
> >>  arch/arm/mach-shmobile/setup-r8a7740.c       |    1 -
> > 
> > I am not able to test the setup-r8a7740 portion properly at this time,
> > booting the armadillo800eva board without the board-armadillo800eva file
> > seems broken without your patch. However, your change seems reasonable to
> > me.
> > 
> >>  arch/arm/mach-shmobile/setup-sh7372.c        |    1 -
> > 
> > I am not able to test the setup-sh7372 portion properly at this time,
> > booting the mackerel board without the board-mackerel file seems broken without
> > your patch. However, your change seems reasonable to me.
> > 
> >>  arch/arm/mach-shmobile/setup-sh73a0.c        |    1 -
> > 
> > I have boot tested the setup-sh73a0 change on the kzm9g board, it seems fine.
> > 
> > 
> > The tests above were made by merging
> > 
> > git://sources.calxeda.com/kernel/linux.git arm-timers
> > head commit: df3f518db302caf9fc0511917c5e9021037f6fcd
> > 	     ("devtree: add binding documentation for sp804")
> > 
> > and the renesas-next-20130403 tag of the renesas tree (URL above).
> > 
> >>  arch/arm/mach-shmobile/timer.c               |    6 ------
> >>  arch/arm/mach-vexpress/v2m.c                 |    7 ++-----
> >>  arch/arm/mach-virt/virt.c                    |    9 ---------
> >>  arch/arm64/include/asm/arch_timer.h          |    5 +++++
> >>  arch/arm64/kernel/time.c                     |    6 ++++--
> >>  drivers/clocksource/Kconfig                  |    1 +
> >>  drivers/clocksource/arm_arch_timer.c         |   23 +++++++++--------------
> >>  include/clocksource/arm_arch_timer.h         |    6 ------
> >>  20 files changed, 27 insertions(+), 89 deletions(-)
> >>
> >> diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
> >> index 7ade91d..7c1bfc0 100644
> >> --- a/arch/arm/include/asm/arch_timer.h
> >> +++ b/arch/arm/include/asm/arch_timer.h
> >> @@ -10,8 +10,7 @@
> >>  #include <clocksource/arm_arch_timer.h>
> >>  
> >>  #ifdef CONFIG_ARM_ARCH_TIMER
> >> -int arch_timer_of_register(void);
> >> -int arch_timer_sched_clock_init(void);
> >> +int arch_timer_arch_init(void);
> >>  
> >>  /*
> >>   * These register accessors are marked inline so the compiler can
> >> @@ -110,16 +109,6 @@ static inline void __cpuinit arch_counter_set_user_access(void)
> >>  
> >>  	asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
> >>  }
> >> -#else
> >> -static inline int arch_timer_of_register(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >> -
> >> -static inline int arch_timer_sched_clock_init(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >>  #endif
> >>  
> >>  #endif
> >> diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
> >> index a7536d4..dc74048 100644
> >> --- a/arch/arm/kernel/arch_timer.c
> >> +++ b/arch/arm/kernel/arch_timer.c
> >> @@ -39,26 +39,15 @@ static void __init arch_timer_delay_timer_register(void)
> >>  	register_current_timer_delay(&arch_delay_timer);
> >>  }
> >>  
> >> -int __init arch_timer_of_register(void)
> >> -{
> >> -	int ret;
> >> -
> >> -	ret = arch_timer_init();
> >> -	if (ret)
> >> -		return ret;
> >> -
> >> -	arch_timer_delay_timer_register();
> >> -
> >> -	return 0;
> >> -}
> >> -
> >> -int __init arch_timer_sched_clock_init(void)
> >> +int __init arch_timer_arch_init(void)
> >>  {
> >>          u32 arch_timer_rate = arch_timer_get_rate();
> >>  
> >>  	if (arch_timer_rate == 0)
> >>  		return -ENXIO;
> >>  
> >> +	arch_timer_delay_timer_register();
> >> +
> >>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
> >>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> >>  	sched_clock_func = arch_timer_sched_clock;
> >> diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> index acaeb14..4d97b43 100644
> >> --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
> >> @@ -216,7 +216,6 @@ DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
> >>  	.map_io		= exynos5_dt_map_io,
> >>  	.init_machine	= exynos5_dt_machine_init,
> >>  	.init_late	= exynos_init_late,
> >> -	.init_time	= exynos4_timer_init,
> >>  	.dt_compat	= exynos5_dt_compat,
> >>  	.restart        = exynos5_restart,
> >>  	.reserve	= exynos5_reserve,
> >> diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
> >> index c9d6650..04aff6a 100644
> >> --- a/arch/arm/mach-exynos/mct.c
> >> +++ b/arch/arm/mach-exynos/mct.c
> >> @@ -21,7 +21,6 @@
> >>  #include <linux/percpu.h>
> >>  #include <linux/of.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/localtimer.h>
> >>  
> >>  #include <plat/cpu.h>
> >> @@ -469,11 +468,6 @@ static void __init exynos4_timer_resources(void)
> >>  
> >>  void __init exynos4_timer_init(void)
> >>  {
> >> -	if (soc_is_exynos5440()) {
> >> -		arch_timer_of_register();
> >> -		return;
> >> -	}
> >> -
> >>  	if ((soc_is_exynos4210()) || (soc_is_exynos5250()))
> >>  		mct_int_type = MCT_INT_SPI;
> >>  	else
> >> diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
> >> index 76c1170..758150e 100644
> >> --- a/arch/arm/mach-highbank/highbank.c
> >> +++ b/arch/arm/mach-highbank/highbank.c
> >> @@ -15,6 +15,7 @@
> >>   */
> >>  #include <linux/clk.h>
> >>  #include <linux/clkdev.h>
> >> +#include <linux/clocksource.h>
> >>  #include <linux/dma-mapping.h>
> >>  #include <linux/io.h>
> >>  #include <linux/irq.h>
> >> @@ -28,7 +29,6 @@
> >>  #include <linux/amba/bus.h>
> >>  #include <linux/clk-provider.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/cacheflush.h>
> >>  #include <asm/cputype.h>
> >>  #include <asm/smp_plat.h>
> >> @@ -118,9 +118,6 @@ static void __init highbank_timer_init(void)
> >>  	sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
> >>  	sp804_clockevents_init(timer_base, irq, "timer0");
> >>  
> >> -	arch_timer_of_register();
> >> -	arch_timer_sched_clock_init();
> >> -
> >>  	clocksource_of_init();
> >>  }
> >>  
> >> diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
> >> index 4fd8025..7dd6453 100644
> >> --- a/arch/arm/mach-omap2/timer.c
> >> +++ b/arch/arm/mach-omap2/timer.c
> >> @@ -46,7 +46,6 @@
> >>  #include <asm/smp_twd.h>
> >>  #include <asm/sched_clock.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include "omap_hwmod.h"
> >>  #include "omap_device.h"
> >>  #include <plat/counter-32k.h>
> >> @@ -624,9 +623,7 @@ void __init omap5_realtime_timer_init(void)
> >>  	omap5_sync32k_timer_init();
> >>  	realtime_counter_init();
> >>  
> >> -	err = arch_timer_of_register();
> >> -	if (err)
> >> -		pr_err("%s: arch_timer_register failed %d\n", __func__, err);
> >> +        clocksource_of_init();
> >>  }
> >>  #endif /* CONFIG_SOC_OMAP5 */
> >>  
> >> diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
> >> index c254782..c016ccd 100644
> >> --- a/arch/arm/mach-shmobile/board-kzm9d.c
> >> +++ b/arch/arm/mach-shmobile/board-kzm9d.c
> >> @@ -90,6 +90,5 @@ DT_MACHINE_START(KZM9D_DT, "kzm9d")
> >>  	.init_irq	= emev2_init_irq,
> >>  	.init_machine	= kzm9d_add_standard_devices,
> >>  	.init_late	= shmobile_init_late,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= kzm9d_boards_compat_dt,
> >>  MACHINE_END
> >> diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
> >> index e48606d..5efc0f0 100644
> >> --- a/arch/arm/mach-shmobile/include/mach/common.h
> >> +++ b/arch/arm/mach-shmobile/include/mach/common.h
> >> @@ -2,7 +2,6 @@
> >>  #define __ARCH_MACH_COMMON_H
> >>  
> >>  extern void shmobile_earlytimer_init(void);
> >> -extern void shmobile_timer_init(void);
> >>  extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
> >>  			 unsigned int mult, unsigned int div);
> >>  struct twd_local_timer;
> >> diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
> >> index 47662a5..4e38a66 100644
> >> --- a/arch/arm/mach-shmobile/setup-emev2.c
> >> +++ b/arch/arm/mach-shmobile/setup-emev2.c
> >> @@ -456,7 +456,6 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
> >>  	.nr_irqs	= NR_IRQS_LEGACY,
> >>  	.init_irq	= irqchip_init,
> >>  	.init_machine	= emev2_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= emev2_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
> >> index 8b85d4d..104b474 100644
> >> --- a/arch/arm/mach-shmobile/setup-r8a7740.c
> >> +++ b/arch/arm/mach-shmobile/setup-r8a7740.c
> >> @@ -906,7 +906,6 @@ DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
> >>  	.init_irq	= r8a7740_init_irq,
> >>  	.handle_irq	= shmobile_handle_irq_intc,
> >>  	.init_machine	= r8a7740_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= r8a7740_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
> >> index 59c7146..5502d62 100644
> >> --- a/arch/arm/mach-shmobile/setup-sh7372.c
> >> +++ b/arch/arm/mach-shmobile/setup-sh7372.c
> >> @@ -1175,7 +1175,6 @@ DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
> >>  	.init_irq	= sh7372_init_irq,
> >>  	.handle_irq	= shmobile_handle_irq_intc,
> >>  	.init_machine	= sh7372_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= sh7372_boards_compat_dt,
> >>  MACHINE_END
> >>  
> >> diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
> >> index bdab575..ea66316 100644
> >> --- a/arch/arm/mach-shmobile/setup-sh73a0.c
> >> +++ b/arch/arm/mach-shmobile/setup-sh73a0.c
> >> @@ -923,7 +923,6 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
> >>  	.nr_irqs	= NR_IRQS_LEGACY,
> >>  	.init_irq	= sh73a0_init_irq_dt,
> >>  	.init_machine	= sh73a0_add_standard_devices_dt,
> >> -	.init_time	= shmobile_timer_init,
> >>  	.dt_compat	= sh73a0_boards_compat_dt,
> >>  MACHINE_END
> >>  #endif /* CONFIG_USE_OF */
> >> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
> >> index 3d16d4d..add2f15 100644
> >> --- a/arch/arm/mach-shmobile/timer.c
> >> +++ b/arch/arm/mach-shmobile/timer.c
> >> @@ -60,9 +60,3 @@ void __init shmobile_earlytimer_init(void)
> >>  {
> >>  	late_time_init = shmobile_late_time_init;
> >>  }
> >> -
> >> -void __init shmobile_timer_init(void)
> >> -{
> >> -	arch_timer_of_register();
> >> -	arch_timer_sched_clock_init();
> >> -}
> >> diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
> >> index d0ad789..6215717 100644
> >> --- a/arch/arm/mach-vexpress/v2m.c
> >> +++ b/arch/arm/mach-vexpress/v2m.c
> >> @@ -1,6 +1,7 @@
> >>  /*
> >>   * Versatile Express V2M Motherboard Support
> >>   */
> >> +#include <linux/clocksource.h>
> >>  #include <linux/device.h>
> >>  #include <linux/amba/bus.h>
> >>  #include <linux/amba/mmci.h>
> >> @@ -23,7 +24,6 @@
> >>  #include <linux/regulator/machine.h>
> >>  #include <linux/vexpress.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/mach-types.h>
> >>  #include <asm/sizes.h>
> >>  #include <asm/mach/arch.h>
> >> @@ -446,10 +446,7 @@ static void __init v2m_dt_timer_init(void)
> >>  				irq_of_parse_and_map(node, 0));
> >>  	}
> >>  
> >> -	arch_timer_of_register();
> >> -
> >> -	if (arch_timer_sched_clock_init() != 0)
> >> -		versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> >> +	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(),
> >>  				24000000);
> >>  }
> >>  
> >> diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
> >> index 31666f6..adc0945 100644
> >> --- a/arch/arm/mach-virt/virt.c
> >> +++ b/arch/arm/mach-virt/virt.c
> >> @@ -23,21 +23,13 @@
> >>  #include <linux/of_platform.h>
> >>  #include <linux/smp.h>
> >>  
> >> -#include <asm/arch_timer.h>
> >>  #include <asm/mach/arch.h>
> >> -#include <asm/mach/time.h>
> >>  
> >>  static void __init virt_init(void)
> >>  {
> >>  	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> >>  }
> >>  
> >> -static void __init virt_timer_init(void)
> >> -{
> >> -	WARN_ON(arch_timer_of_register() != 0);
> >> -	WARN_ON(arch_timer_sched_clock_init() != 0);
> >> -}
> >> -
> >>  static const char *virt_dt_match[] = {
> >>  	"linux,dummy-virt",
> >>  	NULL
> >> @@ -47,7 +39,6 @@ extern struct smp_operations virt_smp_ops;
> >>  
> >>  DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
> >>  	.init_irq	= irqchip_init,
> >> -	.init_time	= virt_timer_init,
> >>  	.init_machine	= virt_init,
> >>  	.smp		= smp_ops(virt_smp_ops),
> >>  	.dt_compat	= virt_dt_match,
> >> diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
> >> index 91e2a6a..bf6ab242 100644
> >> --- a/arch/arm64/include/asm/arch_timer.h
> >> +++ b/arch/arm64/include/asm/arch_timer.h
> >> @@ -130,4 +130,9 @@ static inline u64 arch_counter_get_cntvct(void)
> >>  	return cval;
> >>  }
> >>  
> >> +static inline int arch_timer_arch_init(void)
> >> +{
> >> +	return 0;
> >> +}
> >> +
> >>  #endif
> >> diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
> >> index b0ef18d..a551f88 100644
> >> --- a/arch/arm64/kernel/time.c
> >> +++ b/arch/arm64/kernel/time.c
> >> @@ -32,6 +32,7 @@
> >>  #include <linux/timer.h>
> >>  #include <linux/irq.h>
> >>  #include <linux/delay.h>
> >> +#include <linux/clocksource.h>
> >>  
> >>  #include <clocksource/arm_arch_timer.h>
> >>  
> >> @@ -77,10 +78,11 @@ void __init time_init(void)
> >>  {
> >>  	u32 arch_timer_rate;
> >>  
> >> -	if (arch_timer_init())
> >> -		panic("Unable to initialise architected timer.\n");
> >> +	clocksource_of_init();
> >>  
> >>  	arch_timer_rate = arch_timer_get_rate();
> >> +	if (!arch_timer_rate)
> >> +		panic("Unable to initialise architected timer.\n");
> >>  
> >>  	/* Cache the sched_clock multiplier to save a divide in the hot path. */
> >>  	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;
> >> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> >> index e507ab7..d98e7e1 100644
> >> --- a/drivers/clocksource/Kconfig
> >> +++ b/drivers/clocksource/Kconfig
> >> @@ -62,6 +62,7 @@ config CLKSRC_DBX500_PRCMU_SCHED_CLOCK
> >>  
> >>  config ARM_ARCH_TIMER
> >>  	bool
> >> +	select CLKSRC_OF if OF
> >>  
> >>  config CLKSRC_METAG_GENERIC
> >>  	def_bool y if METAG
> >> diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
> >> index d7ad425..122ff05 100644
> >> --- a/drivers/clocksource/arm_arch_timer.c
> >> +++ b/drivers/clocksource/arm_arch_timer.c
> >> @@ -337,22 +337,14 @@ out:
> >>  	return err;
> >>  }
> >>  
> >> -static const struct of_device_id arch_timer_of_match[] __initconst = {
> >> -	{ .compatible	= "arm,armv7-timer",	},
> >> -	{ .compatible	= "arm,armv8-timer",	},
> >> -	{},
> >> -};
> >> -
> >> -int __init arch_timer_init(void)
> >> +static void __init arch_timer_init(struct device_node *np)
> >>  {
> >> -	struct device_node *np;
> >>  	u32 freq;
> >>  	int i;
> >>  
> >> -	np = of_find_matching_node(NULL, arch_timer_of_match);
> >> -	if (!np) {
> >> -		pr_err("arch_timer: can't find DT node\n");
> >> -		return -ENODEV;
> >> +	if (arch_timer_get_rate()) {
> >> +		pr_warn("arch_timer: multiple nodes in dt, skipping\n");
> >> +		return;
> >>  	}
> >>  
> >>  	/* Try to determine the frequency from the device tree or CNTFRQ */
> >> @@ -378,7 +370,7 @@ int __init arch_timer_init(void)
> >>  		if (!arch_timer_ppi[PHYS_SECURE_PPI] ||
> >>  		    !arch_timer_ppi[PHYS_NONSECURE_PPI]) {
> >>  			pr_warn("arch_timer: No interrupt available, giving up\n");
> >> -			return -EINVAL;
> >> +			return;
> >>  		}
> >>  	}
> >>  
> >> @@ -387,5 +379,8 @@ int __init arch_timer_init(void)
> >>  	else
> >>  		arch_timer_read_counter = arch_counter_get_cntpct;
> >>  
> >> -	return arch_timer_register();
> >> +	arch_timer_register();
> >> +	arch_timer_arch_init();
> >>  }
> >> +CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
> >> +CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init);
> >> diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
> >> index 2603267..e6c9c4c 100644
> >> --- a/include/clocksource/arm_arch_timer.h
> >> +++ b/include/clocksource/arm_arch_timer.h
> >> @@ -31,18 +31,12 @@
> >>  
> >>  #ifdef CONFIG_ARM_ARCH_TIMER
> >>  
> >> -extern int arch_timer_init(void);
> >>  extern u32 arch_timer_get_rate(void);
> >>  extern u64 (*arch_timer_read_counter)(void);
> >>  extern struct timecounter *arch_timer_get_timecounter(void);
> >>  
> >>  #else
> >>  
> >> -static inline int arch_timer_init(void)
> >> -{
> >> -	return -ENXIO;
> >> -}
> >> -
> >>  static inline u32 arch_timer_get_rate(void)
> >>  {
> >>  	return 0;
> >> -- 
> >> 1.7.10.4
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> >> the body of a message to majordomo at vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >>
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-10 23:23         ` Rob Herring
@ 2013-04-11  8:33           ` Linus Walleij
  2013-04-11 15:12             ` Rob Herring
  0 siblings, 1 reply; 44+ messages in thread
From: Linus Walleij @ 2013-04-11  8:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Apr 11, 2013 at 1:23 AM, Rob Herring <robherring2@gmail.com> wrote:

> I'm waiting until there is some clear direction on how or if to split up
> clksrc and clkevt drivers. So I will drop this patch for 3.10 unless you
> are okay with moving it to drivers/clocksource first and sorting out how
> to split things later.

No hurries.

What do you think about my proposal to create drivers/timer
and move the clocksource drivers in a subdir there?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource
  2013-04-11  8:33           ` Linus Walleij
@ 2013-04-11 15:12             ` Rob Herring
  0 siblings, 0 replies; 44+ messages in thread
From: Rob Herring @ 2013-04-11 15:12 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/11/2013 03:33 AM, Linus Walleij wrote:
> On Thu, Apr 11, 2013 at 1:23 AM, Rob Herring <robherring2@gmail.com> wrote:
> 
>> I'm waiting until there is some clear direction on how or if to split up
>> clksrc and clkevt drivers. So I will drop this patch for 3.10 unless you
>> are okay with moving it to drivers/clocksource first and sorting out how
>> to split things later.
> 
> No hurries.
> 
> What do you think about my proposal to create drivers/timer
> and move the clocksource drivers in a subdir there?

I had the exact same idea. I not convinced on how many of the drivers
could be split though. So if everything just ends up in drivers/timers
rather than drivers/timers/ subdirectories, we haven't really
accomplished anything.

Rob

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
  2013-04-01 22:21   ` Rob Herring
  (?)
@ 2013-04-15  9:39     ` Catalin Marinas
  -1 siblings, 0 replies; 44+ messages in thread
From: Catalin Marinas @ 2013-04-15  9:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 01, 2013 at 11:21:12PM +0100, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-samsung-soc@vger.kernel.org
> Cc: linux-omap@vger.kernel.org
> Cc: linux-sh@vger.kernel.org

Unless you pushed the patches already (I've been away for two weeks),
for arm64:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-15  9:39     ` Catalin Marinas
  0 siblings, 0 replies; 44+ messages in thread
From: Catalin Marinas @ 2013-04-15  9:39 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-arm-kernel, Thomas Gleixner, Mark Rutland, Russell King,
	John Stultz, arm, Marc Zyngier, Linus Walleij, rob.herring,
	Kukjin Kim, Tony Lindgren, Simon Horman, Magnus Damm,
	Will Deacon, linux-samsung-soc, linux-omap, linux-sh

On Mon, Apr 01, 2013 at 11:21:12PM +0100, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-samsung-soc@vger.kernel.org
> Cc: linux-omap@vger.kernel.org
> Cc: linux-sh@vger.kernel.org

Unless you pushed the patches already (I've been away for two weeks),
for arm64:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init
@ 2013-04-15  9:39     ` Catalin Marinas
  0 siblings, 0 replies; 44+ messages in thread
From: Catalin Marinas @ 2013-04-15  9:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 01, 2013 at 11:21:12PM +0100, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This converts arm and arm64 to use CLKSRC_OF DT based initialization for
> the arch timer. A new function arch_timer_arch_init is added to allow for
> arch specific setup.
> 
> This has a side effect of enabling sched_clock on omap5 and exynos5. There
> should not be any reason not to use the arch timers for sched_clock.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-samsung-soc at vger.kernel.org
> Cc: linux-omap at vger.kernel.org
> Cc: linux-sh at vger.kernel.org

Unless you pushed the patches already (I've been away for two weeks),
for arm64:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 04/13] ARM: timer-sp: convert to use CLKSRC_OF init
  2013-04-01 22:21 ` [PATCH v2 04/13] ARM: timer-sp: convert to use CLKSRC_OF init Rob Herring
@ 2013-04-19 16:30   ` Russell King - ARM Linux
  0 siblings, 0 replies; 44+ messages in thread
From: Russell King - ARM Linux @ 2013-04-19 16:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 01, 2013 at 05:21:14PM -0500, Rob Herring wrote:
> -void __init sp804_clockevents_init(void __iomem *base, unsigned int irq,
> -	const char *name)
> +void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct clk *clk, const char *name)

This line is really too long.  That's why the previous wrapped it.  Please
do the same with yours.

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2013-04-19 16:30 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-01 22:21 [PATCH v2 00/13] ARM arch, sp804 and integrator timer CLKSRC_OF support Rob Herring
2013-04-01 22:21 ` [PATCH v2 01/13] ARM: make machine_desc->init_time default to clocksource_of_init Rob Herring
2013-04-01 22:21 ` [PATCH v2 02/13] ARM: convert arm/arm64 arch timer to use CLKSRC_OF init Rob Herring
2013-04-01 22:21   ` Rob Herring
2013-04-01 22:21   ` Rob Herring
2013-04-02  3:23   ` Santosh Shilimkar
2013-04-02  3:35     ` Santosh Shilimkar
2013-04-02  3:23     ` Santosh Shilimkar
2013-04-04  5:56   ` Simon Horman
2013-04-04  5:56     ` Simon Horman
2013-04-04  5:56     ` Simon Horman
2013-04-10 23:17     ` Rob Herring
2013-04-10 23:17       ` Rob Herring
2013-04-10 23:17       ` Rob Herring
2013-04-11  0:09       ` Simon Horman
2013-04-11  0:09         ` Simon Horman
2013-04-11  0:09         ` Simon Horman
2013-04-15  9:39   ` Catalin Marinas
2013-04-15  9:39     ` Catalin Marinas
2013-04-15  9:39     ` Catalin Marinas
2013-04-01 22:21 ` [PATCH v2 03/13] OF: add empty of_device_is_available for !OF Rob Herring
2013-04-01 22:21 ` [PATCH v2 04/13] ARM: timer-sp: convert to use CLKSRC_OF init Rob Herring
2013-04-19 16:30   ` Russell King - ARM Linux
2013-04-01 22:21 ` [PATCH v2 05/13] ARM: highbank: use OF init for sp804 timer Rob Herring
2013-04-01 22:21 ` [PATCH v2 06/13] ARM: vexpress: remove sp804 OF init Rob Herring
2013-04-02 16:41   ` Pawel Moll
2013-04-01 22:21 ` [PATCH v2 07/13] ARM: dts: vexpress: disable CA9 core tile sp804 timer Rob Herring
2013-04-02 16:47   ` Pawel Moll
2013-04-01 22:21 ` [PATCH v2 08/13] ARM: vexpress: remove extra timer-sp control register clearing Rob Herring
2013-04-02 16:48   ` Pawel Moll
2013-04-01 22:21 ` [PATCH v2 09/13] ARM: versatile: add versatile dtbs to dtbs target Rob Herring
2013-04-01 22:21 ` [PATCH v2 10/13] ARM: versatile: use OF init for sp804 timer Rob Herring
2013-04-01 22:21 ` [PATCH v2 11/13] ARM: integrator-cp: convert use CLKSRC_OF for timer init Rob Herring
2013-04-01 22:21 ` [PATCH v2 12/13] ARM: move sp804 and integrator timers to drivers/clocksource Rob Herring
2013-04-01 23:26   ` John Stultz
2013-04-02 19:49     ` Rob Herring
2013-04-03  0:41       ` John Stultz
2013-04-03  2:31         ` Rob Herring
2013-04-10 23:23         ` Rob Herring
2013-04-11  8:33           ` Linus Walleij
2013-04-11 15:12             ` Rob Herring
2013-04-03 16:52       ` Linus Walleij
2013-04-04 11:06         ` Daniel Lezcano
2013-04-01 22:21 ` [PATCH v2 13/13] devtree: add binding documentation for sp804 Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.