Blackfin arch: noMMU CPLB lookup tables can be in L1 SRAM
[linux-2.6] / arch / blackfin / include / asm / irq.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file COPYING in the main directory of this archive
4  * for more details.
5  *
6  * Changed by HuTao Apr18, 2003
7  *
8  * Copyright was missing when I got the code so took from MIPS arch ...MaTed---
9  * Copyright (C) 1994 by Waldorf GMBH, written by Ralf Baechle
10  * Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001 by Ralf Baechle
11  *
12  * Adapted for BlackFin (ADI) by Ted Ma <mated@sympatico.ca>
13  * Copyright (c) 2002 Arcturus Networks Inc. (www.arcturusnetworks.com)
14  * Copyright (c) 2002 Lineo, Inc. <mattw@lineo.com>
15  */
16
17 #ifndef _BFIN_IRQ_H_
18 #define _BFIN_IRQ_H_
19
20 /* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h>*/
21 #include <mach/irq.h>
22 #include <asm/pda.h>
23 #include <asm/processor.h>
24
25 static __inline__ int irq_canonicalize(int irq)
26 {
27         return irq;
28 }
29
30 /*
31  * Interrupt configuring macros.
32  */
33 #define local_irq_disable() \
34         do { \
35                 int __tmp_dummy; \
36                 __asm__ __volatile__( \
37                         "cli %0;" \
38                         : "=d" (__tmp_dummy) \
39                 ); \
40         } while (0)
41
42 #if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE)
43 # define NOP_PAD_ANOMALY_05000244 "nop; nop;"
44 #else
45 # define NOP_PAD_ANOMALY_05000244
46 #endif
47
48 #ifdef CONFIG_SMP
49 /* Forward decl needed due to cdef inter dependencies */
50 static inline uint32_t __pure bfin_dspid(void);
51 # define blackfin_core_id() (bfin_dspid() & 0xff)
52 # define bfin_irq_flags cpu_pda[blackfin_core_id()].imask
53 #else
54 extern unsigned long bfin_irq_flags;
55 #endif
56
57 #define local_irq_enable() \
58         __asm__ __volatile__( \
59                 "sti %0;" \
60                 : \
61                 : "d" (bfin_irq_flags) \
62         )
63
64 #define idle_with_irq_disabled() \
65         __asm__ __volatile__( \
66                 NOP_PAD_ANOMALY_05000244 \
67                 ".align 8;" \
68                 "sti %0;" \
69                 "idle;" \
70                 : \
71                 : "d" (bfin_irq_flags) \
72         )
73
74 #ifdef CONFIG_DEBUG_HWERR
75 # define __save_and_cli(x) \
76         __asm__ __volatile__( \
77                 "cli %0;" \
78                 "sti %1;" \
79                 : "=&d" (x) \
80                 : "d" (0x3F) \
81         )
82 #else
83 # define __save_and_cli(x) \
84         __asm__ __volatile__( \
85                 "cli %0;" \
86                 : "=&d" (x) \
87         )
88 #endif
89
90 #define local_save_flags(x) \
91         __asm__ __volatile__( \
92                 "cli %0;" \
93                 "sti %0;" \
94                 : "=d" (x) \
95         )
96
97 #ifdef CONFIG_DEBUG_HWERR
98 #define irqs_enabled_from_flags(x) (((x) & ~0x3f) != 0)
99 #else
100 #define irqs_enabled_from_flags(x) ((x) != 0x1f)
101 #endif
102
103 #define local_irq_restore(x) \
104         do { \
105                 if (irqs_enabled_from_flags(x)) \
106                         local_irq_enable(); \
107         } while (0)
108
109 /* For spinlocks etc */
110 #define local_irq_save(x) __save_and_cli(x)
111
112 #define irqs_disabled()                         \
113 ({                                              \
114         unsigned long flags;                    \
115         local_save_flags(flags);                \
116         !irqs_enabled_from_flags(flags);        \
117 })
118
119 #endif                          /* _BFIN_IRQ_H_ */