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 for (i
= 0; i
< SYS_IRQS
; i
++) {
99 if (mach_default_handler
)
100 irq_list
[i
].handler
= (*mach_default_handler
)[i
];
101 irq_list
[i
].flags
= 0;
102 irq_list
[i
].dev_id
= NULL
;
103 irq_list
[i
].devname
= default_names
[i
];
106 for (i
= 0; i
< NUM_IRQ_NODES
; i
++)
107 nodes
[i
].handler
= NULL
;
112 irq_node_t
*new_irq_node(void)
117 for (node
= nodes
, i
= NUM_IRQ_NODES
-1; i
>= 0; node
++, i
--)
121 printk ("new_irq_node: out of nodes\n");
126 * We will keep these functions until I have convinced Linus to move
127 * the declaration of them from include/linux/sched.h to
130 int request_irq(unsigned int irq
,
131 irqreturn_t (*handler
) (int, void *, struct pt_regs
*),
132 unsigned long flags
, const char *devname
, void *dev_id
)
134 return mach_request_irq(irq
, handler
, flags
, devname
, dev_id
);
137 EXPORT_SYMBOL(request_irq
);
139 void free_irq(unsigned int irq
, void *dev_id
)
141 mach_free_irq(irq
, dev_id
);
144 EXPORT_SYMBOL(free_irq
);
146 int cpu_request_irq(unsigned int irq
,
147 irqreturn_t (*handler
)(int, void *, struct pt_regs
*),
148 unsigned long flags
, const char *devname
, void *dev_id
)
150 if (irq
< IRQ1
|| irq
> IRQ7
) {
151 printk("%s: Incorrect IRQ %d from %s\n",
152 __FUNCTION__
, irq
, devname
);
157 if (!(irq_list
[irq
].flags
& IRQ_FLG_STD
)) {
158 if (irq_list
[irq
].flags
& IRQ_FLG_LOCK
) {
159 printk("%s: IRQ %d from %s is not replaceable\n",
160 __FUNCTION__
, irq
, irq_list
[irq
].devname
);
163 if (!(flags
& IRQ_FLG_REPLACE
)) {
164 printk("%s: %s can't replace IRQ %d from %s\n",
165 __FUNCTION__
, devname
, irq
, irq_list
[irq
].devname
);
171 irq_list
[irq
].handler
= handler
;
172 irq_list
[irq
].flags
= flags
;
173 irq_list
[irq
].dev_id
= dev_id
;
174 irq_list
[irq
].devname
= devname
;
178 void cpu_free_irq(unsigned int irq
, void *dev_id
)
180 if (irq
< IRQ1
|| irq
> IRQ7
) {
181 printk("%s: Incorrect IRQ %d\n", __FUNCTION__
, irq
);
185 if (irq_list
[irq
].dev_id
!= dev_id
)
186 printk("%s: Removing probably wrong IRQ %d from %s\n",
187 __FUNCTION__
, irq
, irq_list
[irq
].devname
);
189 irq_list
[irq
].handler
= (*mach_default_handler
)[irq
];
190 irq_list
[irq
].flags
= 0;
191 irq_list
[irq
].dev_id
= NULL
;
192 irq_list
[irq
].devname
= default_names
[irq
];
196 * Do we need these probe functions on the m68k?
198 * ... may be useful with ISA devices
200 unsigned long probe_irq_on (void)
204 return q40_probe_irq_on();
209 EXPORT_SYMBOL(probe_irq_on
);
211 int probe_irq_off (unsigned long irqs
)
215 return q40_probe_irq_off(irqs
);
220 EXPORT_SYMBOL(probe_irq_off
);
222 static void dummy_enable_irq(unsigned int irq
)
224 printk("calling uninitialized enable_irq()\n");
227 static void dummy_disable_irq(unsigned int irq
)
229 printk("calling uninitialized disable_irq()\n");
232 static int dummy_request_irq(unsigned int irq
,
233 irqreturn_t (*handler
) (int, void *, struct pt_regs
*),
234 unsigned long flags
, const char *devname
, void *dev_id
)
236 printk("calling uninitialized request_irq()\n");
240 static void dummy_free_irq(unsigned int irq
, void *dev_id
)
242 printk("calling uninitialized disable_irq()\n");
245 asmlinkage
void process_int(unsigned long vec
, struct pt_regs
*fp
)
247 if (vec
>= VEC_INT1
&& vec
<= VEC_INT7
&& !MACH_IS_BVME6000
) {
249 kstat_cpu(0).irqs
[vec
]++;
250 irq_list
[vec
].handler(vec
, irq_list
[vec
].dev_id
, fp
);
252 if (mach_process_int
)
253 mach_process_int(vec
, fp
);
255 panic("Can't process interrupt vector %ld\n", vec
);
260 int show_interrupts(struct seq_file
*p
, void *v
)
262 int i
= *(loff_t
*) v
;
264 /* autovector interrupts */
266 if (mach_default_handler
) {
267 seq_printf(p
, "auto %2d: %10u ", i
,
268 i
? kstat_cpu(0).irqs
[i
] : num_spurious
);
270 seq_printf(p
, "%s\n", irq_list
[i
].devname
);
272 } else if (i
== SYS_IRQS
)
273 mach_get_irq_list(p
, v
);
277 void init_irq_proc(void)
279 /* Insert /proc/irq driver here */