Commit 97f902b7be4dd6ba03c6aa8d3400783ed687ebd1
Committed by
Linus Torvalds
1 parent
33df2ee1bb
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 18 additions and 4 deletions Side-by-side Diff
drivers/rtc/rtc-ds1307.c
... | ... | @@ -32,6 +32,7 @@ |
32 | 32 | ds_1339, |
33 | 33 | ds_1340, |
34 | 34 | ds_1388, |
35 | + ds_3231, | |
35 | 36 | m41t00, |
36 | 37 | rx_8025, |
37 | 38 | // rs5c372 too? different address... |
... | ... | @@ -67,6 +68,7 @@ |
67 | 68 | #define DS1337_REG_CONTROL 0x0e |
68 | 69 | # define DS1337_BIT_nEOSC 0x80 |
69 | 70 | # define DS1339_BIT_BBSQI 0x20 |
71 | +# define DS3231_BIT_BBSQW 0x40 /* same as BBSQI */ | |
70 | 72 | # define DS1337_BIT_RS2 0x10 |
71 | 73 | # define DS1337_BIT_RS1 0x08 |
72 | 74 | # define DS1337_BIT_INTCN 0x04 |
... | ... | @@ -130,6 +132,9 @@ |
130 | 132 | }, |
131 | 133 | [ds_1340] = { |
132 | 134 | }, |
135 | +[ds_3231] = { | |
136 | + .alarm = 1, | |
137 | +}, | |
133 | 138 | [m41t00] = { |
134 | 139 | }, |
135 | 140 | [rx_8025] = { |
... | ... | @@ -142,6 +147,7 @@ |
142 | 147 | { "ds1339", ds_1339 }, |
143 | 148 | { "ds1388", ds_1388 }, |
144 | 149 | { "ds1340", ds_1340 }, |
150 | + { "ds3231", ds_3231 }, | |
145 | 151 | { "m41t00", m41t00 }, |
146 | 152 | { "rx8025", rx_8025 }, |
147 | 153 | { } |
... | ... | @@ -356,6 +362,7 @@ |
356 | 362 | switch (ds1307->type) { |
357 | 363 | case ds_1337: |
358 | 364 | case ds_1339: |
365 | + case ds_3231: | |
359 | 366 | buf[DS1307_REG_MONTH] |= DS1337_BIT_CENTURY; |
360 | 367 | break; |
361 | 368 | case ds_1340: |
... | ... | @@ -628,6 +635,11 @@ |
628 | 635 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
629 | 636 | int want_irq = false; |
630 | 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 | 644 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA) |
633 | 645 | && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) |
... | ... | @@ -654,6 +666,7 @@ |
654 | 666 | switch (ds1307->type) { |
655 | 667 | case ds_1337: |
656 | 668 | case ds_1339: |
669 | + case ds_3231: | |
657 | 670 | /* has IRQ? */ |
658 | 671 | if (ds1307->client->irq > 0 && chip->alarm) { |
659 | 672 | INIT_WORK(&ds1307->work, ds1307_work); |
660 | 673 | |
... | ... | @@ -673,12 +686,12 @@ |
673 | 686 | ds1307->regs[0] &= ~DS1337_BIT_nEOSC; |
674 | 687 | |
675 | 688 | /* Using IRQ? Disable the square wave and both alarms. |
676 | - * For ds1339, be sure alarms can trigger when we're | |
677 | - * running on Vbackup (BBSQI); we assume ds1337 will | |
678 | - * ignore that bit | |
689 | + * For some variants, be sure alarms can trigger when we're | |
690 | + * running on Vbackup (BBSQI/BBSQW) | |
679 | 691 | */ |
680 | 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 | 695 | ds1307->regs[0] &= ~(DS1337_BIT_A2IE | DS1337_BIT_A1IE); |
683 | 696 | } |
684 | 697 | |
... | ... | @@ -825,6 +838,7 @@ |
825 | 838 | case ds_1337: |
826 | 839 | case ds_1339: |
827 | 840 | case ds_1388: |
841 | + case ds_3231: | |
828 | 842 | break; |
829 | 843 | } |
830 | 844 |