blob: dea4aed6478f7de6652c8b5491ebfc165cf52d53 [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 Baechle631330f2009-06-19 14:05:26 +010013#include <linux/smp.h>
Ralf Baechle41c594a2006-04-05 09:45:45 +010014
15#include <asm/mipsmtregs.h>
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <irq.h>
18
19#ifdef CONFIG_I8259
20static inline int irq_canonicalize(int irq)
21{
Atsushi Nemoto2fa79372007-01-14 23:41:42 +090022 return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070023}
24#else
25#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
26#endif
27
Ralf Baechle1146fe32007-09-21 17:13:55 +010028#ifdef CONFIG_MIPS_MT_SMTC
29
30struct irqaction;
31
32extern unsigned long irq_hwmask[];
33extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
34 unsigned long hwmask);
35
36static inline void smtc_im_ack_irq(unsigned int irq)
37{
38 if (irq_hwmask[irq] & ST0_IM)
39 set_c0_status(irq_hwmask[irq] & ST0_IM);
40}
41
42#else
43
44static inline void smtc_im_ack_irq(unsigned int irq)
45{
46}
47
48#endif /* CONFIG_MIPS_MT_SMTC */
49
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020050#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
51#include <linux/cpumask.h>
52
Yinghai Lud5dedd42009-04-27 17:59:21 -070053extern int plat_set_irq_affinity(unsigned int irq,
Rusty Russell0de26522008-12-13 21:20:26 +103054 const struct cpumask *affinity);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020055extern void smtc_forward_irq(unsigned int irq);
56
57/*
58 * IRQ affinity hook invoked at the beginning of interrupt dispatch
59 * if option is enabled.
60 *
61 * Up through Linux 2.6.22 (at least) cpumask operations are very
62 * inefficient on MIPS. Initial prototypes of SMTC IRQ affinity
63 * used a "fast path" per-IRQ-descriptor cache of affinity information
64 * to reduce latency. As there is a project afoot to optimize the
65 * cpumask implementations, this version is optimistically assuming
66 * that cpumask.h macro overhead is reasonable during interrupt dispatch.
67 */
68#define IRQ_AFFINITY_HOOK(irq) \
69do { \
Mike Travise65e49d2009-01-12 15:27:13 -080070 if (!cpumask_test_cpu(smp_processor_id(), irq_desc[irq].affinity)) {\
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020071 smtc_forward_irq(irq); \
72 irq_exit(); \
73 return; \
74 } \
75} while (0)
76
77#else /* Not doing SMTC affinity */
78
79#define IRQ_AFFINITY_HOOK(irq) do { } while (0)
80
81#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
82
Kevin D. Kissell0db34212007-07-12 16:21:08 +010083#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
Ralf Baechle1146fe32007-09-21 17:13:55 +010084
Ralf Baechle41c594a2006-04-05 09:45:45 +010085/*
86 * Clear interrupt mask handling "backstop" if irq_hwmask
87 * entry so indicates. This implies that the ack() or end()
88 * functions will take over re-enabling the low-level mask.
89 * Otherwise it will be done on return from exception.
90 */
Atsushi Nemotof9bba752007-01-08 00:50:34 +090091#define __DO_IRQ_SMTC_HOOK(irq) \
Ralf Baechle41c594a2006-04-05 09:45:45 +010092do { \
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020093 IRQ_AFFINITY_HOOK(irq); \
Ralf Baechle41c594a2006-04-05 09:45:45 +010094 if (irq_hwmask[irq] & 0x0000ff00) \
95 write_c0_tccontext(read_c0_tccontext() & \
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020096 ~(irq_hwmask[irq] & 0x0000ff00)); \
Ralf Baechle41c594a2006-04-05 09:45:45 +010097} while (0)
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020098
99#define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) \
100do { \
101 if (irq_hwmask[irq] & 0x0000ff00) \
102 write_c0_tccontext(read_c0_tccontext() & \
103 ~(irq_hwmask[irq] & 0x0000ff00)); \
104} while (0)
105
Ralf Baechle41c594a2006-04-05 09:45:45 +0100106#else
Ralf Baechle1146fe32007-09-21 17:13:55 +0100107
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200108#define __DO_IRQ_SMTC_HOOK(irq) \
109do { \
110 IRQ_AFFINITY_HOOK(irq); \
111} while (0)
112#define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) do { } while (0)
113
Ralf Baechle41c594a2006-04-05 09:45:45 +0100114#endif
115
Wu Zhangjin8f99a162009-11-20 20:34:33 +0800116extern void do_IRQ(unsigned int irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200118#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200119
Wu Zhangjin8f99a162009-11-20 20:34:33 +0800120extern void do_IRQ_no_affinity(unsigned int irq);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200121
122#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124extern void arch_init_irq(void);
Ralf Baechle937a8012006-10-07 19:44:33 +0100125extern void spurious_interrupt(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Ralf Baechle4a4cf772006-11-06 17:41:06 +0000127extern int allocate_irqno(void);
128extern void alloc_legacy_irqno(void);
129extern void free_irqno(unsigned int irq);
130
Ralf Baechle3b1d4ed2007-06-20 22:27:10 +0100131/*
132 * Before R2 the timer and performance counter interrupts were both fixed to
133 * IE7. Since R2 their number has to be read from the c0_intctl register.
134 */
135#define CP0_LEGACY_COMPARE_IRQ 7
136
137extern int cp0_compare_irq;
David VomLehn010c1082009-12-21 17:49:22 -0800138extern int cp0_compare_irq_shift;
Ralf Baechle3b1d4ed2007-06-20 22:27:10 +0100139extern int cp0_perfcount_irq;
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#endif /* _ASM_IRQ_H */