Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux/fpc-iii.git] / arch / arc / include / asm / irqflags.h
blobcb7efc29f16ff076778c254f97d17212c0631e89
1 /*
2 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #ifndef __ASM_ARC_IRQFLAGS_H
10 #define __ASM_ARC_IRQFLAGS_H
12 /* vineetg: March 2010 : local_irq_save( ) optimisation
13 * -Remove explicit mov of current status32 into reg, that is not needed
14 * -Use BIC insn instead of INVERTED + AND
15 * -Conditionally disable interrupts (if they are not enabled, don't disable)
18 #ifdef __KERNEL__
20 #include <asm/arcregs.h>
22 /* status32 Reg bits related to Interrupt Handling */
23 #define STATUS_E1_BIT 1 /* Int 1 enable */
24 #define STATUS_E2_BIT 2 /* Int 2 enable */
25 #define STATUS_A1_BIT 3 /* Int 1 active */
26 #define STATUS_A2_BIT 4 /* Int 2 active */
28 #define STATUS_E1_MASK (1<<STATUS_E1_BIT)
29 #define STATUS_E2_MASK (1<<STATUS_E2_BIT)
30 #define STATUS_A1_MASK (1<<STATUS_A1_BIT)
31 #define STATUS_A2_MASK (1<<STATUS_A2_BIT)
33 /* Other Interrupt Handling related Aux regs */
34 #define AUX_IRQ_LEV 0x200 /* IRQ Priority: L1 or L2 */
35 #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
36 #define AUX_IRQ_LV12 0x43 /* interrupt level register */
38 #define AUX_IENABLE 0x40c
39 #define AUX_ITRIGGER 0x40d
40 #define AUX_IPULSE 0x415
42 #ifndef __ASSEMBLY__
44 /******************************************************************
45 * IRQ Control Macros
46 ******************************************************************/
49 * Save IRQ state and disable IRQs
51 static inline long arch_local_irq_save(void)
53 unsigned long temp, flags;
55 __asm__ __volatile__(
56 " lr %1, [status32] \n"
57 " bic %0, %1, %2 \n"
58 " and.f 0, %1, %2 \n"
59 " flag.nz %0 \n"
60 : "=r"(temp), "=r"(flags)
61 : "n"((STATUS_E1_MASK | STATUS_E2_MASK))
62 : "memory", "cc");
64 return flags;
68 * restore saved IRQ state
70 static inline void arch_local_irq_restore(unsigned long flags)
73 __asm__ __volatile__(
74 " flag %0 \n"
76 : "r"(flags)
77 : "memory");
81 * Unconditionally Enable IRQs
83 extern void arch_local_irq_enable(void);
86 * Unconditionally Disable IRQs
88 static inline void arch_local_irq_disable(void)
90 unsigned long temp;
92 __asm__ __volatile__(
93 " lr %0, [status32] \n"
94 " and %0, %0, %1 \n"
95 " flag %0 \n"
96 : "=&r"(temp)
97 : "n"(~(STATUS_E1_MASK | STATUS_E2_MASK))
98 : "memory");
102 * save IRQ state
104 static inline long arch_local_save_flags(void)
106 unsigned long temp;
108 __asm__ __volatile__(
109 " lr %0, [status32] \n"
110 : "=&r"(temp)
112 : "memory");
114 return temp;
118 * Query IRQ state
120 static inline int arch_irqs_disabled_flags(unsigned long flags)
122 return !(flags & (STATUS_E1_MASK
123 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
124 | STATUS_E2_MASK
125 #endif
129 static inline int arch_irqs_disabled(void)
131 return arch_irqs_disabled_flags(arch_local_save_flags());
134 static inline void arch_mask_irq(unsigned int irq)
136 unsigned int ienb;
138 ienb = read_aux_reg(AUX_IENABLE);
139 ienb &= ~(1 << irq);
140 write_aux_reg(AUX_IENABLE, ienb);
143 static inline void arch_unmask_irq(unsigned int irq)
145 unsigned int ienb;
147 ienb = read_aux_reg(AUX_IENABLE);
148 ienb |= (1 << irq);
149 write_aux_reg(AUX_IENABLE, ienb);
152 #else
154 #ifdef CONFIG_TRACE_IRQFLAGS
156 .macro TRACE_ASM_IRQ_DISABLE
157 bl trace_hardirqs_off
158 .endm
160 .macro TRACE_ASM_IRQ_ENABLE
161 bl trace_hardirqs_on
162 .endm
164 #else
166 .macro TRACE_ASM_IRQ_DISABLE
167 .endm
169 .macro TRACE_ASM_IRQ_ENABLE
170 .endm
172 #endif
174 .macro IRQ_DISABLE scratch
175 lr \scratch, [status32]
176 bic \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
177 flag \scratch
178 TRACE_ASM_IRQ_DISABLE
179 .endm
181 .macro IRQ_ENABLE scratch
182 lr \scratch, [status32]
183 or \scratch, \scratch, (STATUS_E1_MASK | STATUS_E2_MASK)
184 flag \scratch
185 TRACE_ASM_IRQ_ENABLE
186 .endm
188 #endif /* __ASSEMBLY__ */
190 #endif /* KERNEL */
192 #endif