s5j/rtc: initialize BCDYEAR at boot
authorHeesub Shin <heesub.shin@samsung.com>
Tue, 25 Apr 2017 14:50:52 +0000 (23:50 +0900)
committerHeesub Shin <heesub.shin@samsung.com>
Wed, 26 Apr 2017 14:57:08 +0000 (23:57 +0900)
On power-on-reset, BCDYEAR in RTC is set to zero which means year 1900.
Since the date and time conversion functions can handle date only after
1970. We need to set BCDYEAR to something greater than that. Year 2010
seems reasonable.

Change-Id: If45985b13900a7de0b0cebc043119c4af94378bb
Signed-off-by: Heesub Shin <heesub.shin@samsung.com>
os/arch/arm/src/s5j/s5j_rtc.c

index e1b3e54..dcb8f79 100644 (file)
@@ -433,6 +433,11 @@ int up_rtc_initialize(void)
                putreg32(1, S5J_RTC_BCDMON);
        }
 
+       /* OS supports to convert epoch only after 1970. Set year to 2010. */
+       if (getreg32(S5J_RTC_BCDYEAR) == 0) {
+               putreg32(0x110, S5J_RTC_BCDYEAR);
+       }
+
        rtc_wprlock();
 
        g_rtc_enabled = true;