blob: 74fefac00899893add2d342726fe2d2050f88cac [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[];
Roman Zippel68387c42006-06-25 05:47:01 -070031extern u16 user_irqvec_fixup[];
32
Roman Zippel68387c42006-06-25 05:47:01 -070033static int m68k_first_user_vec;
Roman Zippelb5dc7842006-06-25 05:47:00 -070034
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020035static struct irq_chip auto_irq_chip = {
Roman Zippelb5dc7842006-06-25 05:47:00 -070036 .name = "auto",
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020037 .irq_startup = m68k_irq_startup,
38 .irq_shutdown = m68k_irq_shutdown,
Roman Zippelb5dc7842006-06-25 05:47:00 -070039};
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020041static struct irq_chip user_irq_chip = {
Roman Zippel68387c42006-06-25 05:47:01 -070042 .name = "user",
Geert Uytterhoevenc288bf22011-04-13 22:31:28 +020043 .irq_startup = m68k_irq_startup,
44 .irq_shutdown = m68k_irq_shutdown,
Linus Torvalds1da177e2005-04-16 15:20:36 -070045};
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047/*
48 * void init_IRQ(void)
49 *
50 * Parameters: None
51 *
52 * Returns: Nothing
53 *
54 * This function should be called during kernel startup to initialize
55 * the IRQ handling routines.
56 */
57
58void __init init_IRQ(void)
59{
60 int i;
61
Roman Zippel6d2f16a2006-06-23 02:04:59 -070062 /* assembly irq entry code relies on this... */
63 if (HARDIRQ_MASK != 0x00ff0000) {
64 extern void hardirq_mask_is_broken(void);
65 hardirq_mask_is_broken();
66 }
67
Roman Zippel68387c42006-06-25 05:47:01 -070068 for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
Geert Uytterhoeven4936f632011-04-21 22:50:52 +020069 irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Roman Zippel68387c42006-06-25 05:47:01 -070071 mach_init_IRQ();
72}
73
74/**
75 * m68k_setup_auto_interrupt
76 * @handler: called from auto vector interrupts
77 *
78 * setup the handler to be called from auto vector interrupts instead of the
Geert Uytterhoeven1425df82011-07-01 20:39:19 +020079 * standard do_IRQ(), it will be called with irq numbers in the range
Roman Zippel68387c42006-06-25 05:47:01 -070080 * from IRQ_AUTO_1 - IRQ_AUTO_7.
81 */
82void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
83{
84 if (handler)
85 *auto_irqhandler_fixup = (u32)handler;
86 flush_icache();
87}
88
89/**
90 * m68k_setup_user_interrupt
91 * @vec: first user vector interrupt to handle
92 * @cnt: number of active user vector interrupts
Roman Zippel68387c42006-06-25 05:47:01 -070093 *
94 * setup user vector interrupts, this includes activating the specified range
95 * of interrupts, only then these interrupts can be requested (note: this is
Geert Uytterhoevenf30a6482011-09-11 11:54:50 +020096 * different from auto vector interrupts).
Roman Zippel68387c42006-06-25 05:47:01 -070097 */
Geert Uytterhoevenf30a6482011-09-11 11:54:50 +020098void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt)
Roman Zippel68387c42006-06-25 05:47:01 -070099{
100 int i;
101
Geert Uytterhoeven27123cb2008-11-14 08:10:19 +0100102 BUG_ON(IRQ_USER + cnt > NR_IRQS);
Roman Zippel68387c42006-06-25 05:47:01 -0700103 m68k_first_user_vec = vec;
104 for (i = 0; i < cnt; i++)
Geert Uytterhoeven40a72c82011-05-27 22:33:41 +0200105 irq_set_chip(IRQ_USER + i, &user_irq_chip);
Roman Zippel68387c42006-06-25 05:47:01 -0700106 *user_irqvec_fixup = vec - IRQ_USER;
Roman Zippel68387c42006-06-25 05:47:01 -0700107 flush_icache();
108}
109
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200110/**
111 * m68k_setup_irq_controller
112 * @chip: irq chip which controls specified irq
113 * @handle: flow handler which handles specified irq
114 * @irq: first irq to be managed by the controller
115 * @cnt: number of irqs to be managed by the controller
116 *
117 * Change the controller for the specified range of irq, which will be used to
118 * manage these irq. auto/user irq already have a default controller, which can
119 * be changed as well, but the controller probably should use m68k_irq_startup/
120 * m68k_irq_shutdown.
121 */
122void m68k_setup_irq_controller(struct irq_chip *chip,
123 irq_flow_handler_t handle, unsigned int irq,
124 unsigned int cnt)
125{
126 int i;
127
128 for (i = 0; i < cnt; i++) {
129 irq_set_chip(irq + i, chip);
130 if (handle)
131 irq_set_handler(irq + i, handle);
132 }
133}
134
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200135unsigned int m68k_irq_startup_irq(unsigned int irq)
Roman Zippelb5dc7842006-06-25 05:47:00 -0700136{
137 if (irq <= IRQ_AUTO_7)
138 vectors[VEC_SPUR + irq] = auto_inthandler;
Roman Zippel68387c42006-06-25 05:47:01 -0700139 else
140 vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700141 return 0;
142}
143
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200144unsigned int m68k_irq_startup(struct irq_data *data)
Roman Zippelb5dc7842006-06-25 05:47:00 -0700145{
Geert Uytterhoevene8abf5e2011-04-17 22:53:04 +0200146 return m68k_irq_startup_irq(data->irq);
147}
148
149void m68k_irq_shutdown(struct irq_data *data)
150{
151 unsigned int irq = data->irq;
152
Roman Zippelb5dc7842006-06-25 05:47:00 -0700153 if (irq <= IRQ_AUTO_7)
154 vectors[VEC_SPUR + irq] = bad_inthandler;
Roman Zippel68387c42006-06-25 05:47:01 -0700155 else
156 vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
Roman Zippelb5dc7842006-06-25 05:47:00 -0700157}
158
159
Roman Zippel68387c42006-06-25 05:47:01 -0700160unsigned int irq_canonicalize(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161{
Roman Zippel68387c42006-06-25 05:47:01 -0700162#ifdef CONFIG_Q40
163 if (MACH_IS_Q40 && irq == 11)
164 irq = 10;
165#endif
166 return irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167}
168
Roman Zippel68387c42006-06-25 05:47:01 -0700169EXPORT_SYMBOL(irq_canonicalize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Geert Uytterhoeven4936f632011-04-21 22:50:52 +0200171
172asmlinkage void handle_badint(struct pt_regs *regs)
173{
174 atomic_inc(&irq_err_count);
175 pr_warn("unexpected interrupt from %u\n", regs->vector);
176}