blob: 37c2f751eebf03d8f9f16d997bacdcb5b8f6323f [file] [log] [blame]
Vineet Gupta820970a2015-03-06 14:08:20 +05301/*
2 * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
3 *
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 */
8
9#ifndef __ASM_IRQFLAGS_ARCV2_H
10#define __ASM_IRQFLAGS_ARCV2_H
11
12#include <asm/arcregs.h>
13
14/* status32 Bits */
15#define STATUS_AD_BIT 19 /* Disable Align chk: core supports non-aligned */
16#define STATUS_IE_BIT 31
17
18#define STATUS_AD_MASK (1<<STATUS_AD_BIT)
19#define STATUS_IE_MASK (1<<STATUS_IE_BIT)
20
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 */
Vineet Guptabb143f82016-02-23 11:55:16 +053025#define AUX_IRQ_HINT 0x201 /* For generating Soft Interrupts */
Vineet Gupta820970a2015-03-06 14:08:20 +053026#define AUX_IRQ_PRIORITY 0x206
27#define ICAUSE 0x40a
28#define AUX_IRQ_SELECT 0x40b
29#define AUX_IRQ_ENABLE 0x40c
30
Vineet Gupta1f6ccff2013-05-13 18:30:41 +053031/* Was Intr taken in User Mode */
32#define AUX_IRQ_ACT_BIT_U 31
33
Vineet Guptadec2b282016-02-07 12:54:35 +053034/*
35 * User space should be interruptable even by lowest prio interrupt
36 * Safe even if actual interrupt priorities is fewer or even one
37 */
38#define ARCV2_IRQ_DEF_PRIO 15
Vineet Gupta820970a2015-03-06 14:08:20 +053039
40/* seed value for status register */
41#define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
42 (ARCV2_IRQ_DEF_PRIO << 1))
43
Vineet Guptab8628f32015-06-17 17:03:18 +053044/* SLEEP needs default irq priority (<=) which can interrupt the doze */
45#define ISA_SLEEP_ARG (0x10 | ARCV2_IRQ_DEF_PRIO)
Vineet Gupta512b5b82015-11-16 13:52:07 +053046
Vineet Gupta820970a2015-03-06 14:08:20 +053047#ifndef __ASSEMBLY__
48
49/*
50 * Save IRQ state and disable IRQs
51 */
52static inline long arch_local_irq_save(void)
53{
54 unsigned long flags;
55
56 __asm__ __volatile__(" clri %0 \n" : "=r" (flags) : : "memory");
57
58 return flags;
59}
60
61/*
62 * restore saved IRQ state
63 */
64static inline void arch_local_irq_restore(unsigned long flags)
65{
66 __asm__ __volatile__(" seti %0 \n" : : "r" (flags) : "memory");
67}
68
69/*
70 * Unconditionally Enable IRQs
71 */
72static inline void arch_local_irq_enable(void)
73{
Vineet Gupta4de0e522014-11-15 17:00:08 +053074 unsigned int irqact = read_aux_reg(AUX_IRQ_ACT);
75
76 if (irqact & 0xffff)
77 write_aux_reg(AUX_IRQ_ACT, irqact & ~0xffff);
78
Vineet Gupta820970a2015-03-06 14:08:20 +053079 __asm__ __volatile__(" seti \n" : : : "memory");
80}
81
82/*
83 * Unconditionally Disable IRQs
84 */
85static inline void arch_local_irq_disable(void)
86{
87 __asm__ __volatile__(" clri \n" : : : "memory");
88}
89
90/*
91 * save IRQ state
92 */
93static inline long arch_local_save_flags(void)
94{
95 unsigned long temp;
96
97 __asm__ __volatile__(
98 " lr %0, [status32] \n"
99 : "=&r"(temp)
100 :
101 : "memory");
102
103 return temp;
104}
105
106/*
107 * Query IRQ state
108 */
109static inline int arch_irqs_disabled_flags(unsigned long flags)
110{
111 return !(flags & (STATUS_IE_MASK));
112}
113
114static inline int arch_irqs_disabled(void)
115{
116 return arch_irqs_disabled_flags(arch_local_save_flags());
117}
118
Vineet Guptabb143f82016-02-23 11:55:16 +0530119static inline void arc_softirq_trigger(int irq)
120{
121 write_aux_reg(AUX_IRQ_HINT, irq);
122}
123
124static inline void arc_softirq_clear(int irq)
125{
126 write_aux_reg(AUX_IRQ_HINT, 0);
127}
128
Vineet Gupta820970a2015-03-06 14:08:20 +0530129#else
130
131.macro IRQ_DISABLE scratch
132 clri
133.endm
134
135.macro IRQ_ENABLE scratch
136 seti
137.endm
138
139#endif /* __ASSEMBLY__ */
140
141#endif