1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
4*4882a593Smuzhiyun */
5*4882a593Smuzhiyun #ifndef _ASM_POWERPC_HW_IRQ_H
6*4882a593Smuzhiyun #define _ASM_POWERPC_HW_IRQ_H
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun #ifdef __KERNEL__
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun #include <linux/errno.h>
11*4882a593Smuzhiyun #include <linux/compiler.h>
12*4882a593Smuzhiyun #include <asm/ptrace.h>
13*4882a593Smuzhiyun #include <asm/processor.h>
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun #ifdef CONFIG_PPC64
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun /*
18*4882a593Smuzhiyun * PACA flags in paca->irq_happened.
19*4882a593Smuzhiyun *
20*4882a593Smuzhiyun * This bits are set when interrupts occur while soft-disabled
21*4882a593Smuzhiyun * and allow a proper replay. Additionally, PACA_IRQ_HARD_DIS
22*4882a593Smuzhiyun * is set whenever we manually hard disable.
23*4882a593Smuzhiyun */
24*4882a593Smuzhiyun #define PACA_IRQ_HARD_DIS 0x01
25*4882a593Smuzhiyun #define PACA_IRQ_DBELL 0x02
26*4882a593Smuzhiyun #define PACA_IRQ_EE 0x04
27*4882a593Smuzhiyun #define PACA_IRQ_DEC 0x08 /* Or FIT */
28*4882a593Smuzhiyun #define PACA_IRQ_HMI 0x10
29*4882a593Smuzhiyun #define PACA_IRQ_PMI 0x20
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun /*
32*4882a593Smuzhiyun * Some soft-masked interrupts must be hard masked until they are replayed
33*4882a593Smuzhiyun * (e.g., because the soft-masked handler does not clear the exception).
34*4882a593Smuzhiyun */
35*4882a593Smuzhiyun #ifdef CONFIG_PPC_BOOK3S
36*4882a593Smuzhiyun #define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE|PACA_IRQ_PMI)
37*4882a593Smuzhiyun #else
38*4882a593Smuzhiyun #define PACA_IRQ_MUST_HARD_MASK (PACA_IRQ_EE)
39*4882a593Smuzhiyun #endif
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun #endif /* CONFIG_PPC64 */
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun /*
44*4882a593Smuzhiyun * flags for paca->irq_soft_mask
45*4882a593Smuzhiyun */
46*4882a593Smuzhiyun #define IRQS_ENABLED 0
47*4882a593Smuzhiyun #define IRQS_DISABLED 1 /* local_irq_disable() interrupts */
48*4882a593Smuzhiyun #define IRQS_PMI_DISABLED 2
49*4882a593Smuzhiyun #define IRQS_ALL_DISABLED (IRQS_DISABLED | IRQS_PMI_DISABLED)
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun #ifndef __ASSEMBLY__
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun extern void replay_system_reset(void);
54*4882a593Smuzhiyun extern void replay_soft_interrupts(void);
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun extern void timer_interrupt(struct pt_regs *);
57*4882a593Smuzhiyun extern void timer_broadcast_interrupt(void);
58*4882a593Smuzhiyun extern void performance_monitor_exception(struct pt_regs *regs);
59*4882a593Smuzhiyun extern void WatchdogException(struct pt_regs *regs);
60*4882a593Smuzhiyun extern void unknown_exception(struct pt_regs *regs);
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun #ifdef CONFIG_PPC64
63*4882a593Smuzhiyun #include <asm/paca.h>
64*4882a593Smuzhiyun
irq_soft_mask_return(void)65*4882a593Smuzhiyun static inline notrace unsigned long irq_soft_mask_return(void)
66*4882a593Smuzhiyun {
67*4882a593Smuzhiyun unsigned long flags;
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun asm volatile(
70*4882a593Smuzhiyun "lbz %0,%1(13)"
71*4882a593Smuzhiyun : "=r" (flags)
72*4882a593Smuzhiyun : "i" (offsetof(struct paca_struct, irq_soft_mask)));
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun return flags;
75*4882a593Smuzhiyun }
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun /*
78*4882a593Smuzhiyun * The "memory" clobber acts as both a compiler barrier
79*4882a593Smuzhiyun * for the critical section and as a clobber because
80*4882a593Smuzhiyun * we changed paca->irq_soft_mask
81*4882a593Smuzhiyun */
irq_soft_mask_set(unsigned long mask)82*4882a593Smuzhiyun static inline notrace void irq_soft_mask_set(unsigned long mask)
83*4882a593Smuzhiyun {
84*4882a593Smuzhiyun #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
85*4882a593Smuzhiyun /*
86*4882a593Smuzhiyun * The irq mask must always include the STD bit if any are set.
87*4882a593Smuzhiyun *
88*4882a593Smuzhiyun * and interrupts don't get replayed until the standard
89*4882a593Smuzhiyun * interrupt (local_irq_disable()) is unmasked.
90*4882a593Smuzhiyun *
91*4882a593Smuzhiyun * Other masks must only provide additional masking beyond
92*4882a593Smuzhiyun * the standard, and they are also not replayed until the
93*4882a593Smuzhiyun * standard interrupt becomes unmasked.
94*4882a593Smuzhiyun *
95*4882a593Smuzhiyun * This could be changed, but it will require partial
96*4882a593Smuzhiyun * unmasks to be replayed, among other things. For now, take
97*4882a593Smuzhiyun * the simple approach.
98*4882a593Smuzhiyun */
99*4882a593Smuzhiyun WARN_ON(mask && !(mask & IRQS_DISABLED));
100*4882a593Smuzhiyun #endif
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun asm volatile(
103*4882a593Smuzhiyun "stb %0,%1(13)"
104*4882a593Smuzhiyun :
105*4882a593Smuzhiyun : "r" (mask),
106*4882a593Smuzhiyun "i" (offsetof(struct paca_struct, irq_soft_mask))
107*4882a593Smuzhiyun : "memory");
108*4882a593Smuzhiyun }
109*4882a593Smuzhiyun
irq_soft_mask_set_return(unsigned long mask)110*4882a593Smuzhiyun static inline notrace unsigned long irq_soft_mask_set_return(unsigned long mask)
111*4882a593Smuzhiyun {
112*4882a593Smuzhiyun unsigned long flags;
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
115*4882a593Smuzhiyun WARN_ON(mask && !(mask & IRQS_DISABLED));
116*4882a593Smuzhiyun #endif
117*4882a593Smuzhiyun
118*4882a593Smuzhiyun asm volatile(
119*4882a593Smuzhiyun "lbz %0,%1(13); stb %2,%1(13)"
120*4882a593Smuzhiyun : "=&r" (flags)
121*4882a593Smuzhiyun : "i" (offsetof(struct paca_struct, irq_soft_mask)),
122*4882a593Smuzhiyun "r" (mask)
123*4882a593Smuzhiyun : "memory");
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun return flags;
126*4882a593Smuzhiyun }
127*4882a593Smuzhiyun
irq_soft_mask_or_return(unsigned long mask)128*4882a593Smuzhiyun static inline notrace unsigned long irq_soft_mask_or_return(unsigned long mask)
129*4882a593Smuzhiyun {
130*4882a593Smuzhiyun unsigned long flags, tmp;
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun asm volatile(
133*4882a593Smuzhiyun "lbz %0,%2(13); or %1,%0,%3; stb %1,%2(13)"
134*4882a593Smuzhiyun : "=&r" (flags), "=r" (tmp)
135*4882a593Smuzhiyun : "i" (offsetof(struct paca_struct, irq_soft_mask)),
136*4882a593Smuzhiyun "r" (mask)
137*4882a593Smuzhiyun : "memory");
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun #ifdef CONFIG_PPC_IRQ_SOFT_MASK_DEBUG
140*4882a593Smuzhiyun WARN_ON((mask | flags) && !((mask | flags) & IRQS_DISABLED));
141*4882a593Smuzhiyun #endif
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun return flags;
144*4882a593Smuzhiyun }
145*4882a593Smuzhiyun
arch_local_save_flags(void)146*4882a593Smuzhiyun static inline unsigned long arch_local_save_flags(void)
147*4882a593Smuzhiyun {
148*4882a593Smuzhiyun return irq_soft_mask_return();
149*4882a593Smuzhiyun }
150*4882a593Smuzhiyun
arch_local_irq_disable(void)151*4882a593Smuzhiyun static inline void arch_local_irq_disable(void)
152*4882a593Smuzhiyun {
153*4882a593Smuzhiyun irq_soft_mask_set(IRQS_DISABLED);
154*4882a593Smuzhiyun }
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun extern void arch_local_irq_restore(unsigned long);
157*4882a593Smuzhiyun
arch_local_irq_enable(void)158*4882a593Smuzhiyun static inline void arch_local_irq_enable(void)
159*4882a593Smuzhiyun {
160*4882a593Smuzhiyun arch_local_irq_restore(IRQS_ENABLED);
161*4882a593Smuzhiyun }
162*4882a593Smuzhiyun
arch_local_irq_save(void)163*4882a593Smuzhiyun static inline unsigned long arch_local_irq_save(void)
164*4882a593Smuzhiyun {
165*4882a593Smuzhiyun return irq_soft_mask_set_return(IRQS_DISABLED);
166*4882a593Smuzhiyun }
167*4882a593Smuzhiyun
arch_irqs_disabled_flags(unsigned long flags)168*4882a593Smuzhiyun static inline bool arch_irqs_disabled_flags(unsigned long flags)
169*4882a593Smuzhiyun {
170*4882a593Smuzhiyun return flags & IRQS_DISABLED;
171*4882a593Smuzhiyun }
172*4882a593Smuzhiyun
arch_irqs_disabled(void)173*4882a593Smuzhiyun static inline bool arch_irqs_disabled(void)
174*4882a593Smuzhiyun {
175*4882a593Smuzhiyun return arch_irqs_disabled_flags(arch_local_save_flags());
176*4882a593Smuzhiyun }
177*4882a593Smuzhiyun
set_pmi_irq_pending(void)178*4882a593Smuzhiyun static inline void set_pmi_irq_pending(void)
179*4882a593Smuzhiyun {
180*4882a593Smuzhiyun /*
181*4882a593Smuzhiyun * Invoked from PMU callback functions to set PMI bit in the paca.
182*4882a593Smuzhiyun * This has to be called with irq's disabled (via hard_irq_disable()).
183*4882a593Smuzhiyun */
184*4882a593Smuzhiyun if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
185*4882a593Smuzhiyun WARN_ON_ONCE(mfmsr() & MSR_EE);
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun get_paca()->irq_happened |= PACA_IRQ_PMI;
188*4882a593Smuzhiyun }
189*4882a593Smuzhiyun
clear_pmi_irq_pending(void)190*4882a593Smuzhiyun static inline void clear_pmi_irq_pending(void)
191*4882a593Smuzhiyun {
192*4882a593Smuzhiyun /*
193*4882a593Smuzhiyun * Invoked from PMU callback functions to clear the pending PMI bit
194*4882a593Smuzhiyun * in the paca.
195*4882a593Smuzhiyun */
196*4882a593Smuzhiyun if (IS_ENABLED(CONFIG_PPC_IRQ_SOFT_MASK_DEBUG))
197*4882a593Smuzhiyun WARN_ON_ONCE(mfmsr() & MSR_EE);
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun get_paca()->irq_happened &= ~PACA_IRQ_PMI;
200*4882a593Smuzhiyun }
201*4882a593Smuzhiyun
pmi_irq_pending(void)202*4882a593Smuzhiyun static inline bool pmi_irq_pending(void)
203*4882a593Smuzhiyun {
204*4882a593Smuzhiyun /*
205*4882a593Smuzhiyun * Invoked from PMU callback functions to check if there is a pending
206*4882a593Smuzhiyun * PMI bit in the paca.
207*4882a593Smuzhiyun */
208*4882a593Smuzhiyun if (get_paca()->irq_happened & PACA_IRQ_PMI)
209*4882a593Smuzhiyun return true;
210*4882a593Smuzhiyun
211*4882a593Smuzhiyun return false;
212*4882a593Smuzhiyun }
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun #ifdef CONFIG_PPC_BOOK3S
215*4882a593Smuzhiyun /*
216*4882a593Smuzhiyun * To support disabling and enabling of irq with PMI, set of
217*4882a593Smuzhiyun * new powerpc_local_irq_pmu_save() and powerpc_local_irq_restore()
218*4882a593Smuzhiyun * functions are added. These macros are implemented using generic
219*4882a593Smuzhiyun * linux local_irq_* code from include/linux/irqflags.h.
220*4882a593Smuzhiyun */
221*4882a593Smuzhiyun #define raw_local_irq_pmu_save(flags) \
222*4882a593Smuzhiyun do { \
223*4882a593Smuzhiyun typecheck(unsigned long, flags); \
224*4882a593Smuzhiyun flags = irq_soft_mask_or_return(IRQS_DISABLED | \
225*4882a593Smuzhiyun IRQS_PMI_DISABLED); \
226*4882a593Smuzhiyun } while(0)
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun #define raw_local_irq_pmu_restore(flags) \
229*4882a593Smuzhiyun do { \
230*4882a593Smuzhiyun typecheck(unsigned long, flags); \
231*4882a593Smuzhiyun arch_local_irq_restore(flags); \
232*4882a593Smuzhiyun } while(0)
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun #ifdef CONFIG_TRACE_IRQFLAGS
235*4882a593Smuzhiyun #define powerpc_local_irq_pmu_save(flags) \
236*4882a593Smuzhiyun do { \
237*4882a593Smuzhiyun raw_local_irq_pmu_save(flags); \
238*4882a593Smuzhiyun if (!raw_irqs_disabled_flags(flags)) \
239*4882a593Smuzhiyun trace_hardirqs_off(); \
240*4882a593Smuzhiyun } while(0)
241*4882a593Smuzhiyun #define powerpc_local_irq_pmu_restore(flags) \
242*4882a593Smuzhiyun do { \
243*4882a593Smuzhiyun if (!raw_irqs_disabled_flags(flags)) \
244*4882a593Smuzhiyun trace_hardirqs_on(); \
245*4882a593Smuzhiyun raw_local_irq_pmu_restore(flags); \
246*4882a593Smuzhiyun } while(0)
247*4882a593Smuzhiyun #else
248*4882a593Smuzhiyun #define powerpc_local_irq_pmu_save(flags) \
249*4882a593Smuzhiyun do { \
250*4882a593Smuzhiyun raw_local_irq_pmu_save(flags); \
251*4882a593Smuzhiyun } while(0)
252*4882a593Smuzhiyun #define powerpc_local_irq_pmu_restore(flags) \
253*4882a593Smuzhiyun do { \
254*4882a593Smuzhiyun raw_local_irq_pmu_restore(flags); \
255*4882a593Smuzhiyun } while (0)
256*4882a593Smuzhiyun #endif /* CONFIG_TRACE_IRQFLAGS */
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun #endif /* CONFIG_PPC_BOOK3S */
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun #ifdef CONFIG_PPC_BOOK3E
261*4882a593Smuzhiyun #define __hard_irq_enable() wrtee(MSR_EE)
262*4882a593Smuzhiyun #define __hard_irq_disable() wrtee(0)
263*4882a593Smuzhiyun #define __hard_EE_RI_disable() wrtee(0)
264*4882a593Smuzhiyun #define __hard_RI_enable() do { } while (0)
265*4882a593Smuzhiyun #else
266*4882a593Smuzhiyun #define __hard_irq_enable() __mtmsrd(MSR_EE|MSR_RI, 1)
267*4882a593Smuzhiyun #define __hard_irq_disable() __mtmsrd(MSR_RI, 1)
268*4882a593Smuzhiyun #define __hard_EE_RI_disable() __mtmsrd(0, 1)
269*4882a593Smuzhiyun #define __hard_RI_enable() __mtmsrd(MSR_RI, 1)
270*4882a593Smuzhiyun #endif
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun #define hard_irq_disable() do { \
273*4882a593Smuzhiyun unsigned long flags; \
274*4882a593Smuzhiyun __hard_irq_disable(); \
275*4882a593Smuzhiyun flags = irq_soft_mask_set_return(IRQS_ALL_DISABLED); \
276*4882a593Smuzhiyun local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \
277*4882a593Smuzhiyun if (!arch_irqs_disabled_flags(flags)) { \
278*4882a593Smuzhiyun asm ("stdx %%r1, 0, %1 ;" \
279*4882a593Smuzhiyun : "=m" (local_paca->saved_r1) \
280*4882a593Smuzhiyun : "b" (&local_paca->saved_r1)); \
281*4882a593Smuzhiyun trace_hardirqs_off(); \
282*4882a593Smuzhiyun } \
283*4882a593Smuzhiyun } while(0)
284*4882a593Smuzhiyun
__lazy_irq_pending(u8 irq_happened)285*4882a593Smuzhiyun static inline bool __lazy_irq_pending(u8 irq_happened)
286*4882a593Smuzhiyun {
287*4882a593Smuzhiyun return !!(irq_happened & ~PACA_IRQ_HARD_DIS);
288*4882a593Smuzhiyun }
289*4882a593Smuzhiyun
290*4882a593Smuzhiyun /*
291*4882a593Smuzhiyun * Check if a lazy IRQ is pending. Should be called with IRQs hard disabled.
292*4882a593Smuzhiyun */
lazy_irq_pending(void)293*4882a593Smuzhiyun static inline bool lazy_irq_pending(void)
294*4882a593Smuzhiyun {
295*4882a593Smuzhiyun return __lazy_irq_pending(get_paca()->irq_happened);
296*4882a593Smuzhiyun }
297*4882a593Smuzhiyun
298*4882a593Smuzhiyun /*
299*4882a593Smuzhiyun * Check if a lazy IRQ is pending, with no debugging checks.
300*4882a593Smuzhiyun * Should be called with IRQs hard disabled.
301*4882a593Smuzhiyun * For use in RI disabled code or other constrained situations.
302*4882a593Smuzhiyun */
lazy_irq_pending_nocheck(void)303*4882a593Smuzhiyun static inline bool lazy_irq_pending_nocheck(void)
304*4882a593Smuzhiyun {
305*4882a593Smuzhiyun return __lazy_irq_pending(local_paca->irq_happened);
306*4882a593Smuzhiyun }
307*4882a593Smuzhiyun
308*4882a593Smuzhiyun /*
309*4882a593Smuzhiyun * This is called by asynchronous interrupts to conditionally
310*4882a593Smuzhiyun * re-enable hard interrupts after having cleared the source
311*4882a593Smuzhiyun * of the interrupt. They are kept disabled if there is a different
312*4882a593Smuzhiyun * soft-masked interrupt pending that requires hard masking.
313*4882a593Smuzhiyun */
may_hard_irq_enable(void)314*4882a593Smuzhiyun static inline void may_hard_irq_enable(void)
315*4882a593Smuzhiyun {
316*4882a593Smuzhiyun if (!(get_paca()->irq_happened & PACA_IRQ_MUST_HARD_MASK)) {
317*4882a593Smuzhiyun get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
318*4882a593Smuzhiyun __hard_irq_enable();
319*4882a593Smuzhiyun }
320*4882a593Smuzhiyun }
321*4882a593Smuzhiyun
arch_irq_disabled_regs(struct pt_regs * regs)322*4882a593Smuzhiyun static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
323*4882a593Smuzhiyun {
324*4882a593Smuzhiyun return (regs->softe & IRQS_DISABLED);
325*4882a593Smuzhiyun }
326*4882a593Smuzhiyun
327*4882a593Smuzhiyun extern bool prep_irq_for_idle(void);
328*4882a593Smuzhiyun extern bool prep_irq_for_idle_irqsoff(void);
329*4882a593Smuzhiyun extern void irq_set_pending_from_srr1(unsigned long srr1);
330*4882a593Smuzhiyun
331*4882a593Smuzhiyun #define fini_irq_for_idle_irqsoff() trace_hardirqs_off();
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun extern void force_external_irq_replay(void);
334*4882a593Smuzhiyun
irq_soft_mask_regs_set_state(struct pt_regs * regs,unsigned long val)335*4882a593Smuzhiyun static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
336*4882a593Smuzhiyun {
337*4882a593Smuzhiyun regs->softe = val;
338*4882a593Smuzhiyun }
339*4882a593Smuzhiyun #else /* CONFIG_PPC64 */
340*4882a593Smuzhiyun
arch_local_save_flags(void)341*4882a593Smuzhiyun static inline unsigned long arch_local_save_flags(void)
342*4882a593Smuzhiyun {
343*4882a593Smuzhiyun return mfmsr();
344*4882a593Smuzhiyun }
345*4882a593Smuzhiyun
arch_local_irq_restore(unsigned long flags)346*4882a593Smuzhiyun static inline void arch_local_irq_restore(unsigned long flags)
347*4882a593Smuzhiyun {
348*4882a593Smuzhiyun if (IS_ENABLED(CONFIG_BOOKE))
349*4882a593Smuzhiyun wrtee(flags);
350*4882a593Smuzhiyun else
351*4882a593Smuzhiyun mtmsr(flags);
352*4882a593Smuzhiyun }
353*4882a593Smuzhiyun
arch_local_irq_save(void)354*4882a593Smuzhiyun static inline unsigned long arch_local_irq_save(void)
355*4882a593Smuzhiyun {
356*4882a593Smuzhiyun unsigned long flags = arch_local_save_flags();
357*4882a593Smuzhiyun
358*4882a593Smuzhiyun if (IS_ENABLED(CONFIG_BOOKE))
359*4882a593Smuzhiyun wrtee(0);
360*4882a593Smuzhiyun else if (IS_ENABLED(CONFIG_PPC_8xx))
361*4882a593Smuzhiyun wrtspr(SPRN_EID);
362*4882a593Smuzhiyun else
363*4882a593Smuzhiyun mtmsr(flags & ~MSR_EE);
364*4882a593Smuzhiyun
365*4882a593Smuzhiyun return flags;
366*4882a593Smuzhiyun }
367*4882a593Smuzhiyun
arch_local_irq_disable(void)368*4882a593Smuzhiyun static inline void arch_local_irq_disable(void)
369*4882a593Smuzhiyun {
370*4882a593Smuzhiyun if (IS_ENABLED(CONFIG_BOOKE))
371*4882a593Smuzhiyun wrtee(0);
372*4882a593Smuzhiyun else if (IS_ENABLED(CONFIG_PPC_8xx))
373*4882a593Smuzhiyun wrtspr(SPRN_EID);
374*4882a593Smuzhiyun else
375*4882a593Smuzhiyun mtmsr(mfmsr() & ~MSR_EE);
376*4882a593Smuzhiyun }
377*4882a593Smuzhiyun
arch_local_irq_enable(void)378*4882a593Smuzhiyun static inline void arch_local_irq_enable(void)
379*4882a593Smuzhiyun {
380*4882a593Smuzhiyun if (IS_ENABLED(CONFIG_BOOKE))
381*4882a593Smuzhiyun wrtee(MSR_EE);
382*4882a593Smuzhiyun else if (IS_ENABLED(CONFIG_PPC_8xx))
383*4882a593Smuzhiyun wrtspr(SPRN_EIE);
384*4882a593Smuzhiyun else
385*4882a593Smuzhiyun mtmsr(mfmsr() | MSR_EE);
386*4882a593Smuzhiyun }
387*4882a593Smuzhiyun
arch_irqs_disabled_flags(unsigned long flags)388*4882a593Smuzhiyun static inline bool arch_irqs_disabled_flags(unsigned long flags)
389*4882a593Smuzhiyun {
390*4882a593Smuzhiyun return (flags & MSR_EE) == 0;
391*4882a593Smuzhiyun }
392*4882a593Smuzhiyun
arch_irqs_disabled(void)393*4882a593Smuzhiyun static inline bool arch_irqs_disabled(void)
394*4882a593Smuzhiyun {
395*4882a593Smuzhiyun return arch_irqs_disabled_flags(arch_local_save_flags());
396*4882a593Smuzhiyun }
397*4882a593Smuzhiyun
398*4882a593Smuzhiyun #define hard_irq_disable() arch_local_irq_disable()
399*4882a593Smuzhiyun
arch_irq_disabled_regs(struct pt_regs * regs)400*4882a593Smuzhiyun static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
401*4882a593Smuzhiyun {
402*4882a593Smuzhiyun return !(regs->msr & MSR_EE);
403*4882a593Smuzhiyun }
404*4882a593Smuzhiyun
may_hard_irq_enable(void)405*4882a593Smuzhiyun static inline void may_hard_irq_enable(void) { }
406*4882a593Smuzhiyun
clear_pmi_irq_pending(void)407*4882a593Smuzhiyun static inline void clear_pmi_irq_pending(void) { }
set_pmi_irq_pending(void)408*4882a593Smuzhiyun static inline void set_pmi_irq_pending(void) { }
pmi_irq_pending(void)409*4882a593Smuzhiyun static inline bool pmi_irq_pending(void) { return false; }
410*4882a593Smuzhiyun
irq_soft_mask_regs_set_state(struct pt_regs * regs,unsigned long val)411*4882a593Smuzhiyun static inline void irq_soft_mask_regs_set_state(struct pt_regs *regs, unsigned long val)
412*4882a593Smuzhiyun {
413*4882a593Smuzhiyun }
414*4882a593Smuzhiyun #endif /* CONFIG_PPC64 */
415*4882a593Smuzhiyun
416*4882a593Smuzhiyun #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
417*4882a593Smuzhiyun
418*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
419*4882a593Smuzhiyun #endif /* __KERNEL__ */
420*4882a593Smuzhiyun #endif /* _ASM_POWERPC_HW_IRQ_H */
421