blob: 21e25f778a6308de586442550e5fd138529e9200 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
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
Mike Frysinger34616c82008-11-18 17:48:22 +080020/* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h>*/
Bryan Wu639f6572008-08-27 10:51:02 +080021#include <mach/irq.h>
Mike Frysingerb6070572008-11-18 17:48:22 +080022#include <asm/pda.h>
23#include <asm/processor.h>
Bryan Wu1394f032007-05-06 14:50:22 -070024
Bryan Wu1394f032007-05-06 14:50:22 -070025static __inline__ int irq_canonicalize(int irq)
26{
27 return irq;
28}
29
Mike Frysingerb6070572008-11-18 17:48:22 +080030/*
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 */
50static inline uint32_t __pure bfin_dspid(void);
51# define blackfin_core_id() (bfin_dspid() & 0xff)
Mike Frysinger40059782008-11-18 17:48:22 +080052# define bfin_irq_flags cpu_pda[blackfin_core_id()].imask
Mike Frysingerb6070572008-11-18 17:48:22 +080053#else
Mike Frysinger40059782008-11-18 17:48:22 +080054extern unsigned long bfin_irq_flags;
Mike Frysingerb6070572008-11-18 17:48:22 +080055#endif
56
57#define local_irq_enable() \
58 __asm__ __volatile__( \
59 "sti %0;" \
60 : \
Mike Frysinger40059782008-11-18 17:48:22 +080061 : "d" (bfin_irq_flags) \
Mike Frysingerb6070572008-11-18 17:48:22 +080062 )
63
64#define idle_with_irq_disabled() \
65 __asm__ __volatile__( \
66 NOP_PAD_ANOMALY_05000244 \
67 ".align 8;" \
68 "sti %0;" \
69 "idle;" \
70 : \
Mike Frysinger40059782008-11-18 17:48:22 +080071 : "d" (bfin_irq_flags) \
Mike Frysingerb6070572008-11-18 17:48:22 +080072 )
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
Bryan Wu1394f032007-05-06 14:50:22 -0700119#endif /* _BFIN_IRQ_H_ */