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
9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/sched.h>
12 #include <linux/interrupt.h>
13 #include <linux/errno.h>
14 #include <linux/init.h>
15 #include <linux/irq.h>
17 #include <asm/setup.h>
19 #include <asm/traps.h>
21 #include <asm/machdep.h>
22 #include <asm/cacheflush.h>
23 #include <asm/irq_regs.h>
26 #include <asm/q40ints.h>
29 extern u32 auto_irqhandler_fixup[];
30 extern u16 user_irqvec_fixup[];
32 static int m68k_first_user_vec;
34 static struct irq_chip auto_irq_chip = {
36 .irq_startup = m68k_irq_startup,
37 .irq_shutdown = m68k_irq_shutdown,
40 static struct irq_chip user_irq_chip = {
42 .irq_startup = m68k_irq_startup,
43 .irq_shutdown = m68k_irq_shutdown,
53 * This function should be called during kernel startup to initialize
54 * the IRQ handling routines.
57 void __init init_IRQ(void)
61 for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
62 irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
68 * m68k_setup_auto_interrupt
69 * @handler: called from auto vector interrupts
71 * setup the handler to be called from auto vector interrupts instead of the
72 * standard do_IRQ(), it will be called with irq numbers in the range
73 * from IRQ_AUTO_1 - IRQ_AUTO_7.
75 void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
78 *auto_irqhandler_fixup = (u32)handler;
83 * m68k_setup_user_interrupt
84 * @vec: first user vector interrupt to handle
85 * @cnt: number of active user vector interrupts
87 * setup user vector interrupts, this includes activating the specified range
88 * of interrupts, only then these interrupts can be requested (note: this is
89 * different from auto vector interrupts).
91 void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt)
95 BUG_ON(IRQ_USER + cnt > NR_IRQS);
96 m68k_first_user_vec = vec;
97 for (i = 0; i < cnt; i++)
98 irq_set_chip_and_handler(i, &user_irq_chip, handle_simple_irq);
99 *user_irqvec_fixup = vec - IRQ_USER;
104 * m68k_setup_irq_controller
105 * @chip: irq chip which controls specified irq
106 * @handle: flow handler which handles specified irq
107 * @irq: first irq to be managed by the controller
108 * @cnt: number of irqs to be managed by the controller
110 * Change the controller for the specified range of irq, which will be used to
111 * manage these irq. auto/user irq already have a default controller, which can
112 * be changed as well, but the controller probably should use m68k_irq_startup/
115 void m68k_setup_irq_controller(struct irq_chip *chip,
116 irq_flow_handler_t handle, unsigned int irq,
121 for (i = 0; i < cnt; i++) {
122 irq_set_chip(irq + i, chip);
124 irq_set_handler(irq + i, handle);
128 unsigned int m68k_irq_startup_irq(unsigned int irq)
130 if (irq <= IRQ_AUTO_7)
131 vectors[VEC_SPUR + irq] = auto_inthandler;
133 vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
137 unsigned int m68k_irq_startup(struct irq_data *data)
139 return m68k_irq_startup_irq(data->irq);
142 void m68k_irq_shutdown(struct irq_data *data)
144 unsigned int irq = data->irq;
146 if (irq <= IRQ_AUTO_7)
147 vectors[VEC_SPUR + irq] = bad_inthandler;
149 vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
153 unsigned int irq_canonicalize(unsigned int irq)
156 if (MACH_IS_Q40 && irq == 11)
162 EXPORT_SYMBOL(irq_canonicalize);
165 asmlinkage void handle_badint(struct pt_regs *regs)
167 atomic_inc(&irq_err_count);
168 pr_warn("unexpected interrupt from %u\n", regs->vector);