Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16672
b: refs/heads/master
c: f9e8957
h: refs/heads/master
v: v3
  • Loading branch information
Michael Burian authored and Greg Kroah-Hartman committed Jan 6, 2006
1 parent 8b1aac2 commit 39fc995
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2e3e13f8e9d9b2111404cdccaa4e1b988b70acce
refs/heads/master: f9e8957937ebf60d22732a5ca9130f48a7603f60
37 changes: 31 additions & 6 deletions trunk/drivers/i2c/chips/ds1337.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,38 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind)

static void ds1337_init_client(struct i2c_client *client)
{
s32 val;
u8 status, control;

/* Ensure that device is set in 24-hour mode */
val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR);
if ((val >= 0) && (val & (1 << 6)))
i2c_smbus_write_byte_data(client, DS1337_REG_HOUR,
val & 0x3f);
/* On some boards, the RTC isn't configured by boot firmware.
* Handle that case by starting/configuring the RTC now.
*/
status = i2c_smbus_read_byte_data(client, DS1337_REG_STATUS);
control = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL);

if ((status & 0x80) || (control & 0x80)) {
/* RTC not running */
u8 buf[16];
struct i2c_msg msg[1];

dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__);

/* Initialize all, including STATUS and CONTROL to zero */
memset(buf, 0, sizeof(buf));
msg[0].addr = client->addr;
msg[0].flags = 0;
msg[0].len = sizeof(buf);
msg[0].buf = &buf[0];

i2c_transfer(client->adapter, msg, 1);
} else {
/* Running: ensure that device is set in 24-hour mode */
s32 val;

val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR);
if ((val >= 0) && (val & (1 << 6)))
i2c_smbus_write_byte_data(client, DS1337_REG_HOUR,
val & 0x3f);
}
}

static int ds1337_detach_client(struct i2c_client *client)
Expand Down

0 comments on commit 39fc995

Please sign in to comment.