2 * linux/arch/m68k/kernel/ints.c -- Linux/m68k general interrupt handling code
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
8 * 07/03/96: Timer initialization, and thus mach_sched_init(),
9 * removed from request_irq() and moved to init_time().
10 * We should therefore consider renaming our add_isr() and
11 * remove_isr() to request_irq() and free_irq()
12 * respectively, so they are compliant with the other
14 * 11/07/96: Changed all add_/remove_isr() to request_/free_irq() calls.
15 * Removed irq list support, if any machine needs an irq server
16 * it must implement this itself (as it's already done), instead
17 * only default handler are used with mach_default_handler.
18 * request_irq got some flags different from other architectures:
19 * - IRQ_FLG_REPLACE : Replace an existing handler (the default one
20 * can be replaced without this flag)
21 * - IRQ_FLG_LOCK : handler can't be replaced
22 * There are other machine depending flags, see there
23 * If you want to replace a default handler you should know what
24 * you're doing, since it might handle different other irq sources
25 * which must be served /Roman Zippel
28 #include <linux/config.h>
29 #include <linux/module.h>
30 #include <linux/types.h>
31 #include <linux/sched.h>
32 #include <linux/kernel_stat.h>
33 #include <linux/errno.h>
34 #include <linux/init.h>
36 #include <asm/setup.h>
37 #include <asm/system.h>
39 #include <asm/traps.h>
41 #include <asm/machdep.h>
44 #include <asm/q40ints.h>
47 /* table for system interrupt handlers */
48 static struct irq_node *irq_list[SYS_IRQS];
49 static struct irq_controller *irq_controller[SYS_IRQS];
51 static struct irq_controller auto_irq_controller = {
53 .lock = SPIN_LOCK_UNLOCKED,
54 .startup = m68k_irq_startup,
55 .shutdown = m68k_irq_shutdown,
58 static const char *default_names[SYS_IRQS] = {
69 /* The number of spurious interrupts */
70 volatile unsigned int num_spurious;
72 #define NUM_IRQ_NODES 100
73 static irq_node_t nodes[NUM_IRQ_NODES];
75 static void dummy_enable_irq(unsigned int irq);
76 static void dummy_disable_irq(unsigned int irq);
77 static int dummy_request_irq(unsigned int irq,
78 irqreturn_t (*handler) (int, void *, struct pt_regs *),
79 unsigned long flags, const char *devname, void *dev_id);
80 static void dummy_free_irq(unsigned int irq, void *dev_id);
82 void (*enable_irq) (unsigned int) = dummy_enable_irq;
83 void (*disable_irq) (unsigned int) = dummy_disable_irq;
85 int (*mach_request_irq) (unsigned int, irqreturn_t (*)(int, void *, struct pt_regs *),
86 unsigned long, const char *, void *) = dummy_request_irq;
87 void (*mach_free_irq) (unsigned int, void *) = dummy_free_irq;
89 void init_irq_proc(void);
98 * This function should be called during kernel startup to initialize
99 * the IRQ handling routines.
102 void __init init_IRQ(void)
106 /* assembly irq entry code relies on this... */
107 if (HARDIRQ_MASK != 0x00ff0000) {
108 extern void hardirq_mask_is_broken(void);
109 hardirq_mask_is_broken();
112 for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++) {
113 irq_controller[i] = &auto_irq_controller;
114 if (mach_default_handler && (*mach_default_handler)[i])
115 cpu_request_irq(i, (*mach_default_handler)[i],
116 0, default_names[i], NULL);
122 irq_node_t *new_irq_node(void)
127 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) {
128 if (!node->handler) {
129 memset(node, 0, sizeof(*node));
134 printk ("new_irq_node: out of nodes\n");
139 * We will keep these functions until I have convinced Linus to move
140 * the declaration of them from include/linux/sched.h to
143 int request_irq(unsigned int irq,
144 irqreturn_t (*handler) (int, void *, struct pt_regs *),
145 unsigned long flags, const char *devname, void *dev_id)
147 return mach_request_irq(irq, handler, flags, devname, dev_id);
150 EXPORT_SYMBOL(request_irq);
152 void free_irq(unsigned int irq, void *dev_id)
154 mach_free_irq(irq, dev_id);
157 EXPORT_SYMBOL(free_irq);
159 int setup_irq(unsigned int irq, struct irq_node *node)
161 struct irq_controller *contr;
162 struct irq_node **prev;
165 if (irq >= SYS_IRQS || !(contr = irq_controller[irq])) {
166 printk("%s: Incorrect IRQ %d from %s\n",
167 __FUNCTION__, irq, node->devname);
171 spin_lock_irqsave(&contr->lock, flags);
173 prev = irq_list + irq;
175 /* Can't share interrupts unless both agree to */
176 if (!((*prev)->flags & node->flags & SA_SHIRQ)) {
177 spin_unlock_irqrestore(&contr->lock, flags);
181 prev = &(*prev)->next;
184 if (!irq_list[irq]) {
193 spin_unlock_irqrestore(&contr->lock, flags);
198 int cpu_request_irq(unsigned int irq,
199 irqreturn_t (*handler)(int, void *, struct pt_regs *),
200 unsigned long flags, const char *devname, void *dev_id)
202 struct irq_node *node;
205 node = new_irq_node();
209 node->handler = handler;
211 node->dev_id = dev_id;
212 node->devname = devname;
214 res = setup_irq(irq, node);
216 node->handler = NULL;
221 void cpu_free_irq(unsigned int irq, void *dev_id)
223 struct irq_controller *contr;
224 struct irq_node **p, *node;
227 if (irq >= SYS_IRQS || !(contr = irq_controller[irq])) {
228 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
232 spin_lock_irqsave(&contr->lock, flags);
235 while ((node = *p)) {
236 if (node->dev_id == dev_id)
243 node->handler = NULL;
245 printk("%s: Removing probably wrong IRQ %d\n",
249 contr->shutdown(irq);
251 spin_unlock_irqrestore(&contr->lock, flags);
254 int m68k_irq_startup(unsigned int irq)
256 if (irq <= IRQ_AUTO_7)
257 vectors[VEC_SPUR + irq] = auto_inthandler;
261 void m68k_irq_shutdown(unsigned int irq)
263 if (irq <= IRQ_AUTO_7)
264 vectors[VEC_SPUR + irq] = bad_inthandler;
269 * Do we need these probe functions on the m68k?
271 * ... may be useful with ISA devices
273 unsigned long probe_irq_on (void)
277 return q40_probe_irq_on();
282 EXPORT_SYMBOL(probe_irq_on);
284 int probe_irq_off (unsigned long irqs)
288 return q40_probe_irq_off(irqs);
293 EXPORT_SYMBOL(probe_irq_off);
295 static void dummy_enable_irq(unsigned int irq)
297 printk("calling uninitialized enable_irq()\n");
300 static void dummy_disable_irq(unsigned int irq)
302 printk("calling uninitialized disable_irq()\n");
305 static int dummy_request_irq(unsigned int irq,
306 irqreturn_t (*handler) (int, void *, struct pt_regs *),
307 unsigned long flags, const char *devname, void *dev_id)
309 printk("calling uninitialized request_irq()\n");
313 static void dummy_free_irq(unsigned int irq, void *dev_id)
315 printk("calling uninitialized disable_irq()\n");
318 asmlinkage void m68k_handle_int(unsigned int irq, struct pt_regs *regs)
320 struct irq_node *node;
322 kstat_cpu(0).irqs[irq]++;
323 node = irq_list[irq];
325 node->handler(irq, node->dev_id, regs);
330 asmlinkage void handle_badint(struct pt_regs *regs)
332 kstat_cpu(0).irqs[0]++;
333 printk("unexpected interrupt from %u\n", regs->vector);
336 int show_interrupts(struct seq_file *p, void *v)
338 struct irq_controller *contr;
339 struct irq_node *node;
340 int i = *(loff_t *) v;
342 /* autovector interrupts */
343 if (i < SYS_IRQS && irq_list[i]) {
344 contr = irq_controller[i];
346 seq_printf(p, "%s %u: %10u %s", contr->name, i, kstat_cpu(0).irqs[i], node->devname);
347 while ((node = node->next))
348 seq_printf(p, ", %s", node->devname);
350 } else if (i == SYS_IRQS)
351 mach_get_irq_list(p, v);
355 void init_irq_proc(void)
357 /* Insert /proc/irq driver here */