Merge branch 'upstream-fixes'
[linux-2.6/linux-loongson.git] / arch / ppc / amiga / ints.c
blob5d318e498f06f7ece7fba335be1db7cde9952da1
1 /*
2 * arch/ppc/amiga/ints.c
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 */
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>
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>
22 /* table for system interrupt handlers */
23 static irq_handler_t irq_list[SYS_IRQS];
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"
30 /* The number of spurious interrupts */
31 volatile unsigned int num_spurious;
33 #define NUM_IRQ_NODES 100
34 static irq_node_t nodes[NUM_IRQ_NODES];
38 * void init_IRQ(void)
40 * Parameters: None
42 * Returns: Nothing
44 * This function should be called during kernel startup to initialize
45 * the IRQ handling routines.
48 __init
49 void m68k_init_IRQ(void)
51 int i;
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];
61 for (i = 0; i < NUM_IRQ_NODES; i++)
62 nodes[i].handler = NULL;
64 mach_init_IRQ ();
67 irq_node_t *new_irq_node(void)
69 irq_node_t *node;
70 short i;
72 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
73 if (!node->handler)
74 return node;
76 printk ("new_irq_node: out of nodes\n");
77 return NULL;
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)
84 if (irq < IRQ1 || irq > IRQ7) {
85 printk("%s: Incorrect IRQ %d from %s\n",
86 __FUNCTION__, irq, devname);
87 return -ENXIO;
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;
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;
103 #endif
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;
112 void sys_free_irq(unsigned int irq, void *dev_id)
114 if (irq < IRQ1 || irq > IRQ7) {
115 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
116 return;
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);
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];
129 asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
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;
144 int m68k_get_irq_list(struct seq_file *p, void *v)
146 int i;
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);
158 mach_get_irq_list(p, v);
159 return 0;