Linux 2.6.13-rc4
[linux-2.6/next.git] / arch / mips / ddb5xxx / ddb5476 / vrc5476_irq.c
bloba77682be01ac27b908b5f6ac9a63351c46ac898e
1 /*
2 * The irq controller for vrc5476.
4 * Copyright (C) 2001 MontaVista Software Inc.
5 * Author: jsun@mvista.com or jsun@junsun.net
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/irq.h>
16 #include <linux/types.h>
17 #include <linux/ptrace.h>
19 #include <asm/system.h>
21 #include <asm/ddb5xxx/ddb5xxx.h>
23 static int irq_base;
25 static void vrc5476_irq_enable(uint irq)
27 nile4_enable_irq(irq - irq_base);
30 static void vrc5476_irq_disable(uint irq)
32 nile4_disable_irq(irq - irq_base);
35 static unsigned int vrc5476_irq_startup(uint irq)
37 nile4_enable_irq(irq - irq_base);
38 return 0;
41 #define vrc5476_irq_shutdown vrc5476_irq_disable
43 static void vrc5476_irq_ack(uint irq)
45 nile4_clear_irq(irq - irq_base);
46 nile4_disable_irq(irq - irq_base);
49 static void vrc5476_irq_end(uint irq)
51 if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
52 vrc5476_irq_enable(irq);
55 static hw_irq_controller vrc5476_irq_controller = {
56 "vrc5476",
57 vrc5476_irq_startup,
58 vrc5476_irq_shutdown,
59 vrc5476_irq_enable,
60 vrc5476_irq_disable,
61 vrc5476_irq_ack,
62 vrc5476_irq_end,
63 NULL /* no affinity stuff for UP */
66 void __init
67 vrc5476_irq_init(u32 base)
69 u32 i;
71 irq_base = base;
72 for (i= base; i< base + NUM_VRC5476_IRQ; i++) {
73 irq_desc[i].status = IRQ_DISABLED;
74 irq_desc[i].action = NULL;
75 irq_desc[i].depth = 1;
76 irq_desc[i].handler = &vrc5476_irq_controller;
81 asmlinkage void
82 vrc5476_irq_dispatch(struct pt_regs *regs)
84 extern void spurious_interrupt(void);
86 u32 mask;
87 int nile4_irq;
89 mask = nile4_get_irq_stat(0);
91 /* quick check for possible time interrupt */
92 if (mask & (1 << VRC5476_IRQ_GPT)) {
93 do_IRQ(VRC5476_IRQ_BASE + VRC5476_IRQ_GPT, regs);
94 return;
97 /* check for i8259 interrupts */
98 if (mask & (1 << VRC5476_I8259_CASCADE)) {
99 int i8259_irq = nile4_i8259_iack();
100 do_IRQ(I8259_IRQ_BASE + i8259_irq, regs);
101 return;
104 /* regular nile4 interrupts (we should not really have any */
105 for (nile4_irq = 0; mask; nile4_irq++, mask >>= 1) {
106 if (mask & 1) {
107 do_IRQ(VRC5476_IRQ_BASE + nile4_irq, regs);
108 return;
111 spurious_interrupt();