All of lore.kernel.org
 help / color / mirror / Atom feed
From: frederic RODO <f.rodo@til-technologies.fr>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] rtc-ds1307 : ds_1340 change init
Date: Wed, 16 Jan 2008 17:05:05 +0100	[thread overview]
Message-ID: <478E2B31.20308@til-technologies.fr> (raw)

Hi,

this patch change the initialization of ds1340 according to the FIXME.

It was tested on a arm custom board, this is the log when I plug the 
board without backup battery.

Linux version 2.6.24-rc7 (fredo@srv-devhard) (gcc version 3.4.6) #22 Tue 
Jan 15 19:45:16 CET 2008
.......
Kernel command line: debug
.......
atmel_spi atmel_spi.1: Atmel SPI Controller at 0xfffcc000 (irq 13)
i2c /dev entries driver
rtc-ds1307 0-0068: SET TIME!
rtc-ds1307 0-0068: rtc core: registered ds1340 as rtc0
i2c-gpio i2c-gpio: using pins 55 (SDA) and 56 (SCL)
.......

If you have any comments please CC me

bye.



Signed-off-by: Frederic RODO <f.rodo@til-technologies.fr>

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index bc1c7fe..3a86898 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -392,6 +392,33 @@ static int __devinit ds1307_probe(struct i2c_client 
*client)
  			dev_warn(&client->dev, "SET TIME!\n");
  		}
  		break;
+	case ds_1340:
+		/* Test nEOSC before OSF */
+		tmp = i2c_smbus_read_byte_data(client, DS1307_REG_SECS);
+		if (tmp < 0) {
+			pr_debug("read error %d\n", tmp);
+			err = -EIO;
+			goto exit_free;
+		}
+
+		/* oscillator off?  turn it on, so clock can tick. */
+		if (tmp & DS1340_BIT_nEOSC)
+			i2c_smbus_write_byte_data(client, DS1307_REG_SECS,
+				tmp & ~DS1340_BIT_nEOSC);
+
+		tmp = i2c_smbus_read_byte_data(client, DS1340_REG_FLAG);
+		if (tmp < 0) {
+			pr_debug("read error %d\n", tmp);
+			err = -EIO;
+			goto exit_free;
+		}
+
+		/* oscillator fault?  clear flag, and warn */
+		if (tmp & DS1340_BIT_OSF) {
+			i2c_smbus_write_byte_data(client, DS1340_REG_FLAG, 0);
+			dev_warn(&client->dev, "SET TIME!\n");
+		}
+		break;
  	default:
  		break;
  	}
@@ -412,11 +439,6 @@ read_rtc:
  	 */
  	tmp = ds1307->regs[DS1307_REG_SECS];
  	switch (ds1307->type) {
-	case ds_1340:
-		/* FIXME read register with DS1340_BIT_OSF, use that to
-		 * trigger the "set time" warning (*after* restarting the
-		 * oscillator!) instead of this weaker ds1307/m41t00 test.
-		 */
  	case ds_1307:
  	case m41t00:
  		/* clock halted?  turn it on, so clock can tick. */
@@ -442,6 +464,7 @@ read_rtc:
  		break;
  	case ds_1337:
  	case ds_1339:
+	case ds_1340:
  		break;
  	}



-------------------------------------------------------------------------
Les informations précédentes peuvent être confidentielles ou privilégiées.
Si vous n'êtes pas le destinataire prévu de ce mail, veuillez en notifier 
l'expéditeur en répondant à ce message puis supprimez-en toute trace 
de vos systèmes.

TIL Technologies
Parc du Golf, Bat 43
350 rue J.R Guilibert Gautier de la Lauzière 
13856 AIX EN PROVENCE
Tel. : +33 4 42 37 11 77
-------------------------------------------------------------------------



                 reply	other threads:[~2008-01-16 16:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=478E2B31.20308@til-technologies.fr \
    --to=f.rodo@til-technologies.fr \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.