irq.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. * Copyright (C) 1994 by Waldorf GMBH, written by Ralf Baechle
  7. * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02, 03 by Ralf Baechle
  8. */
  9. #ifndef _ASM_IRQ_H
  10. #define _ASM_IRQ_H
  11. #include <linux/linkage.h>
  12. #include <linux/smp.h>
  13. #include <asm/mipsmtregs.h>
  14. #include <irq.h>
  15. #ifdef CONFIG_I8259
  16. static inline int irq_canonicalize(int irq)
  17. {
  18. return ((irq == I8259A_IRQ_BASE + 2) ? I8259A_IRQ_BASE + 9 : irq);
  19. }
  20. #else
  21. #define irq_canonicalize(irq) (irq) /* Sane hardware, sane code ... */
  22. #endif
  23. #ifdef CONFIG_MIPS_MT_SMTC
  24. struct irqaction;
  25. extern unsigned long irq_hwmask[];
  26. extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
  27. unsigned long hwmask);
  28. static inline void smtc_im_ack_irq(unsigned int irq)
  29. {
  30. if (irq_hwmask[irq] & ST0_IM)
  31. set_c0_status(irq_hwmask[irq] & ST0_IM);
  32. }
  33. #else
  34. static inline void smtc_im_ack_irq(unsigned int irq)
  35. {
  36. }
  37. #endif /* CONFIG_MIPS_MT_SMTC */
  38. #ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
  39. #include <linux/cpumask.h>
  40. extern int plat_set_irq_affinity(unsigned int irq,
  41. const struct cpumask *affinity);
  42. extern void smtc_forward_irq(unsigned int irq);
  43. /*
  44. * IRQ affinity hook invoked at the beginning of interrupt dispatch
  45. * if option is enabled.
  46. *
  47. * Up through Linux 2.6.22 (at least) cpumask operations are very
  48. * inefficient on MIPS. Initial prototypes of SMTC IRQ affinity
  49. * used a "fast path" per-IRQ-descriptor cache of affinity information
  50. * to reduce latency. As there is a project afoot to optimize the
  51. * cpumask implementations, this version is optimistically assuming
  52. * that cpumask.h macro overhead is reasonable during interrupt dispatch.
  53. */
  54. #define IRQ_AFFINITY_HOOK(irq) \
  55. do { \
  56. if (!cpumask_test_cpu(smp_processor_id(), irq_desc[irq].affinity)) {\
  57. smtc_forward_irq(irq); \
  58. irq_exit(); \
  59. return; \
  60. } \
  61. } while (0)
  62. #else /* Not doing SMTC affinity */
  63. #define IRQ_AFFINITY_HOOK(irq) do { } while (0)
  64. #endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
  65. #ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
  66. /*
  67. * Clear interrupt mask handling "backstop" if irq_hwmask
  68. * entry so indicates. This implies that the ack() or end()
  69. * functions will take over re-enabling the low-level mask.
  70. * Otherwise it will be done on return from exception.
  71. */
  72. #define __DO_IRQ_SMTC_HOOK(irq) \
  73. do { \
  74. IRQ_AFFINITY_HOOK(irq); \
  75. if (irq_hwmask[irq] & 0x0000ff00) \
  76. write_c0_tccontext(read_c0_tccontext() & \
  77. ~(irq_hwmask[irq] & 0x0000ff00)); \
  78. } while (0)
  79. #define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) \
  80. do { \
  81. if (irq_hwmask[irq] & 0x0000ff00) \
  82. write_c0_tccontext(read_c0_tccontext() & \
  83. ~(irq_hwmask[irq] & 0x0000ff00)); \
  84. } while (0)
  85. #else
  86. #define __DO_IRQ_SMTC_HOOK(irq) \
  87. do { \
  88. IRQ_AFFINITY_HOOK(irq); \
  89. } while (0)
  90. #define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) do { } while (0)
  91. #endif
  92. /*
  93. * do_IRQ handles all normal device IRQ's (the special
  94. * SMP cross-CPU interrupts have their own specific
  95. * handlers).
  96. *
  97. * Ideally there should be away to get this into kernel/irq/handle.c to
  98. * avoid the overhead of a call for just a tiny function ...
  99. */
  100. #define do_IRQ(irq) \
  101. do { \
  102. irq_enter(); \
  103. __DO_IRQ_SMTC_HOOK(irq); \
  104. generic_handle_irq(irq); \
  105. irq_exit(); \
  106. } while (0)
  107. #ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
  108. /*
  109. * To avoid inefficient and in some cases pathological re-checking of
  110. * IRQ affinity, we have this variant that skips the affinity check.
  111. */
  112. #define do_IRQ_no_affinity(irq) \
  113. do { \
  114. irq_enter(); \
  115. __NO_AFFINITY_IRQ_SMTC_HOOK(irq); \
  116. generic_handle_irq(irq); \
  117. irq_exit(); \
  118. } while (0)
  119. #endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
  120. extern void arch_init_irq(void);
  121. extern void spurious_interrupt(void);
  122. extern int allocate_irqno(void);
  123. extern void alloc_legacy_irqno(void);
  124. extern void free_irqno(unsigned int irq);
  125. /*
  126. * Before R2 the timer and performance counter interrupts were both fixed to
  127. * IE7. Since R2 their number has to be read from the c0_intctl register.
  128. */
  129. #define CP0_LEGACY_COMPARE_IRQ 7
  130. extern int cp0_compare_irq;
  131. extern int cp0_perfcount_irq;
  132. #endif /* _ASM_IRQ_H */