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.
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)
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
44 /******************************************************************
46 ******************************************************************/
49 * Save IRQ state and disable IRQs
51 static inline long arch_local_irq_save(void)
53 unsigned long temp
, flags
;
56 " lr %1, [status32] \n"
60 : "=r"(temp
), "=r"(flags
)
61 : "n"((STATUS_E1_MASK
| STATUS_E2_MASK
))
68 * restore saved IRQ state
70 static inline void arch_local_irq_restore(unsigned long flags
)
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)
93 " lr %0, [status32] \n"
97 : "n"(~(STATUS_E1_MASK
| STATUS_E2_MASK
))
104 static inline long arch_local_save_flags(void)
108 __asm__
__volatile__(
109 " lr %0, [status32] \n"
120 static inline int arch_irqs_disabled_flags(unsigned long flags
)
122 return !(flags
& (STATUS_E1_MASK
123 #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS
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
)
138 ienb
= read_aux_reg(AUX_IENABLE
);
140 write_aux_reg(AUX_IENABLE
, ienb
);
143 static inline void arch_unmask_irq(unsigned int irq
)
147 ienb
= read_aux_reg(AUX_IENABLE
);
149 write_aux_reg(AUX_IENABLE
, ienb
);
154 .macro IRQ_DISABLE scratch
155 lr \scratch
, [status32
]
156 bic \scratch
, \scratch
, (STATUS_E1_MASK
| STATUS_E2_MASK
)
160 .macro IRQ_DISABLE_SAVE scratch
, save
161 lr \scratch
, [status32
]
162 mov \save
, \scratch
/* Make a copy */
163 bic \scratch
, \scratch
, (STATUS_E1_MASK
| STATUS_E2_MASK
)
167 .macro IRQ_ENABLE scratch
168 lr \scratch
, [status32
]
169 or \scratch
, \scratch
, (STATUS_E1_MASK
| STATUS_E2_MASK
)
173 #endif /* __ASSEMBLY__ */