diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 15:25:08 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-06 15:25:08 -0800 |
commit | 0feb9bfcfa3f9bf67a4a1e3f2608700ad73f92ed (patch) | |
tree | 22c71657387b42787bc070502899a881ed909f39 /drivers/i2c/chips/ds1337.c | |
parent | d8d8f6a4fd635dcc9e4f946394c1fbde85eeab66 (diff) | |
parent | ccf18968b1bbc2fb117190a1984ac2a826dac228 (diff) | |
download | kernel_samsung_tuna-0feb9bfcfa3f9bf67a4a1e3f2608700ad73f92ed.zip kernel_samsung_tuna-0feb9bfcfa3f9bf67a4a1e3f2608700ad73f92ed.tar.gz kernel_samsung_tuna-0feb9bfcfa3f9bf67a4a1e3f2608700ad73f92ed.tar.bz2 |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/i2c-2.6
Diffstat (limited to 'drivers/i2c/chips/ds1337.c')
-rw-r--r-- | drivers/i2c/chips/ds1337.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 02682fb..93d483b 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -52,9 +52,9 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, * Driver data (common to all clients) */ static struct i2c_driver ds1337_driver = { - .owner = THIS_MODULE, - .name = "ds1337", - .flags = I2C_DF_NOTIFY, + .driver = { + .name = "ds1337", + }, .attach_adapter = ds1337_attach_adapter, .detach_client = ds1337_detach_client, .command = ds1337_command, @@ -337,13 +337,38 @@ exit: 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) |