Commit e1df962e authored by Changhwan Youn's avatar Changhwan Youn Committed by Linus Torvalds

rtc: rtc-s3c: fix RTC initialization method

Change RTC initialization method in probe().  The 'rtc_valid_tm(tm)' can
check whether RTC BCD is valid or not.  And change the method of checking
because the previous method cannot validate RTC BCD registers properly.
Signed-off-by: default avatarChanghwan Youn <chaos.youn@samsung.com>
Signed-off-by: default avatarKukjin Kim <kgene.kim@samsung.com>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 30ffc40c
...@@ -456,8 +456,8 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) ...@@ -456,8 +456,8 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev)
static int __devinit s3c_rtc_probe(struct platform_device *pdev) static int __devinit s3c_rtc_probe(struct platform_device *pdev)
{ {
struct rtc_device *rtc; struct rtc_device *rtc;
struct rtc_time rtc_tm;
struct resource *res; struct resource *res;
unsigned int tmp, i;
int ret; int ret;
pr_debug("%s: probe=%p\n", __func__, pdev); pr_debug("%s: probe=%p\n", __func__, pdev);
...@@ -538,11 +538,19 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) ...@@ -538,11 +538,19 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev)
/* Check RTC Time */ /* Check RTC Time */
for (i = S3C2410_RTCSEC; i <= S3C2410_RTCYEAR; i += 0x4) { s3c_rtc_gettime(NULL, &rtc_tm);
tmp = readb(s3c_rtc_base + i);
if ((tmp & 0xf) > 0x9 || ((tmp >> 4) & 0xf) > 0x9) if (rtc_valid_tm(&rtc_tm)) {
writeb(0, s3c_rtc_base + i); rtc_tm.tm_year = 100;
rtc_tm.tm_mon = 0;
rtc_tm.tm_mday = 1;
rtc_tm.tm_hour = 0;
rtc_tm.tm_min = 0;
rtc_tm.tm_sec = 0;
s3c_rtc_settime(NULL, &rtc_tm);
dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n");
} }
if (s3c_rtc_cpu_type == TYPE_S3C64XX) if (s3c_rtc_cpu_type == TYPE_S3C64XX)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment