From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 4/6] ARM: architected timers: add DT support
Date: Mon, 16 Apr 2012 17:13:28 +0100 [thread overview]
Message-ID: <1334592810-4382-5-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1334592810-4382-1-git-send-email-marc.zyngier@arm.com>
Add runtime DT support and documentation for the Cortex A7/A15
architected timers.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
.../devicetree/bindings/arm/arch_timer.txt | 27 ++++++++++
arch/arm/include/asm/arch_timer.h | 6 ++
arch/arm/kernel/arch_timer.c | 53 +++++++++++++++++---
3 files changed, 79 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/arch_timer.txt
diff --git a/Documentation/devicetree/bindings/arm/arch_timer.txt b/Documentation/devicetree/bindings/arm/arch_timer.txt
new file mode 100644
index 0000000..52478c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/arch_timer.txt
@@ -0,0 +1,27 @@
+* ARM architected timer
+
+ARM Cortex-A7 and Cortex-A15 have a per-core architected timer, which
+provides per-cpu timers.
+
+The timer is attached to a GIC to deliver its per-processor interrupts.
+
+** Timer node properties:
+
+- compatible : Should at least contain "arm,armv7-timer".
+
+- interrupts : Interrupt list for secure, non-secure, virtual and
+ hypervisor timers, in that order.
+
+- clock-frequency : The frequency of the main counter, in Hz. Optional.
+
+Example:
+
+ timer {
+ compatible = "arm,cortex-a15-timer",
+ "arm,armv7-timer";
+ interrupts = <1 13 0xf08>,
+ <1 14 0xf08>,
+ <1 11 0xf08>,
+ <1 10 0xf08>;
+ clock-frequency = <100000000>;
+ };
diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h
index dc008c6..935897f 100644
--- a/arch/arm/include/asm/arch_timer.h
+++ b/arch/arm/include/asm/arch_timer.h
@@ -10,12 +10,18 @@ struct arch_timer {
#ifdef CONFIG_ARM_ARCH_TIMER
int arch_timer_register(struct arch_timer *);
int arch_timer_sched_clock_init(void);
+int arch_timer_of_register(void);
#else
static inline int arch_timer_register(struct arch_timer *at)
{
return -ENXIO;
}
+static inline int arch_timer_of_register(void)
+{
+ return -ENXIO;
+}
+
static inline int arch_timer_sched_clock_init(void)
{
return -ENXIO;
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index 611859a..e2c1f86 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -17,6 +17,7 @@
#include <linux/jiffies.h>
#include <linux/clockchips.h>
#include <linux/interrupt.h>
+#include <linux/of_irq.h>
#include <linux/io.h>
#include <asm/cputype.h>
@@ -244,13 +245,10 @@ static struct local_timer_ops arch_timer_ops __cpuinitdata = {
.stop = arch_timer_stop,
};
-int __init arch_timer_register(struct arch_timer *at)
+static int __init arch_timer_common_register(void)
{
int err;
- if (at->res[0].start <= 0 || !(at->res[0].flags & IORESOURCE_IRQ))
- return -EINVAL;
-
err = arch_timer_available();
if (err)
return err;
@@ -261,7 +259,6 @@ int __init arch_timer_register(struct arch_timer *at)
clocksource_register_hz(&clocksource_counter, arch_timer_rate);
- arch_timer_ppi = at->res[0].start;
err = request_percpu_irq(arch_timer_ppi, arch_timer_handler,
"arch_timer", arch_timer_evt);
if (err) {
@@ -270,8 +267,7 @@ int __init arch_timer_register(struct arch_timer *at)
goto out_free;
}
- if (at->res[1].start > 0 || (at->res[1].flags & IORESOURCE_IRQ)) {
- arch_timer_ppi2 = at->res[1].start;
+ if (arch_timer_ppi2) {
err = request_percpu_irq(arch_timer_ppi2, arch_timer_handler,
"arch_timer", arch_timer_evt);
if (err) {
@@ -299,6 +295,49 @@ out_free:
return err;
}
+int __init arch_timer_register(struct arch_timer *at)
+{
+ if (at->res[0].start <= 0 || !(at->res[0].flags & IORESOURCE_IRQ))
+ return -EINVAL;
+
+ arch_timer_ppi = at->res[0].start;
+
+ if (at->res[1].start > 0 || (at->res[1].flags & IORESOURCE_IRQ))
+ arch_timer_ppi2 = at->res[1].start;
+
+ return arch_timer_common_register();
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id arch_timer_of_match[] __initconst = {
+ { .compatible = "arm,armv7-timer", },
+ {},
+};
+
+int __init arch_timer_of_register(void)
+{
+ struct device_node *np;
+ u32 freq;
+
+ np = of_find_matching_node(NULL, arch_timer_of_match);
+ if (!np) {
+ pr_err("arch_timer: can't find DT node\n");
+ return -ENODEV;
+ }
+
+ /* Try to determine the frequency from the device tree or CNTFRQ */
+ if (!of_property_read_u32(np, "clock-frequency", &freq))
+ arch_timer_rate = freq;
+
+ arch_timer_ppi = irq_of_parse_and_map(np, 0);
+ arch_timer_ppi2 = irq_of_parse_and_map(np, 1);
+ pr_info("arch_timer: found %s irqs %d %d\n",
+ np->name, arch_timer_ppi, arch_timer_ppi2);
+
+ return arch_timer_common_register();
+}
+#endif
+
int __init arch_timer_sched_clock_init(void)
{
int err;
--
1.7.7.1
next prev parent reply other threads:[~2012-04-16 16:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-16 16:13 [PATCH v3 0/6] A7/A15 architected timer support Marc Zyngier
2012-04-16 16:13 ` [PATCH v3 1/6] ARM: local timers: reserve local_timer_register() to SMP Marc Zyngier
2012-04-16 16:13 ` [PATCH v3 2/6] ARM: local timers: Add A15 architected timer support Marc Zyngier
2012-04-16 17:45 ` Stephen Boyd
2012-04-17 9:21 ` Marc Zyngier
2012-04-16 16:13 ` [PATCH v3 3/6] ARM: architected timers: Add A15 specific sched_clock implementation Marc Zyngier
2012-04-16 16:13 ` Marc Zyngier [this message]
2012-04-19 12:55 ` [PATCH v3 4/6] ARM: architected timers: add DT support Arnd Bergmann
2012-04-19 13:07 ` Marc Zyngier
2012-04-16 16:13 ` [PATCH v3 5/6] ARM: architected timers: add support for UP timer Marc Zyngier
2012-04-16 16:13 ` [PATCH v3 6/6] ARM: vexpress: plug local timers into the DT code Marc Zyngier
2012-04-17 9:22 ` Pawel Moll
2012-04-17 9:41 ` 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=1334592810-4382-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).