m68k/irq: Remove obsolete m68k irq framework
[pandora-kernel.git] / arch / m68k / kernel / ints.c
1 /*
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
9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/sched.h>
12 #include <linux/interrupt.h>
13 #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>
23 #include <asm/cacheflush.h>
24 #include <asm/irq_regs.h>
25
26 #ifdef CONFIG_Q40
27 #include <asm/q40ints.h>
28 #endif
29
30 extern u32 auto_irqhandler_fixup[];
31 extern u32 user_irqhandler_fixup[];
32 extern u16 user_irqvec_fixup[];
33
34 static int m68k_first_user_vec;
35
36 static struct irq_chip auto_irq_chip = {
37         .name           = "auto",
38         .irq_startup    = m68k_irq_startup,
39         .irq_shutdown   = m68k_irq_shutdown,
40 };
41
42 static struct irq_chip user_irq_chip = {
43         .name           = "user",
44         .irq_startup    = m68k_irq_startup,
45         .irq_shutdown   = m68k_irq_shutdown,
46 };
47
48 /*
49  * void init_IRQ(void)
50  *
51  * Parameters:  None
52  *
53  * Returns:     Nothing
54  *
55  * This function should be called during kernel startup to initialize
56  * the IRQ handling routines.
57  */
58
59 void __init init_IRQ(void)
60 {
61         int i;
62
63         /* assembly irq entry code relies on this... */
64         if (HARDIRQ_MASK != 0x00ff0000) {
65                 extern void hardirq_mask_is_broken(void);
66                 hardirq_mask_is_broken();
67         }
68
69         for (i = IRQ_AUTO_1; i <= IRQ_AUTO_7; i++)
70                 irq_set_chip_and_handler(i, &auto_irq_chip, handle_simple_irq);
71
72         mach_init_IRQ();
73 }
74
75 /**
76  * m68k_setup_auto_interrupt
77  * @handler: called from auto vector interrupts
78  *
79  * setup the handler to be called from auto vector interrupts instead of the
80  * standard do_IRQ(), it will be called with irq numbers in the range
81  * from IRQ_AUTO_1 - IRQ_AUTO_7.
82  */
83 void __init m68k_setup_auto_interrupt(void (*handler)(unsigned int, struct pt_regs *))
84 {
85         if (handler)
86                 *auto_irqhandler_fixup = (u32)handler;
87         flush_icache();
88 }
89
90 /**
91  * m68k_setup_user_interrupt
92  * @vec: first user vector interrupt to handle
93  * @cnt: number of active user vector interrupts
94  * @handler: called from user vector interrupts
95  *
96  * setup user vector interrupts, this includes activating the specified range
97  * of interrupts, only then these interrupts can be requested (note: this is
98  * different from auto vector interrupts). An optional handler can be installed
99  * to be called instead of the default do_IRQ(), it will be called
100  * with irq numbers starting from IRQ_USER.
101  */
102 void __init m68k_setup_user_interrupt(unsigned int vec, unsigned int cnt,
103                                       void (*handler)(unsigned int, struct pt_regs *))
104 {
105         int i;
106
107         BUG_ON(IRQ_USER + cnt > NR_IRQS);
108         m68k_first_user_vec = vec;
109         for (i = 0; i < cnt; i++)
110                 irq_set_chip(IRQ_USER + i, &user_irq_chip);
111         *user_irqvec_fixup = vec - IRQ_USER;
112         if (handler)
113                 *user_irqhandler_fixup = (u32)handler;
114         flush_icache();
115 }
116
117 /**
118  * m68k_setup_irq_controller
119  * @chip: irq chip which controls specified irq
120  * @handle: flow handler which handles specified irq
121  * @irq: first irq to be managed by the controller
122  * @cnt: number of irqs to be managed by the controller
123  *
124  * Change the controller for the specified range of irq, which will be used to
125  * manage these irq. auto/user irq already have a default controller, which can
126  * be changed as well, but the controller probably should use m68k_irq_startup/
127  * m68k_irq_shutdown.
128  */
129 void m68k_setup_irq_controller(struct irq_chip *chip,
130                                irq_flow_handler_t handle, unsigned int irq,
131                                unsigned int cnt)
132 {
133         int i;
134
135         for (i = 0; i < cnt; i++) {
136                 irq_set_chip(irq + i, chip);
137                 if (handle)
138                         irq_set_handler(irq + i, handle);
139         }
140 }
141
142 unsigned int m68k_irq_startup_irq(unsigned int irq)
143 {
144         if (irq <= IRQ_AUTO_7)
145                 vectors[VEC_SPUR + irq] = auto_inthandler;
146         else
147                 vectors[m68k_first_user_vec + irq - IRQ_USER] = user_inthandler;
148         return 0;
149 }
150
151 unsigned int m68k_irq_startup(struct irq_data *data)
152 {
153         return m68k_irq_startup_irq(data->irq);
154 }
155
156 void m68k_irq_shutdown(struct irq_data *data)
157 {
158         unsigned int irq = data->irq;
159
160         if (irq <= IRQ_AUTO_7)
161                 vectors[VEC_SPUR + irq] = bad_inthandler;
162         else
163                 vectors[m68k_first_user_vec + irq - IRQ_USER] = bad_inthandler;
164 }
165
166
167 unsigned int irq_canonicalize(unsigned int irq)
168 {
169 #ifdef CONFIG_Q40
170         if (MACH_IS_Q40 && irq == 11)
171                 irq = 10;
172 #endif
173         return irq;
174 }
175
176 EXPORT_SYMBOL(irq_canonicalize);
177
178
179 asmlinkage void handle_badint(struct pt_regs *regs)
180 {
181         atomic_inc(&irq_err_count);
182         pr_warn("unexpected interrupt from %u\n", regs->vector);
183 }