Pull video into test branch
[linux-drm-fsl-dcu.git] / arch / mips / vr41xx / nec-cmbvr4133 / irq.c
1 /*
2  * arch/mips/vr41xx/nec-cmbvr4133/irq.c
3  *
4  * Interrupt routines for the NEC CMB-VR4133 board.
5  *
6  * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
7  *         Alex Sapkov <asapkov@ru.mvista.com>
8  *
9  * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under
10  * the terms of the GNU General Public License version 2. This program
11  * is licensed "as is" without any warranty of any kind, whether express
12  * or implied.
13  *
14  * Support for NEC-CMBVR4133 in 2.6
15  * Manish Lachwani (mlachwani@mvista.com)
16  */
17 #include <linux/bitops.h>
18 #include <linux/errno.h>
19 #include <linux/init.h>
20 #include <linux/ioport.h>
21 #include <linux/interrupt.h>
22
23 #include <asm/io.h>
24 #include <asm/vr41xx/cmbvr4133.h>
25
26 extern void enable_8259A_irq(unsigned int irq);
27 extern void disable_8259A_irq(unsigned int irq);
28 extern void mask_and_ack_8259A(unsigned int irq);
29 extern void init_8259A(int hoge);
30
31 extern int vr4133_rockhopper;
32
33 static void enable_i8259_irq(unsigned int irq)
34 {
35         enable_8259A_irq(irq - I8259_IRQ_BASE);
36 }
37
38 static void disable_i8259_irq(unsigned int irq)
39 {
40         disable_8259A_irq(irq - I8259_IRQ_BASE);
41 }
42
43 static void ack_i8259_irq(unsigned int irq)
44 {
45         mask_and_ack_8259A(irq - I8259_IRQ_BASE);
46 }
47
48 static struct irq_chip i8259_irq_type = {
49         .typename       = "XT-PIC",
50         .ack            = ack_i8259_irq,
51         .mask           = disable_i8259_irq,
52         .mask_ack       = ack_i8259_irq,
53         .unmask         = enable_i8259_irq,
54 };
55
56 static int i8259_get_irq_number(int irq)
57 {
58         unsigned long isr;
59
60         isr = inb(0x20);
61         irq = ffz(~isr);
62         if (irq == 2) {
63                 isr = inb(0xa0);
64                 irq = 8 + ffz(~isr);
65         }
66
67         if (irq < 0 || irq > 15)
68                 return -EINVAL;
69
70         return I8259_IRQ_BASE + irq;
71 }
72
73 static struct irqaction i8259_slave_cascade = {
74         .handler        = &no_action,
75         .name           = "cascade",
76 };
77
78 void __init rockhopper_init_irq(void)
79 {
80         int i;
81
82         if(!vr4133_rockhopper) {
83                 printk(KERN_ERR "Not a Rockhopper Board \n");
84                 return;
85         }
86
87         for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++)
88                 set_irq_chip_and_handler(i, &i8259_irq_type, handle_level_irq);
89
90         setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade);
91
92         vr41xx_set_irq_trigger(CMBVR41XX_INTC_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
93         vr41xx_set_irq_level(CMBVR41XX_INTC_PIN, LEVEL_HIGH);
94         vr41xx_cascade_irq(CMBVR41XX_INTC_IRQ, i8259_get_irq_number);
95 }