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 #define AUX_USER_SP 0x00D
22 #define AUX_IRQ_CTRL 0x00E
23 #define AUX_IRQ_ACT 0x043 /* Active Intr across all levels */
24 #define AUX_IRQ_LVL_PEND 0x200 /* Pending Intr across all levels */
25 #define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
26 #define AUX_IRQ_PRIORITY 0x206
28 #define AUX_IRQ_SELECT 0x40b
29 #define AUX_IRQ_ENABLE 0x40c
31 /* Was Intr taken in User Mode */
32 #define AUX_IRQ_ACT_BIT_U 31
35 * User space should be interruptable even by lowest prio interrupt
36 * Safe even if actual interrupt priorities is fewer or even one
38 #define ARCV2_IRQ_DEF_PRIO 15
40 /* seed value for status register */
41 #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
42 (ARCV2_IRQ_DEF_PRIO << 1))
44 /* SLEEP needs default irq priority (<=) which can interrupt the doze */
45 #define ISA_SLEEP_ARG (0x10 | ARCV2_IRQ_DEF_PRIO)
50 * Save IRQ state and disable IRQs
52 static inline long arch_local_irq_save(void)
56 __asm__
__volatile__(" clri %0 \n" : "=r" (flags
) : : "memory");
62 * restore saved IRQ state
64 static inline void arch_local_irq_restore(unsigned long flags
)
66 __asm__
__volatile__(" seti %0 \n" : : "r" (flags
) : "memory");
70 * Unconditionally Enable IRQs
72 static inline void arch_local_irq_enable(void)
74 unsigned int irqact
= read_aux_reg(AUX_IRQ_ACT
);
77 write_aux_reg(AUX_IRQ_ACT
, irqact
& ~0xffff);
79 __asm__
__volatile__(" seti \n" : : : "memory");
83 * Unconditionally Disable IRQs
85 static inline void arch_local_irq_disable(void)
87 __asm__
__volatile__(" clri \n" : : : "memory");
93 static inline long arch_local_save_flags(void)
98 " lr %0, [status32] \n"
109 static inline int arch_irqs_disabled_flags(unsigned long flags
)
111 return !(flags
& (STATUS_IE_MASK
));
114 static inline int arch_irqs_disabled(void)
116 return arch_irqs_disabled_flags(arch_local_save_flags());
119 static inline void arc_softirq_trigger(int irq
)
121 write_aux_reg(AUX_IRQ_HINT
, irq
);
124 static inline void arc_softirq_clear(int irq
)
126 write_aux_reg(AUX_IRQ_HINT
, 0);
131 .macro IRQ_DISABLE scratch
135 .macro IRQ_ENABLE scratch
139 #endif /* __ASSEMBLY__ */