diff options
Diffstat (limited to 'drivers/rtc/rtc-ds1307.c')
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index b2005b44e4f7..62b0763b7b9a 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -34,6 +34,7 @@ enum ds_type { | |||
34 | ds_1388, | 34 | ds_1388, |
35 | ds_3231, | 35 | ds_3231, |
36 | m41t00, | 36 | m41t00, |
37 | mcp7941x, | ||
37 | rx_8025, | 38 | rx_8025, |
38 | // rs5c372 too? different address... | 39 | // rs5c372 too? different address... |
39 | }; | 40 | }; |
@@ -43,6 +44,7 @@ enum ds_type { | |||
43 | #define DS1307_REG_SECS 0x00 /* 00-59 */ | 44 | #define DS1307_REG_SECS 0x00 /* 00-59 */ |
44 | # define DS1307_BIT_CH 0x80 | 45 | # define DS1307_BIT_CH 0x80 |
45 | # define DS1340_BIT_nEOSC 0x80 | 46 | # define DS1340_BIT_nEOSC 0x80 |
47 | # define MCP7941X_BIT_ST 0x80 | ||
46 | #define DS1307_REG_MIN 0x01 /* 00-59 */ | 48 | #define DS1307_REG_MIN 0x01 /* 00-59 */ |
47 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ | 49 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ |
48 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ | 50 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ |
@@ -50,6 +52,7 @@ enum ds_type { | |||
50 | # define DS1340_BIT_CENTURY_EN 0x80 /* in REG_HOUR */ | 52 | # define DS1340_BIT_CENTURY_EN 0x80 /* in REG_HOUR */ |
51 | # define DS1340_BIT_CENTURY 0x40 /* in REG_HOUR */ | 53 | # define DS1340_BIT_CENTURY 0x40 /* in REG_HOUR */ |
52 | #define DS1307_REG_WDAY 0x03 /* 01-07 */ | 54 | #define DS1307_REG_WDAY 0x03 /* 01-07 */ |
55 | # define MCP7941X_BIT_VBATEN 0x08 | ||
53 | #define DS1307_REG_MDAY 0x04 /* 01-31 */ | 56 | #define DS1307_REG_MDAY 0x04 /* 01-31 */ |
54 | #define DS1307_REG_MONTH 0x05 /* 01-12 */ | 57 | #define DS1307_REG_MONTH 0x05 /* 01-12 */ |
55 | # define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ | 58 | # define DS1337_BIT_CENTURY 0x80 /* in REG_MONTH */ |
@@ -137,6 +140,8 @@ static const struct chip_desc chips[] = { | |||
137 | }, | 140 | }, |
138 | [m41t00] = { | 141 | [m41t00] = { |
139 | }, | 142 | }, |
143 | [mcp7941x] = { | ||
144 | }, | ||
140 | [rx_8025] = { | 145 | [rx_8025] = { |
141 | }, }; | 146 | }, }; |
142 | 147 | ||
@@ -149,6 +154,7 @@ static const struct i2c_device_id ds1307_id[] = { | |||
149 | { "ds1340", ds_1340 }, | 154 | { "ds1340", ds_1340 }, |
150 | { "ds3231", ds_3231 }, | 155 | { "ds3231", ds_3231 }, |
151 | { "m41t00", m41t00 }, | 156 | { "m41t00", m41t00 }, |
157 | { "mcp7941x", mcp7941x }, | ||
152 | { "pt7c4338", ds_1307 }, | 158 | { "pt7c4338", ds_1307 }, |
153 | { "rx8025", rx_8025 }, | 159 | { "rx8025", rx_8025 }, |
154 | { } | 160 | { } |
@@ -365,6 +371,10 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) | |||
365 | buf[DS1307_REG_HOUR] |= DS1340_BIT_CENTURY_EN | 371 | buf[DS1307_REG_HOUR] |= DS1340_BIT_CENTURY_EN |
366 | | DS1340_BIT_CENTURY; | 372 | | DS1340_BIT_CENTURY; |
367 | break; | 373 | break; |
374 | case mcp7941x: | ||
375 | buf[DS1307_REG_SECS] |= MCP7941X_BIT_ST; | ||
376 | buf[DS1307_REG_WDAY] |= MCP7941X_BIT_VBATEN; | ||
377 | break; | ||
368 | default: | 378 | default: |
369 | break; | 379 | break; |
370 | } | 380 | } |
@@ -809,6 +819,23 @@ read_rtc: | |||
809 | dev_warn(&client->dev, "SET TIME!\n"); | 819 | dev_warn(&client->dev, "SET TIME!\n"); |
810 | } | 820 | } |
811 | break; | 821 | break; |
822 | case mcp7941x: | ||
823 | /* make sure that the backup battery is enabled */ | ||
824 | if (!(ds1307->regs[DS1307_REG_WDAY] & MCP7941X_BIT_VBATEN)) { | ||
825 | i2c_smbus_write_byte_data(client, DS1307_REG_WDAY, | ||
826 | ds1307->regs[DS1307_REG_WDAY] | ||
827 | | MCP7941X_BIT_VBATEN); | ||
828 | } | ||
829 | |||
830 | /* clock halted? turn it on, so clock can tick. */ | ||
831 | if (!(tmp & MCP7941X_BIT_ST)) { | ||
832 | i2c_smbus_write_byte_data(client, DS1307_REG_SECS, | ||
833 | MCP7941X_BIT_ST); | ||
834 | dev_warn(&client->dev, "SET TIME!\n"); | ||
835 | goto read_rtc; | ||
836 | } | ||
837 | |||
838 | break; | ||
812 | case rx_8025: | 839 | case rx_8025: |
813 | case ds_1337: | 840 | case ds_1337: |
814 | case ds_1339: | 841 | case ds_1339: |