intc2.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Interrupt handling for INTC2-based IRQ.
  3. *
  4. * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
  5. * Copyright (C) 2005, 2006 Paul Mundt (lethal@linux-sh.org)
  6. *
  7. * May be copied or modified under the terms of the GNU General Public
  8. * License. See linux/COPYING for more information.
  9. *
  10. * These are the "new Hitachi style" interrupts, as present on the
  11. * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/irq.h>
  16. #include <asm/system.h>
  17. #include <asm/io.h>
  18. static void disable_intc2_irq(unsigned int irq)
  19. {
  20. struct intc2_data *p = get_irq_chip_data(irq);
  21. ctrl_outl(1 << p->msk_shift,
  22. INTC2_BASE + INTC2_INTMSK_OFFSET + p->msk_offset);
  23. }
  24. static void enable_intc2_irq(unsigned int irq)
  25. {
  26. struct intc2_data *p = get_irq_chip_data(irq);
  27. ctrl_outl(1 << p->msk_shift,
  28. INTC2_BASE + INTC2_INTMSKCLR_OFFSET + p->msk_offset);
  29. }
  30. static struct irq_chip intc2_irq_chip = {
  31. .typename = "intc2",
  32. .mask = disable_intc2_irq,
  33. .unmask = enable_intc2_irq,
  34. .mask_ack = disable_intc2_irq,
  35. };
  36. /*
  37. * Setup an INTC2 style interrupt.
  38. * NOTE: Unlike IPR interrupts, parameters are not shifted by this code,
  39. * allowing the use of the numbers straight out of the datasheet.
  40. * For example:
  41. * PIO1 which is INTPRI00[19,16] and INTMSK00[13]
  42. * would be: ^ ^ ^ ^
  43. * | | | |
  44. * make_intc2_irq(84, 0, 16, 0, 13);
  45. */
  46. void make_intc2_irq(struct intc2_data *p)
  47. {
  48. unsigned int flags;
  49. unsigned long ipr;
  50. disable_irq_nosync(p->irq);
  51. /* Set the priority level */
  52. local_irq_save(flags);
  53. ipr = ctrl_inl(INTC2_BASE + INTC2_INTPRI_OFFSET + p->ipr_offset);
  54. ipr &= ~(0xf << p->ipr_shift);
  55. ipr |= p->priority << p->ipr_shift;
  56. ctrl_outl(ipr, INTC2_BASE + INTC2_INTPRI_OFFSET + p->ipr_offset);
  57. local_irq_restore(flags);
  58. set_irq_chip_and_handler(p->irq, &intc2_irq_chip, handle_level_irq);
  59. set_irq_chip_data(p->irq, p);
  60. enable_intc2_irq(p->irq);
  61. }
  62. static struct intc2_data intc2_irq_table[] = {
  63. #if defined(CONFIG_CPU_SUBTYPE_ST40)
  64. {64, 0, 0, 0, 0, 13}, /* PCI serr */
  65. {65, 0, 4, 0, 1, 13}, /* PCI err */
  66. {66, 0, 4, 0, 2, 13}, /* PCI ad */
  67. {67, 0, 4, 0, 3, 13}, /* PCI pwd down */
  68. {72, 0, 8, 0, 5, 13}, /* DMAC INT0 */
  69. {73, 0, 8, 0, 6, 13}, /* DMAC INT1 */
  70. {74, 0, 8, 0, 7, 13}, /* DMAC INT2 */
  71. {75, 0, 8, 0, 8, 13}, /* DMAC INT3 */
  72. {76, 0, 8, 0, 9, 13}, /* DMAC INT4 */
  73. {78, 0, 8, 0, 11, 13}, /* DMAC ERR */
  74. {80, 0, 12, 0, 12, 13}, /* PIO0 */
  75. {84, 0, 16, 0, 13, 13}, /* PIO1 */
  76. {88, 0, 20, 0, 14, 13}, /* PIO2 */
  77. {112, 4, 0, 4, 0, 13}, /* Mailbox */
  78. #ifdef CONFIG_CPU_SUBTYPE_ST40GX1
  79. {116, 4, 4, 4, 4, 13}, /* SSC0 */
  80. {120, 4, 8, 4, 8, 13}, /* IR Blaster */
  81. {124, 4, 12, 4, 12, 13}, /* USB host */
  82. {128, 4, 16, 4, 16, 13}, /* Video processor BLITTER */
  83. {132, 4, 20, 4, 20, 13}, /* UART0 */
  84. {134, 4, 20, 4, 22, 13}, /* UART2 */
  85. {136, 4, 24, 4, 24, 13}, /* IO_PIO0 */
  86. {140, 4, 28, 4, 28, 13}, /* EMPI */
  87. {144, 8, 0, 8, 0, 13}, /* MAFE */
  88. {148, 8, 4, 8, 4, 13}, /* PWM */
  89. {152, 8, 8, 8, 8, 13}, /* SSC1 */
  90. {156, 8, 12, 8, 12, 13}, /* IO_PIO1 */
  91. {160, 8, 16, 8, 16, 13}, /* USB target */
  92. {164, 8, 20, 8, 20, 13}, /* UART1 */
  93. {168, 8, 24, 8, 24, 13}, /* Teletext */
  94. {172, 8, 28, 8, 28, 13}, /* VideoSync VTG */
  95. {173, 8, 28, 8, 29, 13}, /* VideoSync DVP0 */
  96. {174, 8, 28, 8, 30, 13}, /* VideoSync DVP1 */
  97. #endif
  98. #elif defined(CONFIG_CPU_SUBTYPE_SH7760)
  99. /*
  100. * SH7760 INTC2-Style interrupts, vectors IRQ48-111 INTEVT 0x800-0xFE0
  101. */
  102. /* INTPRIO0 | INTMSK0 */
  103. {48, 0, 28, 0, 31, 3}, /* IRQ 4 */
  104. {49, 0, 24, 0, 30, 3}, /* IRQ 3 */
  105. {50, 0, 20, 0, 29, 3}, /* IRQ 2 */
  106. {51, 0, 16, 0, 28, 3}, /* IRQ 1 */
  107. /* 52-55 (INTEVT 0x880-0x8E0) unused/reserved */
  108. /* INTPRIO4 | INTMSK0 */
  109. {56, 4, 28, 0, 25, 3}, /* HCAN2_CHAN0 */
  110. {57, 4, 24, 0, 24, 3}, /* HCAN2_CHAN1 */
  111. {58, 4, 20, 0, 23, 3}, /* I2S_CHAN0 */
  112. {59, 4, 16, 0, 22, 3}, /* I2S_CHAN1 */
  113. {60, 4, 12, 0, 21, 3}, /* AC97_CHAN0 */
  114. {61, 4, 8, 0, 20, 3}, /* AC97_CHAN1 */
  115. {62, 4, 4, 0, 19, 3}, /* I2C_CHAN0 */
  116. {63, 4, 0, 0, 18, 3}, /* I2C_CHAN1 */
  117. /* INTPRIO8 | INTMSK0 */
  118. {52, 8, 16, 0, 11, 3}, /* SCIF0_ERI_IRQ */
  119. {53, 8, 16, 0, 10, 3}, /* SCIF0_RXI_IRQ */
  120. {54, 8, 16, 0, 9, 3}, /* SCIF0_BRI_IRQ */
  121. {55, 8, 16, 0, 8, 3}, /* SCIF0_TXI_IRQ */
  122. {64, 8, 28, 0, 17, 3}, /* USBHI_IRQ */
  123. {65, 8, 24, 0, 16, 3}, /* LCDC */
  124. /* 66, 67 unused */
  125. {68, 8, 20, 0, 14, 13}, /* DMABRGI0_IRQ */
  126. {69, 8, 20, 0, 13, 13}, /* DMABRGI1_IRQ */
  127. {70, 8, 20, 0, 12, 13}, /* DMABRGI2_IRQ */
  128. /* 71 unused */
  129. {72, 8, 12, 0, 7, 3}, /* SCIF1_ERI_IRQ */
  130. {73, 8, 12, 0, 6, 3}, /* SCIF1_RXI_IRQ */
  131. {74, 8, 12, 0, 5, 3}, /* SCIF1_BRI_IRQ */
  132. {75, 8, 12, 0, 4, 3}, /* SCIF1_TXI_IRQ */
  133. {76, 8, 8, 0, 3, 3}, /* SCIF2_ERI_IRQ */
  134. {77, 8, 8, 0, 2, 3}, /* SCIF2_RXI_IRQ */
  135. {78, 8, 8, 0, 1, 3}, /* SCIF2_BRI_IRQ */
  136. {79, 8, 8, 0, 0, 3}, /* SCIF2_TXI_IRQ */
  137. /* | INTMSK4 */
  138. {80, 8, 4, 4, 23, 3}, /* SIM_ERI */
  139. {81, 8, 4, 4, 22, 3}, /* SIM_RXI */
  140. {82, 8, 4, 4, 21, 3}, /* SIM_TXI */
  141. {83, 8, 4, 4, 20, 3}, /* SIM_TEI */
  142. {84, 8, 0, 4, 19, 3}, /* HSPII */
  143. /* INTPRIOC | INTMSK4 */
  144. /* 85-87 unused/reserved */
  145. {88, 12, 20, 4, 18, 3}, /* MMCI0 */
  146. {89, 12, 20, 4, 17, 3}, /* MMCI1 */
  147. {90, 12, 20, 4, 16, 3}, /* MMCI2 */
  148. {91, 12, 20, 4, 15, 3}, /* MMCI3 */
  149. {92, 12, 12, 4, 6, 3}, /* MFI (unsure, bug? in my 7760 manual*/
  150. /* 93-107 reserved/undocumented */
  151. {108,12, 4, 4, 1, 3}, /* ADC */
  152. {109,12, 0, 4, 0, 3}, /* CMTI */
  153. /* 110-111 reserved/unused */
  154. #elif defined(CONFIG_CPU_SUBTYPE_SH7780)
  155. { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2},
  156. { 21, 1, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY },
  157. { 22, 1, 1, 0, INTC_RTC_MSK, TIMER_PRIORITY },
  158. { 23, 1, 2, 0, INTC_RTC_MSK, TIMER_PRIORITY },
  159. { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
  160. { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
  161. { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
  162. { SCIF0_TXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
  163. { SCIF1_ERI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
  164. { SCIF1_RXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
  165. { SCIF1_BRI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
  166. { SCIF1_TXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
  167. { PCIC0_IRQ, 0x10, 8, 0, INTC_PCIC0_MSK, PCIC0_PRIORITY },
  168. { PCIC1_IRQ, 0x10, 0, 0, INTC_PCIC1_MSK, PCIC1_PRIORITY },
  169. { PCIC2_IRQ, 0x14, 24, 0, INTC_PCIC2_MSK, PCIC2_PRIORITY },
  170. { PCIC3_IRQ, 0x14, 16, 0, INTC_PCIC3_MSK, PCIC3_PRIORITY },
  171. { PCIC4_IRQ, 0x14, 8, 0, INTC_PCIC4_MSK, PCIC4_PRIORITY },
  172. #endif
  173. };
  174. void __init init_IRQ_intc2(void)
  175. {
  176. int i;
  177. for (i = 0; i < ARRAY_SIZE(intc2_irq_table); i++)
  178. make_intc2_irq(intc2_irq_table + i);
  179. }