irq.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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(struct irq_data *d,
  45. const struct cpumask *affinity, bool force);
  46. extern void smtc_forward_irq(struct irq_data *d);
  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. static inline int handle_on_other_cpu(unsigned int irq)
  59. {
  60. struct irq_data *d = irq_get_irq_data(irq);
  61. if (cpumask_test_cpu(smp_processor_id(), d->affinity))
  62. return 0;
  63. smtc_forward_irq(d);
  64. return 1;
  65. }
  66. #else /* Not doing SMTC affinity */
  67. static inline int handle_on_other_cpu(unsigned int irq) { return 0; }
  68. #endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
  69. #ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP
  70. static inline void smtc_im_backstop(unsigned int irq)
  71. {
  72. if (irq_hwmask[irq] & 0x0000ff00)
  73. write_c0_tccontext(read_c0_tccontext() &
  74. ~(irq_hwmask[irq] & 0x0000ff00));
  75. }
  76. /*
  77. * Clear interrupt mask handling "backstop" if irq_hwmask
  78. * entry so indicates. This implies that the ack() or end()
  79. * functions will take over re-enabling the low-level mask.
  80. * Otherwise it will be done on return from exception.
  81. */
  82. static inline int smtc_handle_on_other_cpu(unsigned int irq)
  83. {
  84. int ret = handle_on_other_cpu(irq);
  85. if (!ret)
  86. smtc_im_backstop(irq);
  87. return ret;
  88. }
  89. #else
  90. static inline void smtc_im_backstop(unsigned int irq) { }
  91. static inline int smtc_handle_on_other_cpu(unsigned int irq)
  92. {
  93. return handle_on_other_cpu(irq);
  94. }
  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 */