xref: /openbmc/linux/arch/mips/include/asm/irq.h (revision 8d539b84)
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>
14384740dcSRalf Baechle 
15384740dcSRalf Baechle #include <asm/mipsmtregs.h>
16384740dcSRalf Baechle 
17384740dcSRalf Baechle #include <irq.h>
18384740dcSRalf Baechle 
19fe8bd18fSMatt Redfearn #define IRQ_STACK_SIZE			THREAD_SIZE
205fdc66e0SMatt Redfearn #define IRQ_STACK_START			(IRQ_STACK_SIZE - 16)
21fe8bd18fSMatt Redfearn 
22fe8bd18fSMatt Redfearn extern void *irq_stack[NR_CPUS];
23fe8bd18fSMatt Redfearn 
24db8466c5SMatt Redfearn /*
25db8466c5SMatt Redfearn  * The highest address on the IRQ stack contains a dummy frame put down in
26db8466c5SMatt Redfearn  * genex.S (handle_int & except_vec_vi_handler) which is structured as follows:
27db8466c5SMatt Redfearn  *
28db8466c5SMatt Redfearn  *   top ------------
29db8466c5SMatt Redfearn  *       | task sp  | <- irq_stack[cpu] + IRQ_STACK_START
30db8466c5SMatt Redfearn  *       ------------
31db8466c5SMatt Redfearn  *       |          | <- First frame of IRQ context
32db8466c5SMatt Redfearn  *       ------------
33db8466c5SMatt Redfearn  *
34db8466c5SMatt Redfearn  * task sp holds a copy of the task stack pointer where the struct pt_regs
35db8466c5SMatt Redfearn  * from exception entry can be found.
36db8466c5SMatt Redfearn  */
37db8466c5SMatt Redfearn 
on_irq_stack(int cpu,unsigned long sp)38fe8bd18fSMatt Redfearn static inline bool on_irq_stack(int cpu, unsigned long sp)
39fe8bd18fSMatt Redfearn {
40fe8bd18fSMatt Redfearn 	unsigned long low = (unsigned long)irq_stack[cpu];
41fe8bd18fSMatt Redfearn 	unsigned long high = low + IRQ_STACK_SIZE;
42fe8bd18fSMatt Redfearn 
43fe8bd18fSMatt Redfearn 	return (low <= sp && sp <= high);
44fe8bd18fSMatt Redfearn }
45fe8bd18fSMatt Redfearn 
46384740dcSRalf Baechle #ifdef CONFIG_I8259
irq_canonicalize(int irq)47384740dcSRalf Baechle static inline int irq_canonicalize(int irq)
48384740dcSRalf Baechle {
49384740dcSRalf Baechle 	return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
50384740dcSRalf Baechle }
51384740dcSRalf Baechle #else
52384740dcSRalf Baechle #define irq_canonicalize(irq) (irq)	/* Sane hardware, sane code ... */
53384740dcSRalf Baechle #endif
54384740dcSRalf Baechle 
55950e97caSSergey Ryazanov asmlinkage void plat_irq_dispatch(void);
56950e97caSSergey Ryazanov 
578f99a162SWu Zhangjin extern void do_IRQ(unsigned int irq);
58384740dcSRalf Baechle 
591fee9db9SMarc Zyngier struct irq_domain;
601fee9db9SMarc Zyngier extern void do_domain_IRQ(struct irq_domain *domain, unsigned int irq);
611fee9db9SMarc Zyngier 
62384740dcSRalf Baechle extern void arch_init_irq(void);
63384740dcSRalf Baechle extern void spurious_interrupt(void);
64384740dcSRalf Baechle 
65384740dcSRalf Baechle /*
66384740dcSRalf Baechle  * Before R2 the timer and performance counter interrupts were both fixed to
67384740dcSRalf Baechle  * IE7.	 Since R2 their number has to be read from the c0_intctl register.
68384740dcSRalf Baechle  */
69384740dcSRalf Baechle #define CP0_LEGACY_COMPARE_IRQ 7
70c6a4ebb9SRalf Baechle #define CP0_LEGACY_PERFCNT_IRQ 7
71384740dcSRalf Baechle 
72384740dcSRalf Baechle extern int cp0_compare_irq;
73010c108dSDavid VomLehn extern int cp0_compare_irq_shift;
74384740dcSRalf Baechle extern int cp0_perfcount_irq;
758f7ff027SJames Hogan extern int cp0_fdc_irq;
768f7ff027SJames Hogan 
77770847baSBjorn Helgaas extern int get_c0_fdc_int(void);
78384740dcSRalf Baechle 
799a01c3edSChris Metcalf void arch_trigger_cpumask_backtrace(const struct cpumask *mask,
80*8d539b84SDouglas Anderson 				    int exclude_cpu);
819a01c3edSChris Metcalf #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
82856839b7SEunbong Song 
83384740dcSRalf Baechle #endif /* _ASM_IRQ_H */
84