From patchwork Wed Jan 14 22:53:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 5635661 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E6F709F6B5 for ; Wed, 14 Jan 2015 22:53:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 25B552017E for ; Wed, 14 Jan 2015 22:53:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 34219200DB for ; Wed, 14 Jan 2015 22:53:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YBWod-0005VV-Nf; Wed, 14 Jan 2015 22:53:31 +0000 Received: from mail.linuxfoundation.org ([140.211.169.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YBWob-0005Sc-ME for linux-rockchip@lists.infradead.org; Wed, 14 Jan 2015 22:53:30 +0000 Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.95]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EB7F6E; Wed, 14 Jan 2015 22:53:07 +0000 (UTC) Date: Wed, 14 Jan 2015 14:53:07 -0800 From: Andrew Morton To: Sonny Rao Subject: Re: [PATCH] RTC: RK808: fix the rtc time reading issue Message-Id: <20150114145307.380c86a83c65760a046382e4@linux-foundation.org> In-Reply-To: References: <1421203412-5159-1-git-send-email-zyw@rock-chips.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150114_145329_764431_88A72139 X-CRM114-Status: GOOD ( 17.38 ) X-Spam-Score: -2.3 (--) Cc: Alessandro Zummo , Heiko =?ISO-8859-1?Q?St=FCbner?= , rtc-linux@googlegroups.com, Doug Anderson , "linux-kernel@vger.kernel.org" , "open list:ARM/Rockchip SoC..." , Chris Zhong X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 14 Jan 2015 11:44:02 -0800 Sonny Rao wrote: > On Wed, Jan 14, 2015 at 10:36 AM, Doug Anderson wrote: > > Sonny, > > > >> Chris, it looks like you swapped the set and the clear of this bit, > >> and you're relying on the fact that the i2c transaction takes a > >> certain amount of time after the RTC_GET_TIME BIT is set. I'm not > >> sure how long it actually takes, but why not just put in a usleep() > >> for the minimum wait time? > > > > I think we are safe. > > > > At 400kHz (the max speed of this part) each bit can be transferred no > > faster than 2.5us. In order to do a valid i2c transaction we need to > > _at least_ write the address of the device and the data onto the bus, > > which is 16 bits. 16 * 2.5us = 40us. That's above the 31.25us > > > > Personally I think what Chris has is fine, with the comment. > > Ok, I'm fine with that if we're sure it's slow enough. Comment > explaining would certainly help. Thanks, all. I did this: --- a/drivers/rtc/rtc-rk808.c~rtc-rk808-fix-the-rtc-time-reading-issue-fix +++ a/drivers/rtc/rtc-rk808.c @@ -73,10 +73,11 @@ static int rk808_rtc_readtime(struct dev return ret; } - /* After we set the GET_TIME bit, the rtc time couldn't be read - * immediately, we should wait up to 31.25 us, about one cycle of + /* + * After we set the GET_TIME bit, the rtc time can't be read + * immediately. So we should wait up to 31.25 us, about one cycle of * 32khz. If we clear the GET_TIME bit here, the time of i2c transfer - * certainly more than 31.25us. + * certainly more than 31.25us: 16 * 2.5us at 400kHz bus frequency. */ ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG, BIT_RTC_CTRL_REG_RTC_GET_TIME,