blob: f7c8d3cbeaa10864569446f8e34ca86d3ccda3be [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 */
25#define AUX_IRQ_PRIORITY 0x206
26#define ICAUSE 0x40a
27#define AUX_IRQ_SELECT 0x40b
28#define AUX_IRQ_ENABLE 0x40c
29
Vineet Gupta1f6ccff2013-05-13 18:30:41 +053030/* Was Intr taken in User Mode */
31#define AUX_IRQ_ACT_BIT_U 31
32
Vineet Gupta820970a2015-03-06 14:08:20 +053033/* 0 is highest level, but taken by FIRQs, if present in design */
34#define ARCV2_IRQ_DEF_PRIO 0
35
36/* seed value for status register */
37#define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
38 (ARCV2_IRQ_DEF_PRIO << 1))
39
Vineet Gupta512b5b82015-11-16 13:52:07 +053040#define ISA_SLEEP_ARG 0x10
41
Vineet Gupta820970a2015-03-06 14:08:20 +053042#ifndef __ASSEMBLY__
43
44/*
45 * Save IRQ state and disable IRQs
46 */
47static inline long arch_local_irq_save(void)
48{
49 unsigned long flags;
50
51 __asm__ __volatile__(" clri %0 \n" : "=r" (flags) : : "memory");
52
53 return flags;
54}
55
56/*
57 * restore saved IRQ state
58 */
59static inline void arch_local_irq_restore(unsigned long flags)
60{
61 __asm__ __volatile__(" seti %0 \n" : : "r" (flags) : "memory");
62}
63
64/*
65 * Unconditionally Enable IRQs
66 */
67static inline void arch_local_irq_enable(void)
68{
Vineet Gupta4de0e522014-11-15 17:00:08 +053069 unsigned int irqact = read_aux_reg(AUX_IRQ_ACT);
70
71 if (irqact & 0xffff)
72 write_aux_reg(AUX_IRQ_ACT, irqact & ~0xffff);
73
Vineet Gupta820970a2015-03-06 14:08:20 +053074 __asm__ __volatile__(" seti \n" : : : "memory");
75}
76
77/*
78 * Unconditionally Disable IRQs
79 */
80static inline void arch_local_irq_disable(void)
81{
82 __asm__ __volatile__(" clri \n" : : : "memory");
83}
84
85/*
86 * save IRQ state
87 */
88static inline long arch_local_save_flags(void)
89{
90 unsigned long temp;
91
92 __asm__ __volatile__(
93 " lr %0, [status32] \n"
94 : "=&r"(temp)
95 :
96 : "memory");
97
98 return temp;
99}
100
101/*
102 * Query IRQ state
103 */
104static inline int arch_irqs_disabled_flags(unsigned long flags)
105{
106 return !(flags & (STATUS_IE_MASK));
107}
108
109static inline int arch_irqs_disabled(void)
110{
111 return arch_irqs_disabled_flags(arch_local_save_flags());
112}
113
114#else
115
116.macro IRQ_DISABLE scratch
117 clri
118.endm
119
120.macro IRQ_ENABLE scratch
121 seti
122.endm
123
124#endif /* __ASSEMBLY__ */
125
126#endif