From 2e2c97674d89d72abf84f05098d82dbc3776146d Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Fri, 23 Dec 2016 15:05:11 +0800 Subject: [PATCH] rk3288: rtc-rk808: fix rtc time reading issue After we set the GET_TIME bit, the rtc time can'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. BUG=chrome-os-partner:61078 BRANCH=veyron TEST=Build and Boot Change-Id: I6ec07fc6c4d6d8b27b12031423b86b8ab15da6f6 Signed-off-by: Jeffy Chen Reviewed-on: https://chromium-review.googlesource.com/423272 Reviewed-by: Julius Werner --- src/soc/rockchip/rk3288/rk808.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/soc/rockchip/rk3288/rk808.c b/src/soc/rockchip/rk3288/rk808.c index b922d81c77..d8d503f71c 100644 --- a/src/soc/rockchip/rk3288/rk808.c +++ b/src/soc/rockchip/rk3288/rk808.c @@ -185,6 +185,12 @@ int rtc_get(struct rtc_time *time) rk808_clrsetbits(RTC_CTRL, RTC_CTRL_GET_TIME, 0); rk808_clrsetbits(RTC_CTRL, 0, RTC_CTRL_GET_TIME | RTC_CTRL_RTC_READSEL); + /* + * After we set the GET_TIME bit, the rtc time can't be read + * immediately. So we should wait up to 31.25 us. + */ + udelay(32); + ret |= rk808_read(RTC_SECOND, &value); time->sec = bcd2bin(value & 0x7f);