Subject: Re: [PATCH] sort out CLOCK_TICK_RATE usage take 3 [1/3]
From: Thorsten Kranzkowski <[email-masked]>
To: [email-masked], [email-masked], [email-masked], [email-masked]
Date: Tue, 4 May 2004 21:03:59 +0000

1/3:    introduce asm-*/8253pit.h, #define PIT_TICK_RATE constant.

diff -urN linux-2.6.5/arch/alpha/kernel/time.c linux-2.6.5-1a/arch/alpha/kernel/time.c
--- linux-2.6.5/arch/alpha/kernel/time.c	Sun Apr 11 14:24:42 2004
+++ linux-2.6.5-1a/arch/alpha/kernel/time.c	Tue Apr 13 17:18:19 2004
@@ -45,6 +45,7 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/hwrpb.h>
+#include <asm/8253pit.h>
 
 #include <linux/mc146818rtc.h>
 #include <linux/time.h>
@@ -254,12 +255,11 @@
  * arch/i386/time.c.
  */
 
-#define PIC_TICK_RATE	1193180UL
 #define CALIBRATE_LATCH	0xffff
 #define TIMEOUT_COUNT	0x100000
 
 static unsigned long __init
-calibrate_cc_with_pic(void)
+calibrate_cc_with_pit(void)
 {
 	int cc, count = 0;
 
@@ -287,7 +287,7 @@
 	if (count <= 1 || count == TIMEOUT_COUNT)
 		return 0;
 
-	return ((long)cc * PIC_TICK_RATE) / (CALIBRATE_LATCH + 1);
+	return ((long)cc * PIT_TICK_RATE) / (CALIBRATE_LATCH + 1);
 }
 
 /* The Linux interpretation of the CMOS clock register contents:
@@ -313,7 +313,7 @@
 
 	/* Calibrate CPU clock -- attempt #1.  */
 	if (!est_cycle_freq)
-		est_cycle_freq = validate_cc_value(calibrate_cc_with_pic());
+		est_cycle_freq = validate_cc_value(calibrate_cc_with_pit());
 
 	cc1 = rpcc_after_update_in_progress();
 
diff -urN linux-2.6.5/include/asm-alpha/8253pit.h linux-2.6.5-1a/include/asm-alpha/8253pit.h
--- linux-2.6.5/include/asm-alpha/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-alpha/8253pit.h	Tue Apr 13 17:14:40 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193180UL
+
+#endif
diff -urN linux-2.6.5/include/asm-i386/8253pit.h linux-2.6.5-1a/include/asm-i386/8253pit.h
--- linux-2.6.5/include/asm-i386/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-i386/8253pit.h	Tue Apr 13 17:21:49 2004
@@ -0,0 +1,12 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#include <asm/timex.h>
+
+#define PIT_TICK_RATE 	CLOCK_TICK_RATE
+
+#endif
diff -urN linux-2.6.5/include/asm-mips/8253pit.h linux-2.6.5-1a/include/asm-mips/8253pit.h
--- linux-2.6.5/include/asm-mips/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-mips/8253pit.h	Tue Apr 13 17:25:12 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-x86_64/8253pit.h linux-2.6.5-1a/include/asm-x86_64/8253pit.h
--- linux-2.6.5/include/asm-x86_64/8253pit.h	Thu Jan  1 00:00:00 1970
+++ linux-2.6.5-1a/include/asm-x86_64/8253pit.h	Tue Apr 13 17:32:49 2004
@@ -0,0 +1,10 @@
+/*
+ * 8253/8254 Programmable Interval Timer
+ */
+
+#ifndef _8253PIT_H
+#define _8253PIT_H
+
+#define PIT_TICK_RATE 	1193182UL
+
+#endif
diff -urN linux-2.6.5/include/asm-x86_64/timex.h linux-2.6.5-1a/include/asm-x86_64/timex.h
--- linux-2.6.5/include/asm-x86_64/timex.h	Sun Apr 11 14:23:27 2004
+++ linux-2.6.5-1a/include/asm-x86_64/timex.h	Tue Apr 13 17:33:26 2004
@@ -7,11 +7,12 @@
 #define _ASMx8664_TIMEX_H
 
 #include <linux/config.h>
+#include <asm/8253pit.h>
 #include <asm/msr.h>
 #include <asm/vsyscall.h>
 #include <asm/hpet.h>
 
-#define CLOCK_TICK_RATE	1193182 /* Underlying HZ */
+#define CLOCK_TICK_RATE	PIT_TICK_RATE	/* Underlying HZ */
 #define CLOCK_TICK_FACTOR	20	/* Factor of both 1000000 and CLOCK_TICK_RATE */
 #define FINETUNE ((((((int)LATCH * HZ - CLOCK_TICK_RATE) << SHIFT_HZ) * \
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
-- 
| Thorsten Kranzkowski        Internet: [email-masked]                      |
| Mobile: ++49 170 1876134       Snail: Kiebitzstr. 14, 49324 Melle, Germany  |
| Ampr: dl8bcu@db0lj.#rpl.deu.eu, [email-masked] [44.130.8.19] |