diff mbox

[v2] OMAP: timekeeping: time should not stop during suspend

Message ID 1258501273-17595-1-git-send-email-khilman@deeprootsystems.com (mailing list archive)
State Superseded
Delegated to: Kevin Hilman
Headers show

Commit Message

Kevin Hilman Nov. 17, 2009, 11:41 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index cc050b3..8057966 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -172,6 +172,25 @@  unsigned long long sched_clock(void)
 				  clocksource_32k.mult, clocksource_32k.shift);
 }
 
+/**
+ * read_persistent_clock -  Return time from the persistent clock.
+ *
+ * Reads the time from a source which isn't disabled during PM: 32k sync
+ * Returns a timespec with tv_sec=0 and tv_nsec=0 if unsupported.
+ *
+ */
+void read_persistent_clock(struct timespec *ts)
+{
+	unsigned long long nsecs;
+	cycle_t cycles;
+
+	ts->tv_sec = ts->tv_nsec = 0;
+	cycles = clocksource_32k.read(&clocksource_32k);
+	nsecs = clocksource_cyc2ns(cycles,
+				   clocksource_32k.mult, clocksource_32k.shift);
+	timespec_add_ns(ts, nsecs);
+}
+
 static int __init omap_init_clocksource_32k(void)
 {
 	static char err[] __initdata = KERN_ERR