* 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)
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: