msm: timer: Store most recent timestamp in memory

It is sometimes useful to know what the last sched_clock
timestamp was in a system - especially when debugging
with ram dumps.

Change-Id: I99c1227005e71ab77d4174cbe47d80bba984bd64
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index febf77f..fd9049f 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -939,12 +939,19 @@
 
 static DEFINE_CLOCK_DATA(cd);
 
+/*
+ * Store the most recent timestamp read from hardware
+ * in last_ns. This is useful for debugging crashes.
+ */
+static u64 last_ns;
+
 unsigned long long notrace sched_clock(void)
 {
 	struct msm_clock *clock = &msm_clocks[msm_global_timer];
 	struct clocksource *cs = &clock->clocksource;
 	u32 cyc = cs->read(cs);
-	return cyc_to_sched_clock(&cd, cyc, ((u32)~0 >> clock->shift));
+	last_ns = cyc_to_sched_clock(&cd, cyc, ((u32)~0 >> clock->shift));
+	return last_ns;
 }
 
 static void notrace msm_update_sched_clock(void)