setup-sh7750.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 <asm/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. /* Period IRQ */
  24. .start = 21,
  25. .flags = IORESOURCE_IRQ,
  26. },
  27. [2] = {
  28. /* Carry IRQ */
  29. .start = 22,
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. [3] = {
  33. /* Alarm IRQ */
  34. .start = 20,
  35. .flags = IORESOURCE_IRQ,
  36. },
  37. };
  38. static struct platform_device rtc_device = {
  39. .name = "sh-rtc",
  40. .id = -1,
  41. .num_resources = ARRAY_SIZE(rtc_resources),
  42. .resource = rtc_resources,
  43. };
  44. static struct plat_sci_port sci_platform_data[] = {
  45. {
  46. #ifndef CONFIG_SH_RTS7751R2D
  47. .mapbase = 0xffe00000,
  48. .flags = UPF_BOOT_AUTOCONF,
  49. .type = PORT_SCI,
  50. .irqs = { 23, 24, 25, 0 },
  51. }, {
  52. #endif
  53. .mapbase = 0xffe80000,
  54. .flags = UPF_BOOT_AUTOCONF,
  55. .type = PORT_SCIF,
  56. .irqs = { 40, 41, 43, 42 },
  57. }, {
  58. .flags = 0,
  59. }
  60. };
  61. static struct platform_device sci_device = {
  62. .name = "sh-sci",
  63. .id = -1,
  64. .dev = {
  65. .platform_data = sci_platform_data,
  66. },
  67. };
  68. static struct platform_device *sh7750_devices[] __initdata = {
  69. &rtc_device,
  70. &sci_device,
  71. };
  72. static int __init sh7750_devices_setup(void)
  73. {
  74. return platform_add_devices(sh7750_devices,
  75. ARRAY_SIZE(sh7750_devices));
  76. }
  77. __initcall(sh7750_devices_setup);
  78. enum {
  79. UNUSED = 0,
  80. /* interrupt sources */
  81. IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
  82. HUDI, GPIOI,
  83. DMAC_DMTE0, DMAC_DMTE1, DMAC_DMTE2, DMAC_DMTE3,
  84. DMAC_DMTE4, DMAC_DMTE5, DMAC_DMTE6, DMAC_DMTE7,
  85. DMAC_DMAE,
  86. PCIC0_PCISERR, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  87. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3,
  88. TMU3, TMU4, TMU0, TMU1, TMU2_TUNI, TMU2_TICPI,
  89. RTC_ATI, RTC_PRI, RTC_CUI,
  90. SCI1_ERI, SCI1_RXI, SCI1_TXI, SCI1_TEI,
  91. SCIF_ERI, SCIF_RXI, SCIF_BRI, SCIF_TXI,
  92. WDT,
  93. REF_RCMI, REF_ROVI,
  94. /* interrupt groups */
  95. DMAC, PCIC1, TMU2, RTC, SCI1, SCIF, REF,
  96. };
  97. static struct intc_vect vectors[] __initdata = {
  98. INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620),
  99. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  100. INTC_VECT(TMU2_TUNI, 0x440), INTC_VECT(TMU2_TICPI, 0x460),
  101. INTC_VECT(RTC_ATI, 0x480), INTC_VECT(RTC_PRI, 0x4a0),
  102. INTC_VECT(RTC_CUI, 0x4c0),
  103. INTC_VECT(SCI1_ERI, 0x4e0), INTC_VECT(SCI1_RXI, 0x500),
  104. INTC_VECT(SCI1_TXI, 0x520), INTC_VECT(SCI1_TEI, 0x540),
  105. INTC_VECT(SCIF_ERI, 0x700), INTC_VECT(SCIF_RXI, 0x720),
  106. INTC_VECT(SCIF_BRI, 0x740), INTC_VECT(SCIF_TXI, 0x760),
  107. INTC_VECT(WDT, 0x560),
  108. INTC_VECT(REF_RCMI, 0x580), INTC_VECT(REF_ROVI, 0x5a0),
  109. };
  110. static struct intc_group groups[] __initdata = {
  111. INTC_GROUP(TMU2, TMU2_TUNI, TMU2_TICPI),
  112. INTC_GROUP(RTC, RTC_ATI, RTC_PRI, RTC_CUI),
  113. INTC_GROUP(SCI1, SCI1_ERI, SCI1_RXI, SCI1_TXI, SCI1_TEI),
  114. INTC_GROUP(SCIF, SCIF_ERI, SCIF_RXI, SCIF_BRI, SCIF_TXI),
  115. INTC_GROUP(REF, REF_RCMI, REF_ROVI),
  116. };
  117. static struct intc_prio priorities[] __initdata = {
  118. INTC_PRIO(SCIF, 3),
  119. INTC_PRIO(SCI1, 3),
  120. INTC_PRIO(DMAC, 7),
  121. };
  122. static struct intc_prio_reg prio_registers[] __initdata = {
  123. { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  124. { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, SCI1, 0 } },
  125. { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, SCIF, HUDI } },
  126. { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
  127. { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
  128. TMU4, TMU3,
  129. PCIC1, PCIC0_PCISERR } },
  130. };
  131. static DECLARE_INTC_DESC(intc_desc, "sh7750", vectors, groups,
  132. priorities, NULL, prio_registers, NULL);
  133. /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
  134. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  135. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  136. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  137. defined(CONFIG_CPU_SUBTYPE_SH7091)
  138. static struct intc_vect vectors_dma4[] __initdata = {
  139. INTC_VECT(DMAC_DMTE0, 0x640), INTC_VECT(DMAC_DMTE1, 0x660),
  140. INTC_VECT(DMAC_DMTE2, 0x680), INTC_VECT(DMAC_DMTE3, 0x6a0),
  141. INTC_VECT(DMAC_DMAE, 0x6c0),
  142. };
  143. static struct intc_group groups_dma4[] __initdata = {
  144. INTC_GROUP(DMAC, DMAC_DMTE0, DMAC_DMTE1, DMAC_DMTE2,
  145. DMAC_DMTE3, DMAC_DMAE),
  146. };
  147. static DECLARE_INTC_DESC(intc_desc_dma4, "sh7750_dma4",
  148. vectors_dma4, groups_dma4,
  149. priorities, NULL, prio_registers, NULL);
  150. #endif
  151. /* SH7750R and SH7751R both have 8-channel DMA controllers */
  152. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  153. static struct intc_vect vectors_dma8[] __initdata = {
  154. INTC_VECT(DMAC_DMTE0, 0x640), INTC_VECT(DMAC_DMTE1, 0x660),
  155. INTC_VECT(DMAC_DMTE2, 0x680), INTC_VECT(DMAC_DMTE3, 0x6a0),
  156. INTC_VECT(DMAC_DMTE4, 0x780), INTC_VECT(DMAC_DMTE5, 0x7a0),
  157. INTC_VECT(DMAC_DMTE6, 0x7c0), INTC_VECT(DMAC_DMTE7, 0x7e0),
  158. INTC_VECT(DMAC_DMAE, 0x6c0),
  159. };
  160. static struct intc_group groups_dma8[] __initdata = {
  161. INTC_GROUP(DMAC, DMAC_DMTE0, DMAC_DMTE1, DMAC_DMTE2,
  162. DMAC_DMTE3, DMAC_DMTE4, DMAC_DMTE5,
  163. DMAC_DMTE6, DMAC_DMTE7, DMAC_DMAE),
  164. };
  165. static DECLARE_INTC_DESC(intc_desc_dma8, "sh7750_dma8",
  166. vectors_dma8, groups_dma8,
  167. priorities, NULL, prio_registers, NULL);
  168. #endif
  169. /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
  170. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  171. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  172. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  173. static struct intc_vect vectors_tmu34[] __initdata = {
  174. INTC_VECT(TMU3, 0xb00), INTC_VECT(TMU4, 0xb80),
  175. };
  176. static struct intc_mask_reg mask_registers[] __initdata = {
  177. { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
  178. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  179. 0, 0, 0, 0, 0, 0, TMU4, TMU3,
  180. PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  181. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2,
  182. PCIC1_PCIDMA3, PCIC0_PCISERR } },
  183. };
  184. static DECLARE_INTC_DESC(intc_desc_tmu34, "sh7750_tmu34",
  185. vectors_tmu34, NULL, priorities,
  186. mask_registers, prio_registers, NULL);
  187. #endif
  188. /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
  189. static struct intc_vect vectors_irlm[] __initdata = {
  190. INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
  191. INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
  192. };
  193. static DECLARE_INTC_DESC(intc_desc_irlm, "sh7750_irlm", vectors_irlm, NULL,
  194. priorities, NULL, prio_registers, NULL);
  195. /* SH7751 and SH7751R both have PCI */
  196. #if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  197. static struct intc_vect vectors_pci[] __initdata = {
  198. INTC_VECT(PCIC0_PCISERR, 0xa00), INTC_VECT(PCIC1_PCIERR, 0xae0),
  199. INTC_VECT(PCIC1_PCIPWDWN, 0xac0), INTC_VECT(PCIC1_PCIPWON, 0xaa0),
  200. INTC_VECT(PCIC1_PCIDMA0, 0xa80), INTC_VECT(PCIC1_PCIDMA1, 0xa60),
  201. INTC_VECT(PCIC1_PCIDMA2, 0xa40), INTC_VECT(PCIC1_PCIDMA3, 0xa20),
  202. };
  203. static struct intc_group groups_pci[] __initdata = {
  204. INTC_GROUP(PCIC1, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  205. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3),
  206. };
  207. static DECLARE_INTC_DESC(intc_desc_pci, "sh7750_pci", vectors_pci, groups_pci,
  208. priorities, mask_registers, prio_registers, NULL);
  209. #endif
  210. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  211. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  212. defined(CONFIG_CPU_SUBTYPE_SH7091)
  213. void __init plat_irq_setup(void)
  214. {
  215. /*
  216. * same vectors for SH7750, SH7750S and SH7091 except for IRLM,
  217. * see below..
  218. */
  219. register_intc_controller(&intc_desc);
  220. register_intc_controller(&intc_desc_dma4);
  221. }
  222. #endif
  223. #if defined(CONFIG_CPU_SUBTYPE_SH7750R)
  224. void __init plat_irq_setup(void)
  225. {
  226. register_intc_controller(&intc_desc);
  227. register_intc_controller(&intc_desc_dma8);
  228. register_intc_controller(&intc_desc_tmu34);
  229. }
  230. #endif
  231. #if defined(CONFIG_CPU_SUBTYPE_SH7751)
  232. void __init plat_irq_setup(void)
  233. {
  234. register_intc_controller(&intc_desc);
  235. register_intc_controller(&intc_desc_dma4);
  236. register_intc_controller(&intc_desc_tmu34);
  237. register_intc_controller(&intc_desc_pci);
  238. }
  239. #endif
  240. #if defined(CONFIG_CPU_SUBTYPE_SH7751R)
  241. void __init plat_irq_setup(void)
  242. {
  243. register_intc_controller(&intc_desc);
  244. register_intc_controller(&intc_desc_dma8);
  245. register_intc_controller(&intc_desc_tmu34);
  246. register_intc_controller(&intc_desc_pci);
  247. }
  248. #endif
  249. #define INTC_ICR 0xffd00000UL
  250. #define INTC_ICR_IRLM (1<<7)
  251. void __init plat_irq_setup_pins(int mode)
  252. {
  253. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)
  254. BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */
  255. return;
  256. #endif
  257. switch (mode) {
  258. case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
  259. ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  260. register_intc_controller(&intc_desc_irlm);
  261. break;
  262. default:
  263. BUG();
  264. }
  265. }