blob: fb698dc09bc9c39c60cf7c0d43992b424e239551 [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>
Grant Likelyabd23632012-02-24 08:07:06 -070014#include <linux/irqdomain.h>
Ralf Baechle41c594a2006-04-05 09:45:45 +010015
16#include <asm/mipsmtregs.h>
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <irq.h>
19
20#ifdef CONFIG_I8259
21static inline int irq_canonicalize(int irq)
22{
Atsushi Nemoto2fa79372007-01-14 23:41:42 +090023 return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024}
25#else
26#define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
27#endif
28
Ralf Baechle1146fe32007-09-21 17:13:55 +010029#ifdef CONFIG_MIPS_MT_SMTC
30
31struct irqaction;
32
33extern unsigned long irq_hwmask[];
34extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
35 unsigned long hwmask);
36
37static inline void smtc_im_ack_irq(unsigned int irq)
38{
39 if (irq_hwmask[irq] & ST0_IM)
40 set_c0_status(irq_hwmask[irq] & ST0_IM);
41}
42
43#else
44
45static inline void smtc_im_ack_irq(unsigned int irq)
46{
47}
48
49#endif /* CONFIG_MIPS_MT_SMTC */
50
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020051#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
52#include <linux/cpumask.h>
53
Thomas Gleixner7c8d9482011-03-23 21:08:57 +000054extern int plat_set_irq_affinity(struct irq_data *d,
55 const struct cpumask *affinity, bool force);
Thomas Gleixner930cd542011-03-23 21:09:04 +000056extern void smtc_forward_irq(struct irq_data *d);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020057
58/*
59 * IRQ affinity hook invoked at the beginning of interrupt dispatch
60 * if option is enabled.
61 *
62 * Up through Linux 2.6.22 (at least) cpumask operations are very
63 * inefficient on MIPS. Initial prototypes of SMTC IRQ affinity
64 * used a "fast path" per-IRQ-descriptor cache of affinity information
65 * to reduce latency. As there is a project afoot to optimize the
66 * cpumask implementations, this version is optimistically assuming
67 * that cpumask.h macro overhead is reasonable during interrupt dispatch.
68 */
Thomas Gleixner930cd542011-03-23 21:09:04 +000069static inline int handle_on_other_cpu(unsigned int irq)
70{
71 struct irq_data *d = irq_get_irq_data(irq);
72
73 if (cpumask_test_cpu(smp_processor_id(), d->affinity))
74 return 0;
75 smtc_forward_irq(d);
76 return 1;
77}
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020078
79#else /* Not doing SMTC affinity */
80
Thomas Gleixner930cd542011-03-23 21:09:04 +000081static inline int handle_on_other_cpu(unsigned int irq) { return 0; }
Kevin D. Kissellf571eff2007-08-03 19:38:03 +020082
83#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
84
Kevin D. Kissell0db34212007-07-12 16:21:08 +010085#ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
Ralf Baechle1146fe32007-09-21 17:13:55 +010086
Thomas Gleixner930cd542011-03-23 21:09:04 +000087static inline void smtc_im_backstop(unsigned int irq)
88{
89 if (irq_hwmask[irq] & 0x0000ff00)
90 write_c0_tccontext(read_c0_tccontext() &
91 ~(irq_hwmask[irq] & 0x0000ff00));
92}
93
Ralf Baechle41c594a2006-04-05 09:45:45 +010094/*
95 * Clear interrupt mask handling "backstop" if irq_hwmask
96 * entry so indicates. This implies that the ack() or end()
97 * functions will take over re-enabling the low-level mask.
98 * Otherwise it will be done on return from exception.
99 */
Thomas Gleixner930cd542011-03-23 21:09:04 +0000100static inline int smtc_handle_on_other_cpu(unsigned int irq)
101{
102 int ret = handle_on_other_cpu(irq);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200103
Thomas Gleixner930cd542011-03-23 21:09:04 +0000104 if (!ret)
105 smtc_im_backstop(irq);
106 return ret;
107}
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200108
Ralf Baechle41c594a2006-04-05 09:45:45 +0100109#else
Ralf Baechle1146fe32007-09-21 17:13:55 +0100110
Thomas Gleixner930cd542011-03-23 21:09:04 +0000111static inline void smtc_im_backstop(unsigned int irq) { }
112static inline int smtc_handle_on_other_cpu(unsigned int irq)
113{
114 return handle_on_other_cpu(irq);
115}
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200116
Ralf Baechle41c594a2006-04-05 09:45:45 +0100117#endif
118
Wu Zhangjin8f99a162009-11-20 20:34:33 +0800119extern void do_IRQ(unsigned int irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200121#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200122
Wu Zhangjin8f99a162009-11-20 20:34:33 +0800123extern void do_IRQ_no_affinity(unsigned int irq);
Kevin D. Kissellf571eff2007-08-03 19:38:03 +0200124
125#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127extern void arch_init_irq(void);
Ralf Baechle937a8012006-10-07 19:44:33 +0100128extern void spurious_interrupt(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
Ralf Baechle4a4cf772006-11-06 17:41:06 +0000130extern int allocate_irqno(void);
131extern void alloc_legacy_irqno(void);
132extern void free_irqno(unsigned int irq);
133
Ralf Baechle3b1d4ed2007-06-20 22:27:10 +0100134/*
135 * Before R2 the timer and performance counter interrupts were both fixed to
136 * IE7. Since R2 their number has to be read from the c0_intctl register.
137 */
138#define CP0_LEGACY_COMPARE_IRQ 7
139
140extern int cp0_compare_irq;
David VomLehn010c1082009-12-21 17:49:22 -0800141extern int cp0_compare_irq_shift;
Ralf Baechle3b1d4ed2007-06-20 22:27:10 +0100142extern int cp0_perfcount_irq;
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144#endif /* _ASM_IRQ_H */