diff options
author | frederic Rodo <f.rodo@til-technologies.fr> | 2008-02-06 04:38:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:14 -0500 |
commit | fcd8db002f784706e9aa190d0b6350f868e61c32 (patch) | |
tree | 7d70a4ee57996bcf03acf539acfa5638843fa43d /drivers/rtc | |
parent | 75b6102257874a4ea796af686de2f72cfa0452f9 (diff) |
rtc ds1307: ds_1340 change init
For DS140, clear the oscillator fault flag as needed.
Signed-off-by: Frederic RODO <f.rodo@til-technologies.fr>
[ And remove some "sparse" warnings. ]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index bc1c7fe94ad3..f389a28720d2 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -256,7 +256,7 @@ ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr, | |||
256 | struct i2c_msg msg[2]; | 256 | struct i2c_msg msg[2]; |
257 | int result; | 257 | int result; |
258 | 258 | ||
259 | client = to_i2c_client(container_of(kobj, struct device, kobj)); | 259 | client = kobj_to_i2c_client(kobj); |
260 | ds1307 = i2c_get_clientdata(client); | 260 | ds1307 = i2c_get_clientdata(client); |
261 | 261 | ||
262 | if (unlikely(off >= NVRAM_SIZE)) | 262 | if (unlikely(off >= NVRAM_SIZE)) |
@@ -294,7 +294,7 @@ ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr, | |||
294 | u8 buffer[NVRAM_SIZE + 1]; | 294 | u8 buffer[NVRAM_SIZE + 1]; |
295 | int ret; | 295 | int ret; |
296 | 296 | ||
297 | client = to_i2c_client(container_of(kobj, struct device, kobj)); | 297 | client = kobj_to_i2c_client(kobj); |
298 | 298 | ||
299 | if (unlikely(off >= NVRAM_SIZE)) | 299 | if (unlikely(off >= NVRAM_SIZE)) |
300 | return -EFBIG; | 300 | return -EFBIG; |
@@ -412,11 +412,6 @@ read_rtc: | |||
412 | */ | 412 | */ |
413 | tmp = ds1307->regs[DS1307_REG_SECS]; | 413 | tmp = ds1307->regs[DS1307_REG_SECS]; |
414 | switch (ds1307->type) { | 414 | switch (ds1307->type) { |
415 | case ds_1340: | ||
416 | /* FIXME read register with DS1340_BIT_OSF, use that to | ||
417 | * trigger the "set time" warning (*after* restarting the | ||
418 | * oscillator!) instead of this weaker ds1307/m41t00 test. | ||
419 | */ | ||
420 | case ds_1307: | 415 | case ds_1307: |
421 | case m41t00: | 416 | case m41t00: |
422 | /* clock halted? turn it on, so clock can tick. */ | 417 | /* clock halted? turn it on, so clock can tick. */ |
@@ -440,6 +435,24 @@ read_rtc: | |||
440 | goto read_rtc; | 435 | goto read_rtc; |
441 | } | 436 | } |
442 | break; | 437 | break; |
438 | case ds_1340: | ||
439 | /* clock halted? turn it on, so clock can tick. */ | ||
440 | if (tmp & DS1340_BIT_nEOSC) | ||
441 | i2c_smbus_write_byte_data(client, DS1307_REG_SECS, 0); | ||
442 | |||
443 | tmp = i2c_smbus_read_byte_data(client, DS1340_REG_FLAG); | ||
444 | if (tmp < 0) { | ||
445 | pr_debug("read error %d\n", tmp); | ||
446 | err = -EIO; | ||
447 | goto exit_free; | ||
448 | } | ||
449 | |||
450 | /* oscillator fault? clear flag, and warn */ | ||
451 | if (tmp & DS1340_BIT_OSF) { | ||
452 | i2c_smbus_write_byte_data(client, DS1340_REG_FLAG, 0); | ||
453 | dev_warn(&client->dev, "SET TIME!\n"); | ||
454 | } | ||
455 | break; | ||
443 | case ds_1337: | 456 | case ds_1337: |
444 | case ds_1339: | 457 | case ds_1339: |
445 | break; | 458 | break; |