blob: 2cb52cf8bd4ebe378b2e6f37890dc857a330dca1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 by Waldorf GMBH, written by Ralf Baechle
7 * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02, 03 by Ralf Baechle
8 */
9#ifndef _ASM_IRQ_H
10#define _ASM_IRQ_H
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/linkage.h>
Ralf Baechle41c594a2006-04-05 09:45:45 +010013
14#include <asm/mipsmtregs.h>
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <irq.h>
17
18#ifdef CONFIG_I8259
19static inline int irq_canonicalize(int irq)
20{
Atsushi Nemoto2fa79372007-01-14 23:41:42 +090021 return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022}
23#else
24#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
25#endif
26
Ralf Baechle1146fe32007-09-21 17:13:55 +010027#ifdef CONFIG_MIPS_MT_SMTC
28
29struct irqaction;
30
31extern unsigned long irq_hwmask[];
32extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
33 unsigned long hwmask);
34
35static inline void smtc_im_ack_irq(unsigned int irq)
36{
37 if (irq_hwmask[irq] & ST0_IM)
38 set_c0_status(irq_hwmask[irq] & ST0_IM);
39}
40
41#else
42
43static inline void smtc_im_ack_irq(unsigned int irq)
44{
45}
46
47#endif /* CONFIG_MIPS_MT_SMTC */
48
Kevin D. Kissell0db34212007-07-12 16:21:08 +010049#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
Ralf Baechle1146fe32007-09-21 17:13:55 +010050
Ralf Baechle41c594a2006-04-05 09:45:45 +010051/*
52 * Clear interrupt mask handling "backstop" if irq_hwmask
53 * entry so indicates. This implies that the ack() or end()
54 * functions will take over re-enabling the low-level mask.
55 * Otherwise it will be done on return from exception.
56 */
Atsushi Nemotof9bba752007-01-08 00:50:34 +090057#define __DO_IRQ_SMTC_HOOK(irq) \
Ralf Baechle41c594a2006-04-05 09:45:45 +010058do { \
59 if (irq_hwmask[irq] & 0x0000ff00) \
60 write_c0_tccontext(read_c0_tccontext() & \
61 ~(irq_hwmask[irq] & 0x0000ff00)); \
62} while (0)
63#else
Ralf Baechle1146fe32007-09-21 17:13:55 +010064
Atsushi Nemotof9bba752007-01-08 00:50:34 +090065#define __DO_IRQ_SMTC_HOOK(irq) do { } while (0)
Ralf Baechle41c594a2006-04-05 09:45:45 +010066#endif
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068/*
69 * do_IRQ handles all normal device IRQ's (the special
70 * SMP cross-CPU interrupts have their own specific
71 * handlers).
72 *
73 * Ideally there should be away to get this into kernel/irq/handle.c to
74 * avoid the overhead of a call for just a tiny function ...
75 */
Ralf Baechle937a8012006-10-07 19:44:33 +010076#define do_IRQ(irq) \
Linus Torvalds1da177e2005-04-16 15:20:36 -070077do { \
78 irq_enter(); \
Atsushi Nemotof9bba752007-01-08 00:50:34 +090079 __DO_IRQ_SMTC_HOOK(irq); \
Atsushi Nemoto14178362006-11-14 01:13:18 +090080 generic_handle_irq(irq); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 irq_exit(); \
82} while (0)
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084extern void arch_init_irq(void);
Ralf Baechle937a8012006-10-07 19:44:33 +010085extern void spurious_interrupt(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Ralf Baechle4a4cf772006-11-06 17:41:06 +000087extern int allocate_irqno(void);
88extern void alloc_legacy_irqno(void);
89extern void free_irqno(unsigned int irq);
90
Ralf Baechle3b1d4ed2007-06-20 22:27:10 +010091/*
92 * Before R2 the timer and performance counter interrupts were both fixed to
93 * IE7. Since R2 their number has to be read from the c0_intctl register.
94 */
95#define CP0_LEGACY_COMPARE_IRQ 7
96
97extern int cp0_compare_irq;
98extern int cp0_perfcount_irq;
99
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100#endif /* _ASM_IRQ_H */