setup-sh7750.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /*
  2. * SH7750/SH7751 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. * Copyright (C) 2006 Jamie Lenehan
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/platform_device.h>
  12. #include <linux/init.h>
  13. #include <linux/serial.h>
  14. #include <linux/io.h>
  15. #include <linux/serial_sci.h>
  16. static struct resource rtc_resources[] = {
  17. [0] = {
  18. .start = 0xffc80000,
  19. .end = 0xffc80000 + 0x58 - 1,
  20. .flags = IORESOURCE_IO,
  21. },
  22. [1] = {
  23. /* Shared Period/Carry/Alarm IRQ */
  24. .start = 20,
  25. .flags = IORESOURCE_IRQ,
  26. },
  27. };
  28. static struct platform_device rtc_device = {
  29. .name = "sh-rtc",
  30. .id = -1,
  31. .num_resources = ARRAY_SIZE(rtc_resources),
  32. .resource = rtc_resources,
  33. };
  34. static struct plat_sci_port sci_platform_data[] = {
  35. {
  36. #ifndef CONFIG_SH_RTS7751R2D
  37. .mapbase = 0xffe00000,
  38. .flags = UPF_BOOT_AUTOCONF,
  39. .type = PORT_SCI,
  40. .irqs = { 23, 23, 23, 0 },
  41. }, {
  42. #endif
  43. .mapbase = 0xffe80000,
  44. .flags = UPF_BOOT_AUTOCONF,
  45. .type = PORT_SCIF,
  46. .irqs = { 40, 40, 40, 40 },
  47. }, {
  48. .flags = 0,
  49. }
  50. };
  51. static struct platform_device sci_device = {
  52. .name = "sh-sci",
  53. .id = -1,
  54. .dev = {
  55. .platform_data = sci_platform_data,
  56. },
  57. };
  58. static struct platform_device *sh7750_devices[] __initdata = {
  59. &rtc_device,
  60. &sci_device,
  61. };
  62. static int __init sh7750_devices_setup(void)
  63. {
  64. return platform_add_devices(sh7750_devices,
  65. ARRAY_SIZE(sh7750_devices));
  66. }
  67. __initcall(sh7750_devices_setup);
  68. enum {
  69. UNUSED = 0,
  70. /* interrupt sources */
  71. IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
  72. HUDI, GPIOI, DMAC,
  73. PCIC0_PCISERR, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  74. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3,
  75. TMU3, TMU4, TMU0, TMU1, TMU2, RTC, SCI1, SCIF, WDT, REF,
  76. /* interrupt groups */
  77. PCIC1,
  78. };
  79. static struct intc_vect vectors[] __initdata = {
  80. INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620),
  81. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  82. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  83. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  84. INTC_VECT(RTC, 0x4c0),
  85. INTC_VECT(SCI1, 0x4e0), INTC_VECT(SCI1, 0x500),
  86. INTC_VECT(SCI1, 0x520), INTC_VECT(SCI1, 0x540),
  87. INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),
  88. INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),
  89. INTC_VECT(WDT, 0x560),
  90. INTC_VECT(REF, 0x580), INTC_VECT(REF, 0x5a0),
  91. };
  92. static struct intc_prio_reg prio_registers[] __initdata = {
  93. { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  94. { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, SCI1, 0 } },
  95. { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, SCIF, HUDI } },
  96. { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
  97. { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
  98. TMU4, TMU3,
  99. PCIC1, PCIC0_PCISERR } },
  100. };
  101. static DECLARE_INTC_DESC(intc_desc, "sh7750", vectors, NULL,
  102. NULL, prio_registers, NULL);
  103. /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
  104. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  105. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  106. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  107. defined(CONFIG_CPU_SUBTYPE_SH7091)
  108. static struct intc_vect vectors_dma4[] __initdata = {
  109. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  110. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  111. INTC_VECT(DMAC, 0x6c0),
  112. };
  113. static DECLARE_INTC_DESC(intc_desc_dma4, "sh7750_dma4",
  114. vectors_dma4, NULL,
  115. NULL, prio_registers, NULL);
  116. #endif
  117. /* SH7750R and SH7751R both have 8-channel DMA controllers */
  118. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  119. static struct intc_vect vectors_dma8[] __initdata = {
  120. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  121. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  122. INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),
  123. INTC_VECT(DMAC, 0x7c0), INTC_VECT(DMAC, 0x7e0),
  124. INTC_VECT(DMAC, 0x6c0),
  125. };
  126. static DECLARE_INTC_DESC(intc_desc_dma8, "sh7750_dma8",
  127. vectors_dma8, NULL,
  128. NULL, prio_registers, NULL);
  129. #endif
  130. /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
  131. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  132. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  133. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  134. static struct intc_vect vectors_tmu34[] __initdata = {
  135. INTC_VECT(TMU3, 0xb00), INTC_VECT(TMU4, 0xb80),
  136. };
  137. static struct intc_mask_reg mask_registers[] __initdata = {
  138. { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
  139. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  140. 0, 0, 0, 0, 0, 0, TMU4, TMU3,
  141. PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  142. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2,
  143. PCIC1_PCIDMA3, PCIC0_PCISERR } },
  144. };
  145. static DECLARE_INTC_DESC(intc_desc_tmu34, "sh7750_tmu34",
  146. vectors_tmu34, NULL,
  147. mask_registers, prio_registers, NULL);
  148. #endif
  149. /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
  150. static struct intc_vect vectors_irlm[] __initdata = {
  151. INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
  152. INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
  153. };
  154. static DECLARE_INTC_DESC(intc_desc_irlm, "sh7750_irlm", vectors_irlm, NULL,
  155. NULL, prio_registers, NULL);
  156. /* SH7751 and SH7751R both have PCI */
  157. #if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  158. static struct intc_vect vectors_pci[] __initdata = {
  159. INTC_VECT(PCIC0_PCISERR, 0xa00), INTC_VECT(PCIC1_PCIERR, 0xae0),
  160. INTC_VECT(PCIC1_PCIPWDWN, 0xac0), INTC_VECT(PCIC1_PCIPWON, 0xaa0),
  161. INTC_VECT(PCIC1_PCIDMA0, 0xa80), INTC_VECT(PCIC1_PCIDMA1, 0xa60),
  162. INTC_VECT(PCIC1_PCIDMA2, 0xa40), INTC_VECT(PCIC1_PCIDMA3, 0xa20),
  163. };
  164. static struct intc_group groups_pci[] __initdata = {
  165. INTC_GROUP(PCIC1, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  166. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3),
  167. };
  168. static DECLARE_INTC_DESC(intc_desc_pci, "sh7750_pci", vectors_pci, groups_pci,
  169. mask_registers, prio_registers, NULL);
  170. #endif
  171. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  172. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  173. defined(CONFIG_CPU_SUBTYPE_SH7091)
  174. void __init plat_irq_setup(void)
  175. {
  176. /*
  177. * same vectors for SH7750, SH7750S and SH7091 except for IRLM,
  178. * see below..
  179. */
  180. register_intc_controller(&intc_desc);
  181. register_intc_controller(&intc_desc_dma4);
  182. }
  183. #endif
  184. #if defined(CONFIG_CPU_SUBTYPE_SH7750R)
  185. void __init plat_irq_setup(void)
  186. {
  187. register_intc_controller(&intc_desc);
  188. register_intc_controller(&intc_desc_dma8);
  189. register_intc_controller(&intc_desc_tmu34);
  190. }
  191. #endif
  192. #if defined(CONFIG_CPU_SUBTYPE_SH7751)
  193. void __init plat_irq_setup(void)
  194. {
  195. register_intc_controller(&intc_desc);
  196. register_intc_controller(&intc_desc_dma4);
  197. register_intc_controller(&intc_desc_tmu34);
  198. register_intc_controller(&intc_desc_pci);
  199. }
  200. #endif
  201. #if defined(CONFIG_CPU_SUBTYPE_SH7751R)
  202. void __init plat_irq_setup(void)
  203. {
  204. register_intc_controller(&intc_desc);
  205. register_intc_controller(&intc_desc_dma8);
  206. register_intc_controller(&intc_desc_tmu34);
  207. register_intc_controller(&intc_desc_pci);
  208. }
  209. #endif
  210. #define INTC_ICR 0xffd00000UL
  211. #define INTC_ICR_IRLM (1<<7)
  212. void __init plat_irq_setup_pins(int mode)
  213. {
  214. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)
  215. BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */
  216. return;
  217. #endif
  218. switch (mode) {
  219. case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
  220. ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  221. register_intc_controller(&intc_desc_irlm);
  222. break;
  223. default:
  224. BUG();
  225. }
  226. }