From d5239f657d06eb8476cc0cb28a934bbc11c302bd Mon Sep 17 00:00:00 2001 From: "Eddie C. Dost" Date: Thu, 26 Oct 2017 10:45:20 +0200 Subject: [PATCH] merge Bug fix by Bruno-w (https://github.com/Bruno-w): RTC alarm wake-up Because of the S3C2410 bug (INT_SRCPND_RTC not set on alarm wake-up), the firmware need to check on power-on if an alarm is triggered by comparing the alarm date to the system date. But, It failed because the firmware read a system date that is 1 second behind the alarm date, while the cpu was waked-up by an alarm. This is because x49gp uses 2 different functions to read host system time in 2 key routines, leading to a 1 second gap when used consecutively. This fix solved this issue. --- s3c2410_rtc.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/s3c2410_rtc.c b/s3c2410_rtc.c index 4699b83..99aca93 100644 --- a/s3c2410_rtc.c +++ b/s3c2410_rtc.c @@ -225,7 +225,6 @@ s3c2410_rtc_alarm(void * user_data) static int s3c2410_rtc_set_rtcalm(s3c2410_rtc_t *rtc) { - struct tm *tm; struct timeval tv; int64_t now, us; @@ -235,7 +234,6 @@ s3c2410_rtc_set_rtcalm(s3c2410_rtc_t *rtc) } gettimeofday(&tv, NULL); - tm = localtime(&tv.tv_sec); now = x49gp_get_clock(); us = 1000000LL - tv.tv_usec; @@ -265,10 +263,10 @@ s3c2410_rtc_read(void *opaque, target_phys_addr_t offset) if (S3C2410_RTC_BCDSEC <= offset && offset <= S3C2410_RTC_BCDYEAR) { struct tm *tm; - time_t t; + struct timeval tv; - t = time(0); - tm = localtime(&t); + gettimeofday(&tv, NULL); + tm = localtime(&tv.tv_sec); switch (offset) { case S3C2410_RTC_BCDSEC: