irq.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Copyright (C) 2003 PMC-Sierra Inc.
  3. * Author: Manish Lachwani (lachwani@pmc-sierra.com)
  4. *
  5. * Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org)
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  15. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  19. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 675 Mass Ave, Cambridge, MA 02139, USA.
  26. *
  27. * Second level Interrupt handlers for the PMC-Sierra Titan/Yosemite board
  28. */
  29. #include <linux/errno.h>
  30. #include <linux/init.h>
  31. #include <linux/kernel_stat.h>
  32. #include <linux/module.h>
  33. #include <linux/signal.h>
  34. #include <linux/sched.h>
  35. #include <linux/types.h>
  36. #include <linux/interrupt.h>
  37. #include <linux/ioport.h>
  38. #include <linux/irq.h>
  39. #include <linux/timex.h>
  40. #include <linux/random.h>
  41. #include <linux/bitops.h>
  42. #include <asm/bootinfo.h>
  43. #include <asm/io.h>
  44. #include <asm/irq.h>
  45. #include <asm/irq_cpu.h>
  46. #include <asm/mipsregs.h>
  47. #include <asm/titan_dep.h>
  48. /* Hypertransport specific */
  49. #define IRQ_ACK_BITS 0x00000000 /* Ack bits */
  50. #define HYPERTRANSPORT_INTA 0x78 /* INTA# */
  51. #define HYPERTRANSPORT_INTB 0x79 /* INTB# */
  52. #define HYPERTRANSPORT_INTC 0x7a /* INTC# */
  53. #define HYPERTRANSPORT_INTD 0x7b /* INTD# */
  54. extern void titan_mailbox_irq(void);
  55. #ifdef CONFIG_HYPERTRANSPORT
  56. /*
  57. * Handle hypertransport & SMP interrupts. The interrupt lines are scarce.
  58. * For interprocessor interrupts, the best thing to do is to use the INTMSG
  59. * register. We use the same external interrupt line, i.e. INTB3 and monitor
  60. * another status bit
  61. */
  62. static void ll_ht_smp_irq_handler(int irq)
  63. {
  64. u32 status = OCD_READ(RM9000x2_OCD_INTP0STATUS4);
  65. /* Ack all the bits that correspond to the interrupt sources */
  66. if (status != 0)
  67. OCD_WRITE(RM9000x2_OCD_INTP0STATUS4, IRQ_ACK_BITS);
  68. status = OCD_READ(RM9000x2_OCD_INTP1STATUS4);
  69. if (status != 0)
  70. OCD_WRITE(RM9000x2_OCD_INTP1STATUS4, IRQ_ACK_BITS);
  71. #ifdef CONFIG_HT_LEVEL_TRIGGER
  72. /*
  73. * Level Trigger Mode only. Send the HT EOI message back to the source.
  74. */
  75. switch (status) {
  76. case 0x1000000:
  77. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTA);
  78. break;
  79. case 0x2000000:
  80. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTB);
  81. break;
  82. case 0x4000000:
  83. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTC);
  84. break;
  85. case 0x8000000:
  86. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTD);
  87. break;
  88. case 0x0000001:
  89. /* PLX */
  90. OCD_WRITE(RM9000x2_OCD_HTEOI, 0x20);
  91. OCD_WRITE(IRQ_CLEAR_REG, IRQ_ACK_BITS);
  92. break;
  93. case 0xf000000:
  94. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTA);
  95. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTB);
  96. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTC);
  97. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTD);
  98. break;
  99. }
  100. #endif /* CONFIG_HT_LEVEL_TRIGGER */
  101. do_IRQ(irq);
  102. }
  103. #endif
  104. asmlinkage void plat_irq_dispatch(void)
  105. {
  106. unsigned int cause = read_c0_cause();
  107. unsigned int status = read_c0_status();
  108. unsigned int pending = cause & status;
  109. if (pending & STATUSF_IP7) {
  110. do_IRQ(7);
  111. } else if (pending & STATUSF_IP2) {
  112. #ifdef CONFIG_HYPERTRANSPORT
  113. ll_ht_smp_irq_handler(2);
  114. #else
  115. do_IRQ(2);
  116. #endif
  117. } else if (pending & STATUSF_IP3) {
  118. do_IRQ(3);
  119. } else if (pending & STATUSF_IP4) {
  120. do_IRQ(4);
  121. } else if (pending & STATUSF_IP5) {
  122. #ifdef CONFIG_SMP
  123. titan_mailbox_irq();
  124. #else
  125. do_IRQ(5);
  126. #endif
  127. } else if (pending & STATUSF_IP6) {
  128. do_IRQ(4);
  129. }
  130. }
  131. /*
  132. * Initialize the next level interrupt handler
  133. */
  134. void __init arch_init_irq(void)
  135. {
  136. clear_c0_status(ST0_IM);
  137. mips_cpu_irq_init();
  138. rm7k_cpu_irq_init();
  139. rm9k_cpu_irq_init();
  140. }