setup-sh7750.c 11 KB

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