setup-sh7750.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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/sh_timer.h>
  16. #include <linux/serial_sci.h>
  17. static struct resource rtc_resources[] = {
  18. [0] = {
  19. .start = 0xffc80000,
  20. .end = 0xffc80000 + 0x58 - 1,
  21. .flags = IORESOURCE_IO,
  22. },
  23. [1] = {
  24. /* Shared Period/Carry/Alarm IRQ */
  25. .start = 20,
  26. .flags = IORESOURCE_IRQ,
  27. },
  28. };
  29. static struct platform_device rtc_device = {
  30. .name = "sh-rtc",
  31. .id = -1,
  32. .num_resources = ARRAY_SIZE(rtc_resources),
  33. .resource = rtc_resources,
  34. };
  35. static struct plat_sci_port sci_platform_data[] = {
  36. {
  37. #ifndef CONFIG_SH_RTS7751R2D
  38. .mapbase = 0xffe00000,
  39. .flags = UPF_BOOT_AUTOCONF,
  40. .type = PORT_SCI,
  41. .irqs = { 23, 23, 23, 0 },
  42. }, {
  43. #endif
  44. .mapbase = 0xffe80000,
  45. .flags = UPF_BOOT_AUTOCONF,
  46. .type = PORT_SCIF,
  47. .irqs = { 40, 40, 40, 40 },
  48. }, {
  49. .flags = 0,
  50. }
  51. };
  52. static struct platform_device sci_device = {
  53. .name = "sh-sci",
  54. .id = -1,
  55. .dev = {
  56. .platform_data = sci_platform_data,
  57. },
  58. };
  59. static struct sh_timer_config tmu0_platform_data = {
  60. .name = "TMU0",
  61. .channel_offset = 0x04,
  62. .timer_bit = 0,
  63. .clk = "peripheral_clk",
  64. .clockevent_rating = 200,
  65. };
  66. static struct resource tmu0_resources[] = {
  67. [0] = {
  68. .name = "TMU0",
  69. .start = 0xffd80008,
  70. .end = 0xffd80013,
  71. .flags = IORESOURCE_MEM,
  72. },
  73. [1] = {
  74. .start = 16,
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. };
  78. static struct platform_device tmu0_device = {
  79. .name = "sh_tmu",
  80. .id = 0,
  81. .dev = {
  82. .platform_data = &tmu0_platform_data,
  83. },
  84. .resource = tmu0_resources,
  85. .num_resources = ARRAY_SIZE(tmu0_resources),
  86. };
  87. static struct sh_timer_config tmu1_platform_data = {
  88. .name = "TMU1",
  89. .channel_offset = 0x10,
  90. .timer_bit = 1,
  91. .clk = "peripheral_clk",
  92. .clocksource_rating = 200,
  93. };
  94. static struct resource tmu1_resources[] = {
  95. [0] = {
  96. .name = "TMU1",
  97. .start = 0xffd80014,
  98. .end = 0xffd8001f,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. [1] = {
  102. .start = 17,
  103. .flags = IORESOURCE_IRQ,
  104. },
  105. };
  106. static struct platform_device tmu1_device = {
  107. .name = "sh_tmu",
  108. .id = 1,
  109. .dev = {
  110. .platform_data = &tmu1_platform_data,
  111. },
  112. .resource = tmu1_resources,
  113. .num_resources = ARRAY_SIZE(tmu1_resources),
  114. };
  115. static struct sh_timer_config tmu2_platform_data = {
  116. .name = "TMU2",
  117. .channel_offset = 0x1c,
  118. .timer_bit = 2,
  119. .clk = "peripheral_clk",
  120. };
  121. static struct resource tmu2_resources[] = {
  122. [0] = {
  123. .name = "TMU2",
  124. .start = 0xffd80020,
  125. .end = 0xffd8002f,
  126. .flags = IORESOURCE_MEM,
  127. },
  128. [1] = {
  129. .start = 18,
  130. .flags = IORESOURCE_IRQ,
  131. },
  132. };
  133. static struct platform_device tmu2_device = {
  134. .name = "sh_tmu",
  135. .id = 2,
  136. .dev = {
  137. .platform_data = &tmu2_platform_data,
  138. },
  139. .resource = tmu2_resources,
  140. .num_resources = ARRAY_SIZE(tmu2_resources),
  141. };
  142. /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
  143. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  144. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  145. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  146. static struct sh_timer_config tmu3_platform_data = {
  147. .name = "TMU3",
  148. .channel_offset = 0x04,
  149. .timer_bit = 0,
  150. .clk = "peripheral_clk",
  151. };
  152. static struct resource tmu3_resources[] = {
  153. [0] = {
  154. .name = "TMU3",
  155. .start = 0xfe100008,
  156. .end = 0xfe100013,
  157. .flags = IORESOURCE_MEM,
  158. },
  159. [1] = {
  160. .start = 72,
  161. .flags = IORESOURCE_IRQ,
  162. },
  163. };
  164. static struct platform_device tmu3_device = {
  165. .name = "sh_tmu",
  166. .id = 3,
  167. .dev = {
  168. .platform_data = &tmu3_platform_data,
  169. },
  170. .resource = tmu3_resources,
  171. .num_resources = ARRAY_SIZE(tmu3_resources),
  172. };
  173. static struct sh_timer_config tmu4_platform_data = {
  174. .name = "TMU4",
  175. .channel_offset = 0x10,
  176. .timer_bit = 1,
  177. .clk = "peripheral_clk",
  178. };
  179. static struct resource tmu4_resources[] = {
  180. [0] = {
  181. .name = "TMU4",
  182. .start = 0xfe100014,
  183. .end = 0xfe10001f,
  184. .flags = IORESOURCE_MEM,
  185. },
  186. [1] = {
  187. .start = 76,
  188. .flags = IORESOURCE_IRQ,
  189. },
  190. };
  191. static struct platform_device tmu4_device = {
  192. .name = "sh_tmu",
  193. .id = 4,
  194. .dev = {
  195. .platform_data = &tmu4_platform_data,
  196. },
  197. .resource = tmu4_resources,
  198. .num_resources = ARRAY_SIZE(tmu4_resources),
  199. };
  200. #endif
  201. static struct platform_device *sh7750_devices[] __initdata = {
  202. &rtc_device,
  203. &sci_device,
  204. &tmu0_device,
  205. &tmu1_device,
  206. &tmu2_device,
  207. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  208. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  209. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  210. &tmu3_device,
  211. &tmu4_device,
  212. #endif
  213. };
  214. static int __init sh7750_devices_setup(void)
  215. {
  216. return platform_add_devices(sh7750_devices,
  217. ARRAY_SIZE(sh7750_devices));
  218. }
  219. arch_initcall(sh7750_devices_setup);
  220. static struct platform_device *sh7750_early_devices[] __initdata = {
  221. &tmu0_device,
  222. &tmu1_device,
  223. &tmu2_device,
  224. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  225. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  226. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  227. &tmu3_device,
  228. &tmu4_device,
  229. #endif
  230. };
  231. void __init plat_early_device_setup(void)
  232. {
  233. early_platform_add_devices(sh7750_early_devices,
  234. ARRAY_SIZE(sh7750_early_devices));
  235. }
  236. enum {
  237. UNUSED = 0,
  238. /* interrupt sources */
  239. IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
  240. HUDI, GPIOI, DMAC,
  241. PCIC0_PCISERR, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  242. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3,
  243. TMU3, TMU4, TMU0, TMU1, TMU2, RTC, SCI1, SCIF, WDT, REF,
  244. /* interrupt groups */
  245. PCIC1,
  246. };
  247. static struct intc_vect vectors[] __initdata = {
  248. INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620),
  249. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  250. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  251. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  252. INTC_VECT(RTC, 0x4c0),
  253. INTC_VECT(SCI1, 0x4e0), INTC_VECT(SCI1, 0x500),
  254. INTC_VECT(SCI1, 0x520), INTC_VECT(SCI1, 0x540),
  255. INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),
  256. INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),
  257. INTC_VECT(WDT, 0x560),
  258. INTC_VECT(REF, 0x580), INTC_VECT(REF, 0x5a0),
  259. };
  260. static struct intc_prio_reg prio_registers[] __initdata = {
  261. { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  262. { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, SCI1, 0 } },
  263. { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, SCIF, HUDI } },
  264. { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
  265. { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
  266. TMU4, TMU3,
  267. PCIC1, PCIC0_PCISERR } },
  268. };
  269. static DECLARE_INTC_DESC(intc_desc, "sh7750", vectors, NULL,
  270. NULL, prio_registers, NULL);
  271. /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
  272. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  273. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  274. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  275. defined(CONFIG_CPU_SUBTYPE_SH7091)
  276. static struct intc_vect vectors_dma4[] __initdata = {
  277. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  278. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  279. INTC_VECT(DMAC, 0x6c0),
  280. };
  281. static DECLARE_INTC_DESC(intc_desc_dma4, "sh7750_dma4",
  282. vectors_dma4, NULL,
  283. NULL, prio_registers, NULL);
  284. #endif
  285. /* SH7750R and SH7751R both have 8-channel DMA controllers */
  286. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  287. static struct intc_vect vectors_dma8[] __initdata = {
  288. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  289. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  290. INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),
  291. INTC_VECT(DMAC, 0x7c0), INTC_VECT(DMAC, 0x7e0),
  292. INTC_VECT(DMAC, 0x6c0),
  293. };
  294. static DECLARE_INTC_DESC(intc_desc_dma8, "sh7750_dma8",
  295. vectors_dma8, NULL,
  296. NULL, prio_registers, NULL);
  297. #endif
  298. /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
  299. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  300. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  301. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  302. static struct intc_vect vectors_tmu34[] __initdata = {
  303. INTC_VECT(TMU3, 0xb00), INTC_VECT(TMU4, 0xb80),
  304. };
  305. static struct intc_mask_reg mask_registers[] __initdata = {
  306. { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
  307. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  308. 0, 0, 0, 0, 0, 0, TMU4, TMU3,
  309. PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  310. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2,
  311. PCIC1_PCIDMA3, PCIC0_PCISERR } },
  312. };
  313. static DECLARE_INTC_DESC(intc_desc_tmu34, "sh7750_tmu34",
  314. vectors_tmu34, NULL,
  315. mask_registers, prio_registers, NULL);
  316. #endif
  317. /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
  318. static struct intc_vect vectors_irlm[] __initdata = {
  319. INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
  320. INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
  321. };
  322. static DECLARE_INTC_DESC(intc_desc_irlm, "sh7750_irlm", vectors_irlm, NULL,
  323. NULL, prio_registers, NULL);
  324. /* SH7751 and SH7751R both have PCI */
  325. #if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  326. static struct intc_vect vectors_pci[] __initdata = {
  327. INTC_VECT(PCIC0_PCISERR, 0xa00), INTC_VECT(PCIC1_PCIERR, 0xae0),
  328. INTC_VECT(PCIC1_PCIPWDWN, 0xac0), INTC_VECT(PCIC1_PCIPWON, 0xaa0),
  329. INTC_VECT(PCIC1_PCIDMA0, 0xa80), INTC_VECT(PCIC1_PCIDMA1, 0xa60),
  330. INTC_VECT(PCIC1_PCIDMA2, 0xa40), INTC_VECT(PCIC1_PCIDMA3, 0xa20),
  331. };
  332. static struct intc_group groups_pci[] __initdata = {
  333. INTC_GROUP(PCIC1, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  334. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3),
  335. };
  336. static DECLARE_INTC_DESC(intc_desc_pci, "sh7750_pci", vectors_pci, groups_pci,
  337. mask_registers, prio_registers, NULL);
  338. #endif
  339. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  340. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  341. defined(CONFIG_CPU_SUBTYPE_SH7091)
  342. void __init plat_irq_setup(void)
  343. {
  344. /*
  345. * same vectors for SH7750, SH7750S and SH7091 except for IRLM,
  346. * see below..
  347. */
  348. register_intc_controller(&intc_desc);
  349. register_intc_controller(&intc_desc_dma4);
  350. }
  351. #endif
  352. #if defined(CONFIG_CPU_SUBTYPE_SH7750R)
  353. void __init plat_irq_setup(void)
  354. {
  355. register_intc_controller(&intc_desc);
  356. register_intc_controller(&intc_desc_dma8);
  357. register_intc_controller(&intc_desc_tmu34);
  358. }
  359. #endif
  360. #if defined(CONFIG_CPU_SUBTYPE_SH7751)
  361. void __init plat_irq_setup(void)
  362. {
  363. register_intc_controller(&intc_desc);
  364. register_intc_controller(&intc_desc_dma4);
  365. register_intc_controller(&intc_desc_tmu34);
  366. register_intc_controller(&intc_desc_pci);
  367. }
  368. #endif
  369. #if defined(CONFIG_CPU_SUBTYPE_SH7751R)
  370. void __init plat_irq_setup(void)
  371. {
  372. register_intc_controller(&intc_desc);
  373. register_intc_controller(&intc_desc_dma8);
  374. register_intc_controller(&intc_desc_tmu34);
  375. register_intc_controller(&intc_desc_pci);
  376. }
  377. #endif
  378. #define INTC_ICR 0xffd00000UL
  379. #define INTC_ICR_IRLM (1<<7)
  380. void __init plat_irq_setup_pins(int mode)
  381. {
  382. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)
  383. BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */
  384. return;
  385. #endif
  386. switch (mode) {
  387. case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
  388. ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  389. register_intc_controller(&intc_desc_irlm);
  390. break;
  391. default:
  392. BUG();
  393. }
  394. }