Commit a188176b authored by Andrew Morton's avatar Andrew Morton Committed by Vojtech Pavlik

[PATCH] Cyclone timer fixes

Patch from: john stultz <johnstul@us.ibm.com>

        This patch "fixes" the timer_cyclone code by having it
initialize fast_gettimeoffset_quotient and cpu_khz in the same manner as
timer_tsc. This is required for enabling the timer_cyclone code on the
x440.

Ideally fast_gettimeoffset_quotient would not be used outside timer_tsc
and cpu_khz would be initialized generically outside the timer
subsystem. I have patches to do this, but they touch quite a bit of
generic code, and I'd rather not make the timer_cyclone enablement
(patch to follow) depend on these larger changes.
parent c8230105
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <asm/fixmap.h> #include <asm/fixmap.h>
extern spinlock_t i8253_lock; extern spinlock_t i8253_lock;
extern unsigned long calibrate_tsc(void);
/* Number of usecs that the last interrupt was delayed */ /* Number of usecs that the last interrupt was delayed */
static int delay_at_last_interrupt; static int delay_at_last_interrupt;
...@@ -145,6 +146,27 @@ static int init_cyclone(void) ...@@ -145,6 +146,27 @@ static int init_cyclone(void)
} }
} }
/* init cpu_khz.
* XXX - This should really be done elsewhere,
* and in a more generic fashion. -johnstul@us.ibm.com
*/
if (cpu_has_tsc) {
unsigned long tsc_quotient = calibrate_tsc();
if (tsc_quotient) {
/* report CPU clock rate in Hz.
* The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
* clock/second. Our precision is about 100 ppm.
*/
{ unsigned long eax=0, edx=1000;
__asm__("divl %2"
:"=a" (cpu_khz), "=d" (edx)
:"r" (tsc_quotient),
"0" (eax), "1" (edx));
printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000);
}
}
}
/* Everything looks good! */ /* Everything looks good! */
return 0; return 0;
} }
......
...@@ -130,7 +130,7 @@ static void delay_tsc(unsigned long loops) ...@@ -130,7 +130,7 @@ static void delay_tsc(unsigned long loops)
#define CALIBRATE_LATCH (5 * LATCH) #define CALIBRATE_LATCH (5 * LATCH)
#define CALIBRATE_TIME (5 * 1000020/HZ) #define CALIBRATE_TIME (5 * 1000020/HZ)
static unsigned long __init calibrate_tsc(void) unsigned long __init calibrate_tsc(void)
{ {
/* Set the Gate high, disable speaker */ /* Set the Gate high, disable speaker */
outb((inb(0x61) & ~0x02) | 0x01, 0x61); outb((inb(0x61) & ~0x02) | 0x01, 0x61);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment