msp_irq.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * IRQ vector handles
  3. *
  4. * Copyright (C) 1995, 1996, 1997, 2003 by Ralf Baechle
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/irq.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/ptrace.h>
  15. #include <linux/time.h>
  16. #include <asm/irq_cpu.h>
  17. #include <msp_int.h>
  18. /* SLP bases systems */
  19. extern void msp_slp_irq_init(void);
  20. extern void msp_slp_irq_dispatch(void);
  21. /* CIC based systems */
  22. extern void msp_cic_irq_init(void);
  23. extern void msp_cic_irq_dispatch(void);
  24. /* VSMP support init */
  25. extern void msp_vsmp_int_init(void);
  26. /* vectored interrupt implementation */
  27. /* SW0/1 interrupts are used for SMP/SMTC */
  28. static inline void mac0_int_dispatch(void) { do_IRQ(MSP_INT_MAC0); }
  29. static inline void mac1_int_dispatch(void) { do_IRQ(MSP_INT_MAC1); }
  30. static inline void mac2_int_dispatch(void) { do_IRQ(MSP_INT_SAR); }
  31. static inline void usb_int_dispatch(void) { do_IRQ(MSP_INT_USB); }
  32. static inline void sec_int_dispatch(void) { do_IRQ(MSP_INT_SEC); }
  33. /*
  34. * The PMC-Sierra MSP interrupts are arranged in a 3 level cascaded
  35. * hierarchical system. The first level are the direct MIPS interrupts
  36. * and are assigned the interrupt range 0-7. The second level is the SLM
  37. * interrupt controller and is assigned the range 8-39. The third level
  38. * comprises the Peripherial block, the PCI block, the PCI MSI block and
  39. * the SLP. The PCI interrupts and the SLP errors are handled by the
  40. * relevant subsystems so the core interrupt code needs only concern
  41. * itself with the Peripheral block. These are assigned interrupts in
  42. * the range 40-71.
  43. */
  44. asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
  45. {
  46. u32 pending;
  47. pending = read_c0_status() & read_c0_cause();
  48. /*
  49. * jump to the correct interrupt routine
  50. * These are arranged in priority order and the timer
  51. * comes first!
  52. */
  53. #ifdef CONFIG_IRQ_MSP_CIC /* break out the CIC stuff for now */
  54. if (pending & C_IRQ4) /* do the peripherals first, that's the timer */
  55. msp_cic_irq_dispatch();
  56. else if (pending & C_IRQ0)
  57. do_IRQ(MSP_INT_MAC0);
  58. else if (pending & C_IRQ1)
  59. do_IRQ(MSP_INT_MAC1);
  60. else if (pending & C_IRQ2)
  61. do_IRQ(MSP_INT_USB);
  62. else if (pending & C_IRQ3)
  63. do_IRQ(MSP_INT_SAR);
  64. else if (pending & C_IRQ5)
  65. do_IRQ(MSP_INT_SEC);
  66. #else
  67. if (pending & C_IRQ5)
  68. do_IRQ(MSP_INT_TIMER);
  69. else if (pending & C_IRQ0)
  70. do_IRQ(MSP_INT_MAC0);
  71. else if (pending & C_IRQ1)
  72. do_IRQ(MSP_INT_MAC1);
  73. else if (pending & C_IRQ3)
  74. do_IRQ(MSP_INT_VE);
  75. else if (pending & C_IRQ4)
  76. msp_slp_irq_dispatch();
  77. #endif
  78. else if (pending & C_SW0) /* do software after hardware */
  79. do_IRQ(MSP_INT_SW0);
  80. else if (pending & C_SW1)
  81. do_IRQ(MSP_INT_SW1);
  82. }
  83. static struct irqaction cic_cascade_msp = {
  84. .handler = no_action,
  85. .name = "MSP CIC cascade",
  86. .flags = IRQF_NO_THREAD,
  87. };
  88. static struct irqaction per_cascade_msp = {
  89. .handler = no_action,
  90. .name = "MSP PER cascade",
  91. .flags = IRQF_NO_THREAD,
  92. };
  93. void __init arch_init_irq(void)
  94. {
  95. /* assume we'll be using vectored interrupt mode except in UP mode*/
  96. #ifdef CONFIG_MIPS_MT
  97. BUG_ON(!cpu_has_vint);
  98. #endif
  99. /* initialize the 1st-level CPU based interrupt controller */
  100. mips_cpu_irq_init();
  101. #ifdef CONFIG_IRQ_MSP_CIC
  102. msp_cic_irq_init();
  103. #ifdef CONFIG_MIPS_MT
  104. set_vi_handler(MSP_INT_CIC, msp_cic_irq_dispatch);
  105. set_vi_handler(MSP_INT_MAC0, mac0_int_dispatch);
  106. set_vi_handler(MSP_INT_MAC1, mac1_int_dispatch);
  107. set_vi_handler(MSP_INT_SAR, mac2_int_dispatch);
  108. set_vi_handler(MSP_INT_USB, usb_int_dispatch);
  109. set_vi_handler(MSP_INT_SEC, sec_int_dispatch);
  110. #ifdef CONFIG_MIPS_MT_SMP
  111. msp_vsmp_int_init();
  112. #elif defined CONFIG_MIPS_MT_SMTC
  113. /*Set hwmask for all platform devices */
  114. irq_hwmask[MSP_INT_MAC0] = C_IRQ0;
  115. irq_hwmask[MSP_INT_MAC1] = C_IRQ1;
  116. irq_hwmask[MSP_INT_USB] = C_IRQ2;
  117. irq_hwmask[MSP_INT_SAR] = C_IRQ3;
  118. irq_hwmask[MSP_INT_SEC] = C_IRQ5;
  119. #endif /* CONFIG_MIPS_MT_SMP */
  120. #endif /* CONFIG_MIPS_MT */
  121. /* setup the cascaded interrupts */
  122. setup_irq(MSP_INT_CIC, &cic_cascade_msp);
  123. setup_irq(MSP_INT_PER, &per_cascade_msp);
  124. #else
  125. /* setup the 2nd-level SLP register based interrupt controller */
  126. /* VSMP /SMTC support support is not enabled for SLP */
  127. msp_slp_irq_init();
  128. /* setup the cascaded SLP/PER interrupts */
  129. setup_irq(MSP_INT_SLP, &cic_cascade_msp);
  130. setup_irq(MSP_INT_PER, &per_cascade_msp);
  131. #endif
  132. }