blob: 6c6fa955baa7c3c5c9f8855813bed7e07240458b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 */
Kumar Galab671ad22005-09-21 16:52:55 -05004#ifndef _ASM_POWERPC_HW_IRQ_H
5#define _ASM_POWERPC_HW_IRQ_H
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#ifdef __KERNEL__
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/errno.h>
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100010#include <linux/compiler.h>
Kumar Galab671ad22005-09-21 16:52:55 -050011#include <asm/ptrace.h>
12#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Kumar Galac7aeffc2005-09-19 09:30:27 -050014extern void timer_interrupt(struct pt_regs *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100016#ifdef CONFIG_PPC64
17#include <asm/paca.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
David Howellsdf9ee292010-10-07 14:08:55 +010019static inline unsigned long arch_local_save_flags(void)
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100020{
Hugh Dickinsef2b3432006-11-10 21:32:40 +000021 unsigned long flags;
22
David Howellsdf9ee292010-10-07 14:08:55 +010023 asm volatile(
24 "lbz %0,%1(13)"
25 : "=r" (flags)
26 : "i" (offsetof(struct paca_struct, soft_enabled)));
Hugh Dickinsef2b3432006-11-10 21:32:40 +000027
28 return flags;
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100029}
30
David Howellsdf9ee292010-10-07 14:08:55 +010031static inline unsigned long arch_local_irq_disable(void)
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100032{
Hugh Dickinsef2b3432006-11-10 21:32:40 +000033 unsigned long flags, zero;
34
David Howellsdf9ee292010-10-07 14:08:55 +010035 asm volatile(
36 "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
37 : "=r" (flags), "=&r" (zero)
38 : "i" (offsetof(struct paca_struct, soft_enabled))
39 : "memory");
Hugh Dickinsef2b3432006-11-10 21:32:40 +000040
41 return flags;
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100042}
43
David Howellsdf9ee292010-10-07 14:08:55 +010044extern void arch_local_irq_restore(unsigned long);
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100045extern void iseries_handle_interrupts(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
David Howellsdf9ee292010-10-07 14:08:55 +010047static inline void arch_local_irq_enable(void)
48{
49 arch_local_irq_restore(1);
50}
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
David Howellsdf9ee292010-10-07 14:08:55 +010052static inline unsigned long arch_local_irq_save(void)
53{
54 return arch_local_irq_disable();
55}
56
57static inline bool arch_irqs_disabled_flags(unsigned long flags)
58{
59 return flags == 0;
60}
61
62static inline bool arch_irqs_disabled(void)
63{
64 return arch_irqs_disabled_flags(arch_local_save_flags());
65}
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Benjamin Herrenschmidt2d27cfd2009-07-23 23:15:59 +000067#ifdef CONFIG_PPC_BOOK3E
David Howellsdf9ee292010-10-07 14:08:55 +010068#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory");
69#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory");
Benjamin Herrenschmidt2d27cfd2009-07-23 23:15:59 +000070#else
Benjamin Herrenschmidtd9ada912012-03-02 11:33:52 +110071#define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
72#define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
Benjamin Herrenschmidt2d27cfd2009-07-23 23:15:59 +000073#endif
Benjamin Herrenschmidte1fa2e12007-05-10 22:22:45 -070074
75#define hard_irq_disable() \
76 do { \
77 __hard_irq_disable(); \
78 get_paca()->soft_enabled = 0; \
79 get_paca()->hard_enabled = 0; \
80 } while(0)
Paul Mackerrasd04c56f2006-10-04 16:47:49 +100081
Benjamin Herrenschmidta5464982012-03-07 16:48:45 +110082static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
83{
84 return !regs->softe;
85}
86
David Howellsdf9ee292010-10-07 14:08:55 +010087#else /* CONFIG_PPC64 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Kumar Galab671ad22005-09-21 16:52:55 -050089#define SET_MSR_EE(x) mtmsr(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
David Howellsdf9ee292010-10-07 14:08:55 +010091static inline unsigned long arch_local_save_flags(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
David Howellsdf9ee292010-10-07 14:08:55 +010093 return mfmsr();
94}
Paul Mackerras4c75f842009-06-12 02:00:50 +000095
David Howellsdf9ee292010-10-07 14:08:55 +010096static inline void arch_local_irq_restore(unsigned long flags)
97{
98#if defined(CONFIG_BOOKE)
99 asm volatile("wrtee %0" : : "r" (flags) : "memory");
100#else
101 mtmsr(flags);
Kumar Galab671ad22005-09-21 16:52:55 -0500102#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103}
104
David Howellsdf9ee292010-10-07 14:08:55 +0100105static inline unsigned long arch_local_irq_save(void)
106{
107 unsigned long flags = arch_local_save_flags();
108#ifdef CONFIG_BOOKE
109 asm volatile("wrteei 0" : : : "memory");
110#else
111 SET_MSR_EE(flags & ~MSR_EE);
112#endif
113 return flags;
114}
115
116static inline void arch_local_irq_disable(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117{
Kumar Galab671ad22005-09-21 16:52:55 -0500118#ifdef CONFIG_BOOKE
David Howellsdf9ee292010-10-07 14:08:55 +0100119 asm volatile("wrteei 0" : : : "memory");
Kumar Galab671ad22005-09-21 16:52:55 -0500120#else
David Howellsdf9ee292010-10-07 14:08:55 +0100121 arch_local_irq_save();
122#endif
123}
Paul Mackerras4c75f842009-06-12 02:00:50 +0000124
David Howellsdf9ee292010-10-07 14:08:55 +0100125static inline void arch_local_irq_enable(void)
126{
127#ifdef CONFIG_BOOKE
128 asm volatile("wrteei 1" : : : "memory");
129#else
130 unsigned long msr = mfmsr();
Kumar Galab671ad22005-09-21 16:52:55 -0500131 SET_MSR_EE(msr | MSR_EE);
132#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133}
134
David Howellsdf9ee292010-10-07 14:08:55 +0100135static inline bool arch_irqs_disabled_flags(unsigned long flags)
Steven Rostedte0eca072008-05-14 23:49:43 -0400136{
137 return (flags & MSR_EE) == 0;
138}
139
David Howellsdf9ee292010-10-07 14:08:55 +0100140static inline bool arch_irqs_disabled(void)
141{
142 return arch_irqs_disabled_flags(arch_local_save_flags());
143}
144
145#define hard_irq_disable() arch_local_irq_disable()
146
Benjamin Herrenschmidta5464982012-03-07 16:48:45 +1100147static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
148{
149 return !(regs->msr & MSR_EE);
150}
151
Paul Mackerrasd04c56f2006-10-04 16:47:49 +1000152#endif /* CONFIG_PPC64 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Thomas Gleixner089fb442011-01-21 06:12:28 +0000154#define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
155
Ingo Molnarc0ad90a2006-06-29 02:24:44 -0700156/*
157 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
158 * or should we not care like we do now ? --BenH.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 */
Thomas Gleixner353bca52009-03-10 14:46:30 +0000160struct irq_chip;
Kumar Galab671ad22005-09-21 16:52:55 -0500161
162#endif /* __KERNEL__ */
163#endif /* _ASM_POWERPC_HW_IRQ_H */