void __init time_init(void) { unsigned long next_tick; static struct pdc_tod tod_data; clocktick = (100 * PAGE0->mem_10msec) / HZ; halftick = clocktick / 2; /* Setup clock interrupt timing */ next_tick = mfctl(16); next_tick += clocktick; cpu_data[smp_processor_id()].it_value = next_tick; /* kick off Itimer (CR16) */ mtctl(next_tick, 16); if(pdc_tod_read(&tod_data) == 0) { write_lock_irq(&xtime_lock); xtime.tv_sec = tod_data.tod_sec; xtime.tv_usec = tod_data.tod_usec; write_unlock_irq(&xtime_lock); } else { printk(KERN_ERR "Error reading tod clock\n"); xtime.tv_sec = 0; xtime.tv_usec = 0; } }
void read_persistent_clock(struct timespec *ts) { static struct pdc_tod tod_data; if (pdc_tod_read(&tod_data) == 0) { ts->tv_sec = tod_data.tod_sec; ts->tv_nsec = tod_data.tod_usec * 1000; } else { printk(KERN_ERR "Error reading tod clock\n"); ts->tv_sec = 0; ts->tv_nsec = 0; } }
static int rtc_generic_get_time(struct device *dev, struct rtc_time *tm) { struct pdc_tod tod_data; memset(tm, 0, sizeof(*tm)); if (pdc_tod_read(&tod_data) < 0) return -EOPNOTSUPP; /* we treat tod_sec as unsigned, so this can work until year 2106 */ rtc_time64_to_tm(tod_data.tod_sec, tm); return rtc_valid_tm(tm); }