ipr.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Interrupt handling for IPR-based IRQ.
  3. *
  4. * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
  5. * Copyright (C) 2000 Kazumoto Kojima
  6. * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
  7. * Copyright (C) 2006 Paul Mundt
  8. *
  9. * Supported system:
  10. * On-chip supporting modules (TMU, RTC, etc.).
  11. * On-chip supporting modules for SH7709/SH7709A/SH7729/SH7300.
  12. * Hitachi SolutionEngine external I/O:
  13. * MS7709SE01, MS7709ASE01, and MS7750SE01
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file "COPYING" in the main directory of this archive
  17. * for more details.
  18. */
  19. #include <linux/init.h>
  20. #include <linux/irq.h>
  21. #include <linux/module.h>
  22. #include <asm/system.h>
  23. #include <asm/io.h>
  24. #include <asm/machvec.h>
  25. static void disable_ipr_irq(unsigned int irq)
  26. {
  27. struct ipr_data *p = get_irq_chip_data(irq);
  28. int shift = p->shift*4;
  29. /* Set the priority in IPR to 0 */
  30. ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << shift)), p->addr);
  31. }
  32. static void enable_ipr_irq(unsigned int irq)
  33. {
  34. struct ipr_data *p = get_irq_chip_data(irq);
  35. int shift = p->shift*4;
  36. /* Set priority in IPR back to original value */
  37. ctrl_outw(ctrl_inw(p->addr) | (p->priority << shift), p->addr);
  38. }
  39. static struct irq_chip ipr_irq_chip = {
  40. .name = "IPR",
  41. .mask = disable_ipr_irq,
  42. .unmask = enable_ipr_irq,
  43. .mask_ack = disable_ipr_irq,
  44. };
  45. void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
  46. {
  47. int i;
  48. for (i = 0; i < nr_irqs; i++) {
  49. unsigned int irq = table[i].irq;
  50. disable_irq_nosync(irq);
  51. set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
  52. handle_level_irq, "level");
  53. set_irq_chip_data(irq, &table[i]);
  54. enable_ipr_irq(irq);
  55. }
  56. }
  57. EXPORT_SYMBOL(make_ipr_irq);
  58. /*
  59. * XXX: Move this garbage in to the drivers, and kill off the ridiculous CPU
  60. * subtype checks.
  61. */
  62. static struct ipr_data sys_ipr_map[] = {
  63. #ifndef CONFIG_CPU_SUBTYPE_SH7780
  64. { TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY },
  65. { TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY },
  66. #ifdef RTC_IRQ
  67. { RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY },
  68. #endif
  69. #ifdef SCI_ERI_IRQ
  70. { SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
  71. { SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
  72. { SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
  73. #endif
  74. #ifdef SCIF1_ERI_IRQ
  75. { SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
  76. { SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
  77. { SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
  78. { SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
  79. #endif
  80. #ifdef SCIF2_ERI_IRQ
  81. { SCIF2_ERI_IRQ, SCIF2_IPR_ADDR, SCIF2_IPR_POS, SCIF2_PRIORITY },
  82. { SCIF2_RXI_IRQ, SCIF2_IPR_ADDR, SCIF2_IPR_POS, SCIF2_PRIORITY },
  83. { SCIF2_BRI_IRQ, SCIF2_IPR_ADDR, SCIF2_IPR_POS, SCIF2_PRIORITY },
  84. { SCIF2_TXI_IRQ, SCIF2_IPR_ADDR, SCIF2_IPR_POS, SCIF2_PRIORITY },
  85. #endif
  86. #ifdef SCIF3_ERI_IRQ
  87. { SCIF3_ERI_IRQ, SCIF3_IPR_ADDR, SCIF3_IPR_POS, SCIF3_PRIORITY },
  88. { SCIF3_RXI_IRQ, SCIF3_IPR_ADDR, SCIF3_IPR_POS, SCIF3_PRIORITY },
  89. { SCIF3_BRI_IRQ, SCIF3_IPR_ADDR, SCIF3_IPR_POS, SCIF3_PRIORITY },
  90. { SCIF3_TXI_IRQ, SCIF3_IPR_ADDR, SCIF3_IPR_POS, SCIF3_PRIORITY },
  91. #endif
  92. #if defined(CONFIG_CPU_SUBTYPE_SH7300)
  93. { SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
  94. { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
  95. { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
  96. { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
  97. #endif
  98. #ifdef SCIF_ERI_IRQ
  99. { SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
  100. { SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
  101. { SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
  102. { SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
  103. #endif
  104. #ifdef IRDA_ERI_IRQ
  105. { IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
  106. { IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
  107. { IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
  108. { IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
  109. #endif
  110. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
  111. defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  112. defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
  113. /*
  114. * Initialize the Interrupt Controller (INTC)
  115. * registers to their power on values
  116. */
  117. /*
  118. * Enable external irq (INTC IRQ mode).
  119. * You should set corresponding bits of PFC to "00"
  120. * to enable these interrupts.
  121. */
  122. { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY },
  123. { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY },
  124. { IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY },
  125. { IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY },
  126. { IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY },
  127. { IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY },
  128. #endif
  129. #endif
  130. };
  131. void __init init_IRQ(void)
  132. {
  133. make_ipr_irq(sys_ipr_map, ARRAY_SIZE(sys_ipr_map));
  134. #ifdef CONFIG_CPU_HAS_PINT_IRQ
  135. init_IRQ_pint();
  136. #endif
  137. #ifdef CONFIG_CPU_HAS_INTC2_IRQ
  138. init_IRQ_intc2();
  139. #endif
  140. /* Perform the machine specific initialisation */
  141. if (sh_mv.mv_init_irq != NULL)
  142. sh_mv.mv_init_irq();
  143. irq_ctx_init(smp_processor_id());
  144. }
  145. #if !defined(CONFIG_CPU_HAS_PINT_IRQ)
  146. int ipr_irq_demux(int irq)
  147. {
  148. return irq;
  149. }
  150. #endif