Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 unsigned int startup_i8259_irq(unsigned int irq) |
| 34 | { |
| 35 | enable_8259A_irq(irq - I8259_IRQ_BASE); |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | static void shutdown_i8259_irq(unsigned int irq) |
| 40 | { |
| 41 | disable_8259A_irq(irq - I8259_IRQ_BASE); |
| 42 | } |
| 43 | |
| 44 | static void enable_i8259_irq(unsigned int irq) |
| 45 | { |
| 46 | enable_8259A_irq(irq - I8259_IRQ_BASE); |
| 47 | } |
| 48 | |
| 49 | static void disable_i8259_irq(unsigned int irq) |
| 50 | { |
| 51 | disable_8259A_irq(irq - I8259_IRQ_BASE); |
| 52 | } |
| 53 | |
| 54 | static void ack_i8259_irq(unsigned int irq) |
| 55 | { |
| 56 | mask_and_ack_8259A(irq - I8259_IRQ_BASE); |
| 57 | } |
| 58 | |
| 59 | static void end_i8259_irq(unsigned int irq) |
| 60 | { |
| 61 | if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) |
| 62 | enable_8259A_irq(irq - I8259_IRQ_BASE); |
| 63 | } |
| 64 | |
| 65 | static struct hw_interrupt_type i8259_irq_type = { |
| 66 | .typename = "XT-PIC", |
| 67 | .startup = startup_i8259_irq, |
| 68 | .shutdown = shutdown_i8259_irq, |
| 69 | .enable = enable_i8259_irq, |
| 70 | .disable = disable_i8259_irq, |
| 71 | .ack = ack_i8259_irq, |
| 72 | .end = end_i8259_irq, |
| 73 | }; |
| 74 | |
| 75 | static int i8259_get_irq_number(int irq) |
| 76 | { |
| 77 | unsigned long isr; |
| 78 | |
| 79 | isr = inb(0x20); |
| 80 | irq = ffz(~isr); |
| 81 | if (irq == 2) { |
| 82 | isr = inb(0xa0); |
| 83 | irq = 8 + ffz(~isr); |
| 84 | } |
| 85 | |
| 86 | if (irq < 0 || irq > 15) |
| 87 | return -EINVAL; |
| 88 | |
| 89 | return I8259_IRQ_BASE + irq; |
| 90 | } |
| 91 | |
| 92 | static struct irqaction i8259_slave_cascade = { |
| 93 | .handler = &no_action, |
| 94 | .name = "cascade", |
| 95 | }; |
| 96 | |
| 97 | void __init rockhopper_init_irq(void) |
| 98 | { |
| 99 | int i; |
| 100 | |
| 101 | if(!vr4133_rockhopper) { |
| 102 | printk(KERN_ERR "Not a Rockhopper Board \n"); |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | for (i = I8259_IRQ_BASE; i <= I8259_IRQ_LAST; i++) |
| 107 | irq_desc[i].handler = &i8259_irq_type; |
| 108 | |
| 109 | setup_irq(I8259_SLAVE_IRQ, &i8259_slave_cascade); |
| 110 | |
| 111 | vr41xx_set_irq_trigger(CMBVR41XX_INTC_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH); |
| 112 | vr41xx_set_irq_level(CMBVR41XX_INTC_PIN, LEVEL_HIGH); |
| 113 | vr41xx_cascade_irq(CMBVR41XX_INTC_IRQ, i8259_get_irq_number); |
| 114 | } |