ipr.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. struct ipr_data {
  26. unsigned int addr; /* Address of Interrupt Priority Register */
  27. int shift; /* Shifts of the 16-bit data */
  28. int priority; /* The priority */
  29. };
  30. static void disable_ipr_irq(unsigned int irq)
  31. {
  32. struct ipr_data *p = get_irq_chip_data(irq);
  33. /* Set the priority in IPR to 0 */
  34. ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << p->shift)), p->addr);
  35. }
  36. static void enable_ipr_irq(unsigned int irq)
  37. {
  38. struct ipr_data *p = get_irq_chip_data(irq);
  39. /* Set priority in IPR back to original value */
  40. ctrl_outw(ctrl_inw(p->addr) | (p->priority << p->shift), p->addr);
  41. }
  42. static struct irq_chip ipr_irq_chip = {
  43. .name = "IPR",
  44. .mask = disable_ipr_irq,
  45. .unmask = enable_ipr_irq,
  46. .mask_ack = disable_ipr_irq,
  47. };
  48. void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority)
  49. {
  50. struct ipr_data ipr_data;
  51. disable_irq_nosync(irq);
  52. ipr_data.addr = addr;
  53. ipr_data.shift = pos*4; /* POSition (0-3) x 4 means shift */
  54. ipr_data.priority = priority;
  55. set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
  56. handle_level_irq, "level");
  57. set_irq_chip_data(irq, &ipr_data);
  58. enable_ipr_irq(irq);
  59. }
  60. /* XXX: This needs to die a horrible death.. */
  61. void __init init_IRQ(void)
  62. {
  63. #ifndef CONFIG_CPU_SUBTYPE_SH7780
  64. make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY);
  65. make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY);
  66. #ifdef RTC_IRQ
  67. make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY);
  68. #endif
  69. #ifdef SCI_ERI_IRQ
  70. make_ipr_irq(SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY);
  71. make_ipr_irq(SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY);
  72. make_ipr_irq(SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY);
  73. #endif
  74. #ifdef SCIF1_ERI_IRQ
  75. make_ipr_irq(SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
  76. make_ipr_irq(SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
  77. make_ipr_irq(SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
  78. make_ipr_irq(SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY);
  79. #endif
  80. #if defined(CONFIG_CPU_SUBTYPE_SH7300)
  81. make_ipr_irq(SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY);
  82. make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
  83. make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
  84. make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
  85. #endif
  86. #ifdef SCIF_ERI_IRQ
  87. make_ipr_irq(SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
  88. make_ipr_irq(SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
  89. make_ipr_irq(SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
  90. make_ipr_irq(SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY);
  91. #endif
  92. #ifdef IRDA_ERI_IRQ
  93. make_ipr_irq(IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
  94. make_ipr_irq(IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
  95. make_ipr_irq(IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
  96. make_ipr_irq(IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY);
  97. #endif
  98. #if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
  99. defined(CONFIG_CPU_SUBTYPE_SH7706) || \
  100. defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
  101. /*
  102. * Initialize the Interrupt Controller (INTC)
  103. * registers to their power on values
  104. */
  105. /*
  106. * Enable external irq (INTC IRQ mode).
  107. * You should set corresponding bits of PFC to "00"
  108. * to enable these interrupts.
  109. */
  110. make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY);
  111. make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY);
  112. make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY);
  113. make_ipr_irq(IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY);
  114. make_ipr_irq(IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY);
  115. make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY);
  116. #endif
  117. #endif
  118. #ifdef CONFIG_CPU_HAS_PINT_IRQ
  119. init_IRQ_pint();
  120. #endif
  121. #ifdef CONFIG_CPU_HAS_INTC2_IRQ
  122. init_IRQ_intc2();
  123. #endif
  124. /* Perform the machine specific initialisation */
  125. if (sh_mv.mv_init_irq != NULL)
  126. sh_mv.mv_init_irq();
  127. irq_ctx_init(smp_processor_id());
  128. }
  129. #if !defined(CONFIG_CPU_HAS_PINT_IRQ)
  130. int ipr_irq_demux(int irq)
  131. {
  132. return irq;
  133. }
  134. #endif
  135. EXPORT_SYMBOL(make_ipr_irq);