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 v3 02/15] ARM: local timers: introduce a new registration interface
Date: Mon, 16 Jan 2012 13:52:27 +0000	[thread overview]
Message-ID: <1326721960-2224-3-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1326721960-2224-1-git-send-email-marc.zyngier@arm.com>

In order to switch to a runtime selectable local timer,
add a registration interface that timer drivers can use to
register to the core.

local_timer_setup() and local_timer_stop() are made weak symbols
in order not to break existing setups.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 arch/arm/include/asm/localtimer.h |   15 +++++++++++++++
 arch/arm/kernel/smp.c             |   27 +++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/localtimer.h b/arch/arm/include/asm/localtimer.h
index 7e1b2c5..f088d63 100644
--- a/arch/arm/include/asm/localtimer.h
+++ b/arch/arm/include/asm/localtimer.h
@@ -15,6 +15,11 @@
 
 struct clock_event_device;
 
+struct local_timer_ops {
+	int  (*setup)(struct clock_event_device *);
+	void (*stop)(struct clock_event_device *);
+};
+
 /*
  * Setup a per-cpu timer, whether it be a local timer or dummy broadcast
  */
@@ -38,6 +43,11 @@ void local_timer_stop(struct clock_event_device *);
  */
 int local_timer_setup(struct clock_event_device *);
 
+/*
+ * Register a local timer driver
+ */
+int local_timer_register(struct local_timer_ops *);
+
 #else
 
 static inline int local_timer_setup(struct clock_event_device *evt)
@@ -48,6 +58,11 @@ static inline int local_timer_setup(struct clock_event_device *evt)
 static inline void local_timer_stop(struct clock_event_device *evt)
 {
 }
+
+static inline int local_timer_register(struct local_timer_ops *ops)
+{
+	return -ENXIO;
+}
 #endif
 
 #endif
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 57db122..69d5f8b 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -475,6 +475,33 @@ static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt)
 	clockevents_register_device(evt);
 }
 
+static struct local_timer_ops *lt_ops;
+
+#ifdef CONFIG_LOCAL_TIMERS
+int local_timer_register(struct local_timer_ops *ops)
+{
+	if (lt_ops)
+		return -EBUSY;
+
+	lt_ops = ops;
+	return 0;
+}
+#endif
+
+int __cpuinit __attribute__ ((weak)) local_timer_setup(struct clock_event_device *clk)
+{
+	if (lt_ops)
+		return lt_ops->setup(clk);
+
+	return -ENXIO;
+}
+
+void __attribute__ ((weak)) local_timer_stop(struct clock_event_device *clk)
+{
+	if (lt_ops)
+		lt_ops->stop(clk);
+}
+
 void __cpuinit percpu_timer_setup(void)
 {
 	unsigned int cpu = smp_processor_id();
-- 
1.7.7.1

  parent reply	other threads:[~2012-01-16 13:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-16 13:52 [PATCH v3 00/15] Runtime registration for local timers Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 01/15] ARM: smp_twd: make local_timer_stop a symbol instead of a #define Marc Zyngier
2012-01-16 13:52 ` Marc Zyngier [this message]
2012-01-16 13:52 ` [PATCH v3 03/15] ARM: smp_twd: add runtime registration support Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 04/15] ARM: smp_twd: add device tree support Marc Zyngier
2012-01-16 15:59   ` Rob Herring
2012-01-16 13:52 ` [PATCH v3 05/15] ARM: OMAP4: convert to twd_local_timer_register() interface Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 06/15] ARM: plat-versatile: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 07/15] ARM: tegra: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 08/15] ARM: shmobile: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 09/15] ARM: ux500: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 10/15] ARM: highbank: " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 11/15] ARM: imx6q: " Marc Zyngier
2012-01-17  3:29   ` Shawn Guo
2012-01-16 13:52 ` [PATCH v3 12/15] ARM: smp_twd: remove old local timer interface Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 13/15] ARM: local timers: convert exynos to runtime registration interface Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 14/15] ARM: local timers: convert MSM " Marc Zyngier
2012-01-16 13:52 ` [PATCH v3 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=1326721960-2224-3-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).