setup.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * linux/arch/m32r/platforms/usrv/setup.c
  3. *
  4. * Setup routines for MITSUBISHI uServer
  5. *
  6. * Copyright (c) 2001, 2002, 2003 Hiroyuki Kondo, Hirokazu Takata,
  7. * Hitoshi Yamamoto
  8. */
  9. #include <linux/irq.h>
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <asm/m32r.h>
  13. #include <asm/io.h>
  14. #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
  15. icu_data_t icu_data[M32700UT_NUM_CPU_IRQ];
  16. static void disable_mappi_irq(unsigned int irq)
  17. {
  18. unsigned long port, data;
  19. port = irq2port(irq);
  20. data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
  21. outl(data, port);
  22. }
  23. static void enable_mappi_irq(unsigned int irq)
  24. {
  25. unsigned long port, data;
  26. port = irq2port(irq);
  27. data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
  28. outl(data, port);
  29. }
  30. static void mask_mappi(struct irq_data *data)
  31. {
  32. disable_mappi_irq(data->irq);
  33. }
  34. static void unmask_mappi(struct irq_data *data)
  35. {
  36. enable_mappi_irq(data->irq);
  37. }
  38. static void shutdown_mappi(struct irq_data *data)
  39. {
  40. unsigned long port;
  41. port = irq2port(data->irq);
  42. outl(M32R_ICUCR_ILEVEL7, port);
  43. }
  44. static struct irq_chip mappi_irq_type =
  45. {
  46. .name = "M32700-IRQ",
  47. .irq_shutdown = shutdown_mappi,
  48. .irq_mask = mask_mappi,
  49. .irq_unmask = unmask_mappi,
  50. };
  51. /*
  52. * Interrupt Control Unit of PLD on M32700UT (Level 2)
  53. */
  54. #define irq2pldirq(x) ((x) - M32700UT_PLD_IRQ_BASE)
  55. #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
  56. (((x) - 1) * sizeof(unsigned short)))
  57. typedef struct {
  58. unsigned short icucr; /* ICU Control Register */
  59. } pld_icu_data_t;
  60. static pld_icu_data_t pld_icu_data[M32700UT_NUM_PLD_IRQ];
  61. static void disable_m32700ut_pld_irq(unsigned int irq)
  62. {
  63. unsigned long port, data;
  64. unsigned int pldirq;
  65. pldirq = irq2pldirq(irq);
  66. port = pldirq2port(pldirq);
  67. data = pld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
  68. outw(data, port);
  69. }
  70. static void enable_m32700ut_pld_irq(unsigned int irq)
  71. {
  72. unsigned long port, data;
  73. unsigned int pldirq;
  74. pldirq = irq2pldirq(irq);
  75. port = pldirq2port(pldirq);
  76. data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  77. outw(data, port);
  78. }
  79. static void mask_m32700ut_pld(struct irq_data *data)
  80. {
  81. disable_m32700ut_pld_irq(data->irq);
  82. }
  83. static void unmask_m32700ut_pld(struct irq_data *data)
  84. {
  85. enable_m32700ut_pld_irq(data->irq);
  86. enable_mappi_irq(M32R_IRQ_INT1);
  87. }
  88. static void shutdown_m32700ut_pld(struct irq_data *data)
  89. {
  90. unsigned long port;
  91. unsigned int pldirq;
  92. pldirq = irq2pldirq(data->irq);
  93. port = pldirq2port(pldirq);
  94. outw(PLD_ICUCR_ILEVEL7, port);
  95. }
  96. static struct irq_chip m32700ut_pld_irq_type =
  97. {
  98. .name = "USRV-PLD-IRQ",
  99. .irq_shutdown = shutdown_m32700ut_pld,
  100. .irq_mask = mask_m32700ut_pld,
  101. .irq_unmask = unmask_m32700ut_pld,
  102. };
  103. void __init init_IRQ(void)
  104. {
  105. static int once = 0;
  106. int i;
  107. if (once)
  108. return;
  109. else
  110. once++;
  111. /* MFT2 : system timer */
  112. irq_set_chip_and_handler(M32R_IRQ_MFT2, &mappi_irq_type,
  113. handle_level_irq);
  114. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  115. disable_mappi_irq(M32R_IRQ_MFT2);
  116. #if defined(CONFIG_SERIAL_M32R_SIO)
  117. /* SIO0_R : uart receive data */
  118. irq_set_chip_and_handler(M32R_IRQ_SIO0_R, &mappi_irq_type,
  119. handle_level_irq);
  120. icu_data[M32R_IRQ_SIO0_R].icucr = 0;
  121. disable_mappi_irq(M32R_IRQ_SIO0_R);
  122. /* SIO0_S : uart send data */
  123. irq_set_chip_and_handler(M32R_IRQ_SIO0_S, &mappi_irq_type,
  124. handle_level_irq);
  125. icu_data[M32R_IRQ_SIO0_S].icucr = 0;
  126. disable_mappi_irq(M32R_IRQ_SIO0_S);
  127. /* SIO1_R : uart receive data */
  128. irq_set_chip_and_handler(M32R_IRQ_SIO1_R, &mappi_irq_type,
  129. handle_level_irq);
  130. icu_data[M32R_IRQ_SIO1_R].icucr = 0;
  131. disable_mappi_irq(M32R_IRQ_SIO1_R);
  132. /* SIO1_S : uart send data */
  133. irq_set_chip_and_handler(M32R_IRQ_SIO1_S, &mappi_irq_type,
  134. handle_level_irq);
  135. icu_data[M32R_IRQ_SIO1_S].icucr = 0;
  136. disable_mappi_irq(M32R_IRQ_SIO1_S);
  137. #endif /* CONFIG_SERIAL_M32R_SIO */
  138. /* INT#67-#71: CFC#0 IREQ on PLD */
  139. for (i = 0 ; i < CONFIG_M32R_CFC_NUM ; i++ ) {
  140. irq_set_chip_and_handler(PLD_IRQ_CF0 + i,
  141. &m32700ut_pld_irq_type,
  142. handle_level_irq);
  143. pld_icu_data[irq2pldirq(PLD_IRQ_CF0 + i)].icucr
  144. = PLD_ICUCR_ISMOD01; /* 'L' level sense */
  145. disable_m32700ut_pld_irq(PLD_IRQ_CF0 + i);
  146. }
  147. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  148. /* INT#76: 16552D#0 IREQ on PLD */
  149. irq_set_chip_and_handler(PLD_IRQ_UART0, &m32700ut_pld_irq_type,
  150. handle_level_irq);
  151. pld_icu_data[irq2pldirq(PLD_IRQ_UART0)].icucr
  152. = PLD_ICUCR_ISMOD03; /* 'H' level sense */
  153. disable_m32700ut_pld_irq(PLD_IRQ_UART0);
  154. /* INT#77: 16552D#1 IREQ on PLD */
  155. irq_set_chip_and_handler(PLD_IRQ_UART1, &m32700ut_pld_irq_type,
  156. handle_level_irq);
  157. pld_icu_data[irq2pldirq(PLD_IRQ_UART1)].icucr
  158. = PLD_ICUCR_ISMOD03; /* 'H' level sense */
  159. disable_m32700ut_pld_irq(PLD_IRQ_UART1);
  160. #endif /* CONFIG_SERIAL_8250 || CONFIG_SERIAL_8250_MODULE */
  161. #if defined(CONFIG_IDC_AK4524) || defined(CONFIG_IDC_AK4524_MODULE)
  162. /* INT#80: AK4524 IREQ on PLD */
  163. irq_set_chip_and_handler(PLD_IRQ_SNDINT, &m32700ut_pld_irq_type,
  164. handle_level_irq);
  165. pld_icu_data[irq2pldirq(PLD_IRQ_SNDINT)].icucr
  166. = PLD_ICUCR_ISMOD01; /* 'L' level sense */
  167. disable_m32700ut_pld_irq(PLD_IRQ_SNDINT);
  168. #endif /* CONFIG_IDC_AK4524 || CONFIG_IDC_AK4524_MODULE */
  169. /*
  170. * INT1# is used for UART, MMC, CF Controller in FPGA.
  171. * We enable it here.
  172. */
  173. icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD11;
  174. enable_mappi_irq(M32R_IRQ_INT1);
  175. }