Add a new boot option related to HPET. Current mode of HPET functioning:

(1) If HPET is listed in BIOS:
default: HPET gets detected at boot time and gets enabled in 
"legacy replacement" mode.
"hpet=standard" boot option: HPET does not get used during early boot and
PIT will be used in early boot. HPET gets enabled in "standard" mode during
late boot stages.
"hpet=disable" boot option: HPET is disabled and not used.

(2) If HPET is not listed in BIOS and force detected with PCI quirks:
default: HPET does not get used during early boot and
PIT will be used in early boot. HPET gets enabled in "standard" mode during
late boot stages.
"hpet=disable" boot option: HPET is disabled and not used.


We can change the default behavior of (1) to match (2) after this patch gets
some testing.

Signed-off-by: Venkatesh Pallipadi <[EMAIL PROTECTED]>

Index: linux-2.6.21/include/asm-i386/hpet.h
===================================================================
--- linux-2.6.21.orig/include/asm-i386/hpet.h   2007-04-27 15:27:12.000000000 
-0700
+++ linux-2.6.21/include/asm-i386/hpet.h        2007-04-27 15:30:22.000000000 
-0700
@@ -112,7 +112,7 @@
 extern int is_hpet_capable(void);
 extern int hpet_readl(unsigned long a);
 #else
-extern int hpet_enable(void);
+extern int hpet_enable(int early_call);
 #endif
 
 #ifdef CONFIG_HPET_EMULATE_RTC
@@ -127,7 +127,7 @@
 
 #else
 
-static inline int hpet_enable(void) { return 0; }
+static inline int hpet_enable(int early_call) { return 0; }
 
 #endif /* CONFIG_HPET_TIMER */
 #endif /* _I386_HPET_H */
Index: linux-2.6.21/arch/i386/kernel/time.c
===================================================================
--- linux-2.6.21.orig/arch/i386/kernel/time.c   2007-04-27 15:27:12.000000000 
-0700
+++ linux-2.6.21/arch/i386/kernel/time.c        2007-04-27 15:30:22.000000000 
-0700
@@ -264,7 +264,7 @@
 /* Duplicate of time_init() below, with hpet_enable part added */
 void __init hpet_time_init(void)
 {
-       if (!hpet_enable())
+       if (!hpet_enable(1))
                setup_pit_timer();
        time_init_hook();
 }
Index: linux-2.6.21/arch/i386/kernel/hpet.c
===================================================================
--- linux-2.6.21.orig/arch/i386/kernel/hpet.c   2007-04-27 15:30:15.000000000 
-0700
+++ linux-2.6.21/arch/i386/kernel/hpet.c        2007-04-27 15:30:22.000000000 
-0700
@@ -51,6 +51,8 @@
        if (str) {
                if (!strncmp("disable", str, 7))
                        boot_hpet_disable = 1;
+               else if (!strncmp("standard", str, 9))
+                       hpet_preferred_int_mode = HPET_INT_STD;
        }
        return 1;
 }
@@ -723,13 +725,16 @@
 /*
  * Try to setup the HPET timer
  */
-int __init hpet_enable(void)
+int __init hpet_enable(int early_call)
 {
        unsigned long id;
 
        if (hpet_virt_address)
                return 0;
 
+       if (early_call && hpet_preferred_int_mode == HPET_INT_STD)
+               return 0;
+
        if (!is_hpet_capable())
                return 0;
 
@@ -784,13 +789,15 @@
        if (boot_hpet_disable)
                return -ENODEV;
 
-       if (!hpet_address) {
-               if (!force_hpet_address)
-                       return -ENODEV;
+       if (!hpet_virt_address) {
+               if (!hpet_address) {
+                       if (!force_hpet_address)
+                               return -ENODEV;
 
-               hpet_address = force_hpet_address;
+                       hpet_address = force_hpet_address;
+               }
                hpet_preferred_int_mode = HPET_INT_STD;
-               ret = hpet_enable();
+               ret = hpet_enable(0);
                if (ret < 0 || !hpet_virt_address)
                        return -ENODEV;
        }
Index: linux-2.6.21/Documentation/kernel-parameters.txt
===================================================================
--- linux-2.6.21.orig/Documentation/kernel-parameters.txt       2007-04-25 
20:08:32.000000000 -0700
+++ linux-2.6.21/Documentation/kernel-parameters.txt    2007-04-27 
15:31:31.000000000 -0700
@@ -384,8 +384,8 @@
                        over the 8254 in addition to over the IO-APIC. The
                        kernel tries to set a sensible default.
 
-       hpet=           [IA-32,HPET] option to disable HPET and use PIT.
-                       Format: disable
+       hpet=           [IA-32,HPET] option to choose HPET modes.
+                       Format: {disable | standard}
 
        cm206=          [HW,CD]
                        Format: { auto | [<io>,][<irq>] }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to