@@ -31,6 +31,9 @@ asmlinkage void do_local_timer(struct pt_regs *);
#define local_timer_ack() twd_timer_ack()
+#define local_timer_save(cpu) twd_context_save(cpu);
+#define local_timer_restore(cpu) twd_context_save(cpu);
+
#else
/*
@@ -46,6 +49,16 @@ int local_timer_ack(void);
*/
void local_timer_setup(struct clock_event_device *);
+/*
+ * Save local timer register context
+ */
+void local_timer_save(unsigned int cpu);
+
+/*
+ * Restore local timer register context
+ */
+void local_timer_restoree(unsigned int cpu);
+
#endif
#endif
@@ -24,5 +24,7 @@ extern void __iomem *twd_base;
int twd_timer_ack(void);
void twd_timer_setup(struct clock_event_device *);
+void twd_context_save(unsigned int cpu);
+void twd_context_restore(unsigned int cpu);
#endif
@@ -24,6 +24,12 @@
/* set up by the platform code */
void __iomem *twd_base;
+/* Timer context to be saved in low power modes */
+struct twd_registers {
+ unsigned long timer_ctrl;
+ unsigned long timer_load;
+};
+static DEFINE_PER_CPU(struct twd_registers, twd_context);
static unsigned long twd_timer_rate;
static void twd_set_mode(enum clock_event_mode mode,
@@ -145,3 +151,21 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
clockevents_register_device(clk);
}
+
+/* Low power context save */
+void twd_context_save(unsigned int cpu)
+{
+ struct twd_registers *regs = &per_cpu(twd_context, cpu);
+
+ regs->timer_ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL);
+ regs->timer_load = __raw_readl(twd_base + TWD_TIMER_LOAD);
+}
+
+/* Low power context restore */
+void twd_context_restore(unsigned int cpu)
+{
+ struct twd_registers *regs = &per_cpu(twd_context, cpu);
+
+ __raw_writel(regs->timer_load, twd_base + TWD_TIMER_LOAD);
+ __raw_writel(regs->timer_ctrl, twd_base + TWD_TIMER_CONTROL);
+}