2 * Copyright (C) 2014-15 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_IRQFLAGS_ARCV2_H
10 #define __ASM_IRQFLAGS_ARCV2_H
12 #include <asm/arcregs.h>
15 #define STATUS_AD_BIT 19 /* Disable Align chk: core supports non-aligned */
16 #define STATUS_IE_BIT 31
18 #define STATUS_AD_MASK (1<<STATUS_AD_BIT)
19 #define STATUS_IE_MASK (1<<STATUS_IE_BIT)
21 /* status32 Bits as encoded/expected by CLRI/SETI */
22 #define CLRI_STATUS_IE_BIT 4
24 #define CLRI_STATUS_E_MASK 0xF
25 #define CLRI_STATUS_IE_MASK (1 << CLRI_STATUS_IE_BIT)
27 #define AUX_USER_SP 0x00D
28 #define AUX_IRQ_CTRL 0x00E
29 #define AUX_IRQ_ACT 0x043 /* Active Intr across all levels */
30 #define AUX_IRQ_LVL_PEND 0x200 /* Pending Intr across all levels */
31 #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
32 #define AUX_IRQ_PRIORITY 0x206
34 #define AUX_IRQ_SELECT 0x40b
35 #define AUX_IRQ_ENABLE 0x40c
37 /* Was Intr taken in User Mode */
38 #define AUX_IRQ_ACT_BIT_U 31
41 * Hardware supports 16 priorities (0 highest, 15 lowest)
42 * Linux by default runs at 1, priority 0 reserved for NMI style interrupts
44 #define ARCV2_IRQ_DEF_PRIO 1
46 /* seed value for status register */
47 #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
48 (ARCV2_IRQ_DEF_PRIO << 1))
53 * Save IRQ state and disable IRQs
55 static inline long arch_local_irq_save(void)
59 __asm__
__volatile__(" clri %0 \n" : "=r" (flags
) : : "memory");
65 * restore saved IRQ state
67 static inline void arch_local_irq_restore(unsigned long flags
)
69 __asm__
__volatile__(" seti %0 \n" : : "r" (flags
) : "memory");
73 * Unconditionally Enable IRQs
75 static inline void arch_local_irq_enable(void)
77 unsigned int irqact
= read_aux_reg(AUX_IRQ_ACT
);
80 write_aux_reg(AUX_IRQ_ACT
, irqact
& ~0xffff);
82 __asm__
__volatile__(" seti \n" : : : "memory");
86 * Unconditionally Disable IRQs
88 static inline void arch_local_irq_disable(void)
90 __asm__
__volatile__(" clri \n" : : : "memory");
96 static inline long arch_local_save_flags(void)
100 __asm__
__volatile__(
101 " lr %0, [status32] \n"
106 /* To be compatible with irq_save()/irq_restore()
107 * encode the irq bits as expected by CLRI/SETI
108 * (this was needed to make CONFIG_TRACE_IRQFLAGS work)
111 ((!!(temp
& STATUS_IE_MASK
)) << CLRI_STATUS_IE_BIT
) |
112 ((temp
>> 1) & CLRI_STATUS_E_MASK
);
119 static inline int arch_irqs_disabled_flags(unsigned long flags
)
121 return !(flags
& CLRI_STATUS_IE_MASK
);
124 static inline int arch_irqs_disabled(void)
126 return arch_irqs_disabled_flags(arch_local_save_flags());
129 static inline void arc_softirq_trigger(int irq
)
131 write_aux_reg(AUX_IRQ_HINT
, irq
);
134 static inline void arc_softirq_clear(int irq
)
136 write_aux_reg(AUX_IRQ_HINT
, 0);
141 #ifdef CONFIG_TRACE_IRQFLAGS
143 .macro TRACE_ASM_IRQ_DISABLE
144 bl trace_hardirqs_off
147 .macro TRACE_ASM_IRQ_ENABLE
153 .macro TRACE_ASM_IRQ_DISABLE
156 .macro TRACE_ASM_IRQ_ENABLE
160 .macro IRQ_DISABLE scratch
162 TRACE_ASM_IRQ_DISABLE
165 .macro IRQ_ENABLE scratch
170 #endif /* __ASSEMBLY__ */