blob: 2354c870a63a1f8eb06bcce96d7036b767bb0497 [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
Dezhong Diaof2ffa5a2010-10-13 00:52:46 -060019static inline void irq_dispose_mapping(unsigned int virq)
20{
Dezhong Diaof2ffa5a2010-10-13 00:52:46 -060021}
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#ifdef CONFIG_I8259
24static inline int irq_canonicalize(int irq)
25{
Atsushi Nemoto2fa79372007-01-14 23:41:42 +090026 return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027}
28#else
29#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
30#endif
31
Ralf Baechle1146fe32007-09-21 17:13:55 +010032#ifdef CONFIG_MIPS_MT_SMTC
33
34struct irqaction;
35
36extern unsigned long irq_hwmask[];
37extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
38 unsigned long hwmask);
39
40static inline void smtc_im_ack_irq(unsigned int irq)
41{
42 if (irq_hwmask[irq] & ST0_IM)
43 set_c0_status(irq_hwmask[irq] & ST0_IM);
44}
45
46#else
47
48static inline void smtc_im_ack_irq(unsigned int irq)
49{
50}
51
52#endif /* CONFIG_MIPS_MT_SMTC */
53
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020054#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
55#include <linux/cpumask.h>
56
Thomas Gleixner7c8d9482011-03-23 21:08:57 +000057extern int plat_set_irq_affinity(struct irq_data *d,
58 const struct cpumask *affinity, bool force);
Thomas Gleixner930cd542011-03-23 21:09:04 +000059extern void smtc_forward_irq(struct irq_data *d);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020060
61/*
62 * IRQ affinity hook invoked at the beginning of interrupt dispatch
63 * if option is enabled.
64 *
65 * Up through Linux 2.6.22 (at least) cpumask operations are very
66 * inefficient on MIPS. Initial prototypes of SMTC IRQ affinity
67 * used a "fast path" per-IRQ-descriptor cache of affinity information
68 * to reduce latency. As there is a project afoot to optimize the
69 * cpumask implementations, this version is optimistically assuming
70 * that cpumask.h macro overhead is reasonable during interrupt dispatch.
71 */
Thomas Gleixner930cd542011-03-23 21:09:04 +000072static inline int handle_on_other_cpu(unsigned int irq)
73{
74 struct irq_data *d = irq_get_irq_data(irq);
75
76 if (cpumask_test_cpu(smp_processor_id(), d->affinity))
77 return 0;
78 smtc_forward_irq(d);
79 return 1;
80}
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020081
82#else /* Not doing SMTC affinity */
83
Thomas Gleixner930cd542011-03-23 21:09:04 +000084static inline int handle_on_other_cpu(unsigned int irq) { return 0; }
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020085
86#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
87
Kevin D. Kissell0db34212007-07-12 16:21:08 +010088#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
Ralf Baechle1146fe32007-09-21 17:13:55 +010089
Thomas Gleixner930cd542011-03-23 21:09:04 +000090static inline void smtc_im_backstop(unsigned int irq)
91{
92 if (irq_hwmask[irq] & 0x0000ff00)
93 write_c0_tccontext(read_c0_tccontext() &
94 ~(irq_hwmask[irq] & 0x0000ff00));
95}
96
Ralf Baechle41c594a2006-04-05 09:45:45 +010097/*
98 * Clear interrupt mask handling "backstop" if irq_hwmask
99 * entry so indicates. This implies that the ack() or end()
100 * functions will take over re-enabling the low-level mask.
101 * Otherwise it will be done on return from exception.
102 */
Thomas Gleixner930cd542011-03-23 21:09:04 +0000103static inline int smtc_handle_on_other_cpu(unsigned int irq)
104{
105 int ret = handle_on_other_cpu(irq);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200106
Thomas Gleixner930cd542011-03-23 21:09:04 +0000107 if (!ret)
108 smtc_im_backstop(irq);
109 return ret;
110}
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200111
Ralf Baechle41c594a2006-04-05 09:45:45 +0100112#else
Ralf Baechle1146fe32007-09-21 17:13:55 +0100113
Thomas Gleixner930cd542011-03-23 21:09:04 +0000114static inline void smtc_im_backstop(unsigned int irq) { }
115static inline int smtc_handle_on_other_cpu(unsigned int irq)
116{
117 return handle_on_other_cpu(irq);
118}
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200119
Ralf Baechle41c594a2006-04-05 09:45:45 +0100120#endif
121
Wu Zhangjin8f99a162009-11-20 20:34:33 +0800122extern void do_IRQ(unsigned int irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200124#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200125
Wu Zhangjin8f99a162009-11-20 20:34:33 +0800126extern void do_IRQ_no_affinity(unsigned int irq);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200127
128#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130extern void arch_init_irq(void);
Ralf Baechle937a8012006-10-07 19:44:33 +0100131extern void spurious_interrupt(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
Ralf Baechle4a4cf772006-11-06 17:41:06 +0000133extern int allocate_irqno(void);
134extern void alloc_legacy_irqno(void);
135extern void free_irqno(unsigned int irq);
136
Ralf Baechle3b1d4ed2007-06-20 22:27:10 +0100137/*
138 * Before R2 the timer and performance counter interrupts were both fixed to
139 * IE7. Since R2 their number has to be read from the c0_intctl register.
140 */
141#define CP0_LEGACY_COMPARE_IRQ 7
142
143extern int cp0_compare_irq;
David VomLehn010c1082009-12-21 17:49:22 -0800144extern int cp0_compare_irq_shift;
Ralf Baechle3b1d4ed2007-06-20 22:27:10 +0100145extern int cp0_perfcount_irq;
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147#endif /* _ASM_IRQ_H */