irq.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #ifndef _BFIN_IRQ_H_
  17. #define _BFIN_IRQ_H_
  18. /* SYS_IRQS and NR_IRQS are defined in <mach-bf5xx/irq.h>*/
  19. #include <mach/irq.h>
  20. #include <asm/pda.h>
  21. #include <asm/processor.h>
  22. static __inline__ int irq_canonicalize(int irq)
  23. {
  24. return irq;
  25. }
  26. /*
  27. * Interrupt configuring macros.
  28. */
  29. #define local_irq_disable() \
  30. do { \
  31. int __tmp_dummy; \
  32. __asm__ __volatile__( \
  33. "cli %0;" \
  34. : "=d" (__tmp_dummy) \
  35. ); \
  36. } while (0)
  37. #if ANOMALY_05000244 && defined(CONFIG_BFIN_ICACHE)
  38. # define NOP_PAD_ANOMALY_05000244 "nop; nop;"
  39. #else
  40. # define NOP_PAD_ANOMALY_05000244
  41. #endif
  42. #ifdef CONFIG_SMP
  43. /* Forward decl needed due to cdef inter dependencies */
  44. static inline uint32_t __pure bfin_dspid(void);
  45. # define blackfin_core_id() (bfin_dspid() & 0xff)
  46. # define bfin_irq_flags cpu_pda[blackfin_core_id()].imask
  47. #else
  48. extern unsigned long bfin_irq_flags;
  49. #endif
  50. #define local_irq_enable() \
  51. __asm__ __volatile__( \
  52. "sti %0;" \
  53. : \
  54. : "d" (bfin_irq_flags) \
  55. )
  56. #define idle_with_irq_disabled() \
  57. __asm__ __volatile__( \
  58. NOP_PAD_ANOMALY_05000244 \
  59. ".align 8;" \
  60. "sti %0;" \
  61. "idle;" \
  62. : \
  63. : "d" (bfin_irq_flags) \
  64. )
  65. #ifdef CONFIG_DEBUG_HWERR
  66. # define __save_and_cli(x) \
  67. __asm__ __volatile__( \
  68. "cli %0;" \
  69. "sti %1;" \
  70. : "=&d" (x) \
  71. : "d" (0x3F) \
  72. )
  73. #else
  74. # define __save_and_cli(x) \
  75. __asm__ __volatile__( \
  76. "cli %0;" \
  77. : "=&d" (x) \
  78. )
  79. #endif
  80. #define local_save_flags(x) \
  81. __asm__ __volatile__( \
  82. "cli %0;" \
  83. "sti %0;" \
  84. : "=d" (x) \
  85. )
  86. #ifdef CONFIG_DEBUG_HWERR
  87. #define irqs_enabled_from_flags(x) (((x) & ~0x3f) != 0)
  88. #else
  89. #define irqs_enabled_from_flags(x) ((x) != 0x1f)
  90. #endif
  91. #define local_irq_restore(x) \
  92. do { \
  93. if (irqs_enabled_from_flags(x)) \
  94. local_irq_enable(); \
  95. } while (0)
  96. /* For spinlocks etc */
  97. #define local_irq_save(x) __save_and_cli(x)
  98. #define irqs_disabled() \
  99. ({ \
  100. unsigned long flags; \
  101. local_save_flags(flags); \
  102. !irqs_enabled_from_flags(flags); \
  103. })
  104. #endif /* _BFIN_IRQ_H_ */