irq.h 4.2 KB

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