[ARM] 3616/1: fix timer handler wrap logic for a number of platforms
[powerpc.git] / arch / arm / mach-ixp2000 / core.c
index df14096..186f632 100644 (file)
@@ -84,63 +84,64 @@ static struct map_desc ixp2000_io_desc[] __initdata = {
                .virtual        = IXP2000_CAP_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_CAP_PHYS_BASE),
                .length         = IXP2000_CAP_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
        }, {
                .virtual        = IXP2000_INTCTL_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_INTCTL_PHYS_BASE),
                .length         = IXP2000_INTCTL_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
        }, {
                .virtual        = IXP2000_PCI_CREG_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_PCI_CREG_PHYS_BASE),
                .length         = IXP2000_PCI_CREG_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
        }, {
                .virtual        = IXP2000_PCI_CSR_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_PCI_CSR_PHYS_BASE),
                .length         = IXP2000_PCI_CSR_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
        }, {
                .virtual        = IXP2000_MSF_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_MSF_PHYS_BASE),
                .length         = IXP2000_MSF_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
+       }, {
+               .virtual        = IXP2000_SCRATCH_RING_VIRT_BASE,
+               .pfn            = __phys_to_pfn(IXP2000_SCRATCH_RING_PHYS_BASE),
+               .length         = IXP2000_SCRATCH_RING_SIZE,
+               .type           = MT_IXP2000_DEVICE,
+       }, {
+               .virtual        = IXP2000_SRAM0_VIRT_BASE,
+               .pfn            = __phys_to_pfn(IXP2000_SRAM0_PHYS_BASE),
+               .length         = IXP2000_SRAM0_SIZE,
+               .type           = MT_IXP2000_DEVICE,
        }, {
                .virtual        = IXP2000_PCI_IO_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_PCI_IO_PHYS_BASE),
                .length         = IXP2000_PCI_IO_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
        }, {
                .virtual        = IXP2000_PCI_CFG0_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_PCI_CFG0_PHYS_BASE),
                .length         = IXP2000_PCI_CFG0_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
        }, {
                .virtual        = IXP2000_PCI_CFG1_VIRT_BASE,
                .pfn            = __phys_to_pfn(IXP2000_PCI_CFG1_PHYS_BASE),
                .length         = IXP2000_PCI_CFG1_SIZE,
-               .type           = MT_DEVICE
+               .type           = MT_IXP2000_DEVICE,
        }
 };
 
 void __init ixp2000_map_io(void)
 {
-       extern unsigned int processor_id;
-
        /*
-        * On IXP2400 CPUs we need to use MT_IXP2000_DEVICE for
-        * tweaking the PMDs so XCB=101. On IXP2800s we use the normal
-        * PMD flags.
+        * On IXP2400 CPUs we need to use MT_IXP2000_DEVICE so that
+        * XCB=101 (to avoid triggering erratum #66), and given that
+        * this mode speeds up I/O accesses and we have write buffer
+        * flushes in the right places anyway, it doesn't hurt to use
+        * XCB=101 for all IXP2000s.
         */
-       if ((processor_id & 0xfffffff0) == 0x69054190) {
-               int i;
-
-               printk(KERN_INFO "Enabling IXP2400 erratum #66 workaround\n");
-
-               for(i=0;i<ARRAY_SIZE(ixp2000_io_desc);i++)
-                       ixp2000_io_desc[i].type = MT_IXP2000_DEVICE;
-       }
-
        iotable_init(ixp2000_io_desc, ARRAY_SIZE(ixp2000_io_desc));
 
        /* Set slowport to 8-bit mode.  */
@@ -210,7 +211,8 @@ static int ixp2000_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        /* clear timer 1 */
        ixp2000_reg_wrb(IXP2000_T1_CLR, 1);
 
-       while ((next_jiffy_time - *missing_jiffy_timer_csr) > ticks_per_jiffy) {
+       while ((signed long)(next_jiffy_time - *missing_jiffy_timer_csr)
+                                                       >= ticks_per_jiffy) {
                timer_tick(regs);
                next_jiffy_time -= ticks_per_jiffy;
        }
@@ -287,8 +289,6 @@ void gpio_line_config(int line, int direction)
 
        local_irq_save(flags);
        if (direction == GPIO_OUT) {
-               irq_desc[line + IRQ_IXP2000_GPIO0].valid = 0;
-
                /* if it's an output, it ain't an interrupt anymore */
                GPIO_IRQ_falling_edge &= ~(1 << line);
                GPIO_IRQ_rising_edge &= ~(1 << line);
@@ -350,11 +350,6 @@ static int ixp2000_GPIO_irq_type(unsigned int irq, unsigned int type)
                GPIO_IRQ_level_high &= ~(1 << line);
        update_gpio_int_csrs();
 
-       /*
-        * Finally, mark the corresponding IRQ as valid.
-        */
-       irq_desc[irq].valid = 1;
-
        return 0;
 }
 
@@ -505,14 +500,10 @@ void __init ixp2000_init_irq(void)
        }
        set_irq_chained_handler(IRQ_IXP2000_ERRSUM, ixp2000_err_irq_handler);
 
-       /*
-        * GPIO IRQs are invalid until someone sets the interrupt mode
-        * by calling set_irq_type().
-        */
        for (irq = IRQ_IXP2000_GPIO0; irq <= IRQ_IXP2000_GPIO7; irq++) {
                set_irq_chip(irq, &ixp2000_GPIO_irq_chip);
                set_irq_handler(irq, do_level_IRQ);
-               set_irq_flags(irq, 0);
+               set_irq_flags(irq, IRQF_VALID);
        }
        set_irq_chained_handler(IRQ_IXP2000_GPIO, ixp2000_GPIO_irq_handler);