linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/15] ARM: smp_twd: add device tree support
Date: Wed, 11 Jan 2012 13:08:43 +0000	[thread overview]
Message-ID: <1326287334-1905-5-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1326287334-1905-1-git-send-email-marc.zyngier@arm.com>

Add bindings to support DT discovery of the ARM Timer Watchdog
(aka TWD). Only the timer side is converted by this patch.

Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 Documentation/devicetree/bindings/arm/twd.txt |   29 +++++++++++
 arch/arm/include/asm/smp_twd.h                |    1 +
 arch/arm/kernel/smp_twd.c                     |   68 ++++++++++++++++++++-----
 3 files changed, 85 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/twd.txt

diff --git a/Documentation/devicetree/bindings/arm/twd.txt b/Documentation/devicetree/bindings/arm/twd.txt
new file mode 100644
index 0000000..a9d5587
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/twd.txt
@@ -0,0 +1,29 @@
+* ARM Timer Watchdog
+
+ARM 11MP, Cortex-A5 and Cortex-A9 are often associated with a per-core
+Timer-Watchdog (aka TWD), which provides both a per-cpu local timer
+and watchdog.
+
+The TWD is usually attached to a GIC to deliver its two per-processor
+interrupts.
+
+Main node required properties:
+
+- compatible : Should be one of:
+	"arm,cortex-a9-twd"
+	"arm,cortex-a5-twd"
+	"arm,arm11mp-twd"
+	"arm,smp-twd"
+
+- interrupts : Two interrupts to each core, the first one for the
+  timer, the second one for the watchdog.
+
+- reg : Specify the base address and the size of the TWD.
+
+Example:
+
+	twd at 2c000600 {
+		compatible = "arm,arm11mp-twd", "arm,smp-twd";
+		reg = <0x2c000600 0x100>;
+		interrupts = <1 13 0xf01 1 14 0xf01>;
+	};
diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h
index 9b6ff85..e8998c9 100644
--- a/arch/arm/include/asm/smp_twd.h
+++ b/arch/arm/include/asm/smp_twd.h
@@ -31,5 +31,6 @@ struct twd_local_timer {
 };
 
 int twd_local_timer_register(struct twd_local_timer *);
+int twd_local_timer_of_register(void);
 
 #endif
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index be245c7..53ddef8 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -20,6 +20,8 @@
 #include <linux/clockchips.h>
 #include <linux/irq.h>
 #include <linux/io.h>
+#include <linux/of_irq.h>
+#include <linux/of_address.h>
 
 #include <asm/smp_twd.h>
 #include <asm/localtimer.h>
@@ -282,37 +284,77 @@ static struct local_timer_ops twd_lt_ops = {
 	.stop	= twd_timer_stop,
 };
 
-int __init twd_local_timer_register(struct twd_local_timer *tlt)
+static int __init twd_local_timer_common_register(void)
 {
 	int err;
 
-	if (twd_base || twd_evt)
-		return -EBUSY;
-
-	twd_ppi	= tlt->res[1].start;
-
 	twd_evt = alloc_percpu(struct clock_event_device *);
-	twd_base = ioremap(tlt->res[0].start, resource_size(&tlt->res[0]));
-	if (!twd_base || !twd_evt) {
+	if (!twd_evt) {
 		err = -ENOMEM;
-		goto out;
+		goto out_free;
 	}
 
 	err = request_percpu_irq(twd_ppi, twd_handler, "twd", twd_evt);
 	if (err) {
 		pr_err("twd: can't register interrupt %d (%d)\n", twd_ppi, err);
-		goto out;
+		goto out_free;
 	}
 
 	err = local_timer_register(&twd_lt_ops);
 	if (err)
-		goto out;
+		goto out_irq;
 
 	return 0;
 
-out:
+out_irq:
+	free_percpu_irq(twd_ppi, twd_evt);
+out_free:
 	iounmap(twd_base);
+	twd_base = NULL;
 	free_percpu(twd_evt);
-	twd_base = twd_evt = NULL;
+
 	return err;
 }
+
+int __init twd_local_timer_register(struct twd_local_timer *tlt)
+{
+	if (twd_base || twd_evt)
+		return -EBUSY;
+
+	twd_ppi	= tlt->res[1].start;
+
+	twd_base = ioremap(tlt->res[0].start, resource_size(&tlt->res[0]));
+	if (!twd_base)
+		return -ENOMEM;
+
+	return twd_local_timer_common_register();
+}
+
+#ifdef CONFIG_OF
+const static struct of_device_id twd_of_match[] __initconst = {
+	{ .compatible = "arm,smp-twd", 		},
+	{ .compatible = "arm,cortex-a9-twd",	},
+	{ .compatible = "arm,cortex-a5-twd",	},
+	{ .compatible = "arm,arm11mp-twd",	},
+	{ },
+};
+
+int __init twd_local_timer_of_register(void)
+{
+	struct device_node *np;
+
+	np = of_find_matching_node(NULL, twd_of_match);
+	if (!np)
+		return -ENODEV;
+
+	twd_ppi = irq_of_parse_and_map(np, 0);
+	if (!twd_ppi)
+		return -EINVAL;
+
+	twd_base = of_iomap(np, 0);
+	if (!twd_base)
+		return -ENOMEM;
+
+	return twd_local_timer_common_register();
+}
+#endif
-- 
1.7.7.1

  parent reply	other threads:[~2012-01-11 13:08 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 13:08 [PATCH 00/15] Runtime registration for local timers Marc Zyngier
2012-01-11 13:08 ` [PATCH 01/15] ARM: smp_twd: make local_timer_stop a symbol instead of a #define Marc Zyngier
2012-01-11 13:08 ` [PATCH 02/15] ARM: local timers: introduce a new registration interface Marc Zyngier
2012-01-11 13:08 ` [PATCH 03/15] ARM: smp_twd: add runtime registration support Marc Zyngier
2012-01-11 13:08 ` Marc Zyngier [this message]
2012-01-11 21:05   ` [PATCH 04/15] ARM: smp_twd: add device tree support Rob Herring
2012-01-12 14:36     ` Marc Zyngier
2012-01-12 15:42       ` Rob Herring
2012-01-12 16:00         ` Marc Zyngier
2012-01-12 16:27           ` Rob Herring
2012-01-12 17:58             ` Marc Zyngier
2012-01-11 13:08 ` [PATCH 05/15] ARM: OMAP4: convert to twd_local_timer_register() interface Marc Zyngier
2012-01-11 13:14   ` Shilimkar, Santosh
2012-01-11 13:08 ` [PATCH 06/15] ARM: plat-versatile: " Marc Zyngier
2012-01-12  9:14   ` Russell King - ARM Linux
2012-01-12 11:53     ` Marc Zyngier
2012-01-11 13:08 ` [PATCH 07/15] ARM: tegra: " Marc Zyngier
2012-01-11 21:49   ` Stephen Warren
2012-01-11 13:08 ` [PATCH 08/15] ARM: shmobile: " Marc Zyngier
2012-01-12  9:19   ` Russell King - ARM Linux
2012-01-12 11:24     ` Marc Zyngier
2012-01-12 12:00       ` Marc Zyngier
2012-01-11 13:08 ` [PATCH 09/15] ARM: ux500: " Marc Zyngier
2012-01-11 23:53   ` Linus Walleij
2012-01-12 13:59     ` Marc Zyngier
2012-01-14 11:43       ` Linus Walleij
2012-01-12  9:16   ` Russell King - ARM Linux
2012-01-12 10:55     ` Marc Zyngier
2012-01-11 13:08 ` [PATCH 10/15] ARM: highbank: " Marc Zyngier
2012-01-11 13:08 ` [PATCH 11/15] ARM: imx6q: " Marc Zyngier
2012-01-12  9:21   ` Shawn Guo
2012-01-11 13:08 ` [PATCH 12/15] ARM: smp_twd: remove old local timer interface Marc Zyngier
2012-01-11 13:08 ` [PATCH 13/15] ARM: local timers: convert exynos to runtime registration interface Marc Zyngier
2012-01-11 13:08 ` [PATCH 14/15] ARM: local timers: convert MSM " Marc Zyngier
2012-01-13  0:13   ` David Brown
2012-01-13  0:27     ` David Brown
2012-01-13 10:11       ` Marc Zyngier
2012-01-11 13:08 ` [PATCH 15/15] ARM: local timers: make the runtime registration interface mandatory Marc Zyngier

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=1326287334-1905-5-git-send-email-marc.zyngier@arm.com \
    --to=marc.zyngier@arm.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).