diff options
Diffstat (limited to 'arch/x86/kernel/time_64.c')
-rw-r--r-- | arch/x86/kernel/time_64.c | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/arch/x86/kernel/time_64.c b/arch/x86/kernel/time_64.c index 2db4d698a2d3..e97a3ee13551 100644 --- a/arch/x86/kernel/time_64.c +++ b/arch/x86/kernel/time_64.c | |||
@@ -292,35 +292,6 @@ static unsigned int __init tsc_calibrate_cpu_khz(void) | |||
292 | return pmc_now * tsc_khz / (tsc_now - tsc_start); | 292 | return pmc_now * tsc_khz / (tsc_now - tsc_start); |
293 | } | 293 | } |
294 | 294 | ||
295 | /* | ||
296 | * pit_calibrate_tsc() uses the speaker output (channel 2) of | ||
297 | * the PIT. This is better than using the timer interrupt output, | ||
298 | * because we can read the value of the speaker with just one inb(), | ||
299 | * where we need three i/o operations for the interrupt channel. | ||
300 | * We count how many ticks the TSC does in 50 ms. | ||
301 | */ | ||
302 | |||
303 | static unsigned int __init pit_calibrate_tsc(void) | ||
304 | { | ||
305 | unsigned long start, end; | ||
306 | unsigned long flags; | ||
307 | |||
308 | spin_lock_irqsave(&i8253_lock, flags); | ||
309 | |||
310 | outb((inb(0x61) & ~0x02) | 0x01, 0x61); | ||
311 | |||
312 | outb(0xb0, 0x43); | ||
313 | outb((PIT_TICK_RATE / (1000 / 50)) & 0xff, 0x42); | ||
314 | outb((PIT_TICK_RATE / (1000 / 50)) >> 8, 0x42); | ||
315 | start = get_cycles_sync(); | ||
316 | while ((inb(0x61) & 0x20) == 0); | ||
317 | end = get_cycles_sync(); | ||
318 | |||
319 | spin_unlock_irqrestore(&i8253_lock, flags); | ||
320 | |||
321 | return (end - start) / 50; | ||
322 | } | ||
323 | |||
324 | #define PIT_MODE 0x43 | 295 | #define PIT_MODE 0x43 |
325 | #define PIT_CH0 0x40 | 296 | #define PIT_CH0 0x40 |
326 | 297 | ||
@@ -376,14 +347,14 @@ void __init time_init(void) | |||
376 | if (hpet_use_timer) { | 347 | if (hpet_use_timer) { |
377 | /* set tick_nsec to use the proper rate for HPET */ | 348 | /* set tick_nsec to use the proper rate for HPET */ |
378 | tick_nsec = TICK_NSEC_HPET; | 349 | tick_nsec = TICK_NSEC_HPET; |
379 | tsc_khz = hpet_calibrate_tsc(); | ||
380 | timename = "HPET"; | 350 | timename = "HPET"; |
381 | } else { | 351 | } else { |
382 | pit_init(); | 352 | pit_init(); |
383 | tsc_khz = pit_calibrate_tsc(); | ||
384 | timename = "PIT"; | 353 | timename = "PIT"; |
385 | } | 354 | } |
386 | 355 | ||
356 | tsc_calibrate(); | ||
357 | |||
387 | cpu_khz = tsc_khz; | 358 | cpu_khz = tsc_khz; |
388 | if (cpu_has(&boot_cpu_data, X86_FEATURE_CONSTANT_TSC) && | 359 | if (cpu_has(&boot_cpu_data, X86_FEATURE_CONSTANT_TSC) && |
389 | boot_cpu_data.x86_vendor == X86_VENDOR_AMD && | 360 | boot_cpu_data.x86_vendor == X86_VENDOR_AMD && |