sync hh.org
[hh.org.git] / arch / v850 / kernel / irq.c
blob858c45819aabe496dd663eb27195ea3d835b4f1c
1 /*
2 * arch/v850/kernel/irq.c -- High-level interrupt handling
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
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.
13 * This file was was derived from the mips version, arch/mips/kernel/irq.c
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>
27 #include <asm/system.h>
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.
34 void ack_bad_irq(unsigned int irq)
36 printk("received IRQ %d with unknown interrupt type\n", irq);
39 volatile unsigned long irq_err_count, spurious_count;
42 * Generic, controller-independent functions:
45 int show_interrupts(struct seq_file *p, void *v)
47 int irq = *(loff_t *) v;
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');
57 if (irq < NR_IRQS) {
58 unsigned long flags;
59 struct irqaction *action;
61 spin_lock_irqsave(&irq_desc[irq].lock, flags);
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;
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++;
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);
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');
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);
96 return 0;
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)
103 irq_enter();
104 __do_IRQ(irq, regs);
105 irq_exit();
106 return 1;
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)
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;