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/irq_cpu.h>
15 #include <asm/i8259.h>
18 #include <asm/pgtable.h>
20 static DEFINE_SPINLOCK(r4030_lock);
22 static void enable_r4030_irq(unsigned int irq)
24 unsigned int mask = 1 << (irq - JAZZ_IRQ_START);
27 spin_lock_irqsave(&r4030_lock, flags);
28 mask |= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
29 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
30 spin_unlock_irqrestore(&r4030_lock, flags);
33 void disable_r4030_irq(unsigned int irq)
35 unsigned int mask = ~(1 << (irq - JAZZ_IRQ_START));
38 spin_lock_irqsave(&r4030_lock, flags);
39 mask &= r4030_read_reg16(JAZZ_IO_IRQ_ENABLE);
40 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, mask);
41 spin_unlock_irqrestore(&r4030_lock, flags);
44 static struct irq_chip r4030_irq_type = {
46 .ack = disable_r4030_irq,
47 .mask = disable_r4030_irq,
48 .mask_ack = disable_r4030_irq,
49 .unmask = enable_r4030_irq,
52 void __init init_r4030_ints(void)
56 for (i = JAZZ_IRQ_START; i <= JAZZ_IRQ_END; i++)
57 set_irq_chip_and_handler(i, &r4030_irq_type, handle_level_irq);
59 r4030_write_reg16(JAZZ_IO_IRQ_ENABLE, 0);
60 r4030_read_reg16(JAZZ_IO_IRQ_SOURCE); /* clear pending IRQs */
61 r4030_read_reg32(JAZZ_R4030_INVAL_ADDR); /* clear error bits */
65 * On systems with i8259-style interrupt controllers we assume for
66 * driver compatibility reasons interrupts 0 - 15 to be the i8259
67 * interrupts even if the hardware uses a different interrupt numbering.
69 void __init arch_init_irq(void)
72 * this is a hack to get back the still needed wired mapping
76 /* Map 0xe0000000 -> 0x0:800005C0, 0xe0010000 -> 0x1:30000580 */
77 add_wired_entry(0x02000017, 0x03c00017, 0xe0000000, PM_64K);
78 /* Map 0xe2000000 -> 0x0:900005C0, 0xe3010000 -> 0x0:910005C0 */
79 add_wired_entry(0x02400017, 0x02440017, 0xe2000000, PM_16M);
80 /* Map 0xe4000000 -> 0x0:600005C0, 0xe4100000 -> 400005C0 */
81 add_wired_entry(0x01800017, 0x01000017, 0xe4000000, PM_4M);
83 init_i8259_irqs(); /* Integrated i8259 */
87 change_c0_status(ST0_IM, IE_IRQ2 | IE_IRQ1);
90 asmlinkage void plat_irq_dispatch(void)
92 unsigned int pending = read_c0_cause() & read_c0_status();
95 if (pending & IE_IRQ4) {
96 r4030_read_reg32(JAZZ_TIMER_REGISTER);
97 do_IRQ(JAZZ_TIMER_IRQ);
98 } else if (pending & IE_IRQ2)
99 do_IRQ(r4030_read_reg32(JAZZ_EISA_IRQ_ACK));
100 else if (pending & IE_IRQ1) {
101 irq = *(volatile u8 *)JAZZ_IO_IRQ_SOURCE >> 2;
103 do_IRQ(irq + JAZZ_IRQ_START - 1);
105 panic("Unimplemented loc_no_irq handler");