From 73f727e81ba6a20c1efbc6989738b586f152f5ba Mon Sep 17 00:00:00 2001 From: hxy Date: Wed, 5 Jan 2011 20:05:23 +0800 Subject: [PATCH] rtc: hym8563: check power down tag --- drivers/rtc/rtc-HYM8563.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/rtc/rtc-HYM8563.c b/drivers/rtc/rtc-HYM8563.c index 1604836aff4b..64df8521594f 100644 --- a/drivers/rtc/rtc-HYM8563.c +++ b/drivers/rtc/rtc-HYM8563.c @@ -323,6 +323,7 @@ static const struct rtc_class_ops hym8563_rtc_ops = { static int __devinit hym8563_probe(struct i2c_client *client,const struct i2c_device_id *id) { int rc = 0; + u8 reg = 0; struct hym8563 *hym8563; struct rtc_device *rtc = NULL; struct rtc_time tm_read, tm = { @@ -352,6 +353,14 @@ static int __devinit hym8563_probe(struct i2c_client *client,const struct i2c_d } hym8563->client = client; hym8563_init_device(client); + + // check power down + hym8563_i2c_read_regs(client,RTC_SEC,®,1); + if (reg&0x80) { + dev_info(&client->dev, "clock/calendar information is no longer guaranteed\n"); + hym8563_set_time(client, &tm); + } + hym8563_read_datetime(client, &tm_read); //read time from hym8563 if(((tm_read.tm_year < 70) | (tm_read.tm_year > 137 )) | (tm_read.tm_mon == -1) | (rtc_valid_tm(&tm_read) != 0)) //if the hym8563 haven't initialized -- 2.34.1