13 #include <linux/errno.h>
14 #include <linux/module.h>
15 #include <linux/sched.h>
16 #include <linux/kernel.h>
18 #include <linux/string.h>
21 #include <linux/time.h>
29 #include <asm/uaccess.h>
33 #include <asm/param.h>
37 #include <linux/timex.h>
60 unsigned long now, now2;
61 unsigned long next_tick;
62 unsigned long cycles_elapsed, ticks_elapsed = 1;
63 unsigned long cycles_remainder;
68 unsigned long cpt = clocktick;
78 cycles_elapsed = now - next_tick;
80 if ((cycles_elapsed >> 6) < cpt) {
84 cycles_remainder = cycles_elapsed;
85 while (cycles_remainder > cpt) {
86 cycles_remainder -=
cpt;
91 cycles_remainder = cycles_elapsed %
cpt;
92 ticks_elapsed += cycles_elapsed /
cpt;
96 cycles_remainder = cpt - cycles_remainder;
102 next_tick = now + cycles_remainder;
109 mtctl(next_tick, 16);
122 if (next_tick - now2 > cpt)
123 mtctl(next_tick+cpt, 16);
132 " next/now %lX/%lX\n",
133 cpu, now2 - now, cycles_elapsed, cycles_remainder,
150 " cycles %lX rem %lX "
151 " next/now %lX/%lX\n",
153 cycles_elapsed, cycles_remainder,
227 unsigned long next_tick =
mfctl(16) + clocktick;
229 mtctl(next_tick, 16);
235 .name =
"rtc-generic",
239 static int __init rtc_init(
void)
251 static struct pdc_tod tod_data;
264 unsigned long current_cr16_khz;
266 clocktick = (100 *
PAGE0->mem_10msec) /
HZ;
271 current_cr16_khz =
PAGE0->mem_10msec/10;
272 clocksource_register_khz(&clocksource_cr16, current_cr16_khz);