2 * BRIEF MODULE DESCRIPTION
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
13 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
14 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
15 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
16 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
17 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <linux/init.h>
27 #include <linux/interrupt.h>
29 #include <asm/mach-au1x00/au1000.h>
31 #ifdef CONFIG_MIPS_PB1200
32 #include <asm/mach-pb1x00/pb1200.h>
35 #ifdef CONFIG_MIPS_DB1200
36 #include <asm/mach-db1x00/db1200.h>
37 #define PB1200_INT_BEGIN DB1200_INT_BEGIN
38 #define PB1200_INT_END DB1200_INT_END
41 struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
42 /* This is external interrupt cascade */
43 { AU1000_GPIO_7, IRQF_TRIGGER_LOW, 0 },
48 * Support for External interrupts on the Pb1200 Development platform.
50 static volatile int pb1200_cascade_en;
52 irqreturn_t pb1200_cascade_handler(int irq, void *dev_id)
54 unsigned short bisr = bcsr->int_status;
57 /* Clear all the edge interrupts. This has no effect on level. */
58 bcsr->int_status = bisr;
59 for ( ; bisr; bisr &= bisr - 1) {
60 extirq_nr = PB1200_INT_BEGIN + __ffs(bisr);
61 /* Ack and dispatch IRQ */
68 inline void pb1200_enable_irq(unsigned int irq_nr)
70 bcsr->intset_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
71 bcsr->intset = 1 << (irq_nr - PB1200_INT_BEGIN);
74 inline void pb1200_disable_irq(unsigned int irq_nr)
76 bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
77 bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
80 static unsigned int pb1200_setup_cascade(void)
82 return request_irq(AU1000_GPIO_7, &pb1200_cascade_handler,
83 0, "Pb1200 Cascade", &pb1200_cascade_handler);
86 static unsigned int pb1200_startup_irq(unsigned int irq)
88 if (++pb1200_cascade_en == 1) {
91 res = pb1200_setup_cascade();
96 pb1200_enable_irq(irq);
101 static void pb1200_shutdown_irq(unsigned int irq)
103 pb1200_disable_irq(irq);
104 if (--pb1200_cascade_en == 0)
105 free_irq(AU1000_GPIO_7, &pb1200_cascade_handler);
108 static struct irq_chip external_irq_type = {
109 #ifdef CONFIG_MIPS_PB1200
110 .name = "Pb1200 Ext",
112 #ifdef CONFIG_MIPS_DB1200
113 .name = "Db1200 Ext",
115 .startup = pb1200_startup_irq,
116 .shutdown = pb1200_shutdown_irq,
117 .ack = pb1200_disable_irq,
118 .mask = pb1200_disable_irq,
119 .mask_ack = pb1200_disable_irq,
120 .unmask = pb1200_enable_irq,
123 void __init board_init_irq(void)
127 au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
129 #ifdef CONFIG_MIPS_PB1200
130 /* We have a problem with CPLD rev 3. */
131 if (((bcsr->whoami & BCSR_WHOAMI_CPLD) >> 4) <= 3) {
132 printk(KERN_ERR "WARNING!!!\n");
133 printk(KERN_ERR "WARNING!!!\n");
134 printk(KERN_ERR "WARNING!!!\n");
135 printk(KERN_ERR "WARNING!!!\n");
136 printk(KERN_ERR "WARNING!!!\n");
137 printk(KERN_ERR "WARNING!!!\n");
138 printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n");
139 printk(KERN_ERR "updated to latest revision. This software will\n");
140 printk(KERN_ERR "not work on anything less than CPLD rev 4.\n");
141 printk(KERN_ERR "WARNING!!!\n");
142 printk(KERN_ERR "WARNING!!!\n");
143 printk(KERN_ERR "WARNING!!!\n");
144 printk(KERN_ERR "WARNING!!!\n");
145 printk(KERN_ERR "WARNING!!!\n");
146 printk(KERN_ERR "WARNING!!!\n");
147 panic("Game over. Your score is 0.");
151 for (irq = PB1200_INT_BEGIN; irq <= PB1200_INT_END; irq++) {
152 set_irq_chip_and_handler(irq, &external_irq_type,
154 pb1200_disable_irq(irq);
158 * GPIO_7 can not be hooked here, so it is hooked upon first
159 * request of any source attached to the cascade.