xref: /openbmc/linux/arch/mips/include/asm/irq.h (revision 5fdc66e046206306bf61ff2d626bfa52ca087f7b)
1384740dcSRalf Baechle /*
2384740dcSRalf Baechle  * This file is subject to the terms and conditions of the GNU General Public
3384740dcSRalf Baechle  * License.  See the file "COPYING" in the main directory of this archive
4384740dcSRalf Baechle  * for more details.
5384740dcSRalf Baechle  *
6384740dcSRalf Baechle  * Copyright (C) 1994 by Waldorf GMBH, written by Ralf Baechle
7384740dcSRalf Baechle  * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02, 03 by Ralf Baechle
8384740dcSRalf Baechle  */
9384740dcSRalf Baechle #ifndef _ASM_IRQ_H
10384740dcSRalf Baechle #define _ASM_IRQ_H
11384740dcSRalf Baechle 
12384740dcSRalf Baechle #include <linux/linkage.h>
13631330f5SRalf Baechle #include <linux/smp.h>
14abd2363fSGrant Likely #include <linux/irqdomain.h>
15384740dcSRalf Baechle 
16384740dcSRalf Baechle #include <asm/mipsmtregs.h>
17384740dcSRalf Baechle 
18384740dcSRalf Baechle #include <irq.h>
19384740dcSRalf Baechle 
20fe8bd18fSMatt Redfearn #define IRQ_STACK_SIZE			THREAD_SIZE
21*5fdc66e0SMatt Redfearn #define IRQ_STACK_START			(IRQ_STACK_SIZE - 16)
22fe8bd18fSMatt Redfearn 
23fe8bd18fSMatt Redfearn extern void *irq_stack[NR_CPUS];
24fe8bd18fSMatt Redfearn 
25db8466c5SMatt Redfearn /*
26db8466c5SMatt Redfearn  * The highest address on the IRQ stack contains a dummy frame put down in
27db8466c5SMatt Redfearn  * genex.S (handle_int & except_vec_vi_handler) which is structured as follows:
28db8466c5SMatt Redfearn  *
29db8466c5SMatt Redfearn  *   top ------------
30db8466c5SMatt Redfearn  *       | task sp  | <- irq_stack[cpu] + IRQ_STACK_START
31db8466c5SMatt Redfearn  *       ------------
32db8466c5SMatt Redfearn  *       |          | <- First frame of IRQ context
33db8466c5SMatt Redfearn  *       ------------
34db8466c5SMatt Redfearn  *
35db8466c5SMatt Redfearn  * task sp holds a copy of the task stack pointer where the struct pt_regs
36db8466c5SMatt Redfearn  * from exception entry can be found.
37db8466c5SMatt Redfearn  */
38db8466c5SMatt Redfearn 
39fe8bd18fSMatt Redfearn static inline bool on_irq_stack(int cpu, unsigned long sp)
40fe8bd18fSMatt Redfearn {
41fe8bd18fSMatt Redfearn 	unsigned long low = (unsigned long)irq_stack[cpu];
42fe8bd18fSMatt Redfearn 	unsigned long high = low + IRQ_STACK_SIZE;
43fe8bd18fSMatt Redfearn 
44fe8bd18fSMatt Redfearn 	return (low <= sp && sp <= high);
45fe8bd18fSMatt Redfearn }
46fe8bd18fSMatt Redfearn 
47384740dcSRalf Baechle #ifdef CONFIG_I8259
48384740dcSRalf Baechle static inline int irq_canonicalize(int irq)
49384740dcSRalf Baechle {
50384740dcSRalf Baechle 	return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
51384740dcSRalf Baechle }
52384740dcSRalf Baechle #else
53384740dcSRalf Baechle #define irq_canonicalize(irq) (irq)	/* Sane hardware, sane code ... */
54384740dcSRalf Baechle #endif
55384740dcSRalf Baechle 
56950e97caSSergey Ryazanov asmlinkage void plat_irq_dispatch(void);
57950e97caSSergey Ryazanov 
588f99a162SWu Zhangjin extern void do_IRQ(unsigned int irq);
59384740dcSRalf Baechle 
60384740dcSRalf Baechle extern void arch_init_irq(void);
61384740dcSRalf Baechle extern void spurious_interrupt(void);
62384740dcSRalf Baechle 
63384740dcSRalf Baechle extern int allocate_irqno(void);
64384740dcSRalf Baechle extern void alloc_legacy_irqno(void);
65384740dcSRalf Baechle extern void free_irqno(unsigned int irq);
66384740dcSRalf Baechle 
67384740dcSRalf Baechle /*
68384740dcSRalf Baechle  * Before R2 the timer and performance counter interrupts were both fixed to
69384740dcSRalf Baechle  * IE7.	 Since R2 their number has to be read from the c0_intctl register.
70384740dcSRalf Baechle  */
71384740dcSRalf Baechle #define CP0_LEGACY_COMPARE_IRQ 7
72c6a4ebb9SRalf Baechle #define CP0_LEGACY_PERFCNT_IRQ 7
73384740dcSRalf Baechle 
74384740dcSRalf Baechle extern int cp0_compare_irq;
75010c108dSDavid VomLehn extern int cp0_compare_irq_shift;
76384740dcSRalf Baechle extern int cp0_perfcount_irq;
778f7ff027SJames Hogan extern int cp0_fdc_irq;
788f7ff027SJames Hogan 
79770847baSBjorn Helgaas extern int get_c0_fdc_int(void);
80384740dcSRalf Baechle 
819a01c3edSChris Metcalf void arch_trigger_cpumask_backtrace(const struct cpumask *mask,
829a01c3edSChris Metcalf 				    bool exclude_self);
839a01c3edSChris Metcalf #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
84856839b7SEunbong Song 
85384740dcSRalf Baechle #endif /* _ASM_IRQ_H */
86