setup-sh7750.c 11 KB

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