aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68knommu/platform/68360/ints.c
diff options
context:
space:
mode:
authorGreg Ungerer <gerg@snapgear.com>2007-07-19 04:49:12 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 13:04:50 -0400
commit2502b667ea835ee16685c74b2a0d89ba8afe117a (patch)
tree31d492fb934df6d83819b679f3aa8d7f6952396d /arch/m68knommu/platform/68360/ints.c
parentf8af0bb890d6cdcb09ec042c128e217a7c500355 (diff)
m68knommu: generic irq handling
Change the m68knommu irq handling to use the generic irq framework. Signed-off-by: Greg Ungerer <gerg@uclinux.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m68knommu/platform/68360/ints.c')
-rw-r--r--arch/m68knommu/platform/68360/ints.c233
1 files changed, 13 insertions, 220 deletions
diff --git a/arch/m68knommu/platform/68360/ints.c b/arch/m68knommu/platform/68360/ints.c
index 4df3c146eb74..c36781157e09 100644
--- a/arch/m68knommu/platform/68360/ints.c
+++ b/arch/m68knommu/platform/68360/ints.c
@@ -10,20 +10,13 @@
10 * Copyright (c) 1999 D. Jeff Dionne <jeff@uclinux.org> 10 * Copyright (c) 1999 D. Jeff Dionne <jeff@uclinux.org>
11 */ 11 */
12 12
13#include <linux/module.h>
14#include <linux/types.h> 13#include <linux/types.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/sched.h> 15#include <linux/init.h>
17#include <linux/kernel_stat.h> 16#include <linux/interrupt.h>
18#include <linux/errno.h> 17#include <linux/irq.h>
19
20#include <asm/system.h>
21#include <asm/irq.h>
22#include <asm/irqnode.h>
23#include <asm/traps.h> 18#include <asm/traps.h>
24#include <asm/io.h>
25#include <asm/machdep.h> 19#include <asm/machdep.h>
26#include <asm/setup.h>
27#include <asm/m68360.h> 20#include <asm/m68360.h>
28 21
29/* from quicc/commproc.c: */ 22/* from quicc/commproc.c: */
@@ -36,26 +29,19 @@ extern void cpm_interrupt_init(void);
36asmlinkage void system_call(void); 29asmlinkage void system_call(void);
37asmlinkage void buserr(void); 30asmlinkage void buserr(void);
38asmlinkage void trap(void); 31asmlinkage void trap(void);
39asmlinkage irqreturn_t bad_interrupt(void); 32asmlinkage void bad_interrupt(void);
40asmlinkage irqreturn_t inthandler(void); 33asmlinkage void inthandler(void);
41 34
42extern void *_ramvec[]; 35extern void *_ramvec[];
43 36
44/* The number of spurious interrupts */ 37/* The number of spurious interrupts */
45volatile unsigned int num_spurious; 38volatile unsigned int num_spurious;
46unsigned int local_irq_count[NR_CPUS];
47
48/* irq node variables for the 32 (potential) on chip sources */
49static irq_node_t int_irq_list[INTERNAL_IRQS];
50
51static short int_irq_ablecount[INTERNAL_IRQS];
52 39
53/* 40/*
54 * This function should be called during kernel startup to initialize 41 * This function should be called during kernel startup to initialize
55 * IRQ handling routines. 42 * the vector table.
56 */ 43 */
57 44void init_vectors(void)
58void init_IRQ(void)
59{ 45{
60 int i; 46 int i;
61 int vba = (CPM_VECTOR_BASE<<4); 47 int vba = (CPM_VECTOR_BASE<<4);
@@ -79,7 +65,6 @@ void init_IRQ(void)
79 _ramvec[32] = system_call; 65 _ramvec[32] = system_call;
80 _ramvec[33] = trap; 66 _ramvec[33] = trap;
81 67
82
83 cpm_interrupt_init(); 68 cpm_interrupt_init();
84 69
85 /* set up CICR for vector base address and irq level */ 70 /* set up CICR for vector base address and irq level */
@@ -124,212 +109,20 @@ void init_IRQ(void)
124 109
125 /* turn off all CPM interrupts */ 110 /* turn off all CPM interrupts */
126 pquicc->intr_cimr = 0x00000000; 111 pquicc->intr_cimr = 0x00000000;
127
128 /* initialize handlers */
129 for (i = 0; i < INTERNAL_IRQS; i++) {
130 int_irq_list[i].handler = NULL;
131 int_irq_list[i].flags = IRQ_FLG_STD;
132 int_irq_list[i].dev_id = NULL;
133 int_irq_list[i].devname = NULL;
134 }
135}
136
137#if 0
138void M68360_insert_irq(irq_node_t **list, irq_node_t *node)
139{
140 unsigned long flags;
141 irq_node_t *cur;
142
143 if (!node->dev_id)
144 printk(KERN_INFO "%s: Warning: dev_id of %s is zero\n",
145 __FUNCTION__, node->devname);
146
147 local_irq_save(flags);
148
149 cur = *list;
150
151 while (cur) {
152 list = &cur->next;
153 cur = cur->next;
154 }
155
156 node->next = cur;
157 *list = node;
158
159 local_irq_restore(flags);
160} 112}
161 113
162void M68360_delete_irq(irq_node_t **list, void *dev_id) 114void enable_vector(unsigned int irq)
163{ 115{
164 unsigned long flags; 116 pquicc->intr_cimr |= (1 << irq);
165 irq_node_t *node;
166
167 local_irq_save(flags);
168
169 for (node = *list; node; list = &node->next, node = *list) {
170 if (node->dev_id == dev_id) {
171 *list = node->next;
172 /* Mark it as free. */
173 node->handler = NULL;
174 local_irq_restore(flags);
175 return;
176 }
177 }
178 local_irq_restore(flags);
179 printk (KERN_INFO "%s: tried to remove invalid irq\n", __FUNCTION__);
180} 117}
181#endif
182 118
183int request_irq( 119void disable_vector(unsigned int irq)
184 unsigned int irq,
185 irqreturn_t (*handler)(int, void *, struct pt_regs *),
186 unsigned long flags,
187 const char *devname,
188 void *dev_id)
189{ 120{
190 int mask = (1<<irq); 121 pquicc->intr_cimr &= ~(1 << irq);
191
192 irq += (CPM_VECTOR_BASE<<4);
193
194 if (irq >= INTERNAL_IRQS) {
195 printk (KERN_ERR "%s: Unknown IRQ %d from %s\n", __FUNCTION__, irq, devname);
196 return -ENXIO;
197 }
198
199 if (!(int_irq_list[irq].flags & IRQ_FLG_STD)) {
200 if (int_irq_list[irq].flags & IRQ_FLG_LOCK) {
201 printk(KERN_ERR "%s: IRQ %d from %s is not replaceable\n",
202 __FUNCTION__, irq, int_irq_list[irq].devname);
203 return -EBUSY;
204 }
205 if (flags & IRQ_FLG_REPLACE) {
206 printk(KERN_ERR "%s: %s can't replace IRQ %d from %s\n",
207 __FUNCTION__, devname, irq, int_irq_list[irq].devname);
208 return -EBUSY;
209 }
210 }
211 int_irq_list[irq].handler = handler;
212 int_irq_list[irq].flags = flags;
213 int_irq_list[irq].dev_id = dev_id;
214 int_irq_list[irq].devname = devname;
215
216 /* enable in the CIMR */
217 if (!int_irq_ablecount[irq])
218 pquicc->intr_cimr |= mask;
219 /* *(volatile unsigned long *)0xfffff304 &= ~(1<<irq); */
220
221 return 0;
222} 122}
223 123
224EXPORT_SYMBOL(request_irq); 124void ack_vector(unsigned int irq)
225
226void free_irq(unsigned int irq, void *dev_id)
227{ 125{
228 if (irq >= INTERNAL_IRQS) { 126 pquicc->intr_cisr = (1 << irq);
229 printk (KERN_ERR "%s: Unknown IRQ %d\n", __FUNCTION__, irq);
230 return;
231 }
232
233 if (int_irq_list[irq].dev_id != dev_id)
234 printk(KERN_INFO "%s: removing probably wrong IRQ %d from %s\n",
235 __FUNCTION__, irq, int_irq_list[irq].devname);
236 int_irq_list[irq].handler = NULL;
237 int_irq_list[irq].flags = IRQ_FLG_STD;
238 int_irq_list[irq].dev_id = NULL;
239 int_irq_list[irq].devname = NULL;
240
241 *(volatile unsigned long *)0xfffff304 |= 1<<irq;
242} 127}
243 128
244EXPORT_SYMBOL(free_irq);
245
246#if 0
247/*
248 * Enable/disable a particular machine specific interrupt source.
249 * Note that this may affect other interrupts in case of a shared interrupt.
250 * This function should only be called for a _very_ short time to change some
251 * internal data, that may not be changed by the interrupt at the same time.
252 * int_(enable|disable)_irq calls may also be nested.
253 */
254void M68360_enable_irq(unsigned int irq)
255{
256 if (irq >= INTERNAL_IRQS) {
257 printk(KERN_ERR "%s: Unknown IRQ %d\n", __FUNCTION__, irq);
258 return;
259 }
260
261 if (--int_irq_ablecount[irq])
262 return;
263
264 /* enable the interrupt */
265 *(volatile unsigned long *)0xfffff304 &= ~(1<<irq);
266}
267
268void M68360_disable_irq(unsigned int irq)
269{
270 if (irq >= INTERNAL_IRQS) {
271 printk(KERN_ERR "%s: Unknown IRQ %d\n", __FUNCTION__, irq);
272 return;
273 }
274
275 if (int_irq_ablecount[irq]++)
276 return;
277
278 /* disable the interrupt */
279 *(volatile unsigned long *)0xfffff304 |= 1<<irq;
280}
281#endif
282
283int show_interrupts(struct seq_file *p, void *v)
284{
285 int i = *(loff_t *) v;
286
287 if (i < NR_IRQS) {
288 if (int_irq_list[i].devname) {
289 seq_printf(p, "%3d: %10u ", i, kstat_cpu(0).irqs[i]);
290 if (int_irq_list[i].flags & IRQ_FLG_LOCK)
291 seq_printf(p, "L ");
292 else
293 seq_printf(p, " ");
294 seq_printf(p, "%s\n", int_irq_list[i].devname);
295 }
296 }
297 if (i == NR_IRQS)
298 seq_printf(p, " : %10u spurious\n", num_spurious);
299
300 return 0;
301}
302
303/* The 68k family did not have a good way to determine the source
304 * of interrupts until later in the family. The EC000 core does
305 * not provide the vector number on the stack, we vector everything
306 * into one vector and look in the blasted mask register...
307 * This code is designed to be fast, almost constant time, not clean!
308 */
309void process_int(int vec, struct pt_regs *fp)
310{
311 int irq;
312 int mask;
313
314 /* unsigned long pend = *(volatile unsigned long *)0xfffff30c; */
315
316 /* irq = vec + (CPM_VECTOR_BASE<<4); */
317 irq = vec;
318
319 /* unsigned long pend = *(volatile unsigned long *)pquicc->intr_cipr; */
320
321 /* Bugger all that weirdness. For the moment, I seem to know where I came from;
322 * vec is passed from a specific ISR, so I'll use it. */
323
324 if (int_irq_list[irq].handler) {
325 int_irq_list[irq].handler(irq , int_irq_list[irq].dev_id, fp);
326 kstat_cpu(0).irqs[irq]++;
327 pquicc->intr_cisr = (1 << vec); /* indicate that irq has been serviced */
328 } else {
329 printk(KERN_ERR "unregistered interrupt %d!\nTurning it off in the CIMR...\n", irq);
330 /* *(volatile unsigned long *)0xfffff304 |= mask; */
331 pquicc->intr_cimr &= ~(1 << vec);
332 num_spurious += 1;
333 }
334 return(IRQ_HANDLED);
335}