irq.h 4.3 KB

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