aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven A. Falco <sfalco@harris.com>2008-10-16 01:03:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:40 -0400
commitd3a126fcf9df7dc59f1cc553c2fb2e668264e86c (patch)
tree3e6359d3ad55bc0ecf585eed8ab0361f89889a92
parent03274572215a1dfc7c382ef9b18c562612b4d466 (diff)
rtc: rtc-m41t80.c: add support for the ST M41T65 RTC
Add support for M41T65 Real Time Clock chip. The main differences I see between the M41T65 and M41T80 are that: 1) The M41T65 watchdog timer has three bits controlling resolution (versus two for the M41T80). 2) There is no register 0x13 for controlling square-wave output. Signed-off-by: Steven A. Falco <sfalco@harris.com> Acked-by: Alessandro Zummo <a.zummo@towertech.it> Cc: "Maciej W. Rozycki" <macro@linux-mips.org> Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rtc/Kconfig14
-rw-r--r--drivers/rtc/rtc-m41t80.c43
2 files changed, 40 insertions, 17 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 1a9459615c39..f660ef3e5b29 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -220,22 +220,22 @@ config RTC_DRV_PCF8583
220 will be called rtc-pcf8583. 220 will be called rtc-pcf8583.
221 221
222config RTC_DRV_M41T80 222config RTC_DRV_M41T80
223 tristate "ST M41T80/81/82/83/84/85/87" 223 tristate "ST M41T65/M41T80/81/82/83/84/85/87"
224 help 224 help
225 If you say Y here you will get support for the 225 If you say Y here you will get support for the ST M41T60
226 ST M41T80 RTC chips series. Currently following chips are 226 and M41T80 RTC chips series. Currently, the following chips are
227 supported: M41T80, M41T81, M41T82, M41T83, M41ST84, M41ST85 227 supported: M41T65, M41T80, M41T81, M41T82, M41T83, M41ST84,
228 and M41ST87. 228 M41ST85, and M41ST87.
229 229
230 This driver can also be built as a module. If so, the module 230 This driver can also be built as a module. If so, the module
231 will be called rtc-m41t80. 231 will be called rtc-m41t80.
232 232
233config RTC_DRV_M41T80_WDT 233config RTC_DRV_M41T80_WDT
234 bool "ST M41T80 series RTC watchdog timer" 234 bool "ST M41T65/M41T80 series RTC watchdog timer"
235 depends on RTC_DRV_M41T80 235 depends on RTC_DRV_M41T80
236 help 236 help
237 If you say Y here you will get support for the 237 If you say Y here you will get support for the
238 watchdog timer in ST M41T80 RTC chips series. 238 watchdog timer in the ST M41T60 and M41T80 RTC chips series.
239 239
240config RTC_DRV_TWL92330 240config RTC_DRV_TWL92330
241 boolean "TI TWL92330/Menelaus" 241 boolean "TI TWL92330/Menelaus"
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 24bc1689fc74..470fb2d29545 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -56,21 +56,27 @@
56#define M41T80_ALHOUR_HT (1 << 6) /* HT: Halt Update Bit */ 56#define M41T80_ALHOUR_HT (1 << 6) /* HT: Halt Update Bit */
57#define M41T80_FLAGS_AF (1 << 6) /* AF: Alarm Flag Bit */ 57#define M41T80_FLAGS_AF (1 << 6) /* AF: Alarm Flag Bit */
58#define M41T80_FLAGS_BATT_LOW (1 << 4) /* BL: Battery Low Bit */ 58#define M41T80_FLAGS_BATT_LOW (1 << 4) /* BL: Battery Low Bit */
59#define M41T80_WATCHDOG_RB2 (1 << 7) /* RB: Watchdog resolution */
60#define M41T80_WATCHDOG_RB1 (1 << 1) /* RB: Watchdog resolution */
61#define M41T80_WATCHDOG_RB0 (1 << 0) /* RB: Watchdog resolution */
59 62
60#define M41T80_FEATURE_HT (1 << 0) 63#define M41T80_FEATURE_HT (1 << 0) /* Halt feature */
61#define M41T80_FEATURE_BL (1 << 1) 64#define M41T80_FEATURE_BL (1 << 1) /* Battery low indicator */
65#define M41T80_FEATURE_SQ (1 << 2) /* Squarewave feature */
66#define M41T80_FEATURE_WD (1 << 3) /* Extra watchdog resolution */
62 67
63#define DRV_VERSION "0.05" 68#define DRV_VERSION "0.05"
64 69
65static const struct i2c_device_id m41t80_id[] = { 70static const struct i2c_device_id m41t80_id[] = {
66 { "m41t80", 0 }, 71 { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD },
67 { "m41t81", M41T80_FEATURE_HT }, 72 { "m41t80", M41T80_FEATURE_SQ },
68 { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 73 { "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ},
69 { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 74 { "m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
70 { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 75 { "m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
71 { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 76 { "m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
72 { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 77 { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
73 { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL }, 78 { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
79 { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ },
74 { } 80 { }
75}; 81};
76MODULE_DEVICE_TABLE(i2c, m41t80_id); 82MODULE_DEVICE_TABLE(i2c, m41t80_id);
@@ -386,8 +392,12 @@ static ssize_t m41t80_sysfs_show_sqwfreq(struct device *dev,
386 struct device_attribute *attr, char *buf) 392 struct device_attribute *attr, char *buf)
387{ 393{
388 struct i2c_client *client = to_i2c_client(dev); 394 struct i2c_client *client = to_i2c_client(dev);
395 struct m41t80_data *clientdata = i2c_get_clientdata(client);
389 int val; 396 int val;
390 397
398 if (!(clientdata->features & M41T80_FEATURE_SQ))
399 return -EINVAL;
400
391 val = i2c_smbus_read_byte_data(client, M41T80_REG_SQW); 401 val = i2c_smbus_read_byte_data(client, M41T80_REG_SQW);
392 if (val < 0) 402 if (val < 0)
393 return -EIO; 403 return -EIO;
@@ -408,9 +418,13 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev,
408 const char *buf, size_t count) 418 const char *buf, size_t count)
409{ 419{
410 struct i2c_client *client = to_i2c_client(dev); 420 struct i2c_client *client = to_i2c_client(dev);
421 struct m41t80_data *clientdata = i2c_get_clientdata(client);
411 int almon, sqw; 422 int almon, sqw;
412 int val = simple_strtoul(buf, NULL, 0); 423 int val = simple_strtoul(buf, NULL, 0);
413 424
425 if (!(clientdata->features & M41T80_FEATURE_SQ))
426 return -EINVAL;
427
414 if (val) { 428 if (val) {
415 if (!is_power_of_2(val)) 429 if (!is_power_of_2(val))
416 return -EINVAL; 430 return -EINVAL;
@@ -499,6 +513,8 @@ static void wdt_ping(void)
499 .buf = i2c_data, 513 .buf = i2c_data,
500 }, 514 },
501 }; 515 };
516 struct m41t80_data *clientdata = i2c_get_clientdata(save_client);
517
502 i2c_data[0] = 0x09; /* watchdog register */ 518 i2c_data[0] = 0x09; /* watchdog register */
503 519
504 if (wdt_margin > 31) 520 if (wdt_margin > 31)
@@ -509,6 +525,13 @@ static void wdt_ping(void)
509 */ 525 */
510 i2c_data[1] = wdt_margin<<2 | 0x82; 526 i2c_data[1] = wdt_margin<<2 | 0x82;
511 527
528 /*
529 * M41T65 has three bits for watchdog resolution. Don't set bit 7, as
530 * that would be an invalid resolution.
531 */
532 if (clientdata->features & M41T80_FEATURE_WD)
533 i2c_data[1] &= ~M41T80_WATCHDOG_RB2;
534
512 i2c_transfer(save_client->adapter, msgs1, 1); 535 i2c_transfer(save_client->adapter, msgs1, 1);
513} 536}
514 537