ARM: local timers: introduce a new registration interface
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 10 Jan 2012 19:26:45 +0000 (19:26 +0000)
committerMarc Zyngier <marc.zyngier@arm.com>
Tue, 13 Mar 2012 13:27:50 +0000 (13:27 +0000)
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
arch/arm/kernel/smp.c

index 7e1b2c5f7d17291f90bb10c3795dfb735c8ce9d1..f088d63b92c705ebbe0b89cb9d3118647102d5e2 100644 (file)
 
 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
index cdeb727527d39768587ffa3dd9946073aeaa6853..89bb02c90ae1cd445a91250843a5bae68fecde3a 100644 (file)
@@ -459,6 +459,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();