From: Chris Zhong <zyw@rock-chips.com>
To: akpm@linux-foundation.org
Cc: dianders@chromium.org, heiko@sntech.de,
linux-rockchip@lists.infradead.org,
Chris Zhong <zyw@rock-chips.com>,
Alessandro Zummo <a.zummo@towertech.it>,
rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org
Subject: [PATCH] RTC: RK808: fix the rtc time reading issue
Date: Wed, 14 Jan 2015 10:43:32 +0800 [thread overview]
Message-ID: <1421203412-5159-1-git-send-email-zyw@rock-chips.com> (raw)
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 32khz. Otherwise reading
RTC time will return a old time. If clear the GET_TIME bit after setting,
the time of i2c transfer certainly more than 31.25us.
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
---
drivers/rtc/rtc-rk808.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-rk808.c b/drivers/rtc/rtc-rk808.c
index df42257..8dae322 100644
--- a/drivers/rtc/rtc-rk808.c
+++ b/drivers/rtc/rtc-rk808.c
@@ -67,15 +67,20 @@ static int rk808_rtc_readtime(struct device *dev, struct rtc_time *tm)
/* Force an update of the shadowed registers right now */
ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,
BIT_RTC_CTRL_REG_RTC_GET_TIME,
- 0);
+ BIT_RTC_CTRL_REG_RTC_GET_TIME);
if (ret) {
dev_err(dev, "Failed to update bits rtc_ctrl: %d\n", ret);
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
+ * 32khz. If we clear the GET_TIME bit here, the time of i2c transfer
+ * certainly more than 31.25us.
+ */
ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,
BIT_RTC_CTRL_REG_RTC_GET_TIME,
- BIT_RTC_CTRL_REG_RTC_GET_TIME);
+ 0);
if (ret) {
dev_err(dev, "Failed to update bits rtc_ctrl: %d\n", ret);
return ret;
--
1.9.1
next reply other threads:[~2015-01-14 2:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-14 2:43 Chris Zhong [this message]
2015-01-14 18:00 ` Sonny Rao
2015-01-14 18:36 ` Doug Anderson
2015-01-14 19:44 ` Sonny Rao
2015-01-14 22:53 ` Andrew Morton
2015-01-14 22:56 ` Doug Anderson
2015-01-14 18:39 ` Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1421203412-5159-1-git-send-email-zyw@rock-chips.com \
--to=zyw@rock-chips.com \
--cc=a.zummo@towertech.it \
--cc=akpm@linux-foundation.org \
--cc=dianders@chromium.org \
--cc=heiko@sntech.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=rtc-linux@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®