Skip to content

Commit 35a34f0

Browse files
Csókás, Bencealexandrebelloni
authored andcommitted
rtc: ds1307: Detect oscillator fail on mcp794xx
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]>
1 parent 43696b3 commit 35a34f0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/rtc/rtc-ds1307.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ enum ds_type {
6565
# define DS1340_BIT_CENTURY_EN 0x80 /* in REG_HOUR */
6666
# define DS1340_BIT_CENTURY 0x40 /* in REG_HOUR */
6767
#define DS1307_REG_WDAY 0x03 /* 01-07 */
68+
# define MCP794XX_BIT_OSCRUN BIT(5)
6869
# define MCP794XX_BIT_VBATEN 0x08
6970
#define DS1307_REG_MDAY 0x04 /* 01-31 */
7071
#define DS1307_REG_MONTH 0x05 /* 01-12 */
@@ -242,6 +243,10 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
242243
regs[DS1307_REG_MIN] & M41T0_BIT_OF) {
243244
dev_warn_once(dev, "oscillator failed, set time!\n");
244245
return -EINVAL;
246+
} else if (ds1307->type == mcp794xx &&
247+
!(regs[DS1307_REG_WDAY] & MCP794XX_BIT_OSCRUN)) {
248+
dev_warn_once(dev, "oscillator failed, set time!\n");
249+
return -EINVAL;
245250
}
246251

247252
tmp = regs[DS1307_REG_SECS];

0 commit comments

Comments
 (0)