setup_mappi2.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * linux/arch/m32r/kernel/setup_mappi2.c
  3. *
  4. * Setup routines for Renesas MAPPI-II(M3A-ZA36) Board
  5. *
  6. * Copyright (c) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata,
  7. * Hitoshi Yamamoto, Mamoru Sakugawa
  8. */
  9. #include <linux/config.h>
  10. #include <linux/irq.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <asm/system.h>
  15. #include <asm/m32r.h>
  16. #include <asm/io.h>
  17. #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
  18. #ifndef CONFIG_SMP
  19. typedef struct {
  20. unsigned long icucr; /* ICU Control Register */
  21. } icu_data_t;
  22. #endif /* CONFIG_SMP */
  23. icu_data_t icu_data[NR_IRQS];
  24. static void disable_mappi2_irq(unsigned int irq)
  25. {
  26. unsigned long port, data;
  27. if ((irq == 0) ||(irq >= NR_IRQS)) {
  28. printk("bad irq 0x%08x\n", irq);
  29. return;
  30. }
  31. port = irq2port(irq);
  32. data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
  33. outl(data, port);
  34. }
  35. static void enable_mappi2_irq(unsigned int irq)
  36. {
  37. unsigned long port, data;
  38. if ((irq == 0) ||(irq >= NR_IRQS)) {
  39. printk("bad irq 0x%08x\n", irq);
  40. return;
  41. }
  42. port = irq2port(irq);
  43. data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
  44. outl(data, port);
  45. }
  46. static void mask_and_ack_mappi2(unsigned int irq)
  47. {
  48. disable_mappi2_irq(irq);
  49. }
  50. static void end_mappi2_irq(unsigned int irq)
  51. {
  52. enable_mappi2_irq(irq);
  53. }
  54. static unsigned int startup_mappi2_irq(unsigned int irq)
  55. {
  56. enable_mappi2_irq(irq);
  57. return (0);
  58. }
  59. static void shutdown_mappi2_irq(unsigned int irq)
  60. {
  61. unsigned long port;
  62. port = irq2port(irq);
  63. outl(M32R_ICUCR_ILEVEL7, port);
  64. }
  65. static struct hw_interrupt_type mappi2_irq_type =
  66. {
  67. .typename = "MAPPI2-IRQ",
  68. .startup = startup_mappi2_irq,
  69. .shutdown = shutdown_mappi2_irq,
  70. .enable = enable_mappi2_irq,
  71. .disable = disable_mappi2_irq,
  72. .ack = mask_and_ack_mappi2,
  73. .end = end_mappi2_irq
  74. };
  75. void __init init_IRQ(void)
  76. {
  77. #if defined(CONFIG_SMC91X)
  78. /* INT0 : LAN controller (SMC91111) */
  79. irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED;
  80. irq_desc[M32R_IRQ_INT0].handler = &mappi2_irq_type;
  81. irq_desc[M32R_IRQ_INT0].action = 0;
  82. irq_desc[M32R_IRQ_INT0].depth = 1;
  83. icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
  84. disable_mappi2_irq(M32R_IRQ_INT0);
  85. #endif /* CONFIG_SMC91X */
  86. /* MFT2 : system timer */
  87. irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
  88. irq_desc[M32R_IRQ_MFT2].handler = &mappi2_irq_type;
  89. irq_desc[M32R_IRQ_MFT2].action = 0;
  90. irq_desc[M32R_IRQ_MFT2].depth = 1;
  91. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  92. disable_mappi2_irq(M32R_IRQ_MFT2);
  93. #ifdef CONFIG_SERIAL_M32R_SIO
  94. /* SIO0_R : uart receive data */
  95. irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
  96. irq_desc[M32R_IRQ_SIO0_R].handler = &mappi2_irq_type;
  97. irq_desc[M32R_IRQ_SIO0_R].action = 0;
  98. irq_desc[M32R_IRQ_SIO0_R].depth = 1;
  99. icu_data[M32R_IRQ_SIO0_R].icucr = 0;
  100. disable_mappi2_irq(M32R_IRQ_SIO0_R);
  101. /* SIO0_S : uart send data */
  102. irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
  103. irq_desc[M32R_IRQ_SIO0_S].handler = &mappi2_irq_type;
  104. irq_desc[M32R_IRQ_SIO0_S].action = 0;
  105. irq_desc[M32R_IRQ_SIO0_S].depth = 1;
  106. icu_data[M32R_IRQ_SIO0_S].icucr = 0;
  107. disable_mappi2_irq(M32R_IRQ_SIO0_S);
  108. /* SIO1_R : uart receive data */
  109. irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
  110. irq_desc[M32R_IRQ_SIO1_R].handler = &mappi2_irq_type;
  111. irq_desc[M32R_IRQ_SIO1_R].action = 0;
  112. irq_desc[M32R_IRQ_SIO1_R].depth = 1;
  113. icu_data[M32R_IRQ_SIO1_R].icucr = 0;
  114. disable_mappi2_irq(M32R_IRQ_SIO1_R);
  115. /* SIO1_S : uart send data */
  116. irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
  117. irq_desc[M32R_IRQ_SIO1_S].handler = &mappi2_irq_type;
  118. irq_desc[M32R_IRQ_SIO1_S].action = 0;
  119. irq_desc[M32R_IRQ_SIO1_S].depth = 1;
  120. icu_data[M32R_IRQ_SIO1_S].icucr = 0;
  121. disable_mappi2_irq(M32R_IRQ_SIO1_S);
  122. #endif /* CONFIG_M32R_USE_DBG_CONSOLE */
  123. #if defined(CONFIG_USB)
  124. /* INT1 : USB Host controller interrupt */
  125. irq_desc[M32R_IRQ_INT1].status = IRQ_DISABLED;
  126. irq_desc[M32R_IRQ_INT1].handler = &mappi2_irq_type;
  127. irq_desc[M32R_IRQ_INT1].action = 0;
  128. irq_desc[M32R_IRQ_INT1].depth = 1;
  129. icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_ISMOD01;
  130. disable_mappi2_irq(M32R_IRQ_INT1);
  131. #endif /* CONFIG_USB */
  132. /* ICUCR40: CFC IREQ */
  133. irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
  134. irq_desc[PLD_IRQ_CFIREQ].handler = &mappi2_irq_type;
  135. irq_desc[PLD_IRQ_CFIREQ].action = 0;
  136. irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
  137. icu_data[PLD_IRQ_CFIREQ].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
  138. disable_mappi2_irq(PLD_IRQ_CFIREQ);
  139. #if defined(CONFIG_M32R_CFC)
  140. /* ICUCR41: CFC Insert */
  141. irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
  142. irq_desc[PLD_IRQ_CFC_INSERT].handler = &mappi2_irq_type;
  143. irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
  144. irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
  145. icu_data[PLD_IRQ_CFC_INSERT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD00;
  146. disable_mappi2_irq(PLD_IRQ_CFC_INSERT);
  147. /* ICUCR42: CFC Eject */
  148. irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
  149. irq_desc[PLD_IRQ_CFC_EJECT].handler = &mappi2_irq_type;
  150. irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
  151. irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
  152. icu_data[PLD_IRQ_CFC_EJECT].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
  153. disable_mappi2_irq(PLD_IRQ_CFC_EJECT);
  154. #endif /* CONFIG_MAPPI2_CFC */
  155. }
  156. #define LAN_IOSTART 0x300
  157. #define LAN_IOEND 0x320
  158. static struct resource smc91x_resources[] = {
  159. [0] = {
  160. .start = (LAN_IOSTART),
  161. .end = (LAN_IOEND),
  162. .flags = IORESOURCE_MEM,
  163. },
  164. [1] = {
  165. .start = M32R_IRQ_INT0,
  166. .end = M32R_IRQ_INT0,
  167. .flags = IORESOURCE_IRQ,
  168. }
  169. };
  170. static struct platform_device smc91x_device = {
  171. .name = "smc91x",
  172. .id = 0,
  173. .num_resources = ARRAY_SIZE(smc91x_resources),
  174. .resource = smc91x_resources,
  175. };
  176. static int __init platform_init(void)
  177. {
  178. platform_device_register(&smc91x_device);
  179. return 0;
  180. }
  181. arch_initcall(platform_init);