/* Read the time from the RTC_STAT. time_in_seconds is seconds since Jan 1970 */ int rtc_get(struct rtc_time *tmp) { uint32_t cur_rtc_stat; int time_in_sec; int tm_sec, tm_min, tm_hr, tm_day; pr_stamp(); if (tmp == NULL) { puts("Error getting the date/time\n"); return -1; } rtc_init(); wait_for_complete(); /* Read the RTC_STAT register */ cur_rtc_stat = bfin_read_RTC_STAT(); /* Convert our encoded format into actual time values */ tm_sec = (cur_rtc_stat & RTC_SEC) >> RTC_SEC_P; tm_min = (cur_rtc_stat & RTC_MIN) >> RTC_MIN_P; tm_hr = (cur_rtc_stat & RTC_HR ) >> RTC_HR_P; tm_day = (cur_rtc_stat & RTC_DAY) >> RTC_DAY_P; /* Calculate the total number of seconds since epoch */ time_in_sec = (tm_sec) + MIN_TO_SECS(tm_min) + HRS_TO_SECS(tm_hr) + DAYS_TO_SECS(tm_day); to_tm(time_in_sec, tmp); return 0; }
void __init time_init(void) { #ifdef CONFIG_RTC_DRV_BFIN /* [#2663] hack to filter junk RTC values that would cause * userspace to have to deal with time values greater than * 2^31 seconds (which uClibc cannot cope with yet) */ if ((bfin_read_RTC_STAT() & 0xC0000000) == 0xC0000000) { printk(KERN_NOTICE "bfin-rtc: invalid date; resetting\n"); bfin_write_RTC_STAT(0); } #endif time_sched_init(timer_interrupt); }
void __init time_init(void) { time_t secs_since_1970 = (365 * 37 + 9) * 24 * 60 * 60; /* 1 Jan 2007 */ #ifdef CONFIG_RTC_DRV_BFIN /* [#2663] hack to filter junk RTC values that would cause * userspace to have to deal with time values greater than * 2^31 seconds (which uClibc cannot cope with yet) */ if ((bfin_read_RTC_STAT() & 0xC0000000) == 0xC0000000) { printk(KERN_NOTICE "bfin-rtc: invalid date; resetting\n"); bfin_write_RTC_STAT(0); } #endif /* Initialize xtime. From now on, xtime is updated with timer interrupts */ xtime.tv_sec = secs_since_1970; xtime.tv_nsec = 0; wall_to_monotonic.tv_sec = -xtime.tv_sec; time_sched_init(timer_interrupt); }