blob: bb712c9488b3c74bcfb6f36c47322044e9c0992d [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 Herrenschmidte1fa2e12007-05-10 22:22:45 -070071#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
72#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 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
David Howellsdf9ee292010-10-07 14:08:55 +010082#else /* CONFIG_PPC64 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Kumar Galab671ad22005-09-21 16:52:55 -050084#define SET_MSR_EE(x) mtmsr(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
David Howellsdf9ee292010-10-07 14:08:55 +010086static inline unsigned long arch_local_save_flags(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
David Howellsdf9ee292010-10-07 14:08:55 +010088 return mfmsr();
89}
Paul Mackerras4c75f842009-06-12 02:00:50 +000090
David Howellsdf9ee292010-10-07 14:08:55 +010091static inline void arch_local_irq_restore(unsigned long flags)
92{
93#if defined(CONFIG_BOOKE)
94 asm volatile("wrtee %0" : : "r" (flags) : "memory");
95#else
96 mtmsr(flags);
Kumar Galab671ad22005-09-21 16:52:55 -050097#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}
99
David Howellsdf9ee292010-10-07 14:08:55 +0100100static inline unsigned long arch_local_irq_save(void)
101{
102 unsigned long flags = arch_local_save_flags();
103#ifdef CONFIG_BOOKE
104 asm volatile("wrteei 0" : : : "memory");
105#else
106 SET_MSR_EE(flags & ~MSR_EE);
107#endif
108 return flags;
109}
110
111static inline void arch_local_irq_disable(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112{
Kumar Galab671ad22005-09-21 16:52:55 -0500113#ifdef CONFIG_BOOKE
David Howellsdf9ee292010-10-07 14:08:55 +0100114 asm volatile("wrteei 0" : : : "memory");
Kumar Galab671ad22005-09-21 16:52:55 -0500115#else
David Howellsdf9ee292010-10-07 14:08:55 +0100116 arch_local_irq_save();
117#endif
118}
Paul Mackerras4c75f842009-06-12 02:00:50 +0000119
David Howellsdf9ee292010-10-07 14:08:55 +0100120static inline void arch_local_irq_enable(void)
121{
122#ifdef CONFIG_BOOKE
123 asm volatile("wrteei 1" : : : "memory");
124#else
125 unsigned long msr = mfmsr();
Kumar Galab671ad22005-09-21 16:52:55 -0500126 SET_MSR_EE(msr | MSR_EE);
127#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
David Howellsdf9ee292010-10-07 14:08:55 +0100130static inline bool arch_irqs_disabled_flags(unsigned long flags)
Steven Rostedte0eca072008-05-14 23:49:43 -0400131{
132 return (flags & MSR_EE) == 0;
133}
134
David Howellsdf9ee292010-10-07 14:08:55 +0100135static inline bool arch_irqs_disabled(void)
136{
137 return arch_irqs_disabled_flags(arch_local_save_flags());
138}
139
140#define hard_irq_disable() arch_local_irq_disable()
141
Paul Mackerrasd04c56f2006-10-04 16:47:49 +1000142#endif /* CONFIG_PPC64 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Thomas Gleixner089fb442011-01-21 06:12:28 +0000144#define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
145
Ingo Molnarc0ad90a2006-06-29 02:24:44 -0700146/*
147 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
148 * or should we not care like we do now ? --BenH.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 */
Thomas Gleixner353bca52009-03-10 14:46:30 +0000150struct irq_chip;
Kumar Galab671ad22005-09-21 16:52:55 -0500151
152#endif /* __KERNEL__ */
153#endif /* _ASM_POWERPC_HW_IRQ_H */