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: 429131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-ig0-x238.google.com (mail-ig0-x238.google.com [IPv6:2607:f8b0:4001:c05::238]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5BD20140161 for ; Thu, 15 Jan 2015 09:53:11 +1100 (AEDT) Received: by mail-ig0-f184.google.com with SMTP id b16sf1309903igk.1 for ; Wed, 14 Jan 2015 14:53:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type: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; bh=kFHnd8MB5IbkGu1wRg9DugrdIOFQI2RgcElVzSeWX+8=; b=nvG6Wxnduw8/OTD7PzBxOpTIomjaKw9ISXtlICs7cbZC6A1r56S1twYJXVomD3Efkv xJor95DQ7JV/xAp3KJ8cjGj9Zn8igeeEis4ZtyxAxf32JU60wN8/cytYi59V2ETfv3NT DVjlySAJ6H3rYwCcHqsimnNrjSGUeeYhh3B63w2JmtgpPEVfDgo9YeViJLg7fjfZ7yS9 hhh2b2gvrgTW+AUnXjoj8nFFVoIUZgx3vi6FPZSqvVdGapK77ntxX3neZYmTZIfPFOby aAFxdDhErR1FrJZbZLfyuXml7rIfZSlLRBfHKxeeSgyQj+deU4jbkgRdYKwl6C4wevXJ y2fw== X-Received: by 10.50.7.100 with SMTP id i4mr135197iga.11.1421275989497; Wed, 14 Jan 2015 14:53:09 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.28.8 with SMTP id x8ls4458igg.11.gmail; Wed, 14 Jan 2015 14:53:09 -0800 (PST) X-Received: by 10.70.13.161 with SMTP id i1mr5254501pdc.3.1421275989137; Wed, 14 Jan 2015 14:53:09 -0800 (PST) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by gmr-mx.google.com with ESMTPS id u27si956517yhu.4.2015.01.14.14.53.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jan 2015 14:53:09 -0800 (PST) Received-SPF: pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; 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 Cc: Doug Anderson , Chris Zhong , Heiko =?ISO-8859-1?Q?St=FCbner?= , "open list:ARM/Rockchip SoC..." , Alessandro Zummo , rtc-linux@googlegroups.com, "linux-kernel@vger.kernel.org" Subject: [rtc-linux] 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-Original-Sender: akpm@linux-foundation.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.12 as permitted sender) smtp.mail=akpm@linux-foundation.org Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , 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,