Skip to contentSkip to conversation

ARM arch, sp804 and integrator timer CLKSRC_OF support

PATCH New Rob Herring 9 participants 32 messages Apr 1, 2013 – Apr 19, 2013

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

v2 cover ARM arch, sp804 and integrator timer CLKSRC_OF support

From: Rob Herring <[email protected]>

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
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/13 ARM: make machine_desc->init_time default to clocksource_of_init

From: Arnd Bergmann <[email protected]>

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.

---
 arch/arm/kernel/time.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/arm/kernel/time.c +6 -1
index 955d92d..abff4e9 100644
@@ -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();
 }
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v2 2/13 ARM: convert arm/arm64 arch timer to use CLKSRC_OF init

In reply to Rob Herring

From: Rob Herring <[email protected]>

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.

Cc Russell King <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Simon Horman <[email protected]>
Cc Magnus Damm <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
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(-)
arch/arm/include/asm/arch_timer.h +1 -12
index 7ade91d..7c1bfc0 100644
@@ -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
arch/arm/kernel/arch_timer.c +3 -14
index a7536d4..dc74048 100644
@@ -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;
arch/arm/mach-exynos/mach-exynos5-dt.c +0 -1
index acaeb14..4d97b43 100644
@@ -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,
arch/arm/mach-exynos/mct.c +0 -6
index c9d6650..04aff6a 100644
@@ -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
arch/arm/mach-highbank/highbank.c +1 -4
index 76c1170..758150e 100644
@@ -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();
 }
 
arch/arm/mach-omap2/timer.c +1 -4
index 4fd8025..7dd6453 100644
@@ -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 */
 
arch/arm/mach-shmobile/board-kzm9d.c +0 -1
index c254782..c016ccd 100644
@@ -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
arch/arm/mach-shmobile/include/mach/common.h +0 -1
index e48606d..5efc0f0 100644
@@ -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;
arch/arm/mach-shmobile/setup-emev2.c +0 -1
index 47662a5..4e38a66 100644
@@ -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
 
arch/arm/mach-shmobile/setup-r8a7740.c +0 -1
index 8b85d4d..104b474 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh7372.c +0 -1
index 59c7146..5502d62 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh73a0.c +0 -1
index bdab575..ea66316 100644
@@ -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 */
arch/arm/mach-shmobile/timer.c +0 -6
index 3d16d4d..add2f15 100644
@@ -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();
-}
arch/arm/mach-vexpress/v2m.c +2 -5
index d0ad789..6215717 100644
@@ -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);
 }
 
arch/arm/mach-virt/virt.c +0 -9
index 31666f6..adc0945 100644
@@ -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,
arch/arm64/include/asm/arch_timer.h +5 -0
index 91e2a6a..bf6ab242 100644
@@ -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
arch/arm64/kernel/time.c +4 -2
index b0ef18d..a551f88 100644
@@ -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;
drivers/clocksource/Kconfig +1 -0
index e507ab7..d98e7e1 100644
@@ -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
drivers/clocksource/arm_arch_timer.c +9 -14
index d7ad425..122ff05 100644
@@ -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);
include/clocksource/arm_arch_timer.h +0 -6
index 2603267..e6c9c4c 100644
@@ -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;
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v2 2/13 ARM: convert arm/arm64 arch timer to use CLKSRC_OF init

Quoted 9 lines · Rob Herring

From: Rob Herring <[email protected]>

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.

Quoted 1 line

[..]

Quoted 1 line
 arch/arm/mach-omap2/timer.c                  |    5 +----
#4 lore raw

PATCH v2 2/13 ARM: convert arm/arm64 arch timer to use CLKSRC_OF init

In reply to Rob Herring
Quoted 8 lines · Rob Herring

From: Rob Herring <[email protected]>

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.

Quoted 13 lines
Cc Russell King <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Simon Horman <[email protected]>
Cc Magnus Damm <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc linux-samsung-soc at vger.kernel.org
Cc linux-omap at vger.kernel.org
Cc linux-sh at vger.kernel.org
Quoted 8 lines
---
 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.

Quoted 2 lines
 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.

Quoted 1 line
 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.

Quoted 1 line
 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.

Quoted 1 line
 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).

Quoted 448 lines
 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(-)
arch/arm/include/asm/arch_timer.h +1 -12
index 7ade91d..7c1bfc0 100644
@@ -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
arch/arm/kernel/arch_timer.c +3 -14
index a7536d4..dc74048 100644
@@ -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;
arch/arm/mach-exynos/mach-exynos5-dt.c +0 -1
index acaeb14..4d97b43 100644
@@ -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,
arch/arm/mach-exynos/mct.c +0 -6
index c9d6650..04aff6a 100644
@@ -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
arch/arm/mach-highbank/highbank.c +1 -4
index 76c1170..758150e 100644
@@ -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();
 }
 
arch/arm/mach-omap2/timer.c +1 -4
index 4fd8025..7dd6453 100644
@@ -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 */
 
arch/arm/mach-shmobile/board-kzm9d.c +0 -1
index c254782..c016ccd 100644
@@ -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
arch/arm/mach-shmobile/include/mach/common.h +0 -1
index e48606d..5efc0f0 100644
@@ -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;
arch/arm/mach-shmobile/setup-emev2.c +0 -1
index 47662a5..4e38a66 100644
@@ -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
 
arch/arm/mach-shmobile/setup-r8a7740.c +0 -1
index 8b85d4d..104b474 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh7372.c +0 -1
index 59c7146..5502d62 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh73a0.c +0 -1
index bdab575..ea66316 100644
@@ -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 */
arch/arm/mach-shmobile/timer.c +0 -6
index 3d16d4d..add2f15 100644
@@ -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();
-}
arch/arm/mach-vexpress/v2m.c +2 -5
index d0ad789..6215717 100644
@@ -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);
 }
 
arch/arm/mach-virt/virt.c +0 -9
index 31666f6..adc0945 100644
@@ -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,
arch/arm64/include/asm/arch_timer.h +5 -0
index 91e2a6a..bf6ab242 100644
@@ -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
arch/arm64/kernel/time.c +4 -2
index b0ef18d..a551f88 100644
@@ -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;
drivers/clocksource/Kconfig +1 -0
index e507ab7..d98e7e1 100644
@@ -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
drivers/clocksource/arm_arch_timer.c +9 -14
index d7ad425..122ff05 100644
@@ -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);
include/clocksource/arm_arch_timer.h +0 -6
index 2603267..e6c9c4c 100644
@@ -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;
Signature · 6 lines
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
#5 lore raw

PATCH v2 2/13 ARM: convert arm/arm64 arch timer to use CLKSRC_OF init

Quoted 7 lines · Simon Horman
Quoted 6 lines · Rob Herring

From: Rob Herring <[email protected]>

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.

Quoted 6 lines
Quoted 2 lines

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.

Quoted 8 lines

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:

Quoted 9 lines

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

Quoted 510 lines

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.

Quoted 13 lines
Cc Russell King <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Simon Horman <[email protected]>
Cc Magnus Damm <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc linux-samsung-soc at vger.kernel.org
Cc linux-omap at vger.kernel.org
Cc linux-sh at vger.kernel.org
Quoted 8 lines
---
 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.

Quoted 2 lines
 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.

Quoted 1 line
 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.

Quoted 1 line
 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.

Quoted 1 line
 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).

Quoted 448 lines
 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(-)
arch/arm/include/asm/arch_timer.h +1 -12
index 7ade91d..7c1bfc0 100644
@@ -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
arch/arm/kernel/arch_timer.c +3 -14
index a7536d4..dc74048 100644
@@ -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;
arch/arm/mach-exynos/mach-exynos5-dt.c +0 -1
index acaeb14..4d97b43 100644
@@ -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,
arch/arm/mach-exynos/mct.c +0 -6
index c9d6650..04aff6a 100644
@@ -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
arch/arm/mach-highbank/highbank.c +1 -4
index 76c1170..758150e 100644
@@ -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();
 }
 
arch/arm/mach-omap2/timer.c +1 -4
index 4fd8025..7dd6453 100644
@@ -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 */
 
arch/arm/mach-shmobile/board-kzm9d.c +0 -1
index c254782..c016ccd 100644
@@ -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
arch/arm/mach-shmobile/include/mach/common.h +0 -1
index e48606d..5efc0f0 100644
@@ -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;
arch/arm/mach-shmobile/setup-emev2.c +0 -1
index 47662a5..4e38a66 100644
@@ -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
 
arch/arm/mach-shmobile/setup-r8a7740.c +0 -1
index 8b85d4d..104b474 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh7372.c +0 -1
index 59c7146..5502d62 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh73a0.c +0 -1
index bdab575..ea66316 100644
@@ -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 */
arch/arm/mach-shmobile/timer.c +0 -6
index 3d16d4d..add2f15 100644
@@ -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();
-}
arch/arm/mach-vexpress/v2m.c +2 -5
index d0ad789..6215717 100644
@@ -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);
 }
 
arch/arm/mach-virt/virt.c +0 -9
index 31666f6..adc0945 100644
@@ -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,
arch/arm64/include/asm/arch_timer.h +5 -0
index 91e2a6a..bf6ab242 100644
@@ -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
arch/arm64/kernel/time.c +4 -2
index b0ef18d..a551f88 100644
@@ -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;
drivers/clocksource/Kconfig +1 -0
index e507ab7..d98e7e1 100644
@@ -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
drivers/clocksource/arm_arch_timer.c +9 -14
index d7ad425..122ff05 100644
@@ -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);
include/clocksource/arm_arch_timer.h +0 -6
index 2603267..e6c9c4c 100644
@@ -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;
Signature · 6 lines
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
#6 lore raw

PATCH v2 2/13 ARM: convert arm/arm64 arch timer to use CLKSRC_OF init

[ CC Magnus Damm ]

Quoted 11 lines · Rob Herring
Quoted 10 lines · Simon Horman
Quoted 8 lines · Rob Herring

From: Rob Herring <[email protected]>

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.

Quoted 7 lines
Quoted 3 lines

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.

Quoted 18 lines
Quoted 8 lines

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:

Quoted 9 lines

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

Quoted 7 lines

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.

Quoted 514 lines

Rob

Quoted 510 lines

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.

Quoted 13 lines
Cc Russell King <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Simon Horman <[email protected]>
Cc Magnus Damm <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc linux-samsung-soc at vger.kernel.org
Cc linux-omap at vger.kernel.org
Cc linux-sh at vger.kernel.org
Quoted 8 lines
---
 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.

Quoted 2 lines
 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.

Quoted 1 line
 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.

Quoted 1 line
 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.

Quoted 1 line
 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).

Quoted 448 lines
 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(-)
arch/arm/include/asm/arch_timer.h +1 -12
index 7ade91d..7c1bfc0 100644
@@ -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
arch/arm/kernel/arch_timer.c +3 -14
index a7536d4..dc74048 100644
@@ -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;
arch/arm/mach-exynos/mach-exynos5-dt.c +0 -1
index acaeb14..4d97b43 100644
@@ -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,
arch/arm/mach-exynos/mct.c +0 -6
index c9d6650..04aff6a 100644
@@ -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
arch/arm/mach-highbank/highbank.c +1 -4
index 76c1170..758150e 100644
@@ -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();
 }
 
arch/arm/mach-omap2/timer.c +1 -4
index 4fd8025..7dd6453 100644
@@ -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 */
 
arch/arm/mach-shmobile/board-kzm9d.c +0 -1
index c254782..c016ccd 100644
@@ -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
arch/arm/mach-shmobile/include/mach/common.h +0 -1
index e48606d..5efc0f0 100644
@@ -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;
arch/arm/mach-shmobile/setup-emev2.c +0 -1
index 47662a5..4e38a66 100644
@@ -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
 
arch/arm/mach-shmobile/setup-r8a7740.c +0 -1
index 8b85d4d..104b474 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh7372.c +0 -1
index 59c7146..5502d62 100644
@@ -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
 
arch/arm/mach-shmobile/setup-sh73a0.c +0 -1
index bdab575..ea66316 100644
@@ -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 */
arch/arm/mach-shmobile/timer.c +0 -6
index 3d16d4d..add2f15 100644
@@ -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();
-}
arch/arm/mach-vexpress/v2m.c +2 -5
index d0ad789..6215717 100644
@@ -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);
 }
 
arch/arm/mach-virt/virt.c +0 -9
index 31666f6..adc0945 100644
@@ -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,
arch/arm64/include/asm/arch_timer.h +5 -0
index 91e2a6a..bf6ab242 100644
@@ -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
arch/arm64/kernel/time.c +4 -2
index b0ef18d..a551f88 100644
@@ -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;
drivers/clocksource/Kconfig +1 -0
index e507ab7..d98e7e1 100644
@@ -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
drivers/clocksource/arm_arch_timer.c +9 -14
index d7ad425..122ff05 100644
@@ -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);
include/clocksource/arm_arch_timer.h +0 -6
index 2603267..e6c9c4c 100644
@@ -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;
Signature · 6 lines
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
maintainer
#7 lore raw

PATCH v2 2/13 ARM: convert arm/arm64 arch timer to use CLKSRC_OF init

In reply to Rob Herring
Quoted 9 lines · Rob Herring

From: Rob Herring <[email protected]>

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.

Quoted 13 lines
Cc Russell King <[email protected]>
Cc Kukjin Kim <[email protected]>
Cc Tony Lindgren <[email protected]>
Cc Simon Horman <[email protected]>
Cc Magnus Damm <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
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:

#8 lore raw

PATCH v2 3/13 OF: add empty of_device_is_available for !OF

In reply to Rob Herring

From: Rob Herring <[email protected]>

Add an empty version of of_device_is_available.

---
 include/linux/of.h |    5 +++++
 1 file changed, 5 insertions(+)
include/linux/of.h +5 -0
index a0f1292..95c8583 100644
@@ -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)
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH v2 4/13 ARM: timer-sp: convert to use CLKSRC_OF init

In reply to Rob Herring

From: Rob Herring <[email protected]>

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

---
 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(-)
arch/arm/Kconfig +1 -0
index 5bfd584..10e3053 100644
@@ -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
arch/arm/common/timer-sp.c +89 -16

156 lines not on this page · raw message

arch/arm/include/asm/hardware/timer-sp.h +12 -4
index 2dd9d3f..bb28af7 100644
@@ -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);
+
+}
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH v2 4/13 ARM: timer-sp: convert to use CLKSRC_OF init

arch/arm/common/timer-sp.c static struct irqaction sp804_timer_irq = { · line 181

Quoted 3 lines · Rob Herring
arch/arm/common/timer-sp.c +1 -2
-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.

#11 lore raw

PATCH v2 5/13 ARM: highbank: use OF init for sp804 timer

In reply to Rob Herring

From: Rob Herring <[email protected]>

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

---
 arch/arm/mach-highbank/highbank.c |   19 -------------------
 1 file changed, 19 deletions(-)
arch/arm/mach-highbank/highbank.c +0 -19
index 758150e..e7df2dd 100644
@@ -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();
 }
Signature · 1 line
1.7.10.4
#12 lore raw

PATCH v2 6/13 ARM: vexpress: remove sp804 OF init

In reply to Rob Herring

From: Rob Herring <[email protected]>

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

---
 arch/arm/mach-vexpress/v2m.c |   11 -----------
 1 file changed, 11 deletions(-)
arch/arm/mach-vexpress/v2m.c +0 -11
index 6215717..cdc29d8 100644
@@ -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);
Signature · 1 line
1.7.10.4
#13 lore raw

PATCH v2 6/13 ARM: vexpress: remove sp804 OF init

Quoted 25 lines · Rob Herring

From: Rob Herring <[email protected]>

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

---
 arch/arm/mach-vexpress/v2m.c |   11 -----------
 1 file changed, 11 deletions(-)
arch/arm/mach-vexpress/v2m.c +0 -4
index 6215717..cdc29d8 100644
@@ -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");

arch/arm/mach-vexpress/v2m.c void __init v2m_dt_init_early(void) · line 439

Quoted 10 lines
arch/arm/mach-vexpress/v2m.c +0 -7
-	} 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);

Thanks!

Pawel

#14 lore raw

PATCH v2 7/13 ARM: dts: vexpress: disable CA9 core tile sp804 timer

In reply to Rob Herring

From: Rob Herring <[email protected]>

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.

---
 arch/arm/boot/dts/vexpress-v2p-ca9.dts |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/vexpress-v2p-ca9.dts +1 -0
index 1420bb1..62d9b22 100644
@@ -98,6 +98,7 @@
 			     <0 49 4>;
 		clocks = <&oscclk2>, <&oscclk2>;
 		clock-names = "timclk", "apb_pclk";
+		status = "disabled";
 	};
 
 	watchdog at 100e5000 {
Signature · 1 line
1.7.10.4
#15 lore raw

PATCH v2 7/13 ARM: dts: vexpress: disable CA9 core tile sp804 timer

Quoted 17 lines · Rob Herring

From: Rob Herring <[email protected]>

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.

---
 arch/arm/boot/dts/vexpress-v2p-ca9.dts |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/vexpress-v2p-ca9.dts +0 -0
index 1420bb1..62d9b22 100644

arch/arm/boot/dts/vexpress-v2p-ca9.dts line 104

Quoted 7 lines
arch/arm/boot/dts/vexpress-v2p-ca9.dts +1 -0
@@ -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?

#16 lore raw

PATCH v2 8/13 ARM: vexpress: remove extra timer-sp control register clearing

In reply to Rob Herring

From: Rob Herring <[email protected]>

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

---
 arch/arm/mach-vexpress/v2m.c |    3 ---
 1 file changed, 3 deletions(-)
arch/arm/mach-vexpress/v2m.c +0 -3
index cdc29d8..09e571d 100644
@@ -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");
 }
Signature · 1 line
1.7.10.4
#17 lore raw

PATCH v2 8/13 ARM: vexpress: remove extra timer-sp control register clearing

Quoted 15 lines · Rob Herring

From: Rob Herring <[email protected]>

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

---
 arch/arm/mach-vexpress/v2m.c |    3 ---
 1 file changed, 3 deletions(-)
arch/arm/mach-vexpress/v2m.c +0 -0
index cdc29d8..09e571d 100644

arch/arm/mach-vexpress/v2m.c static void __init v2m_sp804_init(void __iomem *base, unsigned int irq) · line 66

Quoted 9 lines
arch/arm/mach-vexpress/v2m.c +0 -3
@@ -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");
 }

Thanks!

Pawel

#18 lore raw

PATCH v2 9/13 ARM: versatile: add versatile dtbs to dtbs target

In reply to Rob Herring

From: Rob Herring <[email protected]>

Add the versatile platform dtbs to the dtbs make rule.

---
 arch/arm/boot/dts/Makefile |    2 ++
 1 file changed, 2 insertions(+)
arch/arm/boot/dts/Makefile +2 -0
index 9c62558..08d298d 100644
@@ -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 \
Signature · 1 line
1.7.10.4
#19 lore raw

PATCH v2 10/13 ARM: versatile: use OF init for sp804 timer

In reply to Rob Herring

From: Rob Herring <[email protected]>

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

---
 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(-)
arch/arm/boot/dts/versatile-ab.dts +12 -0
index e2fe319..dde75ae 100644
@@ -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>;
arch/arm/mach-versatile/core.c +13 -13
index 25160ae..54bb80b 100644
@@ -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)
arch/arm/mach-versatile/versatile_dt.c +0 -1
index 2558f2e..3621b00 100644
@@ -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,
Signature · 1 line
1.7.10.4
#20 lore raw

PATCH v2 11/13 ARM: integrator-cp: convert use CLKSRC_OF for timer init

In reply to Rob Herring

From: Rob Herring <[email protected]>

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.

---
 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(-)
arch/arm/boot/dts/integratorcp.dts +3 -3
index 8b11939..ff1aea0 100644
@@ -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 {
arch/arm/common/timer-sp.c +35 -0
index ded926f..ddc7407 100644
@@ -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);
arch/arm/mach-integrator/integrator_cp.c +0 -34
index 2b0db82..5781f3c 100644
@@ -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,
Signature · 1 line
1.7.10.4
#21 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

In reply to Rob Herring

From: Rob Herring <[email protected]>

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.

---
 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%)
arch/arm/Kconfig +0 -6
index 10e3053..982076c 100644
@@ -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
arch/arm/common/Makefile +0 -1
index dc8dd0d..5a4cc1a 100644
@@ -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
arch/arm/mach-integrator/Kconfig +1 -0
index abeff25..c5e4ff3 100644
@@ -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
arch/arm/mach-integrator/integrator_ap.c +2 -168

213 lines not on this page · raw message

arch/arm/mach-integrator/integrator_cp.c +2 -3
index 5781f3c..19e2497 100644
@@ -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>
 
arch/arm/mach-realview/core.c +2 -3
index 1d5ee5c..ac59770 100644
@@ -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>
arch/arm/mach-versatile/core.c +2 -2
index 54bb80b..84f26c7 100644
@@ -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>
arch/arm/mach-vexpress/ct-ca9x4.c +1 -3
index 6f34497..8cce326 100644
@@ -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>
 
arch/arm/mach-vexpress/v2m.c +2 -2
index 09e571d..dc15485 100644
@@ -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>
drivers/clocksource/Kconfig +12 -0
index d98e7e1..00aa4cd 100644
@@ -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
 
drivers/clocksource/Makefile +2 -0
index 4d8283a..9f3b62b 100644
@@ -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
drivers/clocksource/integrator_ap_timer.c new file +189 -0

189 lines not on this page · raw message

drivers/clocksource/timer-sp.c renamed from arch/arm/common/timer-sp.c +2 -4
similarity index 98%
rename from arch/arm/common/timer-sp.c
rename to drivers/clocksource/timer-sp.c
index ddc7407..b0fc7f0 100644
@@ -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)
 {
include/clocksource/arm_timer.h renamed from arch/arm/include/asm/hardware/arm_timer.h +2 -2
similarity index 93%
rename from arch/arm/include/asm/hardware/arm_timer.h
rename to include/clocksource/arm_timer.h
index d6030ff..f4a443a 100644
@@ -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
include/clocksource/integrator_ap_timer.h new file +7 -0
new file mode 100644
index 0000000..2f585fc
@@ -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
include/clocksource/timer-sp.h renamed from arch/arm/include/asm/hardware/timer-sp.h +0 -0
similarity index 100%
rename from arch/arm/include/asm/hardware/timer-sp.h
rename to include/clocksource/timer-sp.h
Signature · 1 line
1.7.10.4
#22 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

Quoted 5 lines · Rob Herring
drivers/clocksource/integrator_ap_timer.c new file +0 -0
new file mode 100644
index 0000000..05e6204

[snip]

Quoted 117 lines
drivers/clocksource/integrator_ap_timer.c new file +117 -0
+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);

drivers/clocksource/integrator_ap_timer.c line 189

Quoted 10 lines
drivers/clocksource/integrator_ap_timer.c new file +10 -0
+		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
<[email protected]> to the cc.

thanks
-john

#23 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

Quoted 10 lines · John Stultz
Quoted 6 lines · Rob Herring
drivers/clocksource/integrator_ap_timer.c new file +0 -0
new file mode 100644
index 0000000..05e6204

[snip]

Quoted 8 lines
Quoted 2 lines

+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?

Quoted 3 lines

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

Quoted 11 lines

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
<[email protected]> to the cc.

thanks
-john

#24 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

Quoted 17 lines · Rob Herring
Quoted 9 lines · John Stultz
Quoted 6 lines · Rob Herring
drivers/clocksource/integrator_ap_timer.c new file +0 -0
new file mode 100644
index 0000000..05e6204

[snip]

Quoted 7 lines
Quoted 2 lines

+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.

Quoted 7 lines

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?

Quoted 1 line

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

I'm hoping to start moving those out soon.

Quoted 7 lines
Quoted 2 lines

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

#25 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

Quoted 24 lines · John Stultz
Quoted 23 lines · Rob Herring
Quoted 9 lines · John Stultz
Quoted 6 lines · Rob Herring
drivers/clocksource/integrator_ap_timer.c new file +0 -0
new file mode 100644
index 0000000..05e6204

[snip]

Quoted 7 lines
Quoted 2 lines

+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).

Quoted 4 lines
Quoted 1 line

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.

Quoted 3 lines
Quoted 1 line

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

Quoted 13 lines
Quoted 7 lines
Quoted 2 lines

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

#26 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

In reply to John Stultz
Quoted 36 lines · John Stultz
Quoted 17 lines · Rob Herring
Quoted 9 lines · John Stultz
Quoted 6 lines · Rob Herring
drivers/clocksource/integrator_ap_timer.c new file +0 -0
new file mode 100644
index 0000000..05e6204

[snip]

Quoted 7 lines
Quoted 2 lines

+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.

Quoted 7 lines

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?

Quoted 1 line

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

I'm hoping to start moving those out soon.

Quoted 2 lines
Quoted 2 lines

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

Quoted 8 lines
Quoted 5 lines

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

#27 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

Quoted 4 lines · Rob Herring

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

#28 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

Quoted 11 lines · Linus Walleij
Quoted 4 lines · Rob Herring

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

#29 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

In reply to Rob Herring
Quoted 14 lines · Rob Herring
Quoted 5 lines · John Stultz

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).

Quoted 3 lines

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

#30 lore raw

PATCH v2 12/13 ARM: move sp804 and integrator timers to drivers/clocksource

Quoted 38 lines · Linus Walleij
Quoted 14 lines · Rob Herring
Quoted 5 lines · John Stultz

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).

Quoted 3 lines

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.

Quoted 7 lines

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

Signature · 5 lines
 <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
#31 lore raw

PATCH v2 13/13 devtree: add binding documentation for sp804

In reply to Rob Herring

From: Haojian Zhuang <[email protected]>

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.

---
 .../devicetree/bindings/timer/arm,sp804.txt        |   29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/arm,sp804.txt
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +29 -0
new file mode 100644
index 0000000..5cd8eee
@@ -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";
+	};
Signature · 1 line
1.7.10.4