linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] arm: move timer init to late_timer_init
@ 2011-05-02 20:42 Jean-Christophe PLAGNIOL-VILLARD
  2011-05-02 22:22 ` Russell King - ARM Linux
  2011-05-03  4:03 ` [V3 PATCH] arm: add global early device init Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-02 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

and add global early device init
this will init earlytimer and will try to probe 1 or 2 timers for clockevents
and clocksource

This will also allow to share timer cross arch such as sh-mobile and sh

all arm timers will be update to early device step by step

tested on at91sam9263-ek, at91rm9200-ek and qemu versatilepb

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
---
 arch/arm/kernel/time.c                  |   23 ++++++++++++++-
 arch/arm/mach-shmobile/Makefile         |    2 +-
 arch/arm/mach-shmobile/board-ag5evm.c   |   13 +--------
 arch/arm/mach-shmobile/board-ap4evb.c   |   18 +++---------
 arch/arm/mach-shmobile/board-g3evm.c    |   12 +-------
 arch/arm/mach-shmobile/board-g4evm.c    |   12 +-------
 arch/arm/mach-shmobile/board-mackerel.c |   18 +++---------
 arch/arm/mach-shmobile/timer.c          |   46 -------------------------------
 8 files changed, 33 insertions(+), 111 deletions(-)
 delete mode 100644 arch/arm/mach-shmobile/timer.c

diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 1ff46ca..7cc21ca 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -13,6 +13,7 @@
  */
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/time.h>
 #include <linux/init.h>
@@ -158,12 +159,30 @@ static int __init timer_init_sysfs(void)
 
 device_initcall(timer_init_sysfs);
 
-void __init time_init(void)
+static void arm_late_time_init(void)
 {
 	system_timer = machine_desc->timer;
-	system_timer->init();
+	if (system_timer->init)
+		system_timer->init();
+
+	/*
+	 * Make sure all compiled-in early timers register themselves.
+	 *
+	 * Run probe() for two "earlytimer" devices, these will be the
+	 * clockevents and clocksource devices respectively. In the event
+	 * that only a clockevents device is available, we -ENODEV on the
+	 * clocksource and the jiffies clocksource is used transparently
+	 * instead. No error handling is necessary here.
+	 */
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 2, 0);
+
 #ifdef CONFIG_HAVE_SCHED_CLOCK
 	sched_clock_postinit();
 #endif
 }
 
+void __init time_init(void)
+{
+	late_time_init = arm_late_time_init;
+}
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 260e09d..6a1cc9e 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -3,7 +3,7 @@
 #
 
 # Common objects
-obj-y				:= map_io.o timer.o console.o clock.o pm_runtime.o
+obj-y				:= map_io.o console.o clock.o pm_runtime.o
 
 # CPU objects
 obj-$(CONFIG_ARCH_SH7367)	+= setup-sh7367.o clock-sh7367.o intc-sh7367.o
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index b30b11d..cd9ba29 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -339,6 +339,7 @@ static void __init ag5evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh73a0_add_early_devices();
 	shmobile_setup_console();
+	sh73a0_clock_init();
 }
 
 #define PINTC_ADDR	0xe6900000
@@ -447,22 +448,10 @@ static void __init ag5evm_init(void)
 	platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
 }
 
-static void __init ag5evm_timer_init(void)
-{
-	sh73a0_clock_init();
-	shmobile_timer.init();
-	return;
-}
-
-struct sys_timer ag5evm_timer = {
-	.init	= ag5evm_timer_init,
-};
-
 MACHINE_START(AG5EVM, "ag5evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= ag5evm_init_irq,
 	.handle_irq	= shmobile_handle_irq_gic,
 	.init_early	= ag5evm_init_early,
 	.init_machine	= ag5evm_init,
-	.timer		= &ag5evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index ed55c01..f800cae 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -1096,6 +1096,10 @@ static void __init ap4evb_init_early(void)
 	/* setup early devices and console here as well */
 	sh7372_add_early_devices();
 	shmobile_setup_console();
+	sh7372_clock_init();
+
+	/* External clock source */
+	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
 }
 
 #define GPIO_PORT9CR	0xE6051009
@@ -1330,24 +1334,10 @@ static void __init ap4evb_init(void)
 	fsi_init_pm_clock();
 }
 
-static void __init ap4evb_timer_init(void)
-{
-	sh7372_clock_init();
-	shmobile_timer.init();
-
-	/* External clock source */
-	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
-}
-
-static struct sys_timer ap4evb_timer = {
-	.init		= ap4evb_timer_init,
-};
-
 MACHINE_START(AP4EVB, "ap4evb")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= ap4evb_init_early,
 	.init_machine	= ap4evb_init,
-	.timer		= &ap4evb_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g3evm.c b/arch/arm/mach-shmobile/board-g3evm.c
index 20eeacf..63a6c35 100644
--- a/arch/arm/mach-shmobile/board-g3evm.c
+++ b/arch/arm/mach-shmobile/board-g3evm.c
@@ -249,6 +249,7 @@ static void __init g3evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh7367_add_early_devices();
 	shmobile_setup_console();
+	sh7367_clock_init();
 }
 
 static void __init g3evm_init(void)
@@ -338,21 +339,10 @@ static void __init g3evm_init(void)
 	platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
 }
 
-static void __init g3evm_timer_init(void)
-{
-	sh7367_clock_init();
-	shmobile_timer.init();
-}
-
-static struct sys_timer g3evm_timer = {
-	.init		= g3evm_timer_init,
-};
-
 MACHINE_START(G3EVM, "g3evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7367_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= g3evm_init_early,
 	.init_machine	= g3evm_init,
-	.timer		= &g3evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
index 079dd35..46e1b0c 100644
--- a/arch/arm/mach-shmobile/board-g4evm.c
+++ b/arch/arm/mach-shmobile/board-g4evm.c
@@ -263,6 +263,7 @@ static void __init g4evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh7377_add_early_devices();
 	shmobile_setup_console();
+	sh7377_clock_init();
 }
 
 #define GPIO_SDHID0_D0	0xe60520fc
@@ -381,21 +382,10 @@ static void __init g4evm_init(void)
 	platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
 }
 
-static void __init g4evm_timer_init(void)
-{
-	sh7377_clock_init();
-	shmobile_timer.init();
-}
-
-static struct sys_timer g4evm_timer = {
-	.init		= g4evm_timer_init,
-};
-
 MACHINE_START(G4EVM, "g4evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7377_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= g4evm_init_early,
 	.init_machine	= g4evm_init,
-	.timer		= &g4evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index f05a673..d52f323 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -1011,6 +1011,10 @@ static void __init mackerel_init_early(void)
 	/* setup early devices and console here as well */
 	sh7372_add_early_devices();
 	shmobile_setup_console();
+	sh7372_clock_init();
+
+	/* External clock source */
+	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
 }
 
 #define GPIO_PORT9CR	0xE6051009
@@ -1203,24 +1207,10 @@ static void __init mackerel_init(void)
 	hdmi_init_pm_clock();
 }
 
-static void __init mackerel_timer_init(void)
-{
-	sh7372_clock_init();
-	shmobile_timer.init();
-
-	/* External clock source */
-	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
-}
-
-static struct sys_timer mackerel_timer = {
-	.init		= mackerel_timer_init,
-};
-
 MACHINE_START(MACKEREL, "mackerel")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= mackerel_init_early,
 	.init_machine	= mackerel_init,
-	.timer		= &mackerel_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
deleted file mode 100644
index 895794b..0000000
--- a/arch/arm/mach-shmobile/timer.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SH-Mobile Timer
- *
- * Copyright (C) 2010  Magnus Damm
- * Copyright (C) 2002 - 2009  Paul Mundt
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-#include <linux/platform_device.h>
-#include <asm/mach/time.h>
-
-static void __init shmobile_late_time_init(void)
-{
-	/*
-	 * Make sure all compiled-in early timers register themselves.
-	 *
-	 * Run probe() for two "earlytimer" devices, these will be the
-	 * clockevents and clocksource devices respectively. In the event
-	 * that only a clockevents device is available, we -ENODEV on the
-	 * clocksource and the jiffies clocksource is used transparently
-	 * instead. No error handling is necessary here.
-	 */
-	early_platform_driver_register_all("earlytimer");
-	early_platform_driver_probe("earlytimer", 2, 0);
-}
-
-static void __init shmobile_timer_init(void)
-{
-	late_time_init = shmobile_late_time_init;
-}
-
-struct sys_timer shmobile_timer = {
-	.init		= shmobile_timer_init,
-};
-- 
1.7.4.1

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

* [RFC PATCH] arm: move timer init to late_timer_init
  2011-05-02 22:22 ` Russell King - ARM Linux
@ 2011-05-02 22:15   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-02 22:19     ` [RFC PATCH] arm: add global early device init Jean-Christophe PLAGNIOL-VILLARD
  2011-05-02 23:19     ` [RFC PATCH] arm: move timer init to late_timer_init Russell King - ARM Linux
  0 siblings, 2 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-02 22:15 UTC (permalink / raw)
  To: linux-arm-kernel

On 23:22 Mon 02 May     , Russell King - ARM Linux wrote:
> On Mon, May 02, 2011 at 10:42:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > and add global early device init
> > this will init earlytimer and will try to probe 1 or 2 timers for clockevents
> > and clocksource
> 
> Why should this change the positioning of sched_clock initialization
> too?
> 
> You know, to spend time sorting out the sched_clock crap that platform
> people came up with, to get sched_clock working at the right point in
> the init sequence so that everything is happy, and then to have all
> that work undone one kernel version later... well, why did I even bother.
so is it ok to put the early init in time_init for you?

this the key point here

remove the sys_timer struct and switch to early device

Best Regards,
J.

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

* [RFC PATCH] arm: add global early device init
  2011-05-02 22:15   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-02 22:19     ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-02 23:19     ` [RFC PATCH] arm: move timer init to late_timer_init Russell King - ARM Linux
  1 sibling, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-02 22:19 UTC (permalink / raw)
  To: linux-arm-kernel

this will init earlytimer and will try to probe 1 or 2 timers for clockevents
and clocksource

This will also allow to share timer cross arch such as sh-mobile and sh

all arm timers will be update to early device step by step

tested on at91sam9263-ek, at91rm9200-ek and qemu versatilepb

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
---
 arch/arm/kernel/time.c                  |   18 +++++++++++-
 arch/arm/mach-shmobile/Makefile         |    2 +-
 arch/arm/mach-shmobile/board-ag5evm.c   |   13 +--------
 arch/arm/mach-shmobile/board-ap4evb.c   |   18 +++---------
 arch/arm/mach-shmobile/board-g3evm.c    |   12 +-------
 arch/arm/mach-shmobile/board-g4evm.c    |   12 +-------
 arch/arm/mach-shmobile/board-mackerel.c |   18 +++---------
 arch/arm/mach-shmobile/timer.c          |   46 -------------------------------
 8 files changed, 28 insertions(+), 111 deletions(-)
 delete mode 100644 arch/arm/mach-shmobile/timer.c

diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 1ff46ca..cb40bbc 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -13,6 +13,7 @@
  */
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/time.h>
 #include <linux/init.h>
@@ -161,9 +162,22 @@ device_initcall(timer_init_sysfs);
 void __init time_init(void)
 {
 	system_timer = machine_desc->timer;
-	system_timer->init();
+	if (system_timer->init)
+		system_timer->init();
+
+	/*
+	 * Make sure all compiled-in early timers register themselves.
+	 *
+	 * Run probe() for two "earlytimer" devices, these will be the
+	 * clockevents and clocksource devices respectively. In the event
+	 * that only a clockevents device is available, we -ENODEV on the
+	 * clocksource and the jiffies clocksource is used transparently
+	 * instead. No error handling is necessary here.
+	 */
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 2, 0);
+
 #ifdef CONFIG_HAVE_SCHED_CLOCK
 	sched_clock_postinit();
 #endif
 }
-
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 260e09d..6a1cc9e 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -3,7 +3,7 @@
 #
 
 # Common objects
-obj-y				:= map_io.o timer.o console.o clock.o pm_runtime.o
+obj-y				:= map_io.o console.o clock.o pm_runtime.o
 
 # CPU objects
 obj-$(CONFIG_ARCH_SH7367)	+= setup-sh7367.o clock-sh7367.o intc-sh7367.o
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index b30b11d..cd9ba29 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -339,6 +339,7 @@ static void __init ag5evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh73a0_add_early_devices();
 	shmobile_setup_console();
+	sh73a0_clock_init();
 }
 
 #define PINTC_ADDR	0xe6900000
@@ -447,22 +448,10 @@ static void __init ag5evm_init(void)
 	platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
 }
 
-static void __init ag5evm_timer_init(void)
-{
-	sh73a0_clock_init();
-	shmobile_timer.init();
-	return;
-}
-
-struct sys_timer ag5evm_timer = {
-	.init	= ag5evm_timer_init,
-};
-
 MACHINE_START(AG5EVM, "ag5evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= ag5evm_init_irq,
 	.handle_irq	= shmobile_handle_irq_gic,
 	.init_early	= ag5evm_init_early,
 	.init_machine	= ag5evm_init,
-	.timer		= &ag5evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index ed55c01..f800cae 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -1096,6 +1096,10 @@ static void __init ap4evb_init_early(void)
 	/* setup early devices and console here as well */
 	sh7372_add_early_devices();
 	shmobile_setup_console();
+	sh7372_clock_init();
+
+	/* External clock source */
+	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
 }
 
 #define GPIO_PORT9CR	0xE6051009
@@ -1330,24 +1334,10 @@ static void __init ap4evb_init(void)
 	fsi_init_pm_clock();
 }
 
-static void __init ap4evb_timer_init(void)
-{
-	sh7372_clock_init();
-	shmobile_timer.init();
-
-	/* External clock source */
-	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
-}
-
-static struct sys_timer ap4evb_timer = {
-	.init		= ap4evb_timer_init,
-};
-
 MACHINE_START(AP4EVB, "ap4evb")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= ap4evb_init_early,
 	.init_machine	= ap4evb_init,
-	.timer		= &ap4evb_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g3evm.c b/arch/arm/mach-shmobile/board-g3evm.c
index 20eeacf..63a6c35 100644
--- a/arch/arm/mach-shmobile/board-g3evm.c
+++ b/arch/arm/mach-shmobile/board-g3evm.c
@@ -249,6 +249,7 @@ static void __init g3evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh7367_add_early_devices();
 	shmobile_setup_console();
+	sh7367_clock_init();
 }
 
 static void __init g3evm_init(void)
@@ -338,21 +339,10 @@ static void __init g3evm_init(void)
 	platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
 }
 
-static void __init g3evm_timer_init(void)
-{
-	sh7367_clock_init();
-	shmobile_timer.init();
-}
-
-static struct sys_timer g3evm_timer = {
-	.init		= g3evm_timer_init,
-};
-
 MACHINE_START(G3EVM, "g3evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7367_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= g3evm_init_early,
 	.init_machine	= g3evm_init,
-	.timer		= &g3evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
index 079dd35..46e1b0c 100644
--- a/arch/arm/mach-shmobile/board-g4evm.c
+++ b/arch/arm/mach-shmobile/board-g4evm.c
@@ -263,6 +263,7 @@ static void __init g4evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh7377_add_early_devices();
 	shmobile_setup_console();
+	sh7377_clock_init();
 }
 
 #define GPIO_SDHID0_D0	0xe60520fc
@@ -381,21 +382,10 @@ static void __init g4evm_init(void)
 	platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
 }
 
-static void __init g4evm_timer_init(void)
-{
-	sh7377_clock_init();
-	shmobile_timer.init();
-}
-
-static struct sys_timer g4evm_timer = {
-	.init		= g4evm_timer_init,
-};
-
 MACHINE_START(G4EVM, "g4evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7377_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= g4evm_init_early,
 	.init_machine	= g4evm_init,
-	.timer		= &g4evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index f05a673..d52f323 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -1011,6 +1011,10 @@ static void __init mackerel_init_early(void)
 	/* setup early devices and console here as well */
 	sh7372_add_early_devices();
 	shmobile_setup_console();
+	sh7372_clock_init();
+
+	/* External clock source */
+	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
 }
 
 #define GPIO_PORT9CR	0xE6051009
@@ -1203,24 +1207,10 @@ static void __init mackerel_init(void)
 	hdmi_init_pm_clock();
 }
 
-static void __init mackerel_timer_init(void)
-{
-	sh7372_clock_init();
-	shmobile_timer.init();
-
-	/* External clock source */
-	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
-}
-
-static struct sys_timer mackerel_timer = {
-	.init		= mackerel_timer_init,
-};
-
 MACHINE_START(MACKEREL, "mackerel")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= mackerel_init_early,
 	.init_machine	= mackerel_init,
-	.timer		= &mackerel_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
deleted file mode 100644
index 895794b..0000000
--- a/arch/arm/mach-shmobile/timer.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SH-Mobile Timer
- *
- * Copyright (C) 2010  Magnus Damm
- * Copyright (C) 2002 - 2009  Paul Mundt
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-#include <linux/platform_device.h>
-#include <asm/mach/time.h>
-
-static void __init shmobile_late_time_init(void)
-{
-	/*
-	 * Make sure all compiled-in early timers register themselves.
-	 *
-	 * Run probe() for two "earlytimer" devices, these will be the
-	 * clockevents and clocksource devices respectively. In the event
-	 * that only a clockevents device is available, we -ENODEV on the
-	 * clocksource and the jiffies clocksource is used transparently
-	 * instead. No error handling is necessary here.
-	 */
-	early_platform_driver_register_all("earlytimer");
-	early_platform_driver_probe("earlytimer", 2, 0);
-}
-
-static void __init shmobile_timer_init(void)
-{
-	late_time_init = shmobile_late_time_init;
-}
-
-struct sys_timer shmobile_timer = {
-	.init		= shmobile_timer_init,
-};
-- 
1.7.4.1

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

* [RFC PATCH] arm: move timer init to late_timer_init
  2011-05-02 20:42 [RFC PATCH] arm: move timer init to late_timer_init Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-02 22:22 ` Russell King - ARM Linux
  2011-05-02 22:15   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-03  4:03 ` [V3 PATCH] arm: add global early device init Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 10+ messages in thread
From: Russell King - ARM Linux @ 2011-05-02 22:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, May 02, 2011 at 10:42:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> and add global early device init
> this will init earlytimer and will try to probe 1 or 2 timers for clockevents
> and clocksource

Why should this change the positioning of sched_clock initialization
too?

You know, to spend time sorting out the sched_clock crap that platform
people came up with, to get sched_clock working at the right point in
the init sequence so that everything is happy, and then to have all
that work undone one kernel version later... well, why did I even bother.

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

* [RFC PATCH] arm: move timer init to late_timer_init
  2011-05-02 23:19     ` [RFC PATCH] arm: move timer init to late_timer_init Russell King - ARM Linux
@ 2011-05-02 23:17       ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-02 23:28         ` Russell King - ARM Linux
  0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-02 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 00:19 Tue 03 May     , Russell King - ARM Linux wrote:
> On Tue, May 03, 2011 at 12:15:22AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 23:22 Mon 02 May     , Russell King - ARM Linux wrote:
> > > On Mon, May 02, 2011 at 10:42:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > and add global early device init
> > > > this will init earlytimer and will try to probe 1 or 2 timers for clockevents
> > > > and clocksource
> > > 
> > > Why should this change the positioning of sched_clock initialization
> > > too?
> > > 
> > > You know, to spend time sorting out the sched_clock crap that platform
> > > people came up with, to get sched_clock working at the right point in
> > > the init sequence so that everything is happy, and then to have all
> > > that work undone one kernel version later... well, why did I even bother.
> > so is it ok to put the early init in time_init for you?
> 
> If it works there, then there's no problem.  I'm just left wondering why
> you decided to try the late_time_init() thing in the first place.  Was
> there a specific reason?
sh-mobile and sh use it this way

Best Regards,
J.

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

* [RFC PATCH] arm: move timer init to late_timer_init
  2011-05-02 22:15   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-02 22:19     ` [RFC PATCH] arm: add global early device init Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-02 23:19     ` Russell King - ARM Linux
  2011-05-02 23:17       ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 10+ messages in thread
From: Russell King - ARM Linux @ 2011-05-02 23:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 03, 2011 at 12:15:22AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 23:22 Mon 02 May     , Russell King - ARM Linux wrote:
> > On Mon, May 02, 2011 at 10:42:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > and add global early device init
> > > this will init earlytimer and will try to probe 1 or 2 timers for clockevents
> > > and clocksource
> > 
> > Why should this change the positioning of sched_clock initialization
> > too?
> > 
> > You know, to spend time sorting out the sched_clock crap that platform
> > people came up with, to get sched_clock working at the right point in
> > the init sequence so that everything is happy, and then to have all
> > that work undone one kernel version later... well, why did I even bother.
> so is it ok to put the early init in time_init for you?

If it works there, then there's no problem.  I'm just left wondering why
you decided to try the late_time_init() thing in the first place.  Was
there a specific reason?

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

* [RFC PATCH] arm: move timer init to late_timer_init
  2011-05-02 23:28         ` Russell King - ARM Linux
@ 2011-05-02 23:27           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-02 23:27 UTC (permalink / raw)
  To: linux-arm-kernel

On 00:28 Tue 03 May     , Russell King - ARM Linux wrote:
> On Tue, May 03, 2011 at 01:17:14AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 00:19 Tue 03 May     , Russell King - ARM Linux wrote:
> > > On Tue, May 03, 2011 at 12:15:22AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > On 23:22 Mon 02 May     , Russell King - ARM Linux wrote:
> > > > > On Mon, May 02, 2011 at 10:42:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > > and add global early device init
> > > > > > this will init earlytimer and will try to probe 1 or 2 timers for clockevents
> > > > > > and clocksource
> > > > > 
> > > > > Why should this change the positioning of sched_clock initialization
> > > > > too?
> > > > > 
> > > > > You know, to spend time sorting out the sched_clock crap that platform
> > > > > people came up with, to get sched_clock working at the right point in
> > > > > the init sequence so that everything is happy, and then to have all
> > > > > that work undone one kernel version later... well, why did I even bother.
> > > > so is it ok to put the early init in time_init for you?
> > > 
> > > If it works there, then there's no problem.  I'm just left wondering why
> > > you decided to try the late_time_init() thing in the first place.  Was
> > > there a specific reason?
> >
> > sh-mobile and sh use it this way
> 
> Do we know why they do?
Magnus or Paul will answer better than me
IIRC on sh it's was because the timer init the IRQ too early

but on sh-mobile not sure

I test it on at91 with pit and st timers and I get no issue

Best Regards,
J.

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

* [RFC PATCH] arm: move timer init to late_timer_init
  2011-05-02 23:17       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-02 23:28         ` Russell King - ARM Linux
  2011-05-02 23:27           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 10+ messages in thread
From: Russell King - ARM Linux @ 2011-05-02 23:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 03, 2011 at 01:17:14AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 00:19 Tue 03 May     , Russell King - ARM Linux wrote:
> > On Tue, May 03, 2011 at 12:15:22AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 23:22 Mon 02 May     , Russell King - ARM Linux wrote:
> > > > On Mon, May 02, 2011 at 10:42:20PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > and add global early device init
> > > > > this will init earlytimer and will try to probe 1 or 2 timers for clockevents
> > > > > and clocksource
> > > > 
> > > > Why should this change the positioning of sched_clock initialization
> > > > too?
> > > > 
> > > > You know, to spend time sorting out the sched_clock crap that platform
> > > > people came up with, to get sched_clock working at the right point in
> > > > the init sequence so that everything is happy, and then to have all
> > > > that work undone one kernel version later... well, why did I even bother.
> > > so is it ok to put the early init in time_init for you?
> > 
> > If it works there, then there's no problem.  I'm just left wondering why
> > you decided to try the late_time_init() thing in the first place.  Was
> > there a specific reason?
>
> sh-mobile and sh use it this way

Do we know why they do?

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

* [V3 PATCH] arm: add global early device init
  2011-05-02 20:42 [RFC PATCH] arm: move timer init to late_timer_init Jean-Christophe PLAGNIOL-VILLARD
  2011-05-02 22:22 ` Russell King - ARM Linux
@ 2011-05-03  4:03 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-06  6:32   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-03  4:03 UTC (permalink / raw)
  To: linux-arm-kernel

this will init earlytimer and will try to probe 1 or 2 timers for clockevents
and clocksource

This will also allow to share timer cross arch such as sh-mobile and sh

all arm timers will be update to early device step by step

on ARM sh-mobile we do not need to use the late_time_init
as the irq are setup before the probe of the timers

tested on at91sam9263-ek, at91rm9200-ek

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
---
V3:
	now we can do not specify the .timer at all
	and just realy on the early device

	on ARM sh-mobile we do not need to use the late_time_init
	as the irq are setup before the probe of the timers

	the only remaing question is is ok to move the clock_init in the
	.init_early on sh-mobile

	this patch depends on [PATCH] shmobile: fix map_io init usage

Best Regards,
J.

 arch/arm/kernel/time.c                  |   28 +++++++++++++++++--
 arch/arm/mach-shmobile/Makefile         |    2 +-
 arch/arm/mach-shmobile/board-ag5evm.c   |   13 +--------
 arch/arm/mach-shmobile/board-ap4evb.c   |   18 +++---------
 arch/arm/mach-shmobile/board-g3evm.c    |   12 +-------
 arch/arm/mach-shmobile/board-g4evm.c    |   12 +-------
 arch/arm/mach-shmobile/board-mackerel.c |   18 +++---------
 arch/arm/mach-shmobile/timer.c          |   46 -------------------------------
 8 files changed, 37 insertions(+), 112 deletions(-)
 delete mode 100644 arch/arm/mach-shmobile/timer.c

diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
index 1ff46ca..12cee50 100644
--- a/arch/arm/kernel/time.c
+++ b/arch/arm/kernel/time.c
@@ -13,6 +13,7 @@
  */
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/time.h>
 #include <linux/init.h>
@@ -77,6 +78,9 @@ EXPORT_SYMBOL(profile_pc);
 #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
 u32 arch_gettimeoffset(void)
 {
+	if (!system_timer)
+		return 0;
+
 	if (system_timer->offset != NULL)
 		return system_timer->offset() * 1000;
 
@@ -147,7 +151,12 @@ static struct sysdev_class timer_sysclass = {
 
 static int __init timer_init_sysfs(void)
 {
-	int ret = sysdev_class_register(&timer_sysclass);
+	int ret;
+
+	if (!system_timer)
+		return 0;
+
+	ret = sysdev_class_register(&timer_sysclass);
 	if (ret == 0) {
 		system_timer->dev.cls = &timer_sysclass;
 		ret = sysdev_register(&system_timer->dev);
@@ -161,9 +170,22 @@ device_initcall(timer_init_sysfs);
 void __init time_init(void)
 {
 	system_timer = machine_desc->timer;
-	system_timer->init();
+	if (system_timer && system_timer->init)
+		system_timer->init();
+
+	/*
+	 * Make sure all compiled-in early timers register themselves.
+	 *
+	 * Run probe() for two "earlytimer" devices, these will be the
+	 * clockevents and clocksource devices respectively. In the event
+	 * that only a clockevents device is available, we -ENODEV on the
+	 * clocksource and the jiffies clocksource is used transparently
+	 * instead. No error handling is necessary here.
+	 */
+	early_platform_driver_register_all("earlytimer");
+	early_platform_driver_probe("earlytimer", 2, 0);
+
 #ifdef CONFIG_HAVE_SCHED_CLOCK
 	sched_clock_postinit();
 #endif
 }
-
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 260e09d..6a1cc9e 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -3,7 +3,7 @@
 #
 
 # Common objects
-obj-y				:= map_io.o timer.o console.o clock.o pm_runtime.o
+obj-y				:= map_io.o console.o clock.o pm_runtime.o
 
 # CPU objects
 obj-$(CONFIG_ARCH_SH7367)	+= setup-sh7367.o clock-sh7367.o intc-sh7367.o
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index b30b11d..cd9ba29 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -339,6 +339,7 @@ static void __init ag5evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh73a0_add_early_devices();
 	shmobile_setup_console();
+	sh73a0_clock_init();
 }
 
 #define PINTC_ADDR	0xe6900000
@@ -447,22 +448,10 @@ static void __init ag5evm_init(void)
 	platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
 }
 
-static void __init ag5evm_timer_init(void)
-{
-	sh73a0_clock_init();
-	shmobile_timer.init();
-	return;
-}
-
-struct sys_timer ag5evm_timer = {
-	.init	= ag5evm_timer_init,
-};
-
 MACHINE_START(AG5EVM, "ag5evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= ag5evm_init_irq,
 	.handle_irq	= shmobile_handle_irq_gic,
 	.init_early	= ag5evm_init_early,
 	.init_machine	= ag5evm_init,
-	.timer		= &ag5evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index ed55c01..f800cae 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -1096,6 +1096,10 @@ static void __init ap4evb_init_early(void)
 	/* setup early devices and console here as well */
 	sh7372_add_early_devices();
 	shmobile_setup_console();
+	sh7372_clock_init();
+
+	/* External clock source */
+	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
 }
 
 #define GPIO_PORT9CR	0xE6051009
@@ -1330,24 +1334,10 @@ static void __init ap4evb_init(void)
 	fsi_init_pm_clock();
 }
 
-static void __init ap4evb_timer_init(void)
-{
-	sh7372_clock_init();
-	shmobile_timer.init();
-
-	/* External clock source */
-	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
-}
-
-static struct sys_timer ap4evb_timer = {
-	.init		= ap4evb_timer_init,
-};
-
 MACHINE_START(AP4EVB, "ap4evb")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= ap4evb_init_early,
 	.init_machine	= ap4evb_init,
-	.timer		= &ap4evb_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g3evm.c b/arch/arm/mach-shmobile/board-g3evm.c
index 20eeacf..63a6c35 100644
--- a/arch/arm/mach-shmobile/board-g3evm.c
+++ b/arch/arm/mach-shmobile/board-g3evm.c
@@ -249,6 +249,7 @@ static void __init g3evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh7367_add_early_devices();
 	shmobile_setup_console();
+	sh7367_clock_init();
 }
 
 static void __init g3evm_init(void)
@@ -338,21 +339,10 @@ static void __init g3evm_init(void)
 	platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
 }
 
-static void __init g3evm_timer_init(void)
-{
-	sh7367_clock_init();
-	shmobile_timer.init();
-}
-
-static struct sys_timer g3evm_timer = {
-	.init		= g3evm_timer_init,
-};
-
 MACHINE_START(G3EVM, "g3evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7367_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= g3evm_init_early,
 	.init_machine	= g3evm_init,
-	.timer		= &g3evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
index 079dd35..46e1b0c 100644
--- a/arch/arm/mach-shmobile/board-g4evm.c
+++ b/arch/arm/mach-shmobile/board-g4evm.c
@@ -263,6 +263,7 @@ static void __init g4evm_init_early(void)
 	/* setup early devices and console here as well */
 	sh7377_add_early_devices();
 	shmobile_setup_console();
+	sh7377_clock_init();
 }
 
 #define GPIO_SDHID0_D0	0xe60520fc
@@ -381,21 +382,10 @@ static void __init g4evm_init(void)
 	platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
 }
 
-static void __init g4evm_timer_init(void)
-{
-	sh7377_clock_init();
-	shmobile_timer.init();
-}
-
-static struct sys_timer g4evm_timer = {
-	.init		= g4evm_timer_init,
-};
-
 MACHINE_START(G4EVM, "g4evm")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7377_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= g4evm_init_early,
 	.init_machine	= g4evm_init,
-	.timer		= &g4evm_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index f05a673..d52f323 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -1011,6 +1011,10 @@ static void __init mackerel_init_early(void)
 	/* setup early devices and console here as well */
 	sh7372_add_early_devices();
 	shmobile_setup_console();
+	sh7372_clock_init();
+
+	/* External clock source */
+	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
 }
 
 #define GPIO_PORT9CR	0xE6051009
@@ -1203,24 +1207,10 @@ static void __init mackerel_init(void)
 	hdmi_init_pm_clock();
 }
 
-static void __init mackerel_timer_init(void)
-{
-	sh7372_clock_init();
-	shmobile_timer.init();
-
-	/* External clock source */
-	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
-}
-
-static struct sys_timer mackerel_timer = {
-	.init		= mackerel_timer_init,
-};
-
 MACHINE_START(MACKEREL, "mackerel")
 	.map_io		= shmobile_map_io,
 	.init_irq	= sh7372_init_irq,
 	.handle_irq	= shmobile_handle_irq_intc,
 	.init_early	= mackerel_init_early,
 	.init_machine	= mackerel_init,
-	.timer		= &mackerel_timer,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
deleted file mode 100644
index 895794b..0000000
--- a/arch/arm/mach-shmobile/timer.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SH-Mobile Timer
- *
- * Copyright (C) 2010  Magnus Damm
- * Copyright (C) 2002 - 2009  Paul Mundt
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-#include <linux/platform_device.h>
-#include <asm/mach/time.h>
-
-static void __init shmobile_late_time_init(void)
-{
-	/*
-	 * Make sure all compiled-in early timers register themselves.
-	 *
-	 * Run probe() for two "earlytimer" devices, these will be the
-	 * clockevents and clocksource devices respectively. In the event
-	 * that only a clockevents device is available, we -ENODEV on the
-	 * clocksource and the jiffies clocksource is used transparently
-	 * instead. No error handling is necessary here.
-	 */
-	early_platform_driver_register_all("earlytimer");
-	early_platform_driver_probe("earlytimer", 2, 0);
-}
-
-static void __init shmobile_timer_init(void)
-{
-	late_time_init = shmobile_late_time_init;
-}
-
-struct sys_timer shmobile_timer = {
-	.init		= shmobile_timer_init,
-};
-- 
1.7.4.1

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

* [V3 PATCH] arm: add global early device init
  2011-05-03  4:03 ` [V3 PATCH] arm: add global early device init Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-06  6:32   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-06  6:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

	Paul, Magnus any feed back?

Best Regards,
J.
On 06:03 Tue 03 May     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> this will init earlytimer and will try to probe 1 or 2 timers for clockevents
> and clocksource
> 
> This will also allow to share timer cross arch such as sh-mobile and sh
> 
> all arm timers will be update to early device step by step
> 
> on ARM sh-mobile we do not need to use the late_time_init
> as the irq are setup before the probe of the timers
> 
> tested on at91sam9263-ek, at91rm9200-ek
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Paul Mundt <lethal@linux-sh.org>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
> Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
> ---
> V3:
> 	now we can do not specify the .timer at all
> 	and just realy on the early device
> 
> 	on ARM sh-mobile we do not need to use the late_time_init
> 	as the irq are setup before the probe of the timers
> 
> 	the only remaing question is is ok to move the clock_init in the
> 	.init_early on sh-mobile
> 
> 	this patch depends on [PATCH] shmobile: fix map_io init usage
> 
> Best Regards,
> J.
> 
>  arch/arm/kernel/time.c                  |   28 +++++++++++++++++--
>  arch/arm/mach-shmobile/Makefile         |    2 +-
>  arch/arm/mach-shmobile/board-ag5evm.c   |   13 +--------
>  arch/arm/mach-shmobile/board-ap4evb.c   |   18 +++---------
>  arch/arm/mach-shmobile/board-g3evm.c    |   12 +-------
>  arch/arm/mach-shmobile/board-g4evm.c    |   12 +-------
>  arch/arm/mach-shmobile/board-mackerel.c |   18 +++---------
>  arch/arm/mach-shmobile/timer.c          |   46 -------------------------------
>  8 files changed, 37 insertions(+), 112 deletions(-)
>  delete mode 100644 arch/arm/mach-shmobile/timer.c
> 
> diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c
> index 1ff46ca..12cee50 100644
> --- a/arch/arm/kernel/time.c
> +++ b/arch/arm/kernel/time.c
> @@ -13,6 +13,7 @@
>   */
>  #include <linux/module.h>
>  #include <linux/kernel.h>
> +#include <linux/platform_device.h>
>  #include <linux/interrupt.h>
>  #include <linux/time.h>
>  #include <linux/init.h>
> @@ -77,6 +78,9 @@ EXPORT_SYMBOL(profile_pc);
>  #ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
>  u32 arch_gettimeoffset(void)
>  {
> +	if (!system_timer)
> +		return 0;
> +
>  	if (system_timer->offset != NULL)
>  		return system_timer->offset() * 1000;
>  
> @@ -147,7 +151,12 @@ static struct sysdev_class timer_sysclass = {
>  
>  static int __init timer_init_sysfs(void)
>  {
> -	int ret = sysdev_class_register(&timer_sysclass);
> +	int ret;
> +
> +	if (!system_timer)
> +		return 0;
> +
> +	ret = sysdev_class_register(&timer_sysclass);
>  	if (ret == 0) {
>  		system_timer->dev.cls = &timer_sysclass;
>  		ret = sysdev_register(&system_timer->dev);
> @@ -161,9 +170,22 @@ device_initcall(timer_init_sysfs);
>  void __init time_init(void)
>  {
>  	system_timer = machine_desc->timer;
> -	system_timer->init();
> +	if (system_timer && system_timer->init)
> +		system_timer->init();
> +
> +	/*
> +	 * Make sure all compiled-in early timers register themselves.
> +	 *
> +	 * Run probe() for two "earlytimer" devices, these will be the
> +	 * clockevents and clocksource devices respectively. In the event
> +	 * that only a clockevents device is available, we -ENODEV on the
> +	 * clocksource and the jiffies clocksource is used transparently
> +	 * instead. No error handling is necessary here.
> +	 */
> +	early_platform_driver_register_all("earlytimer");
> +	early_platform_driver_probe("earlytimer", 2, 0);
> +
>  #ifdef CONFIG_HAVE_SCHED_CLOCK
>  	sched_clock_postinit();
>  #endif
>  }
> -
> diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
> index 260e09d..6a1cc9e 100644
> --- a/arch/arm/mach-shmobile/Makefile
> +++ b/arch/arm/mach-shmobile/Makefile
> @@ -3,7 +3,7 @@
>  #
>  
>  # Common objects
> -obj-y				:= map_io.o timer.o console.o clock.o pm_runtime.o
> +obj-y				:= map_io.o console.o clock.o pm_runtime.o
>  
>  # CPU objects
>  obj-$(CONFIG_ARCH_SH7367)	+= setup-sh7367.o clock-sh7367.o intc-sh7367.o
> diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
> index b30b11d..cd9ba29 100644
> --- a/arch/arm/mach-shmobile/board-ag5evm.c
> +++ b/arch/arm/mach-shmobile/board-ag5evm.c
> @@ -339,6 +339,7 @@ static void __init ag5evm_init_early(void)
>  	/* setup early devices and console here as well */
>  	sh73a0_add_early_devices();
>  	shmobile_setup_console();
> +	sh73a0_clock_init();
>  }
>  
>  #define PINTC_ADDR	0xe6900000
> @@ -447,22 +448,10 @@ static void __init ag5evm_init(void)
>  	platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
>  }
>  
> -static void __init ag5evm_timer_init(void)
> -{
> -	sh73a0_clock_init();
> -	shmobile_timer.init();
> -	return;
> -}
> -
> -struct sys_timer ag5evm_timer = {
> -	.init	= ag5evm_timer_init,
> -};
> -
>  MACHINE_START(AG5EVM, "ag5evm")
>  	.map_io		= shmobile_map_io,
>  	.init_irq	= ag5evm_init_irq,
>  	.handle_irq	= shmobile_handle_irq_gic,
>  	.init_early	= ag5evm_init_early,
>  	.init_machine	= ag5evm_init,
> -	.timer		= &ag5evm_timer,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
> index ed55c01..f800cae 100644
> --- a/arch/arm/mach-shmobile/board-ap4evb.c
> +++ b/arch/arm/mach-shmobile/board-ap4evb.c
> @@ -1096,6 +1096,10 @@ static void __init ap4evb_init_early(void)
>  	/* setup early devices and console here as well */
>  	sh7372_add_early_devices();
>  	shmobile_setup_console();
> +	sh7372_clock_init();
> +
> +	/* External clock source */
> +	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
>  }
>  
>  #define GPIO_PORT9CR	0xE6051009
> @@ -1330,24 +1334,10 @@ static void __init ap4evb_init(void)
>  	fsi_init_pm_clock();
>  }
>  
> -static void __init ap4evb_timer_init(void)
> -{
> -	sh7372_clock_init();
> -	shmobile_timer.init();
> -
> -	/* External clock source */
> -	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
> -}
> -
> -static struct sys_timer ap4evb_timer = {
> -	.init		= ap4evb_timer_init,
> -};
> -
>  MACHINE_START(AP4EVB, "ap4evb")
>  	.map_io		= shmobile_map_io,
>  	.init_irq	= sh7372_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_early	= ap4evb_init_early,
>  	.init_machine	= ap4evb_init,
> -	.timer		= &ap4evb_timer,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/board-g3evm.c b/arch/arm/mach-shmobile/board-g3evm.c
> index 20eeacf..63a6c35 100644
> --- a/arch/arm/mach-shmobile/board-g3evm.c
> +++ b/arch/arm/mach-shmobile/board-g3evm.c
> @@ -249,6 +249,7 @@ static void __init g3evm_init_early(void)
>  	/* setup early devices and console here as well */
>  	sh7367_add_early_devices();
>  	shmobile_setup_console();
> +	sh7367_clock_init();
>  }
>  
>  static void __init g3evm_init(void)
> @@ -338,21 +339,10 @@ static void __init g3evm_init(void)
>  	platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
>  }
>  
> -static void __init g3evm_timer_init(void)
> -{
> -	sh7367_clock_init();
> -	shmobile_timer.init();
> -}
> -
> -static struct sys_timer g3evm_timer = {
> -	.init		= g3evm_timer_init,
> -};
> -
>  MACHINE_START(G3EVM, "g3evm")
>  	.map_io		= shmobile_map_io,
>  	.init_irq	= sh7367_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_early	= g3evm_init_early,
>  	.init_machine	= g3evm_init,
> -	.timer		= &g3evm_timer,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
> index 079dd35..46e1b0c 100644
> --- a/arch/arm/mach-shmobile/board-g4evm.c
> +++ b/arch/arm/mach-shmobile/board-g4evm.c
> @@ -263,6 +263,7 @@ static void __init g4evm_init_early(void)
>  	/* setup early devices and console here as well */
>  	sh7377_add_early_devices();
>  	shmobile_setup_console();
> +	sh7377_clock_init();
>  }
>  
>  #define GPIO_SDHID0_D0	0xe60520fc
> @@ -381,21 +382,10 @@ static void __init g4evm_init(void)
>  	platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
>  }
>  
> -static void __init g4evm_timer_init(void)
> -{
> -	sh7377_clock_init();
> -	shmobile_timer.init();
> -}
> -
> -static struct sys_timer g4evm_timer = {
> -	.init		= g4evm_timer_init,
> -};
> -
>  MACHINE_START(G4EVM, "g4evm")
>  	.map_io		= shmobile_map_io,
>  	.init_irq	= sh7377_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_early	= g4evm_init_early,
>  	.init_machine	= g4evm_init,
> -	.timer		= &g4evm_timer,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
> index f05a673..d52f323 100644
> --- a/arch/arm/mach-shmobile/board-mackerel.c
> +++ b/arch/arm/mach-shmobile/board-mackerel.c
> @@ -1011,6 +1011,10 @@ static void __init mackerel_init_early(void)
>  	/* setup early devices and console here as well */
>  	sh7372_add_early_devices();
>  	shmobile_setup_console();
> +	sh7372_clock_init();
> +
> +	/* External clock source */
> +	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
>  }
>  
>  #define GPIO_PORT9CR	0xE6051009
> @@ -1203,24 +1207,10 @@ static void __init mackerel_init(void)
>  	hdmi_init_pm_clock();
>  }
>  
> -static void __init mackerel_timer_init(void)
> -{
> -	sh7372_clock_init();
> -	shmobile_timer.init();
> -
> -	/* External clock source */
> -	clk_set_rate(&sh7372_dv_clki_clk, 27000000);
> -}
> -
> -static struct sys_timer mackerel_timer = {
> -	.init		= mackerel_timer_init,
> -};
> -
>  MACHINE_START(MACKEREL, "mackerel")
>  	.map_io		= shmobile_map_io,
>  	.init_irq	= sh7372_init_irq,
>  	.handle_irq	= shmobile_handle_irq_intc,
>  	.init_early	= mackerel_init_early,
>  	.init_machine	= mackerel_init,
> -	.timer		= &mackerel_timer,
>  MACHINE_END
> diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
> deleted file mode 100644
> index 895794b..0000000
> --- a/arch/arm/mach-shmobile/timer.c
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/*
> - * SH-Mobile Timer
> - *
> - * Copyright (C) 2010  Magnus Damm
> - * Copyright (C) 2002 - 2009  Paul Mundt
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; version 2 of the License.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> - *
> - */
> -#include <linux/platform_device.h>
> -#include <asm/mach/time.h>
> -
> -static void __init shmobile_late_time_init(void)
> -{
> -	/*
> -	 * Make sure all compiled-in early timers register themselves.
> -	 *
> -	 * Run probe() for two "earlytimer" devices, these will be the
> -	 * clockevents and clocksource devices respectively. In the event
> -	 * that only a clockevents device is available, we -ENODEV on the
> -	 * clocksource and the jiffies clocksource is used transparently
> -	 * instead. No error handling is necessary here.
> -	 */
> -	early_platform_driver_register_all("earlytimer");
> -	early_platform_driver_probe("earlytimer", 2, 0);
> -}
> -
> -static void __init shmobile_timer_init(void)
> -{
> -	late_time_init = shmobile_late_time_init;
> -}
> -
> -struct sys_timer shmobile_timer = {
> -	.init		= shmobile_timer_init,
> -};
> -- 
> 1.7.4.1

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

end of thread, other threads:[~2011-05-06  6:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-02 20:42 [RFC PATCH] arm: move timer init to late_timer_init Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 22:22 ` Russell King - ARM Linux
2011-05-02 22:15   ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 22:19     ` [RFC PATCH] arm: add global early device init Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 23:19     ` [RFC PATCH] arm: move timer init to late_timer_init Russell King - ARM Linux
2011-05-02 23:17       ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 23:28         ` Russell King - ARM Linux
2011-05-02 23:27           ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-03  4:03 ` [V3 PATCH] arm: add global early device init Jean-Christophe PLAGNIOL-VILLARD
2011-05-06  6:32   ` Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).