public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH: 2.6.14] i2c chips: ds1337 1/2
@ 2005-11-03 20:23 James Chapman
  2005-11-05  7:54 ` Jean Delvare
  0 siblings, 1 reply; 3+ messages in thread
From: James Chapman @ 2005-11-03 20:23 UTC (permalink / raw)
  To: LKML; +Cc: Michael Burian

[-- Attachment #1: Type: text/plain, Size: 378 bytes --]

Patch for ds1337 i2c driver:

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 <dynmail1@gassner-waagen.at>
Signed-off-by: James Chapman <jchapman@katalix.com>

-- 
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development




[-- Attachment #2: ds1337-init.patch --]
[-- Type: text/plain, Size: 1314 bytes --]

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 <dynmail1@gassner-waagen.at>
Signed-off-by: James Chapman <jchapman@katalix.com>

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,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-05 10:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-03 20:23 [PATCH: 2.6.14] i2c chips: ds1337 1/2 James Chapman
2005-11-05  7:54 ` Jean Delvare
2005-11-05 10:55   ` James Chapman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox