diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2009-06-17 19:26:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-18 16:03:43 -0400 |
commit | 97f902b7be4dd6ba03c6aa8d3400783ed687ebd1 (patch) | |
tree | 219df2ddebc1b6ab2acf071fdcc6d507e1e649a3 /drivers | |
parent | 33df2ee1bb59b8cd14e3a375d826a40de21f388c (diff) |
rtc: rtc-ds1307 add ds3231
Add ds3231 variant. For that, the BBSQI bit position was changed from a
simple define into a lookup-array as it differs. This also removes
writing to an unused bit in case of the ds1337.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 52e2427e5a95..8a6f9a9f9cb8 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -32,6 +32,7 @@ enum ds_type { | |||
32 | ds_1339, | 32 | ds_1339, |
33 | ds_1340, | 33 | ds_1340, |
34 | ds_1388, | 34 | ds_1388, |
35 | ds_3231, | ||
35 | m41t00, | 36 | m41t00, |
36 | rx_8025, | 37 | rx_8025, |
37 | // rs5c372 too? different address... | 38 | // rs5c372 too? different address... |
@@ -67,6 +68,7 @@ enum ds_type { | |||
67 | #define DS1337_REG_CONTROL 0x0e | 68 | #define DS1337_REG_CONTROL 0x0e |
68 | # define DS1337_BIT_nEOSC 0x80 | 69 | # define DS1337_BIT_nEOSC 0x80 |
69 | # define DS1339_BIT_BBSQI 0x20 | 70 | # define DS1339_BIT_BBSQI 0x20 |
71 | # define DS3231_BIT_BBSQW 0x40 /* same as BBSQI */ | ||
70 | # define DS1337_BIT_RS2 0x10 | 72 | # define DS1337_BIT_RS2 0x10 |
71 | # define DS1337_BIT_RS1 0x08 | 73 | # define DS1337_BIT_RS1 0x08 |
72 | # define DS1337_BIT_INTCN 0x04 | 74 | # define DS1337_BIT_INTCN 0x04 |
@@ -130,6 +132,9 @@ static const struct chip_desc chips[] = { | |||
130 | }, | 132 | }, |
131 | [ds_1340] = { | 133 | [ds_1340] = { |
132 | }, | 134 | }, |
135 | [ds_3231] = { | ||
136 | .alarm = 1, | ||
137 | }, | ||
133 | [m41t00] = { | 138 | [m41t00] = { |
134 | }, | 139 | }, |
135 | [rx_8025] = { | 140 | [rx_8025] = { |
@@ -142,6 +147,7 @@ static const struct i2c_device_id ds1307_id[] = { | |||
142 | { "ds1339", ds_1339 }, | 147 | { "ds1339", ds_1339 }, |
143 | { "ds1388", ds_1388 }, | 148 | { "ds1388", ds_1388 }, |
144 | { "ds1340", ds_1340 }, | 149 | { "ds1340", ds_1340 }, |
150 | { "ds3231", ds_3231 }, | ||
145 | { "m41t00", m41t00 }, | 151 | { "m41t00", m41t00 }, |
146 | { "rx8025", rx_8025 }, | 152 | { "rx8025", rx_8025 }, |
147 | { } | 153 | { } |
@@ -356,6 +362,7 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) | |||
356 | switch (ds1307->type) { | 362 | switch (ds1307->type) { |
357 | case ds_1337: | 363 | case ds_1337: |
358 | case ds_1339: | 364 | case ds_1339: |
365 | case ds_3231: | ||
359 | buf[DS1307_REG_MONTH] |= DS1337_BIT_CENTURY; | 366 | buf[DS1307_REG_MONTH] |= DS1337_BIT_CENTURY; |
360 | break; | 367 | break; |
361 | case ds_1340: | 368 | case ds_1340: |
@@ -628,6 +635,11 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
628 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 635 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
629 | int want_irq = false; | 636 | int want_irq = false; |
630 | unsigned char *buf; | 637 | unsigned char *buf; |
638 | static const int bbsqi_bitpos[] = { | ||
639 | [ds_1337] = 0, | ||
640 | [ds_1339] = DS1339_BIT_BBSQI, | ||
641 | [ds_3231] = DS3231_BIT_BBSQW, | ||
642 | }; | ||
631 | 643 | ||
632 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA) | 644 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA) |
633 | && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) | 645 | && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
@@ -654,6 +666,7 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
654 | switch (ds1307->type) { | 666 | switch (ds1307->type) { |
655 | case ds_1337: | 667 | case ds_1337: |
656 | case ds_1339: | 668 | case ds_1339: |
669 | case ds_3231: | ||
657 | /* has IRQ? */ | 670 | /* has IRQ? */ |
658 | if (ds1307->client->irq > 0 && chip->alarm) { | 671 | if (ds1307->client->irq > 0 && chip->alarm) { |
659 | INIT_WORK(&ds1307->work, ds1307_work); | 672 | INIT_WORK(&ds1307->work, ds1307_work); |
@@ -673,12 +686,12 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
673 | ds1307->regs[0] &= ~DS1337_BIT_nEOSC; | 686 | ds1307->regs[0] &= ~DS1337_BIT_nEOSC; |
674 | 687 | ||
675 | /* Using IRQ? Disable the square wave and both alarms. | 688 | /* Using IRQ? Disable the square wave and both alarms. |
676 | * For ds1339, be sure alarms can trigger when we're | 689 | * For some variants, be sure alarms can trigger when we're |
677 | * running on Vbackup (BBSQI); we assume ds1337 will | 690 | * running on Vbackup (BBSQI/BBSQW) |
678 | * ignore that bit | ||
679 | */ | 691 | */ |
680 | if (want_irq) { | 692 | if (want_irq) { |
681 | ds1307->regs[0] |= DS1337_BIT_INTCN | DS1339_BIT_BBSQI; | 693 | ds1307->regs[0] |= DS1337_BIT_INTCN |
694 | | bbsqi_bitpos[ds1307->type]; | ||
682 | ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); | 695 | ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); |
683 | } | 696 | } |
684 | 697 | ||
@@ -825,6 +838,7 @@ read_rtc: | |||
825 | case ds_1337: | 838 | case ds_1337: |
826 | case ds_1339: | 839 | case ds_1339: |
827 | case ds_1388: | 840 | case ds_1388: |
841 | case ds_3231: | ||
828 | break; | 842 | break; |
829 | } | 843 | } |
830 | 844 | ||