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 irq_handler_t irq_list[SYS_IRQS];
50 static const char *default_names[SYS_IRQS] = {
61 /* The number of spurious interrupts */
62 volatile unsigned int num_spurious;
64 #define NUM_IRQ_NODES 100
65 static irq_node_t nodes[NUM_IRQ_NODES];
67 static void dummy_enable_irq(unsigned int irq);
68 static void dummy_disable_irq(unsigned int irq);
69 static int dummy_request_irq(unsigned int irq,
70 irqreturn_t (*handler) (int, void *, struct pt_regs *),
71 unsigned long flags, const char *devname, void *dev_id);
72 static void dummy_free_irq(unsigned int irq, void *dev_id);
74 void (*enable_irq) (unsigned int) = dummy_enable_irq;
75 void (*disable_irq) (unsigned int) = dummy_disable_irq;
77 int (*mach_request_irq) (unsigned int, irqreturn_t (*)(int, void *, struct pt_regs *),
78 unsigned long, const char *, void *) = dummy_request_irq;
79 void (*mach_free_irq) (unsigned int, void *) = dummy_free_irq;
81 void init_irq_proc(void);
90 * This function should be called during kernel startup to initialize
91 * the IRQ handling routines.
94 void __init init_IRQ(void)
98 /* assembly irq entry code relies on this... */
99 if (HARDIRQ_MASK != 0x00ff0000) {
100 extern void hardirq_mask_is_broken(void);
101 hardirq_mask_is_broken();
104 for (i = 0; i < SYS_IRQS; i++) {
105 if (mach_default_handler)
106 irq_list[i].handler = (*mach_default_handler)[i];
107 irq_list[i].flags = 0;
108 irq_list[i].dev_id = NULL;
109 irq_list[i].devname = default_names[i];
112 for (i = 0; i < NUM_IRQ_NODES; i++)
113 nodes[i].handler = NULL;
118 irq_node_t *new_irq_node(void)
123 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
127 printk ("new_irq_node: out of nodes\n");
132 * We will keep these functions until I have convinced Linus to move
133 * the declaration of them from include/linux/sched.h to
136 int request_irq(unsigned int irq,
137 irqreturn_t (*handler) (int, void *, struct pt_regs *),
138 unsigned long flags, const char *devname, void *dev_id)
140 return mach_request_irq(irq, handler, flags, devname, dev_id);
143 EXPORT_SYMBOL(request_irq);
145 void free_irq(unsigned int irq, void *dev_id)
147 mach_free_irq(irq, dev_id);
150 EXPORT_SYMBOL(free_irq);
152 int cpu_request_irq(unsigned int irq,
153 irqreturn_t (*handler)(int, void *, struct pt_regs *),
154 unsigned long flags, const char *devname, void *dev_id)
156 if (irq < IRQ1 || irq > IRQ7) {
157 printk("%s: Incorrect IRQ %d from %s\n",
158 __FUNCTION__, irq, devname);
163 if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
164 if (irq_list[irq].flags & IRQ_FLG_LOCK) {
165 printk("%s: IRQ %d from %s is not replaceable\n",
166 __FUNCTION__, irq, irq_list[irq].devname);
169 if (!(flags & IRQ_FLG_REPLACE)) {
170 printk("%s: %s can't replace IRQ %d from %s\n",
171 __FUNCTION__, devname, irq, irq_list[irq].devname);
177 irq_list[irq].handler = handler;
178 irq_list[irq].flags = flags;
179 irq_list[irq].dev_id = dev_id;
180 irq_list[irq].devname = devname;
184 void cpu_free_irq(unsigned int irq, void *dev_id)
186 if (irq < IRQ1 || irq > IRQ7) {
187 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
191 if (irq_list[irq].dev_id != dev_id)
192 printk("%s: Removing probably wrong IRQ %d from %s\n",
193 __FUNCTION__, irq, irq_list[irq].devname);
195 irq_list[irq].handler = (*mach_default_handler)[irq];
196 irq_list[irq].flags = 0;
197 irq_list[irq].dev_id = NULL;
198 irq_list[irq].devname = default_names[irq];
202 * Do we need these probe functions on the m68k?
204 * ... may be useful with ISA devices
206 unsigned long probe_irq_on (void)
210 return q40_probe_irq_on();
215 EXPORT_SYMBOL(probe_irq_on);
217 int probe_irq_off (unsigned long irqs)
221 return q40_probe_irq_off(irqs);
226 EXPORT_SYMBOL(probe_irq_off);
228 static void dummy_enable_irq(unsigned int irq)
230 printk("calling uninitialized enable_irq()\n");
233 static void dummy_disable_irq(unsigned int irq)
235 printk("calling uninitialized disable_irq()\n");
238 static int dummy_request_irq(unsigned int irq,
239 irqreturn_t (*handler) (int, void *, struct pt_regs *),
240 unsigned long flags, const char *devname, void *dev_id)
242 printk("calling uninitialized request_irq()\n");
246 static void dummy_free_irq(unsigned int irq, void *dev_id)
248 printk("calling uninitialized disable_irq()\n");
251 asmlinkage void m68k_handle_int(unsigned int irq, struct pt_regs *regs)
253 kstat_cpu(0).irqs[irq]++;
254 irq_list[irq].handler(irq, irq_list[irq].dev_id, regs);
257 asmlinkage void handle_badint(struct pt_regs *regs)
259 kstat_cpu(0).irqs[0]++;
260 printk("unexpected interrupt from %u\n", regs->vector);
263 int show_interrupts(struct seq_file *p, void *v)
265 int i = *(loff_t *) v;
267 /* autovector interrupts */
269 if (mach_default_handler) {
270 seq_printf(p, "auto %2d: %10u ", i,
271 i ? kstat_cpu(0).irqs[i] : num_spurious);
273 seq_printf(p, "%s\n", irq_list[i].devname);
275 } else if (i == SYS_IRQS)
276 mach_get_irq_list(p, v);
280 void init_irq_proc(void)
282 /* Insert /proc/irq driver here */