Commit | Line | Data |
---|---|---|
88278ca2 | 1 | /* |
fd49bf48 SR |
2 | * Interrupt request handling routines. On the |
3 | * Sparc the IRQs are basically 'cast in stone' | |
4 | * and you are supposed to probe the prom's device | |
5 | * node trees to find out who's got which IRQ. | |
1da177e4 LT |
6 | * |
7 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | |
8 | * Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx) | |
9 | * Copyright (C) 1995,2002 Pete A. Zaitcev (zaitcev@yahoo.com) | |
10 | * Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk) | |
11 | * Copyright (C) 1998-2000 Anton Blanchard (anton@samba.org) | |
12 | */ | |
13 | ||
1da177e4 | 14 | #include <linux/kernel_stat.h> |
1da177e4 LT |
15 | #include <linux/seq_file.h> |
16 | ||
a2a211cb | 17 | #include <asm/cacheflush.h> |
1da177e4 | 18 | #include <asm/pcic.h> |
0fd7ef1f | 19 | #include <asm/leon.h> |
1da177e4 | 20 | |
81265fd9 | 21 | #include "kernel.h" |
32231a66 AV |
22 | #include "irq.h" |
23 | ||
1da177e4 LT |
24 | #ifdef CONFIG_SMP |
25 | #define SMP_NOP2 "nop; nop;\n\t" | |
26 | #define SMP_NOP3 "nop; nop; nop;\n\t" | |
27 | #else | |
28 | #define SMP_NOP2 | |
29 | #define SMP_NOP3 | |
30 | #endif /* SMP */ | |
fd49bf48 | 31 | |
df9ee292 | 32 | unsigned long arch_local_irq_save(void) |
1da177e4 LT |
33 | { |
34 | unsigned long retval; | |
35 | unsigned long tmp; | |
36 | ||
37 | __asm__ __volatile__( | |
38 | "rd %%psr, %0\n\t" | |
39 | SMP_NOP3 /* Sun4m + Cypress + SMP bug */ | |
40 | "or %0, %2, %1\n\t" | |
41 | "wr %1, 0, %%psr\n\t" | |
42 | "nop; nop; nop\n" | |
43 | : "=&r" (retval), "=r" (tmp) | |
44 | : "i" (PSR_PIL) | |
45 | : "memory"); | |
46 | ||
47 | return retval; | |
48 | } | |
df9ee292 | 49 | EXPORT_SYMBOL(arch_local_irq_save); |
1da177e4 | 50 | |
df9ee292 | 51 | void arch_local_irq_enable(void) |
1da177e4 LT |
52 | { |
53 | unsigned long tmp; | |
54 | ||
55 | __asm__ __volatile__( | |
56 | "rd %%psr, %0\n\t" | |
57 | SMP_NOP3 /* Sun4m + Cypress + SMP bug */ | |
58 | "andn %0, %1, %0\n\t" | |
59 | "wr %0, 0, %%psr\n\t" | |
60 | "nop; nop; nop\n" | |
61 | : "=&r" (tmp) | |
62 | : "i" (PSR_PIL) | |
63 | : "memory"); | |
64 | } | |
df9ee292 | 65 | EXPORT_SYMBOL(arch_local_irq_enable); |
1da177e4 | 66 | |
df9ee292 | 67 | void arch_local_irq_restore(unsigned long old_psr) |
1da177e4 LT |
68 | { |
69 | unsigned long tmp; | |
70 | ||
71 | __asm__ __volatile__( | |
72 | "rd %%psr, %0\n\t" | |
73 | "and %2, %1, %2\n\t" | |
74 | SMP_NOP2 /* Sun4m + Cypress + SMP bug */ | |
75 | "andn %0, %1, %0\n\t" | |
76 | "wr %0, %2, %%psr\n\t" | |
77 | "nop; nop; nop\n" | |
78 | : "=&r" (tmp) | |
79 | : "i" (PSR_PIL), "r" (old_psr) | |
80 | : "memory"); | |
81 | } | |
df9ee292 | 82 | EXPORT_SYMBOL(arch_local_irq_restore); |
1da177e4 LT |
83 | |
84 | /* | |
85 | * Dave Redman (djhr@tadpole.co.uk) | |
86 | * | |
87 | * IRQ numbers.. These are no longer restricted to 15.. | |
88 | * | |
89 | * this is done to enable SBUS cards and onboard IO to be masked | |
90 | * correctly. using the interrupt level isn't good enough. | |
91 | * | |
92 | * For example: | |
93 | * A device interrupting at sbus level6 and the Floppy both come in | |
94 | * at IRQ11, but enabling and disabling them requires writing to | |
95 | * different bits in the SLAVIO/SEC. | |
96 | * | |
97 | * As a result of these changes sun4m machines could now support | |
98 | * directed CPU interrupts using the existing enable/disable irq code | |
99 | * with tweaks. | |
100 | * | |
101 | */ | |
102 | ||
103 | static void irq_panic(void) | |
104 | { | |
b7afdb7e SR |
105 | prom_printf("machine: %s doesn't have irq handlers defined!\n", |
106 | &cputypval[0]); | |
107 | prom_halt(); | |
1da177e4 LT |
108 | } |
109 | ||
fd49bf48 | 110 | void (*sparc_init_timers)(irq_handler_t) = (void (*)(irq_handler_t))irq_panic; |
1da177e4 LT |
111 | |
112 | /* | |
113 | * Dave Redman (djhr@tadpole.co.uk) | |
114 | * | |
115 | * There used to be extern calls and hard coded values here.. very sucky! | |
116 | * instead, because some of the devices attach very early, I do something | |
117 | * equally sucky but at least we'll never try to free statically allocated | |
118 | * space or call kmalloc before kmalloc_init :(. | |
fd49bf48 | 119 | * |
1da177e4 LT |
120 | * In fact it's the timer10 that attaches first.. then timer14 |
121 | * then kmalloc_init is called.. then the tty interrupts attach. | |
122 | * hmmm.... | |
123 | * | |
124 | */ | |
125 | #define MAX_STATIC_ALLOC 4 | |
126 | struct irqaction static_irqaction[MAX_STATIC_ALLOC]; | |
127 | int static_irq_count; | |
128 | ||
c61c65cd | 129 | static struct { |
a54123e2 BB |
130 | struct irqaction *action; |
131 | int flags; | |
132 | } sparc_irq[NR_IRQS]; | |
133 | #define SPARC_IRQ_INPROGRESS 1 | |
1da177e4 LT |
134 | |
135 | /* Used to protect the IRQ action lists */ | |
136 | DEFINE_SPINLOCK(irq_action_lock); | |
137 | ||
138 | int show_interrupts(struct seq_file *p, void *v) | |
139 | { | |
fd49bf48 SR |
140 | int i = *(loff_t *)v; |
141 | struct irqaction *action; | |
1da177e4 LT |
142 | unsigned long flags; |
143 | #ifdef CONFIG_SMP | |
144 | int j; | |
145 | #endif | |
146 | ||
fd49bf48 | 147 | if (sparc_cpu_model == sun4d) |
1da177e4 | 148 | return show_sun4d_interrupts(p, v); |
fd49bf48 | 149 | |
1da177e4 LT |
150 | spin_lock_irqsave(&irq_action_lock, flags); |
151 | if (i < NR_IRQS) { | |
a54123e2 | 152 | action = sparc_irq[i].action; |
fd49bf48 | 153 | if (!action) |
1da177e4 LT |
154 | goto out_unlock; |
155 | seq_printf(p, "%3d: ", i); | |
156 | #ifndef CONFIG_SMP | |
157 | seq_printf(p, "%10u ", kstat_irqs(i)); | |
158 | #else | |
394e3902 AM |
159 | for_each_online_cpu(j) { |
160 | seq_printf(p, "%10u ", | |
a54123e2 | 161 | kstat_cpu(j).irqs[i]); |
1da177e4 LT |
162 | } |
163 | #endif | |
164 | seq_printf(p, " %c %s", | |
67413202 | 165 | (action->flags & IRQF_DISABLED) ? '+' : ' ', |
1da177e4 | 166 | action->name); |
fd49bf48 | 167 | for (action = action->next; action; action = action->next) { |
1da177e4 | 168 | seq_printf(p, ",%s %s", |
67413202 | 169 | (action->flags & IRQF_DISABLED) ? " +" : "", |
1da177e4 LT |
170 | action->name); |
171 | } | |
172 | seq_putc(p, '\n'); | |
173 | } | |
174 | out_unlock: | |
175 | spin_unlock_irqrestore(&irq_action_lock, flags); | |
176 | return 0; | |
177 | } | |
178 | ||
179 | void free_irq(unsigned int irq, void *dev_id) | |
180 | { | |
fd49bf48 | 181 | struct irqaction *action; |
a54123e2 | 182 | struct irqaction **actionp; |
fd49bf48 | 183 | unsigned long flags; |
1da177e4 | 184 | unsigned int cpu_irq; |
fd49bf48 | 185 | |
1da177e4 | 186 | if (sparc_cpu_model == sun4d) { |
1da177e4 LT |
187 | sun4d_free_irq(irq, dev_id); |
188 | return; | |
189 | } | |
190 | cpu_irq = irq & (NR_IRQS - 1); | |
fd49bf48 SR |
191 | if (cpu_irq > 14) { /* 14 irq levels on the sparc */ |
192 | printk(KERN_ERR "Trying to free bogus IRQ %d\n", irq); | |
193 | return; | |
194 | } | |
1da177e4 LT |
195 | |
196 | spin_lock_irqsave(&irq_action_lock, flags); | |
197 | ||
a54123e2 BB |
198 | actionp = &sparc_irq[cpu_irq].action; |
199 | action = *actionp; | |
1da177e4 LT |
200 | |
201 | if (!action->handler) { | |
fd49bf48 | 202 | printk(KERN_ERR "Trying to free free IRQ%d\n", irq); |
1da177e4 LT |
203 | goto out_unlock; |
204 | } | |
205 | if (dev_id) { | |
206 | for (; action; action = action->next) { | |
207 | if (action->dev_id == dev_id) | |
208 | break; | |
a54123e2 | 209 | actionp = &action->next; |
1da177e4 LT |
210 | } |
211 | if (!action) { | |
fd49bf48 SR |
212 | printk(KERN_ERR "Trying to free free shared IRQ%d\n", |
213 | irq); | |
1da177e4 LT |
214 | goto out_unlock; |
215 | } | |
67413202 | 216 | } else if (action->flags & IRQF_SHARED) { |
fd49bf48 SR |
217 | printk(KERN_ERR "Trying to free shared IRQ%d with NULL device ID\n", |
218 | irq); | |
1da177e4 LT |
219 | goto out_unlock; |
220 | } | |
fd49bf48 SR |
221 | if (action->flags & SA_STATIC_ALLOC) { |
222 | /* | |
223 | * This interrupt is marked as specially allocated | |
1da177e4 LT |
224 | * so it is a bad idea to free it. |
225 | */ | |
fd49bf48 | 226 | printk(KERN_ERR "Attempt to free statically allocated IRQ%d (%s)\n", |
1da177e4 LT |
227 | irq, action->name); |
228 | goto out_unlock; | |
229 | } | |
a54123e2 BB |
230 | |
231 | *actionp = action->next; | |
1da177e4 LT |
232 | |
233 | spin_unlock_irqrestore(&irq_action_lock, flags); | |
234 | ||
235 | synchronize_irq(irq); | |
236 | ||
237 | spin_lock_irqsave(&irq_action_lock, flags); | |
238 | ||
239 | kfree(action); | |
240 | ||
a54123e2 | 241 | if (!sparc_irq[cpu_irq].action) |
0f516813 | 242 | __disable_irq(irq); |
1da177e4 LT |
243 | |
244 | out_unlock: | |
245 | spin_unlock_irqrestore(&irq_action_lock, flags); | |
246 | } | |
1da177e4 LT |
247 | EXPORT_SYMBOL(free_irq); |
248 | ||
249 | /* | |
250 | * This is called when we want to synchronize with | |
251 | * interrupts. We may for example tell a device to | |
252 | * stop sending interrupts: but to make sure there | |
253 | * are no interrupts that are executing on another | |
254 | * CPU we need to call this function. | |
255 | */ | |
256 | #ifdef CONFIG_SMP | |
257 | void synchronize_irq(unsigned int irq) | |
258 | { | |
a54123e2 BB |
259 | unsigned int cpu_irq; |
260 | ||
261 | cpu_irq = irq & (NR_IRQS - 1); | |
262 | while (sparc_irq[cpu_irq].flags & SPARC_IRQ_INPROGRESS) | |
263 | cpu_relax(); | |
1da177e4 | 264 | } |
6943f3da | 265 | EXPORT_SYMBOL(synchronize_irq); |
1da177e4 LT |
266 | #endif /* SMP */ |
267 | ||
fd49bf48 | 268 | void unexpected_irq(int irq, void *dev_id, struct pt_regs *regs) |
1da177e4 | 269 | { |
fd49bf48 SR |
270 | int i; |
271 | struct irqaction *action; | |
1da177e4 | 272 | unsigned int cpu_irq; |
fd49bf48 | 273 | |
1da177e4 | 274 | cpu_irq = irq & (NR_IRQS - 1); |
a54123e2 | 275 | action = sparc_irq[cpu_irq].action; |
1da177e4 | 276 | |
fd49bf48 SR |
277 | printk(KERN_ERR "IO device interrupt, irq = %d\n", irq); |
278 | printk(KERN_ERR "PC = %08lx NPC = %08lx FP=%08lx\n", regs->pc, | |
1da177e4 LT |
279 | regs->npc, regs->u_regs[14]); |
280 | if (action) { | |
fd49bf48 SR |
281 | printk(KERN_ERR "Expecting: "); |
282 | for (i = 0; i < 16; i++) | |
283 | if (action->handler) | |
284 | printk(KERN_CONT "[%s:%d:0x%x] ", action->name, | |
285 | i, (unsigned int)action->handler); | |
1da177e4 | 286 | } |
fd49bf48 | 287 | printk(KERN_ERR "AIEEE\n"); |
1da177e4 LT |
288 | panic("bogus interrupt received"); |
289 | } | |
290 | ||
fd49bf48 | 291 | void handler_irq(int pil, struct pt_regs *regs) |
1da177e4 | 292 | { |
0d84438d | 293 | struct pt_regs *old_regs; |
fd49bf48 | 294 | struct irqaction *action; |
1da177e4 | 295 | int cpu = smp_processor_id(); |
1da177e4 | 296 | |
0d84438d | 297 | old_regs = set_irq_regs(regs); |
1da177e4 | 298 | irq_enter(); |
d4d1ec48 | 299 | disable_pil_irq(pil); |
1da177e4 | 300 | #ifdef CONFIG_SMP |
d1a78c32 | 301 | /* Only rotate on lower priority IRQs (scsi, ethernet, etc.). */ |
fd49bf48 | 302 | if ((sparc_cpu_model==sun4m) && (pil < 10)) |
1da177e4 LT |
303 | smp4m_irq_rotate(cpu); |
304 | #endif | |
d4d1ec48 SR |
305 | action = sparc_irq[pil].action; |
306 | sparc_irq[pil].flags |= SPARC_IRQ_INPROGRESS; | |
307 | kstat_cpu(cpu).irqs[pil]++; | |
1da177e4 LT |
308 | do { |
309 | if (!action || !action->handler) | |
d4d1ec48 SR |
310 | unexpected_irq(pil, NULL, regs); |
311 | action->handler(pil, action->dev_id); | |
1da177e4 LT |
312 | action = action->next; |
313 | } while (action); | |
d4d1ec48 SR |
314 | sparc_irq[pil].flags &= ~SPARC_IRQ_INPROGRESS; |
315 | enable_pil_irq(pil); | |
1da177e4 | 316 | irq_exit(); |
0d84438d | 317 | set_irq_regs(old_regs); |
1da177e4 LT |
318 | } |
319 | ||
0a808a31 | 320 | #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE) |
1da177e4 | 321 | |
fd49bf48 SR |
322 | /* |
323 | * Fast IRQs on the Sparc can only have one routine attached to them, | |
1da177e4 LT |
324 | * thus no sharing possible. |
325 | */ | |
0a808a31 DM |
326 | static int request_fast_irq(unsigned int irq, |
327 | void (*handler)(void), | |
328 | unsigned long irqflags, const char *devname) | |
1da177e4 LT |
329 | { |
330 | struct irqaction *action; | |
331 | unsigned long flags; | |
332 | unsigned int cpu_irq; | |
333 | int ret; | |
51672321 | 334 | #if defined CONFIG_SMP && !defined CONFIG_SPARC_LEON |
1da177e4 | 335 | struct tt_entry *trap_table; |
1da177e4 | 336 | #endif |
1da177e4 | 337 | cpu_irq = irq & (NR_IRQS - 1); |
fd49bf48 | 338 | if (cpu_irq > 14) { |
1da177e4 LT |
339 | ret = -EINVAL; |
340 | goto out; | |
341 | } | |
fd49bf48 | 342 | if (!handler) { |
1da177e4 LT |
343 | ret = -EINVAL; |
344 | goto out; | |
345 | } | |
346 | ||
347 | spin_lock_irqsave(&irq_action_lock, flags); | |
348 | ||
a54123e2 | 349 | action = sparc_irq[cpu_irq].action; |
fd49bf48 SR |
350 | if (action) { |
351 | if (action->flags & IRQF_SHARED) | |
1da177e4 | 352 | panic("Trying to register fast irq when already shared.\n"); |
fd49bf48 | 353 | if (irqflags & IRQF_SHARED) |
1da177e4 LT |
354 | panic("Trying to register fast irq as shared.\n"); |
355 | ||
356 | /* Anyway, someone already owns it so cannot be made fast. */ | |
fd49bf48 | 357 | printk(KERN_ERR "request_fast_irq: Trying to register yet already owned.\n"); |
1da177e4 LT |
358 | ret = -EBUSY; |
359 | goto out_unlock; | |
360 | } | |
361 | ||
fd49bf48 SR |
362 | /* |
363 | * If this is flagged as statically allocated then we use our | |
1da177e4 LT |
364 | * private struct which is never freed. |
365 | */ | |
366 | if (irqflags & SA_STATIC_ALLOC) { | |
fd49bf48 SR |
367 | if (static_irq_count < MAX_STATIC_ALLOC) |
368 | action = &static_irqaction[static_irq_count++]; | |
369 | else | |
370 | printk(KERN_ERR "Fast IRQ%d (%s) SA_STATIC_ALLOC failed using kmalloc\n", | |
371 | irq, devname); | |
1da177e4 | 372 | } |
fd49bf48 | 373 | |
1da177e4 | 374 | if (action == NULL) |
fd49bf48 SR |
375 | action = kmalloc(sizeof(struct irqaction), GFP_ATOMIC); |
376 | if (!action) { | |
1da177e4 LT |
377 | ret = -ENOMEM; |
378 | goto out_unlock; | |
379 | } | |
380 | ||
381 | /* Dork with trap table if we get this far. */ | |
382 | #define INSTANTIATE(table) \ | |
383 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_one = SPARC_RD_PSR_L0; \ | |
384 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_two = \ | |
385 | SPARC_BRANCH((unsigned long) handler, \ | |
386 | (unsigned long) &table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_two);\ | |
387 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_three = SPARC_RD_WIM_L3; \ | |
388 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_four = SPARC_NOP; | |
389 | ||
390 | INSTANTIATE(sparc_ttable) | |
51672321 | 391 | #if defined CONFIG_SMP && !defined CONFIG_SPARC_LEON |
fd49bf48 SR |
392 | trap_table = &trapbase_cpu1; |
393 | INSTANTIATE(trap_table) | |
394 | trap_table = &trapbase_cpu2; | |
395 | INSTANTIATE(trap_table) | |
396 | trap_table = &trapbase_cpu3; | |
397 | INSTANTIATE(trap_table) | |
1da177e4 LT |
398 | #endif |
399 | #undef INSTANTIATE | |
400 | /* | |
401 | * XXX Correct thing whould be to flush only I- and D-cache lines | |
402 | * which contain the handler in question. But as of time of the | |
403 | * writing we have no CPU-neutral interface to fine-grained flushes. | |
404 | */ | |
405 | flush_cache_all(); | |
406 | ||
1da177e4 | 407 | action->flags = irqflags; |
1da177e4 LT |
408 | action->name = devname; |
409 | action->dev_id = NULL; | |
410 | action->next = NULL; | |
411 | ||
a54123e2 | 412 | sparc_irq[cpu_irq].action = action; |
1da177e4 | 413 | |
0f516813 | 414 | __enable_irq(irq); |
1da177e4 LT |
415 | |
416 | ret = 0; | |
417 | out_unlock: | |
418 | spin_unlock_irqrestore(&irq_action_lock, flags); | |
419 | out: | |
420 | return ret; | |
421 | } | |
422 | ||
fd49bf48 SR |
423 | /* |
424 | * These variables are used to access state from the assembler | |
0a808a31 DM |
425 | * interrupt handler, floppy_hardint, so we cannot put these in |
426 | * the floppy driver image because that would not work in the | |
427 | * modular case. | |
428 | */ | |
429 | volatile unsigned char *fdc_status; | |
430 | EXPORT_SYMBOL(fdc_status); | |
431 | ||
432 | char *pdma_vaddr; | |
433 | EXPORT_SYMBOL(pdma_vaddr); | |
434 | ||
435 | unsigned long pdma_size; | |
436 | EXPORT_SYMBOL(pdma_size); | |
437 | ||
438 | volatile int doing_pdma; | |
439 | EXPORT_SYMBOL(doing_pdma); | |
440 | ||
441 | char *pdma_base; | |
442 | EXPORT_SYMBOL(pdma_base); | |
443 | ||
444 | unsigned long pdma_areasize; | |
445 | EXPORT_SYMBOL(pdma_areasize); | |
446 | ||
7c239975 | 447 | static irq_handler_t floppy_irq_handler; |
0a808a31 DM |
448 | |
449 | void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs) | |
450 | { | |
451 | struct pt_regs *old_regs; | |
452 | int cpu = smp_processor_id(); | |
453 | ||
454 | old_regs = set_irq_regs(regs); | |
455 | disable_pil_irq(irq); | |
456 | irq_enter(); | |
457 | kstat_cpu(cpu).irqs[irq]++; | |
458 | floppy_irq_handler(irq, dev_id); | |
459 | irq_exit(); | |
460 | enable_pil_irq(irq); | |
461 | set_irq_regs(old_regs); | |
fd49bf48 SR |
462 | /* |
463 | * XXX Eek, it's totally changed with preempt_count() and such | |
464 | * if (softirq_pending(cpu)) | |
465 | * do_softirq(); | |
466 | */ | |
0a808a31 DM |
467 | } |
468 | ||
469 | int sparc_floppy_request_irq(int irq, unsigned long flags, | |
7c239975 | 470 | irq_handler_t irq_handler) |
0a808a31 DM |
471 | { |
472 | floppy_irq_handler = irq_handler; | |
473 | return request_fast_irq(irq, floppy_hardint, flags, "floppy"); | |
474 | } | |
475 | EXPORT_SYMBOL(sparc_floppy_request_irq); | |
476 | ||
477 | #endif | |
478 | ||
1da177e4 | 479 | int request_irq(unsigned int irq, |
40220c1a | 480 | irq_handler_t handler, |
fd49bf48 | 481 | unsigned long irqflags, const char *devname, void *dev_id) |
1da177e4 | 482 | { |
fd49bf48 | 483 | struct irqaction *action, **actionp; |
1da177e4 LT |
484 | unsigned long flags; |
485 | unsigned int cpu_irq; | |
486 | int ret; | |
fd49bf48 SR |
487 | |
488 | if (sparc_cpu_model == sun4d) | |
1da177e4 | 489 | return sun4d_request_irq(irq, handler, irqflags, devname, dev_id); |
fd49bf48 | 490 | |
1da177e4 | 491 | cpu_irq = irq & (NR_IRQS - 1); |
fd49bf48 | 492 | if (cpu_irq > 14) { |
1da177e4 LT |
493 | ret = -EINVAL; |
494 | goto out; | |
495 | } | |
496 | if (!handler) { | |
497 | ret = -EINVAL; | |
498 | goto out; | |
499 | } | |
fd49bf48 | 500 | |
1da177e4 LT |
501 | spin_lock_irqsave(&irq_action_lock, flags); |
502 | ||
a54123e2 BB |
503 | actionp = &sparc_irq[cpu_irq].action; |
504 | action = *actionp; | |
1da177e4 | 505 | if (action) { |
67413202 | 506 | if (!(action->flags & IRQF_SHARED) || !(irqflags & IRQF_SHARED)) { |
1da177e4 LT |
507 | ret = -EBUSY; |
508 | goto out_unlock; | |
509 | } | |
67413202 | 510 | if ((action->flags & IRQF_DISABLED) != (irqflags & IRQF_DISABLED)) { |
fd49bf48 SR |
511 | printk(KERN_ERR "Attempt to mix fast and slow interrupts on IRQ%d denied\n", |
512 | irq); | |
1da177e4 LT |
513 | ret = -EBUSY; |
514 | goto out_unlock; | |
a54123e2 BB |
515 | } |
516 | for ( ; action; action = *actionp) | |
517 | actionp = &action->next; | |
1da177e4 LT |
518 | } |
519 | ||
520 | /* If this is flagged as statically allocated then we use our | |
521 | * private struct which is never freed. | |
522 | */ | |
523 | if (irqflags & SA_STATIC_ALLOC) { | |
524 | if (static_irq_count < MAX_STATIC_ALLOC) | |
525 | action = &static_irqaction[static_irq_count++]; | |
526 | else | |
fd49bf48 SR |
527 | printk(KERN_ERR "Request for IRQ%d (%s) SA_STATIC_ALLOC failed using kmalloc\n", |
528 | irq, devname); | |
1da177e4 | 529 | } |
1da177e4 | 530 | if (action == NULL) |
fd49bf48 SR |
531 | action = kmalloc(sizeof(struct irqaction), GFP_ATOMIC); |
532 | if (!action) { | |
1da177e4 LT |
533 | ret = -ENOMEM; |
534 | goto out_unlock; | |
535 | } | |
536 | ||
537 | action->handler = handler; | |
538 | action->flags = irqflags; | |
1da177e4 LT |
539 | action->name = devname; |
540 | action->next = NULL; | |
541 | action->dev_id = dev_id; | |
542 | ||
a54123e2 | 543 | *actionp = action; |
1da177e4 | 544 | |
0f516813 | 545 | __enable_irq(irq); |
1da177e4 LT |
546 | |
547 | ret = 0; | |
548 | out_unlock: | |
549 | spin_unlock_irqrestore(&irq_action_lock, flags); | |
550 | out: | |
551 | return ret; | |
552 | } | |
1da177e4 LT |
553 | EXPORT_SYMBOL(request_irq); |
554 | ||
0f516813 AV |
555 | void disable_irq_nosync(unsigned int irq) |
556 | { | |
81265fd9 | 557 | __disable_irq(irq); |
0f516813 AV |
558 | } |
559 | EXPORT_SYMBOL(disable_irq_nosync); | |
560 | ||
561 | void disable_irq(unsigned int irq) | |
562 | { | |
81265fd9 | 563 | __disable_irq(irq); |
0f516813 AV |
564 | } |
565 | EXPORT_SYMBOL(disable_irq); | |
566 | ||
567 | void enable_irq(unsigned int irq) | |
568 | { | |
81265fd9 | 569 | __enable_irq(irq); |
0f516813 | 570 | } |
0f516813 AV |
571 | EXPORT_SYMBOL(enable_irq); |
572 | ||
fd49bf48 SR |
573 | /* |
574 | * We really don't need these at all on the Sparc. We only have | |
1da177e4 LT |
575 | * stubs here because they are exported to modules. |
576 | */ | |
577 | unsigned long probe_irq_on(void) | |
578 | { | |
579 | return 0; | |
580 | } | |
1da177e4 LT |
581 | EXPORT_SYMBOL(probe_irq_on); |
582 | ||
583 | int probe_irq_off(unsigned long mask) | |
584 | { | |
585 | return 0; | |
586 | } | |
1da177e4 LT |
587 | EXPORT_SYMBOL(probe_irq_off); |
588 | ||
589 | /* djhr | |
590 | * This could probably be made indirect too and assigned in the CPU | |
591 | * bits of the code. That would be much nicer I think and would also | |
592 | * fit in with the idea of being able to tune your kernel for your machine | |
593 | * by removing unrequired machine and device support. | |
594 | * | |
595 | */ | |
596 | ||
597 | void __init init_IRQ(void) | |
598 | { | |
fd49bf48 | 599 | switch (sparc_cpu_model) { |
1da177e4 LT |
600 | case sun4c: |
601 | case sun4: | |
602 | sun4c_init_IRQ(); | |
603 | break; | |
604 | ||
605 | case sun4m: | |
606 | #ifdef CONFIG_PCI | |
607 | pcic_probe(); | |
608 | if (pcic_present()) { | |
609 | sun4m_pci_init_IRQ(); | |
610 | break; | |
611 | } | |
612 | #endif | |
613 | sun4m_init_IRQ(); | |
614 | break; | |
fd49bf48 | 615 | |
1da177e4 LT |
616 | case sun4d: |
617 | sun4d_init_IRQ(); | |
618 | break; | |
619 | ||
0fd7ef1f KE |
620 | case sparc_leon: |
621 | leon_init_IRQ(); | |
622 | break; | |
623 | ||
1da177e4 | 624 | default: |
d1a78c32 | 625 | prom_printf("Cannot initialize IRQs on this Sun machine..."); |
1da177e4 LT |
626 | break; |
627 | } | |
628 | btfixup(); | |
629 | } | |
630 | ||
4696b64d | 631 | #ifdef CONFIG_PROC_FS |
1da177e4 LT |
632 | void init_irq_proc(void) |
633 | { | |
634 | /* For now, nothing... */ | |
635 | } | |
4696b64d | 636 | #endif /* CONFIG_PROC_FS */ |