diff options
-rw-r--r-- | drivers/rtc/Kconfig | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 18 |
2 files changed, 15 insertions, 7 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 09d5cd33a3f6..56002f7d26bd 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -225,11 +225,11 @@ config RTC_DRV_PCF8583 | |||
225 | will be called rtc-pcf8583. | 225 | will be called rtc-pcf8583. |
226 | 226 | ||
227 | config RTC_DRV_M41T80 | 227 | config RTC_DRV_M41T80 |
228 | tristate "ST M41T65/M41T80/81/82/83/84/85/87" | 228 | tristate "ST M41T62/65/M41T80/81/82/83/84/85/87" |
229 | help | 229 | help |
230 | If you say Y here you will get support for the ST M41T60 | 230 | If you say Y here you will get support for the ST M41T60 |
231 | and M41T80 RTC chips series. Currently, the following chips are | 231 | and M41T80 RTC chips series. Currently, the following chips are |
232 | supported: M41T65, M41T80, M41T81, M41T82, M41T83, M41ST84, | 232 | supported: M41T62, M41T65, M41T80, M41T81, M41T82, M41T83, M41ST84, |
233 | M41ST85, and M41ST87. | 233 | M41ST85, and M41ST87. |
234 | 234 | ||
235 | This driver can also be built as a module. If so, the module | 235 | This driver can also be built as a module. If so, the module |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 893f7dece239..60fe266f0f49 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -64,10 +64,12 @@ | |||
64 | #define M41T80_FEATURE_BL (1 << 1) /* Battery low indicator */ | 64 | #define M41T80_FEATURE_BL (1 << 1) /* Battery low indicator */ |
65 | #define M41T80_FEATURE_SQ (1 << 2) /* Squarewave feature */ | 65 | #define M41T80_FEATURE_SQ (1 << 2) /* Squarewave feature */ |
66 | #define M41T80_FEATURE_WD (1 << 3) /* Extra watchdog resolution */ | 66 | #define M41T80_FEATURE_WD (1 << 3) /* Extra watchdog resolution */ |
67 | #define M41T80_FEATURE_SQ_ALT (1 << 4) /* RSx bits are in reg 4 */ | ||
67 | 68 | ||
68 | #define DRV_VERSION "0.05" | 69 | #define DRV_VERSION "0.05" |
69 | 70 | ||
70 | static const struct i2c_device_id m41t80_id[] = { | 71 | static const struct i2c_device_id m41t80_id[] = { |
72 | { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, | ||
71 | { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, | 73 | { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, |
72 | { "m41t80", M41T80_FEATURE_SQ }, | 74 | { "m41t80", M41T80_FEATURE_SQ }, |
73 | { "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ}, | 75 | { "m41t81", M41T80_FEATURE_HT | M41T80_FEATURE_SQ}, |
@@ -393,12 +395,15 @@ static ssize_t m41t80_sysfs_show_sqwfreq(struct device *dev, | |||
393 | { | 395 | { |
394 | struct i2c_client *client = to_i2c_client(dev); | 396 | struct i2c_client *client = to_i2c_client(dev); |
395 | struct m41t80_data *clientdata = i2c_get_clientdata(client); | 397 | struct m41t80_data *clientdata = i2c_get_clientdata(client); |
396 | int val; | 398 | int val, reg_sqw; |
397 | 399 | ||
398 | if (!(clientdata->features & M41T80_FEATURE_SQ)) | 400 | if (!(clientdata->features & M41T80_FEATURE_SQ)) |
399 | return -EINVAL; | 401 | return -EINVAL; |
400 | 402 | ||
401 | val = i2c_smbus_read_byte_data(client, M41T80_REG_SQW); | 403 | reg_sqw = M41T80_REG_SQW; |
404 | if (clientdata->features & M41T80_FEATURE_SQ_ALT) | ||
405 | reg_sqw = M41T80_REG_WDAY; | ||
406 | val = i2c_smbus_read_byte_data(client, reg_sqw); | ||
402 | if (val < 0) | 407 | if (val < 0) |
403 | return -EIO; | 408 | return -EIO; |
404 | val = (val >> 4) & 0xf; | 409 | val = (val >> 4) & 0xf; |
@@ -419,7 +424,7 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev, | |||
419 | { | 424 | { |
420 | struct i2c_client *client = to_i2c_client(dev); | 425 | struct i2c_client *client = to_i2c_client(dev); |
421 | struct m41t80_data *clientdata = i2c_get_clientdata(client); | 426 | struct m41t80_data *clientdata = i2c_get_clientdata(client); |
422 | int almon, sqw; | 427 | int almon, sqw, reg_sqw; |
423 | int val = simple_strtoul(buf, NULL, 0); | 428 | int val = simple_strtoul(buf, NULL, 0); |
424 | 429 | ||
425 | if (!(clientdata->features & M41T80_FEATURE_SQ)) | 430 | if (!(clientdata->features & M41T80_FEATURE_SQ)) |
@@ -440,13 +445,16 @@ static ssize_t m41t80_sysfs_set_sqwfreq(struct device *dev, | |||
440 | almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); | 445 | almon = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); |
441 | if (almon < 0) | 446 | if (almon < 0) |
442 | return -EIO; | 447 | return -EIO; |
443 | sqw = i2c_smbus_read_byte_data(client, M41T80_REG_SQW); | 448 | reg_sqw = M41T80_REG_SQW; |
449 | if (clientdata->features & M41T80_FEATURE_SQ_ALT) | ||
450 | reg_sqw = M41T80_REG_WDAY; | ||
451 | sqw = i2c_smbus_read_byte_data(client, reg_sqw); | ||
444 | if (sqw < 0) | 452 | if (sqw < 0) |
445 | return -EIO; | 453 | return -EIO; |
446 | sqw = (sqw & 0x0f) | (val << 4); | 454 | sqw = (sqw & 0x0f) | (val << 4); |
447 | if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, | 455 | if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, |
448 | almon & ~M41T80_ALMON_SQWE) < 0 || | 456 | almon & ~M41T80_ALMON_SQWE) < 0 || |
449 | i2c_smbus_write_byte_data(client, M41T80_REG_SQW, sqw) < 0) | 457 | i2c_smbus_write_byte_data(client, reg_sqw, sqw) < 0) |
450 | return -EIO; | 458 | return -EIO; |
451 | if (val && i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, | 459 | if (val && i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, |
452 | almon | M41T80_ALMON_SQWE) < 0) | 460 | almon | M41T80_ALMON_SQWE) < 0) |