Merge master.kernel.org:/pub/scm/linux/kernel/git/kyle/parisc-2.6
[linux-2.6] / arch / v850 / kernel / irq.c
1 /*
2  * arch/v850/kernel/irq.c -- High-level interrupt handling
3  *
4  *  Copyright (C) 2001,02,03,04,05  NEC Electronics Corporation
5  *  Copyright (C) 2001,02,03,04,05  Miles Bader <miles@gnu.org>
6  *  Copyright (C) 1994-2000  Ralf Baechle
7  *  Copyright (C) 1992  Linus Torvalds
8  *
9  * This file is subject to the terms and conditions of the GNU General
10  * Public License.  See the file COPYING in the main directory of this
11  * archive for more details.
12  *
13  * This file was was derived from the mips version, arch/mips/kernel/irq.c
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/irq.h>
19 #include <linux/init.h>
20 #include <linux/interrupt.h>
21 #include <linux/kernel_stat.h>
22 #include <linux/slab.h>
23 #include <linux/mm.h>
24 #include <linux/random.h>
25 #include <linux/seq_file.h>
26
27 #include <asm/system.h>
28
29 /*
30  * 'what should we do if we get a hw irq event on an illegal vector'.
31  * each architecture has to answer this themselves, it doesn't deserve
32  * a generic callback i think.
33  */
34 void ack_bad_irq(unsigned int irq)
35 {
36         printk("received IRQ %d with unknown interrupt type\n", irq);
37 }
38
39 volatile unsigned long irq_err_count, spurious_count;
40
41 /*
42  * Generic, controller-independent functions:
43  */
44
45 int show_interrupts(struct seq_file *p, void *v)
46 {
47         int irq = *(loff_t *) v;
48
49         if (irq == 0) {
50                 int cpu;
51                 seq_puts(p, "           ");
52                 for (cpu=0; cpu < 1 /*smp_num_cpus*/; cpu++)
53                         seq_printf(p, "CPU%d       ", cpu);
54                 seq_putc(p, '\n');
55         }
56
57         if (irq < NR_IRQS) {
58                 unsigned long flags;
59                 struct irqaction *action;
60
61                 spin_lock_irqsave(&irq_desc[irq].lock, flags);
62
63                 action = irq_desc[irq].action;
64                 if (action) {
65                         int j;
66                         int count = 0;
67                         int num = -1;
68                         const char *type_name = irq_desc[irq].chip->typename;
69
70                         for (j = 0; j < NR_IRQS; j++)
71                                 if (irq_desc[j].chip->typename == type_name){
72                                         if (irq == j)
73                                                 num = count;
74                                         count++;
75                                 }
76
77                         seq_printf(p, "%3d: ",irq);
78                         seq_printf(p, "%10u ", kstat_irqs(irq));
79                         if (count > 1) {
80                                 int prec = (num >= 100 ? 3 : num >= 10 ? 2 : 1);
81                                 seq_printf(p, " %*s%d", 14 - prec,
82                                            type_name, num);
83                         } else
84                                 seq_printf(p, " %14s", type_name);
85                 
86                         seq_printf(p, "  %s", action->name);
87                         for (action=action->next; action; action = action->next)
88                                 seq_printf(p, ", %s", action->name);
89                         seq_putc(p, '\n');
90                 }
91
92                 spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
93         } else if (irq == NR_IRQS)
94                 seq_printf(p, "ERR: %10lu\n", irq_err_count);
95
96         return 0;
97 }
98
99 /* Handle interrupt IRQ.  REGS are the registers at the time of ther
100    interrupt.  */
101 unsigned int handle_irq (int irq, struct pt_regs *regs)
102 {
103         irq_enter();
104         __do_IRQ(irq, regs);
105         irq_exit();
106         return 1;
107 }
108
109 /* Initialize irq handling for IRQs.
110    BASE_IRQ, BASE_IRQ+INTERVAL, ..., BASE_IRQ+NUM*INTERVAL
111    to IRQ_TYPE.  An IRQ_TYPE of 0 means to use a generic interrupt type.  */
112 void __init
113 init_irq_handlers (int base_irq, int num, int interval,
114                    struct hw_interrupt_type *irq_type)
115 {
116         while (num-- > 0) {
117                 irq_desc[base_irq].status  = IRQ_DISABLED;
118                 irq_desc[base_irq].action  = NULL;
119                 irq_desc[base_irq].depth   = 1;
120                 irq_desc[base_irq].chip = irq_type;
121                 base_irq += interval;
122         }
123 }