irq.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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/config.h>
  30. #include <linux/errno.h>
  31. #include <linux/init.h>
  32. #include <linux/kernel_stat.h>
  33. #include <linux/module.h>
  34. #include <linux/signal.h>
  35. #include <linux/sched.h>
  36. #include <linux/types.h>
  37. #include <linux/interrupt.h>
  38. #include <linux/ioport.h>
  39. #include <linux/irq.h>
  40. #include <linux/timex.h>
  41. #include <linux/slab.h>
  42. #include <linux/random.h>
  43. #include <linux/bitops.h>
  44. #include <asm/bootinfo.h>
  45. #include <asm/io.h>
  46. #include <asm/irq.h>
  47. #include <asm/irq_cpu.h>
  48. #include <asm/mipsregs.h>
  49. #include <asm/system.h>
  50. #include <asm/titan_dep.h>
  51. /* Hypertransport specific */
  52. #define IRQ_ACK_BITS 0x00000000 /* Ack bits */
  53. #define HYPERTRANSPORT_INTA 0x78 /* INTA# */
  54. #define HYPERTRANSPORT_INTB 0x79 /* INTB# */
  55. #define HYPERTRANSPORT_INTC 0x7a /* INTC# */
  56. #define HYPERTRANSPORT_INTD 0x7b /* INTD# */
  57. extern void jaguar_mailbox_irq(struct pt_regs *);
  58. /*
  59. * Handle hypertransport & SMP interrupts. The interrupt lines are scarce.
  60. * For interprocessor interrupts, the best thing to do is to use the INTMSG
  61. * register. We use the same external interrupt line, i.e. INTB3 and monitor
  62. * another status bit
  63. */
  64. asmlinkage void ll_ht_smp_irq_handler(int irq, struct pt_regs *regs)
  65. {
  66. u32 status = OCD_READ(RM9000x2_OCD_INTP0STATUS4);
  67. /* Ack all the bits that correspond to the interrupt sources */
  68. if (status != 0)
  69. OCD_WRITE(RM9000x2_OCD_INTP0STATUS4, IRQ_ACK_BITS);
  70. status = OCD_READ(RM9000x2_OCD_INTP1STATUS4);
  71. if (status != 0)
  72. OCD_WRITE(RM9000x2_OCD_INTP1STATUS4, IRQ_ACK_BITS);
  73. #ifdef CONFIG_HT_LEVEL_TRIGGER
  74. /*
  75. * Level Trigger Mode only. Send the HT EOI message back to the source.
  76. */
  77. switch (status) {
  78. case 0x1000000:
  79. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTA);
  80. break;
  81. case 0x2000000:
  82. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTB);
  83. break;
  84. case 0x4000000:
  85. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTC);
  86. break;
  87. case 0x8000000:
  88. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTD);
  89. break;
  90. case 0x0000001:
  91. /* PLX */
  92. OCD_WRITE(RM9000x2_OCD_HTEOI, 0x20);
  93. OCD_WRITE(IRQ_CLEAR_REG, IRQ_ACK_BITS);
  94. break;
  95. case 0xf000000:
  96. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTA);
  97. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTB);
  98. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTC);
  99. OCD_WRITE(RM9000x2_OCD_HTEOI, HYPERTRANSPORT_INTD);
  100. break;
  101. }
  102. #endif /* CONFIG_HT_LEVEL_TRIGGER */
  103. do_IRQ(irq, regs);
  104. }
  105. asmlinkage void do_extended_irq(struct pt_regs *regs)
  106. {
  107. unsigned int intcontrol = read_c0_intcontrol();
  108. unsigned int cause = read_c0_cause();
  109. unsigned int status = read_c0_status();
  110. unsigned int pending_sr, pending_ic;
  111. pending_sr = status & cause & 0xff00;
  112. pending_ic = (cause >> 8) & intcontrol & 0xff00;
  113. if (pending_ic & (1 << 13))
  114. do_IRQ(13, regs);
  115. }
  116. asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
  117. {
  118. unsigned int cause = read_c0_cause();
  119. unsigned int status = read_c0_status();
  120. unsigned int pending = cause & status;
  121. if (pending & STATUSF_IP7) {
  122. do_IRQ(7, regs);
  123. } else if (pending & STATUSF_IP2) {
  124. #ifdef CONFIG_HYPERTRANSPORT
  125. ll_ht_smp_irq_handler(2, regs);
  126. #else
  127. do_IRQ(2, regs);
  128. #endif
  129. } else if (pending & STATUSF_IP3) {
  130. do_IRQ(3, regs);
  131. } else if (pending & STATUSF_IP4) {
  132. do_IRQ(4, regs);
  133. } else if (pending & STATUSF_IP5) {
  134. #ifdef CONFIG_SMP
  135. titan_mailbox_irq(regs);
  136. #else
  137. do_IRQ(5, regs);
  138. #endif
  139. } else if (pending & STATUSF_IP6) {
  140. do_IRQ(4, regs);
  141. }
  142. }
  143. #ifdef CONFIG_KGDB
  144. extern void init_second_port(void);
  145. #endif
  146. /*
  147. * Initialize the next level interrupt handler
  148. */
  149. void __init arch_init_irq(void)
  150. {
  151. clear_c0_status(ST0_IM);
  152. mips_cpu_irq_init(0);
  153. rm7k_cpu_irq_init(8);
  154. rm9k_cpu_irq_init(12);
  155. #ifdef CONFIG_KGDB
  156. /* At this point, initialize the second serial port */
  157. init_second_port();
  158. #endif
  159. #ifdef CONFIG_GDB_CONSOLE
  160. register_gdb_console();
  161. #endif
  162. }
  163. #ifdef CONFIG_KGDB
  164. /*
  165. * The 16550 DUART has two ports, but is allocated one IRQ
  166. * for the serial console. Hence, a generic framework for
  167. * serial IRQ routing in place. Currently, just calls the
  168. * do_IRQ fuction. But, going in the future, need to check
  169. * DUART registers for channel A and B, then decide the
  170. * appropriate action
  171. */
  172. asmlinkage void yosemite_kgdb_irq(int irq, struct pt_regs *regs)
  173. {
  174. do_IRQ(irq, regs);
  175. }
  176. #endif