| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * arch/v850/kernel/irq.c -- High-level interrupt handling | 
|  | 3 | * | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 4 | *  Copyright (C) 2001,02,03,04,05  NEC Electronics Corporation | 
|  | 5 | *  Copyright (C) 2001,02,03,04,05  Miles Bader <miles@gnu.org> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | /* | 
| Christoph Hellwig | 0c53508 | 2005-11-15 00:09:18 -0800 | [diff] [blame] | 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. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | */ | 
| Christoph Hellwig | 0c53508 | 2005-11-15 00:09:18 -0800 | [diff] [blame] | 34 | void ack_bad_irq(unsigned int irq) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | printk("received IRQ %d with unknown interrupt type\n", irq); | 
|  | 37 | } | 
|  | 38 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | { | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 47 | int irq = *(loff_t *) v; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 |  | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 49 | if (irq == 0) { | 
|  | 50 | int cpu; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | seq_puts(p, "           "); | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 52 | for (cpu=0; cpu < 1 /*smp_num_cpus*/; cpu++) | 
|  | 53 | seq_printf(p, "CPU%d       ", cpu); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | seq_putc(p, '\n'); | 
|  | 55 | } | 
|  | 56 |  | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 57 | if (irq < NR_IRQS) { | 
|  | 58 | unsigned long flags; | 
|  | 59 | struct irqaction *action; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 |  | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 61 | spin_lock_irqsave(&irq_desc[irq].lock, flags); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 |  | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 63 | action = irq_desc[irq].action; | 
|  | 64 | if (action) { | 
|  | 65 | int j; | 
|  | 66 | int count = 0; | 
|  | 67 | int num = -1; | 
| Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 68 | const char *type_name = irq_desc[irq].chip->typename; | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 69 |  | 
|  | 70 | for (j = 0; j < NR_IRQS; j++) | 
| Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 71 | if (irq_desc[j].chip->typename == type_name){ | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 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); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 |  | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 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) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | seq_printf(p, "ERR: %10lu\n", irq_err_count); | 
| Miles Bader | 228322f | 2005-11-15 00:09:16 -0800 | [diff] [blame] | 95 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | return 0; | 
|  | 97 | } | 
|  | 98 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | irq_enter(); | 
| Christoph Hellwig | 0c53508 | 2005-11-15 00:09:18 -0800 | [diff] [blame] | 104 | __do_IRQ(irq, regs); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | irq_exit(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | return 1; | 
|  | 107 | } | 
|  | 108 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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; | 
| Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 120 | irq_desc[base_irq].chip = irq_type; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | base_irq += interval; | 
|  | 122 | } | 
|  | 123 | } |