setup-sh7750.c 11 KB

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