rtc-ds1307 : ds_1340 change init
PATCH 1/1 rtc-ds1307 : ds_1340 change init
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.
drivers/rtc/rtc-ds1307.c +28 -5
@@ -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
-------------------------------------------------------------------------