[i2c] [PATCH] DS1339: oscillator code added.

Rodolfo Giometti giometti at enneenne.com
Tue Jun 19 14:13:59 CEST 2007


Signed-off-by: Rodolfo Giometti <giometti at linux.it>
---
 drivers/rtc/rtc-ds1307.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 8cb007e..0e6ca03 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -292,10 +292,12 @@ static int __devinit ds1307_probe(struct i2c_client *client)
 		/* oscillator is off; need to turn it on */
 		if ((ds1307->regs[0] & DS1337_BIT_nEOSC)
 				|| (ds1307->regs[1] & DS1337_BIT_OSF)) {
-no_osc_start:
-			printk(KERN_ERR "no %s oscillator code\n",
-				chip->name);
-			goto exit_free;
+			dev_info(&client->dev,
+				"oscillator is off. Turned on!\n");
+			i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL,
+				ds1307->regs[0] & ~DS1337_BIT_nEOSC);
+			i2c_smbus_write_byte_data(client, DS1337_REG_STATUS,
+				ds1307->regs[1] & ~DS1337_BIT_OSF);
 		}
 		break;
 	default:
@@ -331,7 +333,9 @@ read_rtc:
 	case ds_1340:
 		/* FIXME write code to start the oscillator */
 		if (tmp & DS1307_BIT_CH)
-			goto no_osc_start;
+			printk(KERN_ERR "no %s oscillator code\n",
+				chip->name);
+			goto exit_free;
 		break;
 	default:
 		break;
-- 
1.5.1.1


-- 

GNU/Linux Solutions                  e-mail:    giometti at enneenne.com
Linux Device Driver                             giometti at gnudd.com
Embedded Systems                     		giometti at linux.it
UNIX programming                     phone:     +39 349 2432127
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.lm-sensors.org/pipermail/i2c/attachments/20070619/85c9d4fc/attachment.bin 


More information about the i2c mailing list