blob: cea439f9819b709dcc945773a643e3bae66ec8b8 [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.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/module.h>
10#include <linux/types.h>
11#include <linux/sched.h>
Andrew Morton6168a702007-02-17 21:22:39 -080012#include <linux/interrupt.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/kernel_stat.h>
14#include <linux/errno.h>
15#include <linux/init.h>
16
17#include <asm/setup.h>
18#include <asm/system.h>
19#include <asm/irq.h>
20#include <asm/traps.h>
21#include <asm/page.h>
22#include <asm/machdep.h>
Roman Zippel68387c42006-06-25 05:47:01 -070023#include <asm/cacheflush.h>
Al Viro2850bc22006-10-07 14:16:45 +010024#include <asm/irq_regs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#ifdef CONFIG_Q40
27#include <asm/q40ints.h>
28#endif
29
Roman Zippel68387c42006-06-25 05:47:01 -070030extern u32 auto_irqhandler_fixup[];
31extern u32 user_irqhandler_fixup[];
32extern u16 user_irqvec_fixup[];
33
Geert Uytterhoeven4936f632011-04-21 22:50:52 +020034#ifndef CONFIG_GENERIC_HARDIRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -070035/* table for system interrupt handlers */
Geert Uytterhoeven6549d532011-04-17 21:59:23 +020036static struct irq_data *irq_list[NR_IRQS];
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020037static struct irq_chip *irq_chip[NR_IRQS];
Roman Zippel68387c42006-06-25 05:47:01 -070038static int irq_depth[NR_IRQS];
39
Geert Uytterhoeven40a72c82011-05-27 22:33:41 +020040static inline int irq_set_chip(unsigned int irq, struct irq_chip *chip)
41{
42 irq_chip[irq] = chip;
43 return 0;
44}
Geert Uytterhoeven4936f632011-04-21 22:50:52 +020045#define irq_set_chip_and_handler(irq, chip, dummy) irq_set_chip(irq, chip)
46#endif /* !CONFIG_GENERIC_HARDIRQS */
Geert Uytterhoeven40a72c82011-05-27 22:33:41 +020047
Roman Zippel68387c42006-06-25 05:47:01 -070048static int m68k_first_user_vec;
Roman Zippelb5dc7842006-06-25 05:47:00 -070049
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020050static struct irq_chip auto_irq_chip = {
Roman Zippelb5dc7842006-06-25 05:47:00 -070051 .name = "auto",
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020052 .irq_startup = m68k_irq_startup,
53 .irq_shutdown = m68k_irq_shutdown,
Roman Zippelb5dc7842006-06-25 05:47:00 -070054};
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020056static struct irq_chip user_irq_chip = {
Roman Zippel68387c42006-06-25 05:47:01 -070057 .name = "user",
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020058 .irq_startup = m68k_irq_startup,
59 .irq_shutdown = m68k_irq_shutdown,
Linus Torvalds1da177e2005-04-16 15:20:36 -070060};
61
Geert Uytterhoeven4936f632011-04-21 22:50:52 +020062#ifndef CONFIG_GENERIC_HARDIRQS
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define NUM_IRQ_NODES 100
Geert Uytterhoeven6549d532011-04-17 21:59:23 +020064static struct irq_data nodes[NUM_IRQ_NODES];
Geert Uytterhoeven4936f632011-04-21 22:50:52 +020065#endif /* !CONFIG_GENERIC_HARDIRQS */
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/*
68 * void init_IRQ(void)
69 *
70 * Parameters: None
71 *
72 * Returns: Nothing
73 *
74 * This function should be called during kernel startup to initialize
75 * the IRQ handling routines.
76 */
77
78void __init init_IRQ(void)
79{
80 int i;
81
Roman Zippel6d2f16a2006-06-23 02:04:59 -070082 /* assembly irq entry code relies on this... */
83 if (HARDIRQ_MASK != 0x00ff0000) {
84 extern void hardirq_mask_is_broken(void);
85 hardirq_mask_is_broken();
86 }
87
Roman Zippel68387c42006-06-25 05:47:01 -070088 for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
Geert Uytterhoeven4936f632011-04-21 22:50:52 +020089 irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Roman Zippel68387c42006-06-25 05:47:01 -070091 mach_init_IRQ();
92}
93
94/**
95 * m68k_setup_auto_interrupt
96 * @handler: called from auto vector interrupts
97 *
98 * setup the handler to be called from auto vector interrupts instead of the
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020099 * standard do_IRQ(), it will be called with irq numbers in the range
Roman Zippel68387c42006-06-25 05:47:01 -0700100 * from IRQ_AUTO_1 - IRQ_AUTO_7.
101 */
102void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
103{
104 if (handler)
105 *auto_irqhandler_fixup = (u32)handler;
106 flush_icache();
107}
108
109/**
110 * m68k_setup_user_interrupt
111 * @vec: first user vector interrupt to handle
112 * @cnt: number of active user vector interrupts
113 * @handler: called from user vector interrupts
114 *
115 * setup user vector interrupts, this includes activating the specified range
116 * of interrupts, only then these interrupts can be requested (note: this is
117 * different from auto vector interrupts). An optional handler can be installed
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200118 * to be called instead of the default do_IRQ(), it will be called
Roman Zippel68387c42006-06-25 05:47:01 -0700119 * with irq numbers starting from IRQ_USER.
120 */
121void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt,
122 void (*handler)(unsigned int, struct pt_regs *))
123{
124 int i;
125
Geert Uytterhoeven27123cb2008-11-14 08:10:19 +0100126 BUG_ON(IRQ_USER + cnt > NR_IRQS);
Roman Zippel68387c42006-06-25 05:47:01 -0700127 m68k_first_user_vec = vec;
128 for (i = 0; i < cnt; i++)
Geert Uytterhoeven40a72c82011-05-27 22:33:41 +0200129 irq_set_chip(IRQ_USER + i, &user_irq_chip);
Roman Zippel68387c42006-06-25 05:47:01 -0700130 *user_irqvec_fixup = vec - IRQ_USER;
131 if (handler)
132 *user_irqhandler_fixup = (u32)handler;
133 flush_icache();
134}
135
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200136#ifdef CONFIG_GENERIC_HARDIRQS
137
138/**
139 * m68k_setup_irq_controller
140 * @chip: irq chip which controls specified irq
141 * @handle: flow handler which handles specified irq
142 * @irq: first irq to be managed by the controller
143 * @cnt: number of irqs to be managed by the controller
144 *
145 * Change the controller for the specified range of irq, which will be used to
146 * manage these irq. auto/user irq already have a default controller, which can
147 * be changed as well, but the controller probably should use m68k_irq_startup/
148 * m68k_irq_shutdown.
149 */
150void m68k_setup_irq_controller(struct irq_chip *chip,
151 irq_flow_handler_t handle, unsigned int irq,
152 unsigned int cnt)
153{
154 int i;
155
156 for (i = 0; i < cnt; i++) {
157 irq_set_chip(irq + i, chip);
158 if (handle)
159 irq_set_handler(irq + i, handle);
160 }
161}
162
163#else /* !CONFIG_GENERIC_HARDIRQS */
164
Roman Zippel68387c42006-06-25 05:47:01 -0700165/**
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200166 * m68k_setup_irq_chip
Roman Zippel68387c42006-06-25 05:47:01 -0700167 * @contr: irq controller which controls specified irq
168 * @irq: first irq to be managed by the controller
169 *
170 * Change the controller for the specified range of irq, which will be used to
171 * manage these irq. auto/user irq already have a default controller, which can
172 * be changed as well, but the controller probably should use m68k_irq_startup/
173 * m68k_irq_shutdown.
174 */
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200175void m68k_setup_irq_chip(struct irq_chip *contr, unsigned int irq,
Roman Zippel68387c42006-06-25 05:47:01 -0700176 unsigned int cnt)
177{
178 int i;
179
180 for (i = 0; i < cnt; i++)
Geert Uytterhoeven40a72c82011-05-27 22:33:41 +0200181 irq_set_chip(irq + i, contr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182}
183
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200184struct irq_data *new_irq_node(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200186 struct irq_data *node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 short i;
188
Roman Zippelb5dc7842006-06-25 05:47:00 -0700189 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--) {
190 if (!node->handler) {
191 memset(node, 0, sizeof(*node));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 return node;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700193 }
194 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196 printk ("new_irq_node: out of nodes\n");
197 return NULL;
198}
199
Geert Uytterhoeven13d6da32011-04-19 20:10:53 +0200200static int m68k_setup_irq(unsigned int irq, struct irq_data *node)
Roman Zippelb5dc7842006-06-25 05:47:00 -0700201{
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200202 struct irq_chip *contr;
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200203 struct irq_data **prev;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700204 unsigned long flags;
205
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200206 if (irq >= NR_IRQS || !(contr = irq_chip[irq])) {
Roman Zippelb5dc7842006-06-25 05:47:00 -0700207 printk("%s: Incorrect IRQ %d from %s\n",
Harvey Harrisonf85e7cd2008-04-28 02:13:49 -0700208 __func__, irq, node->devname);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700209 return -ENXIO;
210 }
211
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200212 local_irq_save(flags);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700213
214 prev = irq_list + irq;
215 if (*prev) {
216 /* Can't share interrupts unless both agree to */
Thomas Gleixnerb0b9fdc2006-07-01 19:29:19 -0700217 if (!((*prev)->flags & node->flags & IRQF_SHARED)) {
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200218 local_irq_restore(flags);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700219 return -EBUSY;
220 }
221 while (*prev)
222 prev = &(*prev)->next;
223 }
224
225 if (!irq_list[irq]) {
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200226 if (contr->irq_startup)
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200227 contr->irq_startup(node);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700228 else
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200229 contr->irq_enable(node);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700230 }
231 node->next = NULL;
232 *prev = node;
233
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200234 local_irq_restore(flags);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700235
236 return 0;
237}
238
Roman Zippel68387c42006-06-25 05:47:01 -0700239int request_irq(unsigned int irq,
David Howells40220c12006-10-09 12:19:47 +0100240 irq_handler_t handler,
Roman Zippel68387c42006-06-25 05:47:01 -0700241 unsigned long flags, const char *devname, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242{
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200243 struct irq_data *node;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700244 int res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245
Roman Zippelb5dc7842006-06-25 05:47:00 -0700246 node = new_irq_node();
247 if (!node)
248 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200250 node->irq = irq;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700251 node->handler = handler;
252 node->flags = flags;
253 node->dev_id = dev_id;
254 node->devname = devname;
255
Geert Uytterhoeven13d6da32011-04-19 20:10:53 +0200256 res = m68k_setup_irq(irq, node);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700257 if (res)
258 node->handler = NULL;
259
260 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261}
262
Roman Zippel68387c42006-06-25 05:47:01 -0700263EXPORT_SYMBOL(request_irq);
264
265void free_irq(unsigned int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266{
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200267 struct irq_chip *contr;
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200268 struct irq_data **p, *node;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700269 unsigned long flags;
270
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200271 if (irq >= NR_IRQS || !(contr = irq_chip[irq])) {
Harvey Harrisonf85e7cd2008-04-28 02:13:49 -0700272 printk("%s: Incorrect IRQ %d\n", __func__, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 return;
274 }
275
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200276 local_irq_save(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Roman Zippelb5dc7842006-06-25 05:47:00 -0700278 p = irq_list + irq;
279 while ((node = *p)) {
280 if (node->dev_id == dev_id)
281 break;
282 p = &node->next;
283 }
284
285 if (node) {
286 *p = node->next;
287 node->handler = NULL;
288 } else
289 printk("%s: Removing probably wrong IRQ %d\n",
Harvey Harrisonf85e7cd2008-04-28 02:13:49 -0700290 __func__, irq);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700291
Roman Zippel68387c42006-06-25 05:47:01 -0700292 if (!irq_list[irq]) {
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200293 if (contr->irq_shutdown)
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200294 contr->irq_shutdown(node);
Roman Zippel68387c42006-06-25 05:47:01 -0700295 else
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200296 contr->irq_disable(node);
Roman Zippel68387c42006-06-25 05:47:01 -0700297 }
Roman Zippelb5dc7842006-06-25 05:47:00 -0700298
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200299 local_irq_restore(flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300}
301
Roman Zippel68387c42006-06-25 05:47:01 -0700302EXPORT_SYMBOL(free_irq);
303
304void enable_irq(unsigned int irq)
305{
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200306 struct irq_chip *contr;
Roman Zippel68387c42006-06-25 05:47:01 -0700307 unsigned long flags;
308
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200309 if (irq >= NR_IRQS || !(contr = irq_chip[irq])) {
Roman Zippel68387c42006-06-25 05:47:01 -0700310 printk("%s: Incorrect IRQ %d\n",
Harvey Harrisonf85e7cd2008-04-28 02:13:49 -0700311 __func__, irq);
Roman Zippel68387c42006-06-25 05:47:01 -0700312 return;
313 }
314
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200315 local_irq_save(flags);
Roman Zippel68387c42006-06-25 05:47:01 -0700316 if (irq_depth[irq]) {
317 if (!--irq_depth[irq]) {
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200318 if (contr->irq_enable)
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200319 contr->irq_enable(irq_list[irq]);
Roman Zippel68387c42006-06-25 05:47:01 -0700320 }
321 } else
322 WARN_ON(1);
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200323 local_irq_restore(flags);
Roman Zippel68387c42006-06-25 05:47:01 -0700324}
325
326EXPORT_SYMBOL(enable_irq);
327
328void disable_irq(unsigned int irq)
329{
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200330 struct irq_chip *contr;
Roman Zippel68387c42006-06-25 05:47:01 -0700331 unsigned long flags;
332
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200333 if (irq >= NR_IRQS || !(contr = irq_chip[irq])) {
Roman Zippel68387c42006-06-25 05:47:01 -0700334 printk("%s: Incorrect IRQ %d\n",
Harvey Harrisonf85e7cd2008-04-28 02:13:49 -0700335 __func__, irq);
Roman Zippel68387c42006-06-25 05:47:01 -0700336 return;
337 }
338
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200339 local_irq_save(flags);
Roman Zippel68387c42006-06-25 05:47:01 -0700340 if (!irq_depth[irq]++) {
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200341 if (contr->irq_disable)
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200342 contr->irq_disable(irq_list[irq]);
Roman Zippel68387c42006-06-25 05:47:01 -0700343 }
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200344 local_irq_restore(flags);
Roman Zippel68387c42006-06-25 05:47:01 -0700345}
346
347EXPORT_SYMBOL(disable_irq);
348
Al Viroe9ed7e72007-07-21 23:29:12 +0100349void disable_irq_nosync(unsigned int irq) __attribute__((alias("disable_irq")));
350
351EXPORT_SYMBOL(disable_irq_nosync);
352
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200353#endif /* !CONFIG_GENERIC_HARDIRQS */
354
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200355unsigned int m68k_irq_startup_irq(unsigned int irq)
Roman Zippelb5dc7842006-06-25 05:47:00 -0700356{
357 if (irq <= IRQ_AUTO_7)
358 vectors[VEC_SPUR + irq] = auto_inthandler;
Roman Zippel68387c42006-06-25 05:47:01 -0700359 else
360 vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700361 return 0;
362}
363
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200364unsigned int m68k_irq_startup(struct irq_data *data)
Roman Zippelb5dc7842006-06-25 05:47:00 -0700365{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200366 return m68k_irq_startup_irq(data->irq);
367}
368
369void m68k_irq_shutdown(struct irq_data *data)
370{
371 unsigned int irq = data->irq;
372
Roman Zippelb5dc7842006-06-25 05:47:00 -0700373 if (irq <= IRQ_AUTO_7)
374 vectors[VEC_SPUR + irq] = bad_inthandler;
Roman Zippel68387c42006-06-25 05:47:01 -0700375 else
376 vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700377}
378
379
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200380#ifndef CONFIG_GENERIC_HARDIRQS
381
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382/*
383 * Do we need these probe functions on the m68k?
384 *
385 * ... may be useful with ISA devices
386 */
387unsigned long probe_irq_on (void)
388{
389#ifdef CONFIG_Q40
390 if (MACH_IS_Q40)
391 return q40_probe_irq_on();
392#endif
393 return 0;
394}
395
396EXPORT_SYMBOL(probe_irq_on);
397
398int probe_irq_off (unsigned long irqs)
399{
400#ifdef CONFIG_Q40
401 if (MACH_IS_Q40)
402 return q40_probe_irq_off(irqs);
403#endif
404 return 0;
405}
406
407EXPORT_SYMBOL(probe_irq_off);
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200408#endif /* CONFIG_GENERIC_HARDIRQS */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
Roman Zippel68387c42006-06-25 05:47:01 -0700410unsigned int irq_canonicalize(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
Roman Zippel68387c42006-06-25 05:47:01 -0700412#ifdef CONFIG_Q40
413 if (MACH_IS_Q40 && irq == 11)
414 irq = 10;
415#endif
416 return irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417}
418
Roman Zippel68387c42006-06-25 05:47:01 -0700419EXPORT_SYMBOL(irq_canonicalize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200421#ifndef CONFIG_GENERIC_HARDIRQS
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200422void generic_handle_irq(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423{
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200424 struct irq_data *node;
Roman Zippel92445ea2006-06-25 05:46:58 -0700425 kstat_cpu(0).irqs[irq]++;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700426 node = irq_list[irq];
427 do {
Al Viro2850bc22006-10-07 14:16:45 +0100428 node->handler(irq, node->dev_id);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700429 node = node->next;
430 } while (node);
Roman Zippel92445ea2006-06-25 05:46:58 -0700431}
432
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200433asmlinkage void do_IRQ(int irq, struct pt_regs *regs)
Al Viro2850bc22006-10-07 14:16:45 +0100434{
435 struct pt_regs *old_regs;
436 old_regs = set_irq_regs(regs);
Geert Uytterhoeven1425df82011-07-01 20:39:19 +0200437 generic_handle_irq(irq);
Al Viro2850bc22006-10-07 14:16:45 +0100438 set_irq_regs(old_regs);
439}
440
Roman Zippel92445ea2006-06-25 05:46:58 -0700441asmlinkage void handle_badint(struct pt_regs *regs)
442{
443 kstat_cpu(0).irqs[0]++;
444 printk("unexpected interrupt from %u\n", regs->vector);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445}
446
447int show_interrupts(struct seq_file *p, void *v)
448{
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200449 struct irq_chip *contr;
Geert Uytterhoeven6549d532011-04-17 21:59:23 +0200450 struct irq_data *node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 int i = *(loff_t *) v;
452
453 /* autovector interrupts */
Roman Zippel68387c42006-06-25 05:47:01 -0700454 if (irq_list[i]) {
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +0200455 contr = irq_chip[i];
Roman Zippelb5dc7842006-06-25 05:47:00 -0700456 node = irq_list[i];
Roman Zippel68387c42006-06-25 05:47:01 -0700457 seq_printf(p, "%-8s %3u: %10u %s", contr->name, i, kstat_cpu(0).irqs[i], node->devname);
Roman Zippelb5dc7842006-06-25 05:47:00 -0700458 while ((node = node->next))
459 seq_printf(p, ", %s", node->devname);
460 seq_puts(p, "\n");
Roman Zippel68387c42006-06-25 05:47:01 -0700461 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 return 0;
463}
464
Geert Uytterhoevenda9870e2008-10-13 21:59:01 +0200465#ifdef CONFIG_PROC_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466void init_irq_proc(void)
467{
468 /* Insert /proc/irq driver here */
469}
Geert Uytterhoevenda9870e2008-10-13 21:59:01 +0200470#endif
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200471
472#else /* CONFIG_GENERIC_HARDIRQS */
473
474asmlinkage void handle_badint(struct pt_regs *regs)
475{
476 atomic_inc(&irq_err_count);
477 pr_warn("unexpected interrupt from %u\n", regs->vector);
478}
479
480#endif /* CONFIG_GENERIC_HARDIRQS */