setup.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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/system.h>
  13. #include <asm/m32r.h>
  14. #include <asm/io.h>
  15. #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
  16. icu_data_t icu_data[M32700UT_NUM_CPU_IRQ];
  17. static void disable_mappi_irq(unsigned int irq)
  18. {
  19. unsigned long port, data;
  20. port = irq2port(irq);
  21. data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
  22. outl(data, port);
  23. }
  24. static void enable_mappi_irq(unsigned int irq)
  25. {
  26. unsigned long port, data;
  27. port = irq2port(irq);
  28. data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
  29. outl(data, port);
  30. }
  31. static void mask_and_ack_mappi(unsigned int irq)
  32. {
  33. disable_mappi_irq(irq);
  34. }
  35. static void end_mappi_irq(unsigned int irq)
  36. {
  37. enable_mappi_irq(irq);
  38. }
  39. static unsigned int startup_mappi_irq(unsigned int irq)
  40. {
  41. enable_mappi_irq(irq);
  42. return 0;
  43. }
  44. static void shutdown_mappi_irq(unsigned int irq)
  45. {
  46. unsigned long port;
  47. port = irq2port(irq);
  48. outl(M32R_ICUCR_ILEVEL7, port);
  49. }
  50. static struct irq_chip mappi_irq_type =
  51. {
  52. .typename = "M32700-IRQ",
  53. .startup = startup_mappi_irq,
  54. .shutdown = shutdown_mappi_irq,
  55. .enable = enable_mappi_irq,
  56. .disable = disable_mappi_irq,
  57. .ack = mask_and_ack_mappi,
  58. .end = end_mappi_irq
  59. };
  60. /*
  61. * Interrupt Control Unit of PLD on M32700UT (Level 2)
  62. */
  63. #define irq2pldirq(x) ((x) - M32700UT_PLD_IRQ_BASE)
  64. #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
  65. (((x) - 1) * sizeof(unsigned short)))
  66. typedef struct {
  67. unsigned short icucr; /* ICU Control Register */
  68. } pld_icu_data_t;
  69. static pld_icu_data_t pld_icu_data[M32700UT_NUM_PLD_IRQ];
  70. static void disable_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_ILEVEL7;
  77. outw(data, port);
  78. }
  79. static void enable_m32700ut_pld_irq(unsigned int irq)
  80. {
  81. unsigned long port, data;
  82. unsigned int pldirq;
  83. pldirq = irq2pldirq(irq);
  84. port = pldirq2port(pldirq);
  85. data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  86. outw(data, port);
  87. }
  88. static void mask_and_ack_m32700ut_pld(unsigned int irq)
  89. {
  90. disable_m32700ut_pld_irq(irq);
  91. }
  92. static void end_m32700ut_pld_irq(unsigned int irq)
  93. {
  94. enable_m32700ut_pld_irq(irq);
  95. end_mappi_irq(M32R_IRQ_INT1);
  96. }
  97. static unsigned int startup_m32700ut_pld_irq(unsigned int irq)
  98. {
  99. enable_m32700ut_pld_irq(irq);
  100. return 0;
  101. }
  102. static void shutdown_m32700ut_pld_irq(unsigned int irq)
  103. {
  104. unsigned long port;
  105. unsigned int pldirq;
  106. pldirq = irq2pldirq(irq);
  107. port = pldirq2port(pldirq);
  108. outw(PLD_ICUCR_ILEVEL7, port);
  109. }
  110. static struct irq_chip m32700ut_pld_irq_type =
  111. {
  112. .typename = "USRV-PLD-IRQ",
  113. .startup = startup_m32700ut_pld_irq,
  114. .shutdown = shutdown_m32700ut_pld_irq,
  115. .enable = enable_m32700ut_pld_irq,
  116. .disable = disable_m32700ut_pld_irq,
  117. .ack = mask_and_ack_m32700ut_pld,
  118. .end = end_m32700ut_pld_irq
  119. };
  120. void __init init_IRQ(void)
  121. {
  122. static int once = 0;
  123. int i;
  124. if (once)
  125. return;
  126. else
  127. once++;
  128. /* MFT2 : system timer */
  129. irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
  130. irq_desc[M32R_IRQ_MFT2].chip = &mappi_irq_type;
  131. irq_desc[M32R_IRQ_MFT2].action = 0;
  132. irq_desc[M32R_IRQ_MFT2].depth = 1;
  133. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  134. disable_mappi_irq(M32R_IRQ_MFT2);
  135. #if defined(CONFIG_SERIAL_M32R_SIO)
  136. /* SIO0_R : uart receive data */
  137. irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
  138. irq_desc[M32R_IRQ_SIO0_R].chip = &mappi_irq_type;
  139. irq_desc[M32R_IRQ_SIO0_R].action = 0;
  140. irq_desc[M32R_IRQ_SIO0_R].depth = 1;
  141. icu_data[M32R_IRQ_SIO0_R].icucr = 0;
  142. disable_mappi_irq(M32R_IRQ_SIO0_R);
  143. /* SIO0_S : uart send data */
  144. irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
  145. irq_desc[M32R_IRQ_SIO0_S].chip = &mappi_irq_type;
  146. irq_desc[M32R_IRQ_SIO0_S].action = 0;
  147. irq_desc[M32R_IRQ_SIO0_S].depth = 1;
  148. icu_data[M32R_IRQ_SIO0_S].icucr = 0;
  149. disable_mappi_irq(M32R_IRQ_SIO0_S);
  150. /* SIO1_R : uart receive data */
  151. irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
  152. irq_desc[M32R_IRQ_SIO1_R].chip = &mappi_irq_type;
  153. irq_desc[M32R_IRQ_SIO1_R].action = 0;
  154. irq_desc[M32R_IRQ_SIO1_R].depth = 1;
  155. icu_data[M32R_IRQ_SIO1_R].icucr = 0;
  156. disable_mappi_irq(M32R_IRQ_SIO1_R);
  157. /* SIO1_S : uart send data */
  158. irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
  159. irq_desc[M32R_IRQ_SIO1_S].chip = &mappi_irq_type;
  160. irq_desc[M32R_IRQ_SIO1_S].action = 0;
  161. irq_desc[M32R_IRQ_SIO1_S].depth = 1;
  162. icu_data[M32R_IRQ_SIO1_S].icucr = 0;
  163. disable_mappi_irq(M32R_IRQ_SIO1_S);
  164. #endif /* CONFIG_SERIAL_M32R_SIO */
  165. /* INT#67-#71: CFC#0 IREQ on PLD */
  166. for (i = 0 ; i < CONFIG_M32R_CFC_NUM ; i++ ) {
  167. irq_desc[PLD_IRQ_CF0 + i].status = IRQ_DISABLED;
  168. irq_desc[PLD_IRQ_CF0 + i].chip = &m32700ut_pld_irq_type;
  169. irq_desc[PLD_IRQ_CF0 + i].action = 0;
  170. irq_desc[PLD_IRQ_CF0 + i].depth = 1; /* disable nested irq */
  171. pld_icu_data[irq2pldirq(PLD_IRQ_CF0 + i)].icucr
  172. = PLD_ICUCR_ISMOD01; /* 'L' level sense */
  173. disable_m32700ut_pld_irq(PLD_IRQ_CF0 + i);
  174. }
  175. #if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
  176. /* INT#76: 16552D#0 IREQ on PLD */
  177. irq_desc[PLD_IRQ_UART0].status = IRQ_DISABLED;
  178. irq_desc[PLD_IRQ_UART0].chip = &m32700ut_pld_irq_type;
  179. irq_desc[PLD_IRQ_UART0].action = 0;
  180. irq_desc[PLD_IRQ_UART0].depth = 1; /* disable nested irq */
  181. pld_icu_data[irq2pldirq(PLD_IRQ_UART0)].icucr
  182. = PLD_ICUCR_ISMOD03; /* 'H' level sense */
  183. disable_m32700ut_pld_irq(PLD_IRQ_UART0);
  184. /* INT#77: 16552D#1 IREQ on PLD */
  185. irq_desc[PLD_IRQ_UART1].status = IRQ_DISABLED;
  186. irq_desc[PLD_IRQ_UART1].chip = &m32700ut_pld_irq_type;
  187. irq_desc[PLD_IRQ_UART1].action = 0;
  188. irq_desc[PLD_IRQ_UART1].depth = 1; /* disable nested irq */
  189. pld_icu_data[irq2pldirq(PLD_IRQ_UART1)].icucr
  190. = PLD_ICUCR_ISMOD03; /* 'H' level sense */
  191. disable_m32700ut_pld_irq(PLD_IRQ_UART1);
  192. #endif /* CONFIG_SERIAL_8250 || CONFIG_SERIAL_8250_MODULE */
  193. #if defined(CONFIG_IDC_AK4524) || defined(CONFIG_IDC_AK4524_MODULE)
  194. /* INT#80: AK4524 IREQ on PLD */
  195. irq_desc[PLD_IRQ_SNDINT].status = IRQ_DISABLED;
  196. irq_desc[PLD_IRQ_SNDINT].chip = &m32700ut_pld_irq_type;
  197. irq_desc[PLD_IRQ_SNDINT].action = 0;
  198. irq_desc[PLD_IRQ_SNDINT].depth = 1; /* disable nested irq */
  199. pld_icu_data[irq2pldirq(PLD_IRQ_SNDINT)].icucr
  200. = PLD_ICUCR_ISMOD01; /* 'L' level sense */
  201. disable_m32700ut_pld_irq(PLD_IRQ_SNDINT);
  202. #endif /* CONFIG_IDC_AK4524 || CONFIG_IDC_AK4524_MODULE */
  203. /*
  204. * INT1# is used for UART, MMC, CF Controller in FPGA.
  205. * We enable it here.
  206. */
  207. icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD11;
  208. enable_mappi_irq(M32R_IRQ_INT1);
  209. }