blob: 4b85514792e7868917436d2f192760a2ddba1ced [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
Roman Zippel6d2f16a2006-06-23 02:04:59 -070098 /* 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();
102 }
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 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];
110 }
111
112 for (i = 0; i < NUM_IRQ_NODES; i++)
113 nodes[i].handler = NULL;
114
115 mach_init_IRQ ();
116}
117
118irq_node_t *new_irq_node(void)
119{
120 irq_node_t *node;
121 short i;
122
123 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
124 if (!node->handler)
125 return node;
126
127 printk ("new_irq_node: out of nodes\n");
128 return NULL;
129}
130
131/*
132 * We will keep these functions until I have convinced Linus to move
133 * the declaration of them from include/linux/sched.h to
134 * include/asm/irq.h.
135 */
136int request_irq(unsigned int irq,
137 irqreturn_t (*handler) (int, void *, struct pt_regs *),
138 unsigned long flags, const char *devname, void *dev_id)
139{
140 return mach_request_irq(irq, handler, flags, devname, dev_id);
141}
142
143EXPORT_SYMBOL(request_irq);
144
145void free_irq(unsigned int irq, void *dev_id)
146{
147 mach_free_irq(irq, dev_id);
148}
149
150EXPORT_SYMBOL(free_irq);
151
152int 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)
155{
156 if (irq < IRQ1 || irq > IRQ7) {
157 printk("%s: Incorrect IRQ %d from %s\n",
158 __FUNCTION__, irq, devname);
159 return -ENXIO;
160 }
161
162#if 0
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);
167 return -EBUSY;
168 }
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);
172 return -EBUSY;
173 }
174 }
175#endif
176
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;
181 return 0;
182}
183
184void cpu_free_irq(unsigned int irq, void *dev_id)
185{
186 if (irq < IRQ1 || irq > IRQ7) {
187 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
188 return;
189 }
190
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);
194
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];
199}
200
201/*
202 * Do we need these probe functions on the m68k?
203 *
204 * ... may be useful with ISA devices
205 */
206unsigned long probe_irq_on (void)
207{
208#ifdef CONFIG_Q40
209 if (MACH_IS_Q40)
210 return q40_probe_irq_on();
211#endif
212 return 0;
213}
214
215EXPORT_SYMBOL(probe_irq_on);
216
217int probe_irq_off (unsigned long irqs)
218{
219#ifdef CONFIG_Q40
220 if (MACH_IS_Q40)
221 return q40_probe_irq_off(irqs);
222#endif
223 return 0;
224}
225
226EXPORT_SYMBOL(probe_irq_off);
227
228static void dummy_enable_irq(unsigned int irq)
229{
230 printk("calling uninitialized enable_irq()\n");
231}
232
233static void dummy_disable_irq(unsigned int irq)
234{
235 printk("calling uninitialized disable_irq()\n");
236}
237
238static 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)
241{
242 printk("calling uninitialized request_irq()\n");
243 return 0;
244}
245
246static void dummy_free_irq(unsigned int irq, void *dev_id)
247{
248 printk("calling uninitialized disable_irq()\n");
249}
250
251asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
252{
253 if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) {
254 vec -= VEC_SPUR;
255 kstat_cpu(0).irqs[vec]++;
256 irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
257 } else {
258 if (mach_process_int)
259 mach_process_int(vec, fp);
260 else
261 panic("Can't process interrupt vector %ld\n", vec);
262 return;
263 }
264}
265
266int show_interrupts(struct seq_file *p, void *v)
267{
268 int i = *(loff_t *) v;
269
270 /* autovector interrupts */
271 if (i < SYS_IRQS) {
272 if (mach_default_handler) {
273 seq_printf(p, "auto %2d: %10u ", i,
274 i ? kstat_cpu(0).irqs[i] : num_spurious);
275 seq_puts(p, " ");
276 seq_printf(p, "%s\n", irq_list[i].devname);
277 }
278 } else if (i == SYS_IRQS)
279 mach_get_irq_list(p, v);
280 return 0;
281}
282
283void init_irq_proc(void)
284{
285 /* Insert /proc/irq driver here */
286}
287