Skip to contentSkip to conversation

RTC: more XSTP/VDET support for rtc-rs5c348 driver

PATCH In review Atsushi Nemoto 2 participants 2 messages Sep 4, 2006 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RTC: more XSTP/VDET support for rtc-rs5c348 driver

If the chip detected "oscillator stop" condition, show an warning message. And initialize it with the Epoch time instead of leaving it with unknown date/time.

drivers/rtc/rtc-rs5c348.c +8 -1
index 0964d1d..2558906 100644
@@ -23,7 +23,7 @@ #include <linux/rtc.h>
 #include <linux/workqueue.h>
 #include <linux/spi/spi.h>
 
-#define DRV_VERSION "0.1"
+#define DRV_VERSION "0.2"
 
 #define RS5C348_REG_SECS	0
 #define RS5C348_REG_MINS	1
@@ -175,8 +175,15 @@ static int __devinit rs5c348_probe(struc
 		goto kfree_exit;
 	if (ret & (RS5C348_BIT_XSTP | RS5C348_BIT_VDET)) {
 		u8 buf[2];
+		struct rtc_time tm;
 		if (ret & RS5C348_BIT_VDET)
 			dev_warn(&spi->dev, "voltage-low detected.\n");
+		if (ret & RS5C348_BIT_XSTP)
+			dev_warn(&spi->dev, "oscillator-stop detected.\n");
+		rtc_time_to_tm(0, &tm);	/* 1970/1/1 */
+		ret = rs5c348_rtc_set_time(&spi->dev, &tm);
+		if (ret < 0)
+			goto kfree_exit;
 		buf[0] = RS5C348_CMD_W(RS5C348_REG_CTL2);
 		buf[1] = 0;
 		ret = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0);
#1 lore raw
Quoted 5 lines · On Mon, 04 Sep 2006 22:22:22 +0900 (JST) Atsushi Nemoto <[email protected]>…

If the chip detected "oscillator stop" condition, show an warning message. And initialize it with the Epoch time instead of leaving it with unknown date/time.

Quoted 29 lines
drivers/rtc/rtc-rs5c348.c +8 -1
index 0964d1d..2558906 100644
@@ -23,7 +23,7 @@ #include <linux/rtc.h>
 #include <linux/workqueue.h>
 #include <linux/spi/spi.h>
 
-#define DRV_VERSION "0.1"
+#define DRV_VERSION "0.2"
 
 #define RS5C348_REG_SECS	0
 #define RS5C348_REG_MINS	1
@@ -175,8 +175,15 @@ static int __devinit rs5c348_probe(struc
 		goto kfree_exit;
 	if (ret & (RS5C348_BIT_XSTP | RS5C348_BIT_VDET)) {
 		u8 buf[2];
+		struct rtc_time tm;
 		if (ret & RS5C348_BIT_VDET)
 			dev_warn(&spi->dev, "voltage-low detected.\n");
+		if (ret & RS5C348_BIT_XSTP)
+			dev_warn(&spi->dev, "oscillator-stop detected.\n");
+		rtc_time_to_tm(0, &tm);	/* 1970/1/1 */
+		ret = rs5c348_rtc_set_time(&spi->dev, &tm);
+		if (ret < 0)
+			goto kfree_exit;
 		buf[0] = RS5C348_CMD_W(RS5C348_REG_CTL2);
 		buf[1] = 0;
 		ret = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0);
Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Turin, Italy

  http://www.towertech.it