diff options
author | Joakim Tjernlund <Joakim.Tjernlund@transmode.se> | 2009-06-17 19:26:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-18 16:03:43 -0400 |
commit | 33df2ee1bb59b8cd14e3a375d826a40de21f388c (patch) | |
tree | 942037f5f217a92b4c384d3d28b464edf1fdc8f5 | |
parent | 3a72970054e72e6d3b5cdb7364a079f8ecae62af (diff) |
rtc: rtc-ds1307 add ds1388
Extend the ds1307 driver to support ds1388 too.
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
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/rtc-ds1307.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 2c4a65302a9d..52e2427e5a95 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -31,6 +31,7 @@ enum ds_type { | |||
31 | ds_1338, | 31 | ds_1338, |
32 | ds_1339, | 32 | ds_1339, |
33 | ds_1340, | 33 | ds_1340, |
34 | ds_1388, | ||
34 | m41t00, | 35 | m41t00, |
35 | rx_8025, | 36 | rx_8025, |
36 | // rs5c372 too? different address... | 37 | // rs5c372 too? different address... |
@@ -94,6 +95,7 @@ enum ds_type { | |||
94 | 95 | ||
95 | 96 | ||
96 | struct ds1307 { | 97 | struct ds1307 { |
98 | u8 offset; /* register's offset */ | ||
97 | u8 regs[11]; | 99 | u8 regs[11]; |
98 | enum ds_type type; | 100 | enum ds_type type; |
99 | unsigned long flags; | 101 | unsigned long flags; |
@@ -138,6 +140,7 @@ static const struct i2c_device_id ds1307_id[] = { | |||
138 | { "ds1337", ds_1337 }, | 140 | { "ds1337", ds_1337 }, |
139 | { "ds1338", ds_1338 }, | 141 | { "ds1338", ds_1338 }, |
140 | { "ds1339", ds_1339 }, | 142 | { "ds1339", ds_1339 }, |
143 | { "ds1388", ds_1388 }, | ||
141 | { "ds1340", ds_1340 }, | 144 | { "ds1340", ds_1340 }, |
142 | { "m41t00", m41t00 }, | 145 | { "m41t00", m41t00 }, |
143 | { "rx8025", rx_8025 }, | 146 | { "rx8025", rx_8025 }, |
@@ -291,7 +294,7 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) | |||
291 | 294 | ||
292 | /* read the RTC date and time registers all at once */ | 295 | /* read the RTC date and time registers all at once */ |
293 | tmp = ds1307->read_block_data(ds1307->client, | 296 | tmp = ds1307->read_block_data(ds1307->client, |
294 | DS1307_REG_SECS, 7, ds1307->regs); | 297 | ds1307->offset, 7, ds1307->regs); |
295 | if (tmp != 7) { | 298 | if (tmp != 7) { |
296 | dev_err(dev, "%s error %d\n", "read", tmp); | 299 | dev_err(dev, "%s error %d\n", "read", tmp); |
297 | return -EIO; | 300 | return -EIO; |
@@ -367,7 +370,8 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t) | |||
367 | "write", buf[0], buf[1], buf[2], buf[3], | 370 | "write", buf[0], buf[1], buf[2], buf[3], |
368 | buf[4], buf[5], buf[6]); | 371 | buf[4], buf[5], buf[6]); |
369 | 372 | ||
370 | result = ds1307->write_block_data(ds1307->client, 0, 7, buf); | 373 | result = ds1307->write_block_data(ds1307->client, |
374 | ds1307->offset, 7, buf); | ||
371 | if (result < 0) { | 375 | if (result < 0) { |
372 | dev_err(dev, "%s error %d\n", "write", result); | 376 | dev_err(dev, "%s error %d\n", "write", result); |
373 | return result; | 377 | return result; |
@@ -632,9 +636,12 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
632 | if (!(ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL))) | 636 | if (!(ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL))) |
633 | return -ENOMEM; | 637 | return -ENOMEM; |
634 | 638 | ||
635 | ds1307->client = client; | ||
636 | i2c_set_clientdata(client, ds1307); | 639 | i2c_set_clientdata(client, ds1307); |
637 | ds1307->type = id->driver_data; | 640 | |
641 | ds1307->client = client; | ||
642 | ds1307->type = id->driver_data; | ||
643 | ds1307->offset = 0; | ||
644 | |||
638 | buf = ds1307->regs; | 645 | buf = ds1307->regs; |
639 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { | 646 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { |
640 | ds1307->read_block_data = i2c_smbus_read_i2c_block_data; | 647 | ds1307->read_block_data = i2c_smbus_read_i2c_block_data; |
@@ -751,6 +758,9 @@ static int __devinit ds1307_probe(struct i2c_client *client, | |||
751 | hour); | 758 | hour); |
752 | } | 759 | } |
753 | break; | 760 | break; |
761 | case ds_1388: | ||
762 | ds1307->offset = 1; /* Seconds starts at 1 */ | ||
763 | break; | ||
754 | default: | 764 | default: |
755 | break; | 765 | break; |
756 | } | 766 | } |
@@ -814,6 +824,7 @@ read_rtc: | |||
814 | case rx_8025: | 824 | case rx_8025: |
815 | case ds_1337: | 825 | case ds_1337: |
816 | case ds_1339: | 826 | case ds_1339: |
827 | case ds_1388: | ||
817 | break; | 828 | break; |
818 | } | 829 | } |
819 | 830 | ||