Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/ppc/amiga/ints.c |
| 3 | * |
| 4 | * Linux/m68k general interrupt handling code from arch/m68k/kernel/ints.c |
| 5 | * Needed to drive the m68k emulating IRQ hardware on the PowerUp boards. |
| 6 | */ |
| 7 | |
| 8 | #include <linux/types.h> |
| 9 | #include <linux/sched.h> |
| 10 | #include <linux/kernel_stat.h> |
| 11 | #include <linux/errno.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/seq_file.h> |
| 14 | |
| 15 | #include <asm/setup.h> |
| 16 | #include <asm/system.h> |
| 17 | #include <asm/irq.h> |
| 18 | #include <asm/traps.h> |
| 19 | #include <asm/page.h> |
| 20 | #include <asm/machdep.h> |
| 21 | |
| 22 | /* table for system interrupt handlers */ |
| 23 | static irq_handler_t irq_list[SYS_IRQS]; |
| 24 | |
| 25 | static const char *default_names[SYS_IRQS] = { |
| 26 | "spurious int", "int1 handler", "int2 handler", "int3 handler", |
| 27 | "int4 handler", "int5 handler", "int6 handler", "int7 handler" |
| 28 | }; |
| 29 | |
| 30 | /* The number of spurious interrupts */ |
| 31 | volatile unsigned int num_spurious; |
| 32 | |
| 33 | #define NUM_IRQ_NODES 100 |
| 34 | static irq_node_t nodes[NUM_IRQ_NODES]; |
| 35 | |
| 36 | |
| 37 | /* |
| 38 | * void init_IRQ(void) |
| 39 | * |
| 40 | * Parameters: None |
| 41 | * |
| 42 | * Returns: Nothing |
| 43 | * |
| 44 | * This function should be called during kernel startup to initialize |
| 45 | * the IRQ handling routines. |
| 46 | */ |
| 47 | |
| 48 | __init |
| 49 | void m68k_init_IRQ(void) |
| 50 | { |
| 51 | int i; |
| 52 | |
| 53 | for (i = 0; i < SYS_IRQS; i++) { |
| 54 | if (mach_default_handler) |
| 55 | irq_list[i].handler = (*mach_default_handler)[i]; |
| 56 | irq_list[i].flags = 0; |
| 57 | irq_list[i].dev_id = NULL; |
| 58 | irq_list[i].devname = default_names[i]; |
| 59 | } |
| 60 | |
| 61 | for (i = 0; i < NUM_IRQ_NODES; i++) |
| 62 | nodes[i].handler = NULL; |
| 63 | |
| 64 | mach_init_IRQ (); |
| 65 | } |
| 66 | |
| 67 | irq_node_t *new_irq_node(void) |
| 68 | { |
| 69 | irq_node_t *node; |
| 70 | short i; |
| 71 | |
| 72 | for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) |
| 73 | if (!node->handler) |
| 74 | return node; |
| 75 | |
| 76 | printk ("new_irq_node: out of nodes\n"); |
| 77 | return NULL; |
| 78 | } |
| 79 | |
| 80 | int sys_request_irq(unsigned int irq, |
| 81 | void (*handler)(int, void *, struct pt_regs *), |
| 82 | unsigned long flags, const char *devname, void *dev_id) |
| 83 | { |
| 84 | if (irq < IRQ1 || irq > IRQ7) { |
| 85 | printk("%s: Incorrect IRQ %d from %s\n", |
| 86 | __FUNCTION__, irq, devname); |
| 87 | return -ENXIO; |
| 88 | } |
| 89 | |
| 90 | #if 0 |
| 91 | if (!(irq_list[irq].flags & IRQ_FLG_STD)) { |
| 92 | if (irq_list[irq].flags & IRQ_FLG_LOCK) { |
| 93 | printk("%s: IRQ %d from %s is not replaceable\n", |
| 94 | __FUNCTION__, irq, irq_list[irq].devname); |
| 95 | return -EBUSY; |
| 96 | } |
| 97 | if (!(flags & IRQ_FLG_REPLACE)) { |
| 98 | printk("%s: %s can't replace IRQ %d from %s\n", |
| 99 | __FUNCTION__, devname, irq, irq_list[irq].devname); |
| 100 | return -EBUSY; |
| 101 | } |
| 102 | } |
| 103 | #endif |
| 104 | |
| 105 | irq_list[irq].handler = handler; |
| 106 | irq_list[irq].flags = flags; |
| 107 | irq_list[irq].dev_id = dev_id; |
| 108 | irq_list[irq].devname = devname; |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | void sys_free_irq(unsigned int irq, void *dev_id) |
| 113 | { |
| 114 | if (irq < IRQ1 || irq > IRQ7) { |
| 115 | printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq); |
| 116 | return; |
| 117 | } |
| 118 | |
| 119 | if (irq_list[irq].dev_id != dev_id) |
| 120 | printk("%s: Removing probably wrong IRQ %d from %s\n", |
| 121 | __FUNCTION__, irq, irq_list[irq].devname); |
| 122 | |
| 123 | irq_list[irq].handler = (*mach_default_handler)[irq]; |
| 124 | irq_list[irq].flags = 0; |
| 125 | irq_list[irq].dev_id = NULL; |
| 126 | irq_list[irq].devname = default_names[irq]; |
| 127 | } |
| 128 | |
| 129 | asmlinkage void process_int(unsigned long vec, struct pt_regs *fp) |
| 130 | { |
| 131 | if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) { |
| 132 | vec -= VEC_SPUR; |
| 133 | kstat_cpu(0).irqs[vec]++; |
| 134 | irq_list[vec].handler(vec, irq_list[vec].dev_id, fp); |
| 135 | } else { |
| 136 | if (mach_process_int) |
| 137 | mach_process_int(vec, fp); |
| 138 | else |
| 139 | panic("Can't process interrupt vector %ld\n", vec); |
| 140 | return; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | int m68k_get_irq_list(struct seq_file *p, void *v) |
| 145 | { |
| 146 | int i; |
| 147 | |
| 148 | /* autovector interrupts */ |
| 149 | if (mach_default_handler) { |
| 150 | for (i = 0; i < SYS_IRQS; i++) { |
| 151 | seq_printf(p, "auto %2d: %10u ", i, |
| 152 | i ? kstat_cpu(0).irqs[i] : num_spurious); |
| 153 | seq_puts(p, " "); |
| 154 | seq_printf(p, "%s\n", irq_list[i].devname); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | mach_get_irq_list(p, v); |
| 159 | return 0; |
| 160 | } |