static int mv_rtc_init(void) { MV_RTC_TIME time; struct timespec tv; struct device *dev; mvRtcTimeGet(&time); dev = device_create(rtc_class, NULL, -1, NULL, "mv_rtc"); /* Date which is not in the 21 century will stop the RTC on 00:00:00 - 01/01/2000, write operation will trigger it */ if ((time.year == 0) && (time.month == 1) && (time.date == 1)) { mvRtcTimeSet(&time); printk(KERN_INFO "RTC has been updated!!!\n"); } tv.tv_nsec = 0; /* same as in the U-Boot we use the year for century 20 only */ tv.tv_sec = mktime ( time.year + 2000, time.month, time.date, time.hours, time.minutes, time.seconds); do_settimeofday(&tv); set_rtc = mv_set_rtc; rtc_device_register("kw-rtc", dev, &rtc_ops, THIS_MODULE); printk("RTC registered\n"); return 0; }
static int mv_set_rtc(void) { MV_RTC_TIME time; to_tm(xtime.tv_sec, &time); time.year -= 2000; mvRtcTimeSet(&time); return 1; }
static inline int mv_rtc_set_time(struct device *dev, struct rtc_time *tm) { MV_RTC_TIME time; unsigned long temp_t; rtc_tm_to_time(tm, &temp_t); to_tm(temp_t, &time); /* same as in the U-Boot we use the year for century 20 only */ time.year -= 2000; mvRtcTimeSet(&time); return 0; }
int rtc_set( struct rtc_time *tmp ) { MV_RTC_TIME time; #ifdef RTC_DEBUG printf( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, tmp->tm_hour, tmp->tm_min, tmp->tm_sec); #endif time.month = tmp->tm_mon; time.date = tmp->tm_mday; time.day = tmp->tm_wday; time.hours = tmp->tm_hour; time.minutes = tmp->tm_min; time.seconds = tmp->tm_sec; if((tmp->tm_year/100) != CENTURY) printf("Warning: century isn't supported to be set(always %d) \n",CENTURY); time.year = tmp->tm_year%100; #ifdef MV_INCLUDE_RTC mvRtcTimeSet(&time); #elif defined(CONFIG_RTC_DS1338_DS1339) mvRtcDS133xTimeSet(&time); #endif return 0; }