rtc: spear: fix spear_rtc_read_time
authorAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 9 Mar 2022 16:22:52 +0000 (17:22 +0100)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Wed, 23 Mar 2022 18:58:40 +0000 (19:58 +0100)
The reference manual doesn't specify whether the registers are latched and
they probably aren't, ensure the read time and date are consistent.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20220309162301.61679-21-alexandre.belloni@bootlin.com
drivers/rtc/rtc-spear.c

index c395af3..d4777b0 100644 (file)
@@ -204,8 +204,10 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm)
        /* we don't report wday/yday/isdst ... */
        rtc_wait_not_busy(config);
 
-       time = readl(config->ioaddr + TIME_REG);
-       date = readl(config->ioaddr + DATE_REG);
+       do {
+               time = readl(config->ioaddr + TIME_REG);
+               date = readl(config->ioaddr + DATE_REG);
+       } while (time == readl(config->ioaddr + TIME_REG));
        tm->tm_sec = (time >> SECOND_SHIFT) & SECOND_MASK;
        tm->tm_min = (time >> MINUTE_SHIFT) & MIN_MASK;
        tm->tm_hour = (time >> HOUR_SHIFT) & HOUR_MASK;