Add code to handle case where board firmware does not start the RTC. This patch was contributed by Michael Burian. Signed-off-by: Michael Burian Signed-off-by: James Chapman Index: linux-2.6.14/drivers/i2c/chips/ds1337.c =================================================================== --- linux-2.6.14.orig/drivers/i2c/chips/ds1337.c 2005-11-02 19:30:17.000000000 +0000 +++ linux-2.6.14/drivers/i2c/chips/ds1337.c 2005-11-03 20:14:58.981735046 +0000 @@ -149,12 +149,25 @@ u8 buf[8]; u8 val; struct i2c_msg msg[1]; + u8 status, control; + int i; if (!dt) { dev_dbg(&client->dev, "%s: EINVAL: dt=NULL\n", __FUNCTION__); return -EINVAL; } + status = i2c_smbus_read_byte_data(client, DS1337_REG_STATUS); + control = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL); + + /* On some boards, the RTC isn't configured by boot firmware. + * Handle that case by starting/configuring the RTC now. + */ + if ((status & 0x80) || (control & 0x80)) + /* Initialize all, including STATUS and CONTROL to zero */ + for (i = 0; i < 16; i++) + i2c_smbus_write_byte_data(client, i, 0); + dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " "mday=%d, mon=%d, year=%d, wday=%d\n", __FUNCTION__, dt->tm_sec, dt->tm_min, dt->tm_hour,