]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/mips/kernel/i8253.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / arch / mips / kernel / i8253.c
index 5d9830df3595d6fb9625b9acbb1a3560413969cb..38fa1a194bf4b429f4146ff427239cfa6b6aa0c4 100644 (file)
 #include <asm/delay.h>
 #include <asm/i8253.h>
 #include <asm/io.h>
+#include <asm/time.h>
 
-static DEFINE_SPINLOCK(i8253_lock);
+DEFINE_SPINLOCK(i8253_lock);
+EXPORT_SYMBOL(i8253_lock);
 
 /*
  * Initialize the PIT timer.
@@ -23,9 +25,7 @@ static DEFINE_SPINLOCK(i8253_lock);
 static void init_pit_timer(enum clock_event_mode mode,
                           struct clock_event_device *evt)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&i8253_lock, flags);
+       spin_lock(&i8253_lock);
 
        switch(mode) {
        case CLOCK_EVT_MODE_PERIODIC:
@@ -54,7 +54,7 @@ static void init_pit_timer(enum clock_event_mode mode,
                /* Nothing to do here */
                break;
        }
-       spin_unlock_irqrestore(&i8253_lock, flags);
+       spin_unlock(&i8253_lock);
 }
 
 /*
@@ -64,12 +64,10 @@ static void init_pit_timer(enum clock_event_mode mode,
  */
 static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&i8253_lock, flags);
+       spin_lock(&i8253_lock);
        outb_p(delta & 0xff , PIT_CH0); /* LSB */
        outb(delta >> 8 , PIT_CH0);     /* MSB */
-       spin_unlock_irqrestore(&i8253_lock, flags);
+       spin_unlock(&i8253_lock);
 
        return 0;
 }
@@ -87,11 +85,10 @@ struct clock_event_device pit_clockevent = {
        .features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
        .set_mode       = init_pit_timer,
        .set_next_event = pit_next_event,
-       .shift          = 32,
        .irq            = 0,
 };
 
-irqreturn_t timer_interrupt(int irq, void *dev_id)
+static irqreturn_t timer_interrupt(int irq, void *dev_id)
 {
        pit_clockevent.event_handler(&pit_clockevent);
 
@@ -111,19 +108,20 @@ static struct irqaction irq0  = {
  */
 void __init setup_pit_timer(void)
 {
+       struct clock_event_device *cd = &pit_clockevent;
+       unsigned int cpu = smp_processor_id();
+
        /*
         * Start pit with the boot cpu mask and make it global after the
         * IO_APIC has been initialized.
         */
-       pit_clockevent.cpumask = cpumask_of_cpu(0);
-       pit_clockevent.mult = div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, 32);
-       pit_clockevent.max_delta_ns =
-               clockevent_delta2ns(0x7FFF, &pit_clockevent);
-       pit_clockevent.min_delta_ns =
-               clockevent_delta2ns(0xF, &pit_clockevent);
-       clockevents_register_device(&pit_clockevent);
-
-       irq0.mask = cpumask_of_cpu(0);
+       cd->cpumask = cpumask_of_cpu(cpu);
+       clockevent_set_clock(cd, CLOCK_TICK_RATE);
+       cd->max_delta_ns = clockevent_delta2ns(0x7FFF, cd);
+       cd->min_delta_ns = clockevent_delta2ns(0xF, cd);
+       clockevents_register_device(cd);
+
+       irq0.mask = cpumask_of_cpu(cpu);
        setup_irq(0, &irq0);
 }