setup.c 5.3 KB

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