Commit 4655e5f9 authored by Ivan Kokshaysky's avatar Ivan Kokshaysky Committed by Linus Torvalds

[PATCH] Alpha cypress CPU frequency calibration

This fixes (again...) CPU frequency calibration on some platforms with
the Cypress chip.  That is, at some point CLOCK_TICK_RATE has been
changed to represent RTC reference clock instead of PIC one.  Which
makes calibrate_cc_with_pic() produce utterly bogus results.
parent cdbd392c
......@@ -249,8 +249,9 @@ validate_cc_value(unsigned long cc)
* arch/i386/time.c.
*/
#define CALIBRATE_LATCH (52 * LATCH)
#define CALIBRATE_TIME (52 * 1000020 / HZ)
#define PIC_TICK_RATE 1193180UL
#define CALIBRATE_LATCH 0xffff
#define TIMEOUT_COUNT 0x100000
static unsigned long __init
calibrate_cc_with_pic(void)
......@@ -273,19 +274,15 @@ calibrate_cc_with_pic(void)
cc = rpcc();
do {
count+=100; /* by 1 takes too long to timeout from 0 */
} while ((inb(0x61) & 0x20) == 0 && count > 0);
count++;
} while ((inb(0x61) & 0x20) == 0 && count < TIMEOUT_COUNT);
cc = rpcc() - cc;
/* Error: ECTCNEVERSET or ECPUTOOFAST. */
if (count <= 100)
if (count <= 1 || count == TIMEOUT_COUNT)
return 0;
/* Error: ECPUTOOSLOW. */
if (cc <= CALIBRATE_TIME)
return 0;
return (cc * 1000000UL) / CALIBRATE_TIME;
return ((long)cc * PIC_TICK_RATE) / (CALIBRATE_LATCH + 1);
}
/* The Linux interpretation of the CMOS clock register contents:
......
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