From patchwork Tue Aug 17 04:44:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 61854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-px0-f184.google.com (mail-px0-f184.google.com [209.85.212.184]) by ozlabs.org (Postfix) with ESMTP id 4F8F5B70A6 for ; Tue, 17 Aug 2010 14:44:04 +1000 (EST) Received: by pxi2 with SMTP id 2sf1082256pxi.11 for ; Mon, 16 Aug 2010 21:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:mime-version:x-beenthere:received :received:received:received:received-spf:received:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=ow2XhoV8Keaq1+UHlqz8lkzOf+0PvuIHmVbTqDZiLvo=; b=antkcpUWi89We2DMRhU30CzR+XiFCIUL/c/no5mnVKsDEu9nE8pi1jTFKWaQ1Msd13 +VMnhg1daZVvyBZXUiq/U/v0eG+fJo6iUGJ431JCE3HzFFTpuNa7xUqNiL+s+mYkymL4 3ZZ+NT+ssmYt4t/WGI+zbkyNsF7vTzPsitVtA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; b=cV+8FOZ5M330bGx8MwrUpcxgWnTnrDJfYDul9CLS6dGY2c0JicQZDxHHGfzuGeIh21 p7z9O3xQ4s9KidzDBt0HfALvcRBftub3A9q4E9Q4yKV1ak1iZgrQDgFXHH7RPY/+NtOn EEyZfBuwYL6fmnRXZx5EjrN7Z4CvTNvcF4Jmg= Received: by 10.115.99.13 with SMTP id b13mr406846wam.14.1282020243431; Mon, 16 Aug 2010 21:44:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.115.98.19 with SMTP id a19ls4919085wam.1.p; Mon, 16 Aug 2010 21:44:03 -0700 (PDT) Received: by 10.114.67.8 with SMTP id p8mr1716156waa.0.1282020242961; Mon, 16 Aug 2010 21:44:02 -0700 (PDT) Received: by 10.114.67.8 with SMTP id p8mr1716155waa.0.1282020242938; Mon, 16 Aug 2010 21:44:02 -0700 (PDT) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by gmr-mx.google.com with ESMTP id k37si9490342wae.2.2010.08.16.21.44.02; Mon, 16 Aug 2010 21:44:02 -0700 (PDT) Received-SPF: pass (google.com: domain of vapier@gentoo.org designates 140.211.166.183 as permitted sender) client-ip=140.211.166.183; Received: from vapier-m.hsd1.ma.comcast.net. (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 5B7481B404D; Tue, 17 Aug 2010 04:44:02 +0000 (UTC) From: Mike Frysinger To: rtc-linux@googlegroups.com, Alessandro Zummo Cc: uclinux-dist-devel@blackfin.uclinux.org, Andrew Morton Subject: [rtc-linux] [PATCH 2/4] rtc-bfin: fix state restoration when resuming Date: Tue, 17 Aug 2010 00:44:07 -0400 Message-Id: <1282020249-8807-2-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.7.2 In-Reply-To: <1282020249-8807-1-git-send-email-vapier@gentoo.org> References: <1282020249-8807-1-git-send-email-vapier@gentoo.org> X-Original-Sender: vapier@gentoo.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of vapier@gentoo.org designates 140.211.166.183 as permitted sender) smtp.mail=vapier@gentoo.org Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Much (but not all) of the RTC state is kept in the RTC peripheral which has its own power domain. Periodically (1 HZ), that state is synced from one power domain to the other (peripheral->core). When we are resuming, we need to wait for the sync to occur so that we don't get a mismatch of reading undefined state in the rest of the driver. Further, once the externally maintained bits have been synced back into the core, we then need to restore the bits maintained in the core. In our particular case, that is just the write completion interrupt bit. If we don't do any of this, working with the RTC causes ~5 second delays from time to time after waking up due to the write completion interrupt never firing. Reported-by: Michael Dean Reported-by: Michael Hennerich Signed-off-by: Mike Frysinger --- drivers/rtc/rtc-bfin.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index 65facfb..d4fb82d 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c @@ -435,8 +435,17 @@ static int bfin_rtc_resume(struct platform_device *pdev) { if (device_may_wakeup(&pdev->dev)) disable_irq_wake(IRQ_RTC); - else - bfin_write_RTC_ISTAT(-1); + + /* + * Since only some of the RTC bits are maintained externally in the + * Vbat domain, we need to wait for the RTC MMRs to be synced into + * the core after waking up. This happens every RTC 1HZ. Once that + * has happened, we can go ahead and re-enable the important write + * complete interrupt event. + */ + while (!(bfin_read_RTC_ISTAT() & RTC_ISTAT_SEC)) + continue; + bfin_rtc_int_set(RTC_ISTAT_WRITE_COMPLETE); return 0; }