xref: /openbmc/linux/arch/mips/include/asm/irq.h (revision 1fee9db9b42d821e8007289d4eea74bdf85b1543)
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 
2201179ca0SYanteng Si extern void __init init_IRQ(void);
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 
60*1fee9db9SMarc Zyngier struct irq_domain;
61*1fee9db9SMarc Zyngier extern void do_domain_IRQ(struct irq_domain *domain, unsigned int irq);
62*1fee9db9SMarc Zyngier 
63384740dcSRalf Baechle extern void arch_init_irq(void);
64384740dcSRalf Baechle extern void spurious_interrupt(void);
65384740dcSRalf Baechle 
66384740dcSRalf Baechle extern int allocate_irqno(void);
67384740dcSRalf Baechle extern void alloc_legacy_irqno(void);
68384740dcSRalf Baechle extern void free_irqno(unsigned int irq);
69384740dcSRalf Baechle 
70384740dcSRalf Baechle /*
71384740dcSRalf Baechle  * Before R2 the timer and performance counter interrupts were both fixed to
72384740dcSRalf Baechle  * IE7.	 Since R2 their number has to be read from the c0_intctl register.
73384740dcSRalf Baechle  */
74384740dcSRalf Baechle #define CP0_LEGACY_COMPARE_IRQ 7
75c6a4ebb9SRalf Baechle #define CP0_LEGACY_PERFCNT_IRQ 7
76384740dcSRalf Baechle 
77384740dcSRalf Baechle extern int cp0_compare_irq;
78010c108dSDavid VomLehn extern int cp0_compare_irq_shift;
79384740dcSRalf Baechle extern int cp0_perfcount_irq;
808f7ff027SJames Hogan extern int cp0_fdc_irq;
818f7ff027SJames Hogan 
82770847baSBjorn Helgaas extern int get_c0_fdc_int(void);
83384740dcSRalf Baechle 
849a01c3edSChris Metcalf void arch_trigger_cpumask_backtrace(const struct cpumask *mask,
859a01c3edSChris Metcalf 				    bool exclude_self);
869a01c3edSChris Metcalf #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
87856839b7SEunbong Song 
88384740dcSRalf Baechle #endif /* _ASM_IRQ_H */
89