]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/powerpc/include/asm/hw_irq.h
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.git] / arch / powerpc / include / asm / hw_irq.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
4 */
5 #ifndef _ASM_POWERPC_HW_IRQ_H
6 #define _ASM_POWERPC_HW_IRQ_H
7
8 #ifdef __KERNEL__
9
10 #include <linux/errno.h>
11 #include <linux/compiler.h>
12 #include <asm/ptrace.h>
13 #include <asm/processor.h>
14
15 #ifdef CONFIG_PPC64
16
17 /*
18 * PACA flags in paca->irq_happened.
19 *
20 * This bits are set when interrupts occur while soft-disabled
21 * and allow a proper replay. Additionally, PACA_IRQ_HARD_DIS
22 * is set whenever we manually hard disable.
23 */
24 #define PACA_IRQ_HARD_DIS 0x01
25 #define PACA_IRQ_DBELL 0x02
26 #define PACA_IRQ_EE 0x04
27 #define PACA_IRQ_DEC 0x08 /* Or FIT */
28 #define PACA_IRQ_EE_EDGE 0x10 /* BookE only */
29 #define PACA_IRQ_HMI 0x20
30
31 /*
32 * flags for paca->irq_soft_mask
33 */
34 #define IRQS_ENABLED 0
35 #define IRQS_DISABLED 1 /* local_irq_disable() interrupts */
36 #define IRQS_PMI_DISABLED 2
37 #define IRQS_ALL_DISABLED (IRQS_DISABLED | IRQS_PMI_DISABLED)
38
39 #endif /* CONFIG_PPC64 */
40
41 #ifndef __ASSEMBLY__
42
43 extern void replay_system_reset(void);
44 extern void __replay_interrupt(unsigned int vector);
45
46 extern void timer_interrupt(struct pt_regs *);
47 extern void performance_monitor_exception(struct pt_regs *regs);
48 extern void WatchdogException(struct pt_regs *regs);
49 extern void unknown_exception(struct pt_regs *regs);
50
51 #ifdef CONFIG_PPC64
52 #include <asm/paca.h>
53
54 static inline unsigned long arch_local_save_flags(void)
55 {
56 unsigned long flags;
57
58 asm volatile(
59 "lbz %0,%1(13)"
60 : "=r" (flags)
61 : "i" (offsetof(struct paca_struct, soft_enabled)));
62
63 return flags;
64 }
65
66 static inline unsigned long arch_local_irq_disable(void)
67 {
68 unsigned long flags, zero;
69
70 asm volatile(
71 "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
72 : "=r" (flags), "=&r" (zero)
73 : "i" (offsetof(struct paca_struct, soft_enabled))
74 : "memory");
75
76 return flags;
77 }
78
79 extern void arch_local_irq_restore(unsigned long);
80
81 static inline void arch_local_irq_enable(void)
82 {
83 arch_local_irq_restore(1);
84 }
85
86 static inline unsigned long arch_local_irq_save(void)
87 {
88 return arch_local_irq_disable();
89 }
90
91 static inline bool arch_irqs_disabled_flags(unsigned long flags)
92 {
93 return flags == 0;
94 }
95
96 static inline bool arch_irqs_disabled(void)
97 {
98 return arch_irqs_disabled_flags(arch_local_save_flags());
99 }
100
101 #ifdef CONFIG_PPC_BOOK3E
102 #define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory")
103 #define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory")
104 #else
105 #define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
106 #define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
107 #endif
108
109 #define hard_irq_disable() do { \
110 u8 _was_enabled; \
111 __hard_irq_disable(); \
112 _was_enabled = local_paca->soft_enabled; \
113 local_paca->soft_enabled = 0; \
114 local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
115 if (_was_enabled) \
116 trace_hardirqs_off(); \
117 } while(0)
118
119 static inline bool lazy_irq_pending(void)
120 {
121 return !!(get_paca()->irq_happened & ~PACA_IRQ_HARD_DIS);
122 }
123
124 /*
125 * This is called by asynchronous interrupts to conditionally
126 * re-enable hard interrupts when soft-disabled after having
127 * cleared the source of the interrupt
128 */
129 static inline void may_hard_irq_enable(void)
130 {
131 get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
132 if (!(get_paca()->irq_happened & PACA_IRQ_EE))
133 __hard_irq_enable();
134 }
135
136 static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
137 {
138 return !regs->softe;
139 }
140
141 extern bool prep_irq_for_idle(void);
142 extern bool prep_irq_for_idle_irqsoff(void);
143 extern void irq_set_pending_from_srr1(unsigned long srr1);
144
145 #define fini_irq_for_idle_irqsoff() trace_hardirqs_off();
146
147 extern void force_external_irq_replay(void);
148
149 #else /* CONFIG_PPC64 */
150
151 #define SET_MSR_EE(x) mtmsr(x)
152
153 static inline unsigned long arch_local_save_flags(void)
154 {
155 return mfmsr();
156 }
157
158 static inline void arch_local_irq_restore(unsigned long flags)
159 {
160 #if defined(CONFIG_BOOKE)
161 asm volatile("wrtee %0" : : "r" (flags) : "memory");
162 #else
163 mtmsr(flags);
164 #endif
165 }
166
167 static inline unsigned long arch_local_irq_save(void)
168 {
169 unsigned long flags = arch_local_save_flags();
170 #ifdef CONFIG_BOOKE
171 asm volatile("wrteei 0" : : : "memory");
172 #elif defined(CONFIG_PPC_8xx)
173 wrtspr(SPRN_EID);
174 #else
175 SET_MSR_EE(flags & ~MSR_EE);
176 #endif
177 return flags;
178 }
179
180 static inline void arch_local_irq_disable(void)
181 {
182 #ifdef CONFIG_BOOKE
183 asm volatile("wrteei 0" : : : "memory");
184 #elif defined(CONFIG_PPC_8xx)
185 wrtspr(SPRN_EID);
186 #else
187 arch_local_irq_save();
188 #endif
189 }
190
191 static inline void arch_local_irq_enable(void)
192 {
193 #ifdef CONFIG_BOOKE
194 asm volatile("wrteei 1" : : : "memory");
195 #elif defined(CONFIG_PPC_8xx)
196 wrtspr(SPRN_EIE);
197 #else
198 unsigned long msr = mfmsr();
199 SET_MSR_EE(msr | MSR_EE);
200 #endif
201 }
202
203 static inline bool arch_irqs_disabled_flags(unsigned long flags)
204 {
205 return (flags & MSR_EE) == 0;
206 }
207
208 static inline bool arch_irqs_disabled(void)
209 {
210 return arch_irqs_disabled_flags(arch_local_save_flags());
211 }
212
213 #define hard_irq_disable() arch_local_irq_disable()
214
215 static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
216 {
217 return !(regs->msr & MSR_EE);
218 }
219
220 static inline void may_hard_irq_enable(void) { }
221
222 #endif /* CONFIG_PPC64 */
223
224 #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
225
226 /*
227 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
228 * or should we not care like we do now ? --BenH.
229 */
230 struct irq_chip;
231
232 #endif /* __ASSEMBLY__ */
233 #endif /* __KERNEL__ */
234 #endif /* _ASM_POWERPC_HW_IRQ_H */