14 #include <linux/kernel.h>
15 #include <linux/module.h>
17 #include <linux/sched.h>
18 #include <linux/time.h>
21 #include <linux/timex.h>
25 #include <asm/machvec.h>
26 #include <asm/delay.h>
27 #include <asm/hw_irq.h>
28 #include <asm/paravirt.h>
29 #include <asm/ptrace.h>
31 #include <asm/sections.h>
43 #ifdef CONFIG_IA64_DEBUG_IRQ
45 unsigned long last_cli_ip;
50 #ifdef CONFIG_PARAVIRT
55 return paravirt_sched_clock();
59 #ifdef CONFIG_PARAVIRT
71 .read = itc_get_cycles,
74 #ifdef CONFIG_PARAVIRT
75 .resume = paravirt_clocksource_resume,
80 #ifdef CONFIG_VIRT_CPU_ACCOUNTING
86 static void vtime_account_user(
struct task_struct *tsk)
92 delta_utime = cycle_to_cputime(ti->ac_utime);
109 vtime_account_system(prev);
111 vtime_account_idle(prev);
113 vtime_account_user(prev);
115 pi->ac_stamp = ni->ac_stamp;
116 ni->ac_stime = ni->ac_utime = 0;
129 now = ia64_get_itc();
131 delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp));
156 vtime_account_user(p);
164 unsigned long new_itm;
175 printk(
KERN_ERR "Oops: timer tick before it's due (itc=%lx,itm=%lx)\n",
176 ia64_get_itc(), new_itm);
181 goto skip_process_time_accounting;
203 skip_process_time_accounting:
217 ia64_set_itm(new_itm);
230 unsigned long shift = 0,
delta;
241 unsigned long hi = 1
UL << ia64_fls(cpu);
242 shift = (2*(cpu - hi) + 1) *
delta/hi/2;
250 static int __init nojitter_setup(
char *
str)
253 printk(
"Jitter checking for ITC timers disabled\n");
257 __setup(
"nojitter", nojitter_setup);
263 unsigned long platform_base_freq, itc_freq;
265 long status, platform_base_drift, itc_drift;
273 &platform_base_freq, &platform_base_drift);
277 status = ia64_pal_freq_ratios(&proc_ratio,
NULL, &itc_ratio);
279 printk(
KERN_ERR "PAL_FREQ_RATIOS failed with status=%ld\n", status);
284 "SAL/PAL failed to obtain frequency info---inventing reasonable values\n");
285 platform_base_freq = 100000000;
286 platform_base_drift = -1;
290 if (platform_base_freq < 40000000) {
291 printk(
KERN_ERR "Platform base frequency %lu bogus---resetting to 75MHz!\n",
293 platform_base_freq = 75000000;
294 platform_base_drift = -1;
301 itc_freq = (platform_base_freq*itc_ratio.
num)/itc_ratio.
den;
306 platform_base_freq / 1000000, (platform_base_freq / 1000) % 1000,
307 itc_ratio.
num, itc_ratio.
den, itc_freq / 1000000, (itc_freq / 1000) % 1000);
309 if (platform_base_drift != -1) {
310 itc_drift = platform_base_drift*itc_ratio.
num/itc_ratio.
den;
311 printk(
"+/-%ldppm\n", itc_drift);
321 + itc_freq/2)/itc_freq;
352 clocksource_itc.
rating = 50;
362 if (!itc_clocksource) {
363 clocksource_register_hz(&clocksource_itc,
365 itc_clocksource = &clocksource_itc;
371 unsigned long lcycle, now,
ret;
406 static int __init rtc_init(
void)
434 ia64_itc_udelay (
unsigned long usecs)
436 unsigned long start = ia64_get_itc();
448 (*ia64_udelay)(
usecs);