]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
rtc: ds1307: Handle oscillator stop flag set on ds1339 chip
authorRonan Dalton <ronan.dalton@alliedtelesis.co.nz>
Tue, 5 May 2026 04:25:31 +0000 (16:25 +1200)
committerTom Rini <trini@konsulko.com>
Thu, 14 May 2026 21:40:52 +0000 (15:40 -0600)
Currently the oscillator stop flag (OSF) bit is never checked or cleared
on the DS1339 RTC chip.

On getting the time from the RTC, check if the OSF bit is set, log a
warning, and clear the flag. This matches the behavior of the DS1337
chip.

Note that the `date` command always reads from the RTC even when
setting or resetting the date, so the OSF flag is cleared in those cases
as well.

Signed-off-by: Ronan Dalton <ronan.dalton@alliedtelesis.co.nz>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Francesco Dolcini <francesco.dolcini@toradex.com>
Cc: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Cc: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/rtc/ds1307.c

index 34d8f8c5276b687ed175484a4e16d526203a5f0f..4176ab3701e417e171211655bb83f480c20bc51e 100644 (file)
@@ -116,9 +116,9 @@ static int ds1307_rtc_get(struct udevice *dev, struct rtc_time *tm)
        if (ret < 0)
                return ret;
 
-       if (type == ds_1337 || type == ds_1340) {
-               uint reg = (type == ds_1337) ? DS1337_STAT_REG_ADDR :
-                                              DS1340_STAT_REG_ADDR;
+       if (type == ds_1337 || type == ds_1339 || type == ds_1340) {
+               uint reg = (type == ds_1340) ? DS1340_STAT_REG_ADDR :
+                                              DS1337_STAT_REG_ADDR;
                int status = dm_i2c_reg_read(dev, reg);
 
                if (status >= 0 && (status & RTC_STAT_BIT_OSF)) {