This commit was generated by cvs2svn to compensate for changes in r1129,
[linux-2.6.git] / arch / i386 / kernel / timers / timer_pit.c
index 7ddbf1c..b9b6bd5 100644 (file)
@@ -6,15 +6,16 @@
 #include <linux/spinlock.h>
 #include <linux/module.h>
 #include <linux/device.h>
-#include <linux/irq.h>
+#include <linux/sysdev.h>
+#include <linux/timex.h>
+#include <asm/delay.h>
 #include <asm/mpspec.h>
 #include <asm/timer.h>
 #include <asm/smp.h>
 #include <asm/io.h>
 #include <asm/arch_hooks.h>
+#include <asm/i8253.h>
 
-extern spinlock_t i8259A_lock;
-extern spinlock_t i8253_lock;
 #include "do_timer.h"
 #include "io_ports.h"
 
@@ -24,8 +25,9 @@ static int __init init_pit(char* override)
 {
        /* check clock override */
        if (override[0] && strncmp(override,"pit",3))
-               printk(KERN_ERR "Warning: clock= override failed. Defaulting to PIT\n");
+               printk(KERN_ERR "Warning: clock= override failed. Defaulting "
+                               "to PIT\n");
+       init_cpu_khz();
        count_p = LATCH;
        return 0;
 }
@@ -149,10 +151,27 @@ static unsigned long get_offset_pit(void)
 
 /* tsc timer_opts struct */
 struct timer_opts timer_pit = {
-       .name =         "pit",
-       .init =         init_pit, 
-       .mark_offset =  mark_offset_pit, 
-       .get_offset =   get_offset_pit,
+       .name = "pit",
+       .mark_offset = mark_offset_pit, 
+       .get_offset = get_offset_pit,
        .monotonic_clock = monotonic_clock_pit,
        .delay = delay_pit,
 };
+
+struct init_timer_opts __initdata timer_pit_init = {
+       .init = init_pit, 
+       .opts = &timer_pit,
+};
+
+void setup_pit_timer(void)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&i8253_lock, flags);
+       outb_p(0x34,PIT_MODE);          /* binary, mode 2, LSB/MSB, ch 0 */
+       udelay(10);
+       outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
+       udelay(10);
+       outb(LATCH >> 8 , PIT_CH0);     /* MSB */
+       spin_unlock_irqrestore(&i8253_lock, flags);
+}