From patchwork Fri Jan 8 17:59:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 71839 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o08HxtJv023737 for ; Fri, 8 Jan 2010 18:00:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753814Ab0AHSAA (ORCPT ); Fri, 8 Jan 2010 13:00:00 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753804Ab0AHR77 (ORCPT ); Fri, 8 Jan 2010 12:59:59 -0500 Received: from mail-pz0-f171.google.com ([209.85.222.171]:49737 "EHLO mail-pz0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753811Ab0AHR76 (ORCPT ); Fri, 8 Jan 2010 12:59:58 -0500 Received: by mail-pz0-f171.google.com with SMTP id 1so3897523pzk.33 for ; Fri, 08 Jan 2010 09:59:58 -0800 (PST) Received: by 10.114.6.32 with SMTP id 32mr6230143waf.189.1262973598557; Fri, 08 Jan 2010 09:59:58 -0800 (PST) Received: from localhost (deeprootsystems.com [216.254.16.51]) by mx.google.com with ESMTPS id 23sm18903282pzk.4.2010.01.08.09.59.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 08 Jan 2010 09:59:58 -0800 (PST) From: Kevin Hilman To: linux-omap@vger.kernel.org Subject: [PATCH 13/13] OMAP: timekeeping: time should not stop during suspend Date: Fri, 8 Jan 2010 09:59:31 -0800 Message-Id: <1262973571-25796-14-git-send-email-khilman@deeprootsystems.com> X-Mailer: git-send-email 1.6.6.rc2.1.g42108 In-Reply-To: <1262973571-25796-13-git-send-email-khilman@deeprootsystems.com> References: <1262973571-25796-1-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-2-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-3-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-4-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-5-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-6-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-7-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-8-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-9-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-10-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-11-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-12-git-send-email-khilman@deeprootsystems.com> <1262973571-25796-13-git-send-email-khilman@deeprootsystems.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c index bf1eaf3..dddc027 100644 --- a/arch/arm/plat-omap/common.c +++ b/arch/arm/plat-omap/common.c @@ -172,6 +172,32 @@ unsigned long long sched_clock(void) clocksource_32k.mult, clocksource_32k.shift); } +/** + * read_persistent_clock - Return time from a persistent clock. + * + * Reads the time from a source which isn't disabled during PM, the + * 32k sync timer. Convert the cycles elapsed since last read into + * nsecs and adds to a monotonically increasing timespec. + */ +static struct timespec persistent_ts; +static cycles_t cycles, last_cycles; +void read_persistent_clock(struct timespec *ts) +{ + unsigned long long nsecs; + cycles_t delta; + struct timespec *tsp = &persistent_ts; + + last_cycles = cycles; + cycles = clocksource_32k.read(&clocksource_32k); + delta = cycles - last_cycles; + + nsecs = clocksource_cyc2ns(delta, + clocksource_32k.mult, clocksource_32k.shift); + + timespec_add_ns(tsp, nsecs); + *ts = *tsp; +} + static int __init omap_init_clocksource_32k(void) { static char err[] __initdata = KERN_ERR