http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / arch / arm / mach-iop3xx / iop310-irq.c
1 /*
2  * linux/arch/arm/mach-iop3xx/iop310-irq.c
3  *
4  * Generic IOP310 IRQ handling functionality
5  *
6  * Author:  Nicolas Pitre
7  * Copyright:   (C) 2001 MontaVista Software Inc.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  * Added IOP310 chipset and IQ80310 board demuxing, masking code. - DS
14  *
15  */
16 #include <linux/init.h>
17 #include <linux/interrupt.h>
18 #include <linux/list.h>
19
20 #include <asm/mach/irq.h>
21 #include <asm/irq.h>
22 #include <asm/hardware.h>
23
24 extern void xs80200_irq_mask(unsigned int);
25 extern void xs80200_irq_unmask(unsigned int);
26 extern void xs80200_init_irq(void);
27
28 extern void do_IRQ(int, struct pt_regs *);
29
30 static u32 iop310_mask /* = 0 */;
31
32 static void iop310_irq_mask (unsigned int irq)
33 {
34         iop310_mask ++;
35
36         /*
37          * No mask bits on the 80312, so we have to
38          * mask everything from the outside!
39          */
40         if (iop310_mask == 1) {
41                 disable_irq(IRQ_XS80200_EXTIRQ);
42                 irq_desc[IRQ_XS80200_EXTIRQ].chip->mask(IRQ_XS80200_EXTIRQ);
43         }
44 }
45
46 static void iop310_irq_unmask (unsigned int irq)
47 {
48         if (iop310_mask)
49                 iop310_mask --;
50
51         /*
52          * Check if all 80312 sources are unmasked now
53          */
54         if (iop310_mask == 0)
55                 enable_irq(IRQ_XS80200_EXTIRQ);
56 }
57
58 struct irqchip ext_chip = {
59         .ack    = iop310_irq_mask,
60         .mask   = iop310_irq_mask,
61         .unmask = iop310_irq_unmask,
62 };
63
64 void
65 iop310_irq_demux(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
66 {
67         u32 fiq1isr = *((volatile u32*)IOP310_FIQ1ISR);
68         u32 fiq2isr = *((volatile u32*)IOP310_FIQ2ISR);
69         struct irqdesc *d;
70         unsigned int irqno = 0;
71
72         if(fiq1isr)
73         {
74                 if(fiq1isr & 0x1)
75                         irqno = IRQ_IOP310_DMA0;
76                 if(fiq1isr & 0x2)
77                         irqno = IRQ_IOP310_DMA1;
78                 if(fiq1isr & 0x4)
79                         irqno = IRQ_IOP310_DMA2;
80                 if(fiq1isr & 0x10)
81                         irqno = IRQ_IOP310_PMON;
82                 if(fiq1isr & 0x20)
83                         irqno = IRQ_IOP310_AAU;
84         }
85         else
86         {
87                 if(fiq2isr & 0x2)
88                         irqno = IRQ_IOP310_I2C;
89                 if(fiq2isr & 0x4)
90                         irqno = IRQ_IOP310_MU;
91         }
92
93         if (irqno) {
94                 d = irq_desc + irqno;
95                 d->handle(irqno, d, regs);
96         }
97 }
98
99 void __init iop310_init_irq(void)
100 {
101         unsigned int i;
102
103         for(i = IOP310_IRQ_OFS; i < NR_IOP310_IRQS; i++)
104         {
105                 set_irq_chip(i, &ext_chip);
106                 set_irq_handler(i, do_level_IRQ);
107                 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
108         }
109
110         xs80200_init_irq();
111 }