2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1992 Linus Torvalds
7 * Copyright (C) 1994 - 2001, 2003 Ralf Baechle
9 #include <linux/init.h>
10 #include <linux/interrupt.h>
11 #include <linux/kernel.h>
12 #include <linux/spinlock.h>
14 #include <asm/i8259.h>
18 extern asmlinkage void jazz_handle_int(void);
20 static spinlock_t r4030_lock = SPIN_LOCK_UNLOCKED;
22 extern asmlinkage void sni_rm200_pci_handle_int(void);
24 static void enable_r4030_irq(unsigned int irq)
26 unsigned int mask = 1 << (irq - JAZZ_IE_PARALLEL);
29 spin_lock_irqsave(&r4030_lock, flags);
30 mask |= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
31 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
32 spin_unlock_irqrestore(&r4030_lock, flags);
35 static unsigned int startup_r4030_irq(unsigned int irq)
37 enable_r4030_irq(irq);
38 return 0; /* never anything pending */
41 #define shutdown_r4030_irq disable_r4030_irq
43 void disable_r4030_irq(unsigned int irq)
45 unsigned int mask = ~(1 << (irq - JAZZ_IE_PARALLEL));
48 spin_lock_irqsave(&r4030_lock, flags);
49 mask &= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
50 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
51 spin_unlock_irqrestore(&r4030_lock, flags);
54 #define mask_and_ack_r4030_irq disable_r4030_irq
56 static void end_r4030_irq(unsigned int irq)
58 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
59 enable_r4030_irq(irq);
62 static struct hw_interrupt_type r4030_irq_type = {
68 mask_and_ack_r4030_irq,
73 void __init init_r4030_ints(void)
77 for (i = JAZZ_PARALLEL_IRQ; i <= JAZZ_TIMER_IRQ; i++) {
78 irq_desc[i].status = IRQ_DISABLED;
79 irq_desc[i].action = 0;
80 irq_desc[i].depth = 1;
81 irq_desc[i].handler = &r4030_irq_type;
84 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0);
85 r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */
86 r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */
90 * On systems with i8259-style interrupt controllers we assume for
91 * driver compatibility reasons interrupts 0 - 15 to be the i8259
92 * interrupts even if the hardware uses a different interrupt numbering.
94 void __init init_IRQ (void)
96 set_except_vector(0, jazz_handle_int);
99 init_i8259_irqs(); /* Integrated i8259 */
102 change_c0_status(ST0_IM, IE_IRQ4 | IE_IRQ3 | IE_IRQ2 | IE_IRQ1);