setup-sh7750.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. .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_register_device(&scif_device);
  209. } else {
  210. platform_register_device(&sci_device);
  211. platform_register_device(&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. if (mach_is_rts7751r2d()) {
  231. scif_platform_data.scscr |= SCSCR_CKE1;
  232. early_platform_add_devices(&scif_device, 1);
  233. } else {
  234. early_platform_add_devices(&sci_device, 1);
  235. early_platform_add_devices(&scif_device, 1);
  236. }
  237. early_platform_add_devices(sh7750_early_devices,
  238. ARRAY_SIZE(sh7750_early_devices));
  239. }
  240. enum {
  241. UNUSED = 0,
  242. /* interrupt sources */
  243. IRL0, IRL1, IRL2, IRL3, /* only IRLM mode supported */
  244. HUDI, GPIOI, DMAC,
  245. PCIC0_PCISERR, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  246. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3,
  247. TMU3, TMU4, TMU0, TMU1, TMU2, RTC, SCI1, SCIF, WDT, REF,
  248. /* interrupt groups */
  249. PCIC1,
  250. };
  251. static struct intc_vect vectors[] __initdata = {
  252. INTC_VECT(HUDI, 0x600), INTC_VECT(GPIOI, 0x620),
  253. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  254. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
  255. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  256. INTC_VECT(RTC, 0x4c0),
  257. INTC_VECT(SCI1, 0x4e0), INTC_VECT(SCI1, 0x500),
  258. INTC_VECT(SCI1, 0x520), INTC_VECT(SCI1, 0x540),
  259. INTC_VECT(SCIF, 0x700), INTC_VECT(SCIF, 0x720),
  260. INTC_VECT(SCIF, 0x740), INTC_VECT(SCIF, 0x760),
  261. INTC_VECT(WDT, 0x560),
  262. INTC_VECT(REF, 0x580), INTC_VECT(REF, 0x5a0),
  263. };
  264. static struct intc_prio_reg prio_registers[] __initdata = {
  265. { 0xffd00004, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  266. { 0xffd00008, 0, 16, 4, /* IPRB */ { WDT, REF, SCI1, 0 } },
  267. { 0xffd0000c, 0, 16, 4, /* IPRC */ { GPIOI, DMAC, SCIF, HUDI } },
  268. { 0xffd00010, 0, 16, 4, /* IPRD */ { IRL0, IRL1, IRL2, IRL3 } },
  269. { 0xfe080000, 0, 32, 4, /* INTPRI00 */ { 0, 0, 0, 0,
  270. TMU4, TMU3,
  271. PCIC1, PCIC0_PCISERR } },
  272. };
  273. static DECLARE_INTC_DESC(intc_desc, "sh7750", vectors, NULL,
  274. NULL, prio_registers, NULL);
  275. /* SH7750, SH7750S, SH7751 and SH7091 all have 4-channel DMA controllers */
  276. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  277. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  278. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  279. defined(CONFIG_CPU_SUBTYPE_SH7091)
  280. static struct intc_vect vectors_dma4[] __initdata = {
  281. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  282. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  283. INTC_VECT(DMAC, 0x6c0),
  284. };
  285. static DECLARE_INTC_DESC(intc_desc_dma4, "sh7750_dma4",
  286. vectors_dma4, NULL,
  287. NULL, prio_registers, NULL);
  288. #endif
  289. /* SH7750R and SH7751R both have 8-channel DMA controllers */
  290. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  291. static struct intc_vect vectors_dma8[] __initdata = {
  292. INTC_VECT(DMAC, 0x640), INTC_VECT(DMAC, 0x660),
  293. INTC_VECT(DMAC, 0x680), INTC_VECT(DMAC, 0x6a0),
  294. INTC_VECT(DMAC, 0x780), INTC_VECT(DMAC, 0x7a0),
  295. INTC_VECT(DMAC, 0x7c0), INTC_VECT(DMAC, 0x7e0),
  296. INTC_VECT(DMAC, 0x6c0),
  297. };
  298. static DECLARE_INTC_DESC(intc_desc_dma8, "sh7750_dma8",
  299. vectors_dma8, NULL,
  300. NULL, prio_registers, NULL);
  301. #endif
  302. /* SH7750R, SH7751 and SH7751R all have two extra timer channels */
  303. #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
  304. defined(CONFIG_CPU_SUBTYPE_SH7751) || \
  305. defined(CONFIG_CPU_SUBTYPE_SH7751R)
  306. static struct intc_vect vectors_tmu34[] __initdata = {
  307. INTC_VECT(TMU3, 0xb00), INTC_VECT(TMU4, 0xb80),
  308. };
  309. static struct intc_mask_reg mask_registers[] __initdata = {
  310. { 0xfe080040, 0xfe080060, 32, /* INTMSK00 / INTMSKCLR00 */
  311. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  312. 0, 0, 0, 0, 0, 0, TMU4, TMU3,
  313. PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  314. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2,
  315. PCIC1_PCIDMA3, PCIC0_PCISERR } },
  316. };
  317. static DECLARE_INTC_DESC(intc_desc_tmu34, "sh7750_tmu34",
  318. vectors_tmu34, NULL,
  319. mask_registers, prio_registers, NULL);
  320. #endif
  321. /* SH7750S, SH7750R, SH7751 and SH7751R all have IRLM priority registers */
  322. static struct intc_vect vectors_irlm[] __initdata = {
  323. INTC_VECT(IRL0, 0x240), INTC_VECT(IRL1, 0x2a0),
  324. INTC_VECT(IRL2, 0x300), INTC_VECT(IRL3, 0x360),
  325. };
  326. static DECLARE_INTC_DESC(intc_desc_irlm, "sh7750_irlm", vectors_irlm, NULL,
  327. NULL, prio_registers, NULL);
  328. /* SH7751 and SH7751R both have PCI */
  329. #if defined(CONFIG_CPU_SUBTYPE_SH7751) || defined(CONFIG_CPU_SUBTYPE_SH7751R)
  330. static struct intc_vect vectors_pci[] __initdata = {
  331. INTC_VECT(PCIC0_PCISERR, 0xa00), INTC_VECT(PCIC1_PCIERR, 0xae0),
  332. INTC_VECT(PCIC1_PCIPWDWN, 0xac0), INTC_VECT(PCIC1_PCIPWON, 0xaa0),
  333. INTC_VECT(PCIC1_PCIDMA0, 0xa80), INTC_VECT(PCIC1_PCIDMA1, 0xa60),
  334. INTC_VECT(PCIC1_PCIDMA2, 0xa40), INTC_VECT(PCIC1_PCIDMA3, 0xa20),
  335. };
  336. static struct intc_group groups_pci[] __initdata = {
  337. INTC_GROUP(PCIC1, PCIC1_PCIERR, PCIC1_PCIPWDWN, PCIC1_PCIPWON,
  338. PCIC1_PCIDMA0, PCIC1_PCIDMA1, PCIC1_PCIDMA2, PCIC1_PCIDMA3),
  339. };
  340. static DECLARE_INTC_DESC(intc_desc_pci, "sh7750_pci", vectors_pci, groups_pci,
  341. mask_registers, prio_registers, NULL);
  342. #endif
  343. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || \
  344. defined(CONFIG_CPU_SUBTYPE_SH7750S) || \
  345. defined(CONFIG_CPU_SUBTYPE_SH7091)
  346. void __init plat_irq_setup(void)
  347. {
  348. /*
  349. * same vectors for SH7750, SH7750S and SH7091 except for IRLM,
  350. * see below..
  351. */
  352. register_intc_controller(&intc_desc);
  353. register_intc_controller(&intc_desc_dma4);
  354. }
  355. #endif
  356. #if defined(CONFIG_CPU_SUBTYPE_SH7750R)
  357. void __init plat_irq_setup(void)
  358. {
  359. register_intc_controller(&intc_desc);
  360. register_intc_controller(&intc_desc_dma8);
  361. register_intc_controller(&intc_desc_tmu34);
  362. }
  363. #endif
  364. #if defined(CONFIG_CPU_SUBTYPE_SH7751)
  365. void __init plat_irq_setup(void)
  366. {
  367. register_intc_controller(&intc_desc);
  368. register_intc_controller(&intc_desc_dma4);
  369. register_intc_controller(&intc_desc_tmu34);
  370. register_intc_controller(&intc_desc_pci);
  371. }
  372. #endif
  373. #if defined(CONFIG_CPU_SUBTYPE_SH7751R)
  374. void __init plat_irq_setup(void)
  375. {
  376. register_intc_controller(&intc_desc);
  377. register_intc_controller(&intc_desc_dma8);
  378. register_intc_controller(&intc_desc_tmu34);
  379. register_intc_controller(&intc_desc_pci);
  380. }
  381. #endif
  382. #define INTC_ICR 0xffd00000UL
  383. #define INTC_ICR_IRLM (1<<7)
  384. void __init plat_irq_setup_pins(int mode)
  385. {
  386. #if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7091)
  387. BUG(); /* impossible to mask interrupts on SH7750 and SH7091 */
  388. return;
  389. #endif
  390. switch (mode) {
  391. case IRQ_MODE_IRQ: /* individual interrupt mode for IRL3-0 */
  392. __raw_writew(__raw_readw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
  393. register_intc_controller(&intc_desc_irlm);
  394. break;
  395. default:
  396. BUG();
  397. }
  398. }