]> Git Repo - linux.git/commitdiff
rtc: ds1307: Detect oscillator fail on mcp794xx
authorCsókás, Bence <[email protected]>
Tue, 11 Jun 2024 07:24:08 +0000 (09:24 +0200)
committerAlexandre Belloni <[email protected]>
Sat, 6 Jul 2024 22:39:15 +0000 (00:39 +0200)
This patch enables the detection of the oscillator failure on mcp794xx chips.

Co-developed-by: Szentendrei, Tamás <[email protected]>
Signed-off-by: Szentendrei, Tamás <[email protected]>
Signed-off-by: Csókás, Bence <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexandre Belloni <[email protected]>
drivers/rtc/rtc-ds1307.c

index 506b7d1c23970169d891bd8c4ac4cd8cde8dc3a3..bdb7b201a1605e345690f61b522a6c1af09e194f 100644 (file)
@@ -65,6 +65,7 @@ enum ds_type {
 #      define DS1340_BIT_CENTURY_EN    0x80    /* in REG_HOUR */
 #      define DS1340_BIT_CENTURY       0x40    /* in REG_HOUR */
 #define DS1307_REG_WDAY                0x03    /* 01-07 */
+#      define MCP794XX_BIT_OSCRUN      BIT(5)
 #      define MCP794XX_BIT_VBATEN      0x08
 #define DS1307_REG_MDAY                0x04    /* 01-31 */
 #define DS1307_REG_MONTH       0x05    /* 01-12 */
@@ -242,6 +243,10 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
            regs[DS1307_REG_MIN] & M41T0_BIT_OF) {
                dev_warn_once(dev, "oscillator failed, set time!\n");
                return -EINVAL;
+       } else if (ds1307->type == mcp794xx &&
+           !(regs[DS1307_REG_WDAY] & MCP794XX_BIT_OSCRUN)) {
+               dev_warn_once(dev, "oscillator failed, set time!\n");
+               return -EINVAL;
        }
 
        tmp = regs[DS1307_REG_SECS];
This page took 0.069879 seconds and 4 git commands to generate.