linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/11] ARM: integrator-cp: convert use CLKSRC_OF for timer init
Date: Wed, 20 Mar 2013 17:54:09 -0500	[thread overview]
Message-ID: <1363820051-24428-10-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1363820051-24428-1-git-send-email-robherring2@gmail.com>

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

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

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

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/boot/dts/integratorcp.dts       |    6 +++---
 arch/arm/common/timer-sp.c               |   29 +++++++++++++++++++++++++++
 arch/arm/mach-integrator/integrator_cp.c |   32 ------------------------------
 3 files changed, 32 insertions(+), 35 deletions(-)

diff --git a/arch/arm/boot/dts/integratorcp.dts b/arch/arm/boot/dts/integratorcp.dts
index 8b11939..ff1aea0 100644
--- a/arch/arm/boot/dts/integratorcp.dts
+++ b/arch/arm/boot/dts/integratorcp.dts
@@ -24,15 +24,15 @@
 	};
 
 	timer0: timer at 13000000 {
-		compatible = "arm,sp804", "arm,primecell";
+		compatible = "arm,integrator-cp-timer";
 	};
 
 	timer1: timer at 13000100 {
-		compatible = "arm,sp804", "arm,primecell";
+		compatible = "arm,integrator-cp-timer";
 	};
 
 	timer2: timer at 13000200 {
-		compatible = "arm,sp804", "arm,primecell";
+		compatible = "arm,integrator-cp-timer";
 	};
 
 	pic: pic at 14000000 {
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index 3e86835..203a2b3 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -31,6 +31,7 @@
 
 #include <asm/sched_clock.h>
 #include <asm/hardware/arm_timer.h>
+#include <asm/hardware/timer-sp.h>
 
 static long __init sp804_get_clock_rate(struct clk *clk)
 {
@@ -255,3 +256,31 @@ static void __init sp804_of_init(struct device_node *np)
 	initialized = true;
 }
 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);
+
+	if (init_count == 2 || !of_device_is_available(np))
+		return;
+
+	base = of_iomap(np, 0);
+	if (WARN_ON(!base))
+		return;
+
+	if (!init_count)
+		sp804_clocksource_init(base, name);
+	else {
+		irq = irq_of_parse_and_map(np, 0);
+		if (irq <= 0)
+			return;
+
+		sp804_clockevents_init(base, irq, name);
+	}
+
+	init_count++;
+}
+CLOCKSOURCE_OF_DECLARE(intcp, "arm,integrator-cp-timer", integrator_cp_of_init);
\ No newline@end of file
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index c68e7d8..5729c3d 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -249,37 +249,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;
-	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);
-	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 */ }
@@ -383,7 +352,6 @@ DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)")
 	.init_early	= intcp_init_early,
 	.init_irq	= intcp_init_irq_of,
 	.handle_irq	= fpga_handle_irq,
-	.init_time	= cp_of_timer_init,
 	.init_machine	= intcp_init_of,
 	.restart	= integrator_restart,
 	.dt_compat      = intcp_dt_board_compat,
-- 
1.7.10.4

  parent reply	other threads:[~2013-03-20 22:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 22:54 [PATCH 00/11] sp804 and integrator timer CLKSRC_OF support Rob Herring
2013-03-20 22:54 ` [PATCH 01/11] OF: add empty of_device_is_available for !OF Rob Herring
2013-03-21 14:18   ` Mark Rutland
2013-03-21 14:26     ` Rob Herring
2013-03-20 22:54 ` [PATCH 02/11] ARM: remove extra timer-sp control register clearing Rob Herring
2013-03-21 17:58   ` Linus Walleij
2013-03-21 18:03     ` Rob Herring
2013-03-21 19:23   ` Russell King - ARM Linux
2013-03-22  2:36     ` Rob Herring
2013-03-20 22:54 ` [PATCH 03/11] ARM: timer-sp: convert to use CLKSRC_OF init Rob Herring
2013-03-21 18:02   ` Linus Walleij
2013-03-21 19:35   ` Russell King - ARM Linux
2013-03-22  2:31     ` Rob Herring
2013-03-22 11:49       ` Russell King - ARM Linux
2013-03-20 22:54 ` [PATCH 04/11] ARM: highbank: use OF init for sp804 timer Rob Herring
2013-03-20 22:54 ` [PATCH 05/11] ARM: vexpress: remove sp804 OF init Rob Herring
2013-03-20 22:54 ` [PATCH 06/11] ARM: dts: vexpress: disable CA9 core tile sp804 timer Rob Herring
2013-03-20 22:54 ` [PATCH 07/11] ARM: versatile: add versatile dtbs to dtbs target Rob Herring
2013-03-20 22:54 ` [PATCH 08/11] ARM: versatile: use OF init for sp804 timer Rob Herring
2013-03-20 22:54 ` Rob Herring [this message]
2013-03-21 18:07   ` [PATCH 09/11] ARM: integrator-cp: convert use CLKSRC_OF for timer init Linus Walleij
2013-03-20 22:54 ` [PATCH 10/11] ARM: move sp804 and integrator timers to drivers/clocksource Rob Herring
2013-03-21 18:15   ` Linus Walleij
2013-03-20 22:54 ` [PATCH 11/11] devtree: add binding documentation for sp804 Rob Herring
2013-03-21 19:36   ` Russell King - ARM Linux
2013-03-21 13:24 ` [PATCH 00/11] sp804 and integrator timer CLKSRC_OF support Arnd Bergmann
2013-03-21 14:06   ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1363820051-24428-10-git-send-email-robherring2@gmail.com \
    --to=robherring2@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).