blob: 514d323ad5369beeba60be337126d8f854309767 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/m68k/kernel/ints.c -- Linux/m68k general interrupt handling code
3 *
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
6 * for more details.
7 *
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
13 * architectures. /Jes
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
26 */
27
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>
35
36#include <asm/setup.h>
37#include <asm/system.h>
38#include <asm/irq.h>
39#include <asm/traps.h>
40#include <asm/page.h>
41#include <asm/machdep.h>
42
43#ifdef CONFIG_Q40
44#include <asm/q40ints.h>
45#endif
46
47/* table for system interrupt handlers */
48static irq_handler_t irq_list[SYS_IRQS];
49
50static const char *default_names[SYS_IRQS] = {
51 [0] = "spurious int",
52 [1] = "int1 handler",
53 [2] = "int2 handler",
54 [3] = "int3 handler",
55 [4] = "int4 handler",
56 [5] = "int5 handler",
57 [6] = "int6 handler",
58 [7] = "int7 handler"
59};
60
61/* The number of spurious interrupts */
62volatile unsigned int num_spurious;
63
64#define NUM_IRQ_NODES 100
65static irq_node_t nodes[NUM_IRQ_NODES];
66
67static void dummy_enable_irq(unsigned int irq);
68static void dummy_disable_irq(unsigned int irq);
69static 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);
72static void dummy_free_irq(unsigned int irq, void *dev_id);
73
74void (*enable_irq) (unsigned int) = dummy_enable_irq;
75void (*disable_irq) (unsigned int) = dummy_disable_irq;
76
77int (*mach_request_irq) (unsigned int, irqreturn_t (*)(int, void *, struct pt_regs *),
78 unsigned long, const char *, void *) = dummy_request_irq;
79void (*mach_free_irq) (unsigned int, void *) = dummy_free_irq;
80
81void init_irq_proc(void);
82
83/*
84 * void init_IRQ(void)
85 *
86 * Parameters: None
87 *
88 * Returns: Nothing
89 *
90 * This function should be called during kernel startup to initialize
91 * the IRQ handling routines.
92 */
93
94void __init init_IRQ(void)
95{
96 int i;
97
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];
104 }
105
106 for (i = 0; i < NUM_IRQ_NODES; i++)
107 nodes[i].handler = NULL;
108
109 mach_init_IRQ ();
110}
111
112irq_node_t *new_irq_node(void)
113{
114 irq_node_t *node;
115 short i;
116
117 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
118 if (!node->handler)
119 return node;
120
121 printk ("new_irq_node: out of nodes\n");
122 return NULL;
123}
124
125/*
126 * We will keep these functions until I have convinced Linus to move
127 * the declaration of them from include/linux/sched.h to
128 * include/asm/irq.h.
129 */
130int request_irq(unsigned int irq,
131 irqreturn_t (*handler) (int, void *, struct pt_regs *),
132 unsigned long flags, const char *devname, void *dev_id)
133{
134 return mach_request_irq(irq, handler, flags, devname, dev_id);
135}
136
137EXPORT_SYMBOL(request_irq);
138
139void free_irq(unsigned int irq, void *dev_id)
140{
141 mach_free_irq(irq, dev_id);
142}
143
144EXPORT_SYMBOL(free_irq);
145
146int 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)
149{
150 if (irq < IRQ1 || irq > IRQ7) {
151 printk("%s: Incorrect IRQ %d from %s\n",
152 __FUNCTION__, irq, devname);
153 return -ENXIO;
154 }
155
156#if 0
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);
161 return -EBUSY;
162 }
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);
166 return -EBUSY;
167 }
168 }
169#endif
170
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;
175 return 0;
176}
177
178void cpu_free_irq(unsigned int irq, void *dev_id)
179{
180 if (irq < IRQ1 || irq > IRQ7) {
181 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
182 return;
183 }
184
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);
188
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];
193}
194
195/*
196 * Do we need these probe functions on the m68k?
197 *
198 * ... may be useful with ISA devices
199 */
200unsigned long probe_irq_on (void)
201{
202#ifdef CONFIG_Q40
203 if (MACH_IS_Q40)
204 return q40_probe_irq_on();
205#endif
206 return 0;
207}
208
209EXPORT_SYMBOL(probe_irq_on);
210
211int probe_irq_off (unsigned long irqs)
212{
213#ifdef CONFIG_Q40
214 if (MACH_IS_Q40)
215 return q40_probe_irq_off(irqs);
216#endif
217 return 0;
218}
219
220EXPORT_SYMBOL(probe_irq_off);
221
222static void dummy_enable_irq(unsigned int irq)
223{
224 printk("calling uninitialized enable_irq()\n");
225}
226
227static void dummy_disable_irq(unsigned int irq)
228{
229 printk("calling uninitialized disable_irq()\n");
230}
231
232static 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)
235{
236 printk("calling uninitialized request_irq()\n");
237 return 0;
238}
239
240static void dummy_free_irq(unsigned int irq, void *dev_id)
241{
242 printk("calling uninitialized disable_irq()\n");
243}
244
245asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
246{
247 if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) {
248 vec -= VEC_SPUR;
249 kstat_cpu(0).irqs[vec]++;
250 irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
251 } else {
252 if (mach_process_int)
253 mach_process_int(vec, fp);
254 else
255 panic("Can't process interrupt vector %ld\n", vec);
256 return;
257 }
258}
259
260int show_interrupts(struct seq_file *p, void *v)
261{
262 int i = *(loff_t *) v;
263
264 /* autovector interrupts */
265 if (i < SYS_IRQS) {
266 if (mach_default_handler) {
267 seq_printf(p, "auto %2d: %10u ", i,
268 i ? kstat_cpu(0).irqs[i] : num_spurious);
269 seq_puts(p, " ");
270 seq_printf(p, "%s\n", irq_list[i].devname);
271 }
272 } else if (i == SYS_IRQS)
273 mach_get_irq_list(p, v);
274 return 0;
275}
276
277void init_irq_proc(void)
278{
279 /* Insert /proc/irq driver here */
280}
281