setup_usrv.c 6.8 KB

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