]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/mips/jazz/irq.c
[MIPS] JAZZ fixes
[linux-2.6-omap-h63xx.git] / arch / mips / jazz / irq.c
1 /*
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
4  * for more details.
5  *
6  * Copyright (C) 1992 Linus Torvalds
7  * Copyright (C) 1994 - 2001, 2003 Ralf Baechle
8  */
9 #include <linux/init.h>
10 #include <linux/interrupt.h>
11 #include <linux/kernel.h>
12 #include <linux/spinlock.h>
13
14 #include <asm/irq_cpu.h>
15 #include <asm/i8259.h>
16 #include <asm/io.h>
17 #include <asm/jazz.h>
18 #include <asm/pgtable.h>
19
20 static DEFINE_SPINLOCK(r4030_lock);
21
22 static void enable_r4030_irq(unsigned int irq)
23 {
24         unsigned int mask = 1 << (irq - JAZZ_IRQ_START);
25         unsigned long flags;
26
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);
31 }
32
33 void disable_r4030_irq(unsigned int irq)
34 {
35         unsigned int mask = ~(1 << (irq - JAZZ_IRQ_START));
36         unsigned long flags;
37
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);
42 }
43
44 static struct irq_chip r4030_irq_type = {
45         .name = "R4030",
46         .ack = disable_r4030_irq,
47         .mask = disable_r4030_irq,
48         .mask_ack = disable_r4030_irq,
49         .unmask = enable_r4030_irq,
50 };
51
52 void __init init_r4030_ints(void)
53 {
54         int i;
55
56         for (i = JAZZ_IRQ_START; i <= JAZZ_IRQ_END; i++)
57                 set_irq_chip_and_handler(i, &r4030_irq_type, handle_level_irq);
58
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 */
62 }
63
64 /*
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.
68  */
69 void __init arch_init_irq(void)
70 {
71         /*
72          * this is a hack to get back the still needed wired mapping
73          * killed by init_mm()
74          */
75
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);
82
83         init_i8259_irqs();                      /* Integrated i8259  */
84         mips_cpu_irq_init();
85         init_r4030_ints();
86
87         change_c0_status(ST0_IM, IE_IRQ2 | IE_IRQ1);
88 }
89
90 asmlinkage void plat_irq_dispatch(void)
91 {
92         unsigned int pending = read_c0_cause() & read_c0_status();
93         unsigned int irq;
94
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;
102                 if (likely(irq > 0))
103                         do_IRQ(irq + JAZZ_IRQ_START - 1);
104                 else
105                         panic("Unimplemented loc_no_irq handler");
106         }
107 }