/* Set the time. Get the time_in_secs which is the number of seconds since Jan 1970 and set the RTC registers * based on this value. */ int rtc_set(struct rtc_time *tmp) { unsigned long remain, days, hrs, mins, secs; pr_stamp(); if (tmp == NULL) { puts("Error setting the date/time\n"); return -1; } rtc_init(); wait_for_complete(); /* Calculate number of seconds this incoming time represents */ remain = mktime(tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); /* Figure out how many days since epoch */ days = remain / NUM_SECS_IN_DAY; /* From the remaining secs, compute the hrs(0-23), mins(0-59) and secs(0-59) */ remain = remain % NUM_SECS_IN_DAY; hrs = remain / NUM_SECS_IN_HR; remain = remain % NUM_SECS_IN_HR; mins = remain / NUM_SECS_IN_MIN; secs = remain % NUM_SECS_IN_MIN; /* Encode these time values into our RTC_STAT register */ bfin_write_RTC_STAT(SET_ALARM(days, hrs, mins, secs)); 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); }