irq.h 3.7 KB

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