setup_usrv.c 6.6 KB

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