]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Alpha cypress CPU frequency calibration
authorIvan Kokshaysky <ink@jurassic.park.msu.ru>
Wed, 1 Oct 2003 15:52:33 +0000 (08:52 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 1 Oct 2003 15:52:33 +0000 (08:52 -0700)
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.

arch/alpha/kernel/time.c

index 162b82fa48669c4a62e94542eccd02120824713c..4b8d93a8209b8f19a35e349d18b8eac6a30f5b21 100644 (file)
@@ -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: