diff options
-rw-r--r-- | Documentation/devicetree/bindings/i2c/trivial-devices.txt | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt index ad10fbe61562..3e0a34c88e07 100644 --- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt +++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt | |||
@@ -160,6 +160,7 @@ sii,s35390a 2-wire CMOS real-time clock | |||
160 | silabs,si7020 Relative Humidity and Temperature Sensors | 160 | silabs,si7020 Relative Humidity and Temperature Sensors |
161 | skyworks,sky81452 Skyworks SKY81452: Six-Channel White LED Driver with Touch Panel Bias Supply | 161 | skyworks,sky81452 Skyworks SKY81452: Six-Channel White LED Driver with Touch Panel Bias Supply |
162 | st,24c256 i2c serial eeprom (24cxx) | 162 | st,24c256 i2c serial eeprom (24cxx) |
163 | st,m41t0 Serial real-time clock (RTC) | ||
163 | st,m41t00 Serial real-time clock (RTC) | 164 | st,m41t00 Serial real-time clock (RTC) |
164 | st,m41t62 Serial real-time clock (RTC) with alarm | 165 | st,m41t62 Serial real-time clock (RTC) with alarm |
165 | st,m41t80 M41T80 - SERIAL ACCESS RTC WITH ALARMS | 166 | st,m41t80 M41T80 - SERIAL ACCESS RTC WITH ALARMS |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index f085b487bbe7..e29481391496 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -39,6 +39,7 @@ enum ds_type { | |||
39 | ds_1340, | 39 | ds_1340, |
40 | ds_1388, | 40 | ds_1388, |
41 | ds_3231, | 41 | ds_3231, |
42 | m41t0, | ||
42 | m41t00, | 43 | m41t00, |
43 | mcp794xx, | 44 | mcp794xx, |
44 | rx_8025, | 45 | rx_8025, |
@@ -53,6 +54,7 @@ enum ds_type { | |||
53 | # define DS1340_BIT_nEOSC 0x80 | 54 | # define DS1340_BIT_nEOSC 0x80 |
54 | # define MCP794XX_BIT_ST 0x80 | 55 | # define MCP794XX_BIT_ST 0x80 |
55 | #define DS1307_REG_MIN 0x01 /* 00-59 */ | 56 | #define DS1307_REG_MIN 0x01 /* 00-59 */ |
57 | # define M41T0_BIT_OF 0x80 | ||
56 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ | 58 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ |
57 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ | 59 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ |
58 | # define DS1307_BIT_PM 0x20 /* in REG_HOUR */ | 60 | # define DS1307_BIT_PM 0x20 /* in REG_HOUR */ |
@@ -183,6 +185,7 @@ static const struct i2c_device_id ds1307_id[] = { | |||
183 | { "ds1388", ds_1388 }, | 185 | { "ds1388", ds_1388 }, |
184 | { "ds1340", ds_1340 }, | 186 | { "ds1340", ds_1340 }, |
185 | { "ds3231", ds_3231 }, | 187 | { "ds3231", ds_3231 }, |
188 | { "m41t0", m41t0 }, | ||
186 | { "m41t00", m41t00 }, | 189 | { "m41t00", m41t00 }, |
187 | { "mcp7940x", mcp794xx }, | 190 | { "mcp7940x", mcp794xx }, |
188 | { "mcp7941x", mcp794xx }, | 191 | { "mcp7941x", mcp794xx }, |
@@ -261,6 +264,7 @@ static const struct acpi_device_id ds1307_acpi_ids[] = { | |||
261 | { .id = "DS1388", .driver_data = ds_1388 }, | 264 | { .id = "DS1388", .driver_data = ds_1388 }, |
262 | { .id = "DS1340", .driver_data = ds_1340 }, | 265 | { .id = "DS1340", .driver_data = ds_1340 }, |
263 | { .id = "DS3231", .driver_data = ds_3231 }, | 266 | { .id = "DS3231", .driver_data = ds_3231 }, |
267 | { .id = "M41T0", .driver_data = m41t0 }, | ||
264 | { .id = "M41T00", .driver_data = m41t00 }, | 268 | { .id = "M41T00", .driver_data = m41t00 }, |
265 | { .id = "MCP7940X", .driver_data = mcp794xx }, | 269 | { .id = "MCP7940X", .driver_data = mcp794xx }, |
266 | { .id = "MCP7941X", .driver_data = mcp794xx }, | 270 | { .id = "MCP7941X", .driver_data = mcp794xx }, |
@@ -456,6 +460,13 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) | |||
456 | 460 | ||
457 | dev_dbg(dev, "%s: %7ph\n", "read", ds1307->regs); | 461 | dev_dbg(dev, "%s: %7ph\n", "read", ds1307->regs); |
458 | 462 | ||
463 | /* if oscillator fail bit is set, no data can be trusted */ | ||
464 | if (ds1307->type == m41t0 && | ||
465 | ds1307->regs[DS1307_REG_MIN] & M41T0_BIT_OF) { | ||
466 | dev_warn_once(dev, "oscillator failed, set time!\n"); | ||
467 | return -EINVAL; | ||
468 | } | ||
469 | |||
459 | t->tm_sec = bcd2bin(ds1307->regs[DS1307_REG_SECS] & 0x7f); | 470 | t->tm_sec = bcd2bin(ds1307->regs[DS1307_REG_SECS] & 0x7f); |
460 | t->tm_min = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f); | 471 | t->tm_min = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f); |
461 | tmp = ds1307->regs[DS1307_REG_HOUR] & 0x3f; | 472 | tmp = ds1307->regs[DS1307_REG_HOUR] & 0x3f; |
@@ -1578,6 +1589,7 @@ read_rtc: | |||
1578 | tmp = ds1307->regs[DS1307_REG_SECS]; | 1589 | tmp = ds1307->regs[DS1307_REG_SECS]; |
1579 | switch (ds1307->type) { | 1590 | switch (ds1307->type) { |
1580 | case ds_1307: | 1591 | case ds_1307: |
1592 | case m41t0: | ||
1581 | case m41t00: | 1593 | case m41t00: |
1582 | /* clock halted? turn it on, so clock can tick. */ | 1594 | /* clock halted? turn it on, so clock can tick. */ |
1583 | if (tmp & DS1307_BIT_CH) { | 1595 | if (tmp & DS1307_BIT_CH) { |
@@ -1642,6 +1654,7 @@ read_rtc: | |||
1642 | tmp = ds1307->regs[DS1307_REG_HOUR]; | 1654 | tmp = ds1307->regs[DS1307_REG_HOUR]; |
1643 | switch (ds1307->type) { | 1655 | switch (ds1307->type) { |
1644 | case ds_1340: | 1656 | case ds_1340: |
1657 | case m41t0: | ||
1645 | case m41t00: | 1658 | case m41t00: |
1646 | /* | 1659 | /* |
1647 | * NOTE: ignores century bits; fix before deploying | 1660 | * NOTE: ignores century bits; fix before deploying |