setup-sh7720.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. /*
  2. * Setup code for SH7720, SH7721.
  3. *
  4. * Copyright (C) 2007 Markus Brunner, Mark Jonas
  5. * Copyright (C) 2009 Paul Mundt
  6. *
  7. * Based on arch/sh/kernel/cpu/sh4/setup-sh7750.c:
  8. *
  9. * Copyright (C) 2006 Paul Mundt
  10. * Copyright (C) 2006 Jamie Lenehan
  11. *
  12. * This file is subject to the terms and conditions of the GNU General Public
  13. * License. See the file "COPYING" in the main directory of this archive
  14. * for more details.
  15. */
  16. #include <linux/platform_device.h>
  17. #include <linux/init.h>
  18. #include <linux/serial.h>
  19. #include <linux/io.h>
  20. #include <linux/serial_sci.h>
  21. #include <linux/sh_timer.h>
  22. #include <asm/rtc.h>
  23. #include <cpu/serial.h>
  24. static struct resource rtc_resources[] = {
  25. [0] = {
  26. .start = 0xa413fec0,
  27. .end = 0xa413fec0 + 0x28 - 1,
  28. .flags = IORESOURCE_IO,
  29. },
  30. [1] = {
  31. /* Shared Period/Carry/Alarm IRQ */
  32. .start = 20,
  33. .flags = IORESOURCE_IRQ,
  34. },
  35. };
  36. static struct sh_rtc_platform_info rtc_info = {
  37. .capabilities = RTC_CAP_4_DIGIT_YEAR,
  38. };
  39. static struct platform_device rtc_device = {
  40. .name = "sh-rtc",
  41. .id = -1,
  42. .num_resources = ARRAY_SIZE(rtc_resources),
  43. .resource = rtc_resources,
  44. .dev = {
  45. .platform_data = &rtc_info,
  46. },
  47. };
  48. static struct plat_sci_port scif0_platform_data = {
  49. .mapbase = 0xa4430000,
  50. .flags = UPF_BOOT_AUTOCONF,
  51. .scscr = SCSCR_RE | SCSCR_TE,
  52. .scbrr_algo_id = SCBRR_ALGO_4,
  53. .type = PORT_SCIF,
  54. .irqs = { 80, 80, 80, 80 },
  55. .ops = &sh7720_sci_port_ops,
  56. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  57. };
  58. static struct platform_device scif0_device = {
  59. .name = "sh-sci",
  60. .id = 0,
  61. .dev = {
  62. .platform_data = &scif0_platform_data,
  63. },
  64. };
  65. static struct plat_sci_port scif1_platform_data = {
  66. .mapbase = 0xa4438000,
  67. .flags = UPF_BOOT_AUTOCONF,
  68. .scscr = SCSCR_RE | SCSCR_TE,
  69. .scbrr_algo_id = SCBRR_ALGO_4,
  70. .type = PORT_SCIF,
  71. .irqs = { 81, 81, 81, 81 },
  72. .ops = &sh7720_sci_port_ops,
  73. .regtype = SCIx_SH7705_SCIF_REGTYPE,
  74. };
  75. static struct platform_device scif1_device = {
  76. .name = "sh-sci",
  77. .id = 1,
  78. .dev = {
  79. .platform_data = &scif1_platform_data,
  80. },
  81. };
  82. static struct resource usb_ohci_resources[] = {
  83. [0] = {
  84. .start = 0xA4428000,
  85. .end = 0xA44280FF,
  86. .flags = IORESOURCE_MEM,
  87. },
  88. [1] = {
  89. .start = 67,
  90. .end = 67,
  91. .flags = IORESOURCE_IRQ,
  92. },
  93. };
  94. static u64 usb_ohci_dma_mask = 0xffffffffUL;
  95. static struct platform_device usb_ohci_device = {
  96. .name = "sh_ohci",
  97. .id = -1,
  98. .dev = {
  99. .dma_mask = &usb_ohci_dma_mask,
  100. .coherent_dma_mask = 0xffffffff,
  101. },
  102. .num_resources = ARRAY_SIZE(usb_ohci_resources),
  103. .resource = usb_ohci_resources,
  104. };
  105. static struct resource usbf_resources[] = {
  106. [0] = {
  107. .name = "sh_udc",
  108. .start = 0xA4420000,
  109. .end = 0xA44200FF,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. [1] = {
  113. .name = "sh_udc",
  114. .start = 65,
  115. .end = 65,
  116. .flags = IORESOURCE_IRQ,
  117. },
  118. };
  119. static struct platform_device usbf_device = {
  120. .name = "sh_udc",
  121. .id = -1,
  122. .dev = {
  123. .dma_mask = NULL,
  124. .coherent_dma_mask = 0xffffffff,
  125. },
  126. .num_resources = ARRAY_SIZE(usbf_resources),
  127. .resource = usbf_resources,
  128. };
  129. static struct sh_timer_config cmt0_platform_data = {
  130. .channel_offset = 0x10,
  131. .timer_bit = 0,
  132. .clockevent_rating = 125,
  133. .clocksource_rating = 125,
  134. };
  135. static struct resource cmt0_resources[] = {
  136. [0] = {
  137. .start = 0x044a0010,
  138. .end = 0x044a001b,
  139. .flags = IORESOURCE_MEM,
  140. },
  141. [1] = {
  142. .start = 104,
  143. .flags = IORESOURCE_IRQ,
  144. },
  145. };
  146. static struct platform_device cmt0_device = {
  147. .name = "sh_cmt",
  148. .id = 0,
  149. .dev = {
  150. .platform_data = &cmt0_platform_data,
  151. },
  152. .resource = cmt0_resources,
  153. .num_resources = ARRAY_SIZE(cmt0_resources),
  154. };
  155. static struct sh_timer_config cmt1_platform_data = {
  156. .channel_offset = 0x20,
  157. .timer_bit = 1,
  158. };
  159. static struct resource cmt1_resources[] = {
  160. [0] = {
  161. .start = 0x044a0020,
  162. .end = 0x044a002b,
  163. .flags = IORESOURCE_MEM,
  164. },
  165. [1] = {
  166. .start = 104,
  167. .flags = IORESOURCE_IRQ,
  168. },
  169. };
  170. static struct platform_device cmt1_device = {
  171. .name = "sh_cmt",
  172. .id = 1,
  173. .dev = {
  174. .platform_data = &cmt1_platform_data,
  175. },
  176. .resource = cmt1_resources,
  177. .num_resources = ARRAY_SIZE(cmt1_resources),
  178. };
  179. static struct sh_timer_config cmt2_platform_data = {
  180. .channel_offset = 0x30,
  181. .timer_bit = 2,
  182. };
  183. static struct resource cmt2_resources[] = {
  184. [0] = {
  185. .start = 0x044a0030,
  186. .end = 0x044a003b,
  187. .flags = IORESOURCE_MEM,
  188. },
  189. [1] = {
  190. .start = 104,
  191. .flags = IORESOURCE_IRQ,
  192. },
  193. };
  194. static struct platform_device cmt2_device = {
  195. .name = "sh_cmt",
  196. .id = 2,
  197. .dev = {
  198. .platform_data = &cmt2_platform_data,
  199. },
  200. .resource = cmt2_resources,
  201. .num_resources = ARRAY_SIZE(cmt2_resources),
  202. };
  203. static struct sh_timer_config cmt3_platform_data = {
  204. .channel_offset = 0x40,
  205. .timer_bit = 3,
  206. };
  207. static struct resource cmt3_resources[] = {
  208. [0] = {
  209. .start = 0x044a0040,
  210. .end = 0x044a004b,
  211. .flags = IORESOURCE_MEM,
  212. },
  213. [1] = {
  214. .start = 104,
  215. .flags = IORESOURCE_IRQ,
  216. },
  217. };
  218. static struct platform_device cmt3_device = {
  219. .name = "sh_cmt",
  220. .id = 3,
  221. .dev = {
  222. .platform_data = &cmt3_platform_data,
  223. },
  224. .resource = cmt3_resources,
  225. .num_resources = ARRAY_SIZE(cmt3_resources),
  226. };
  227. static struct sh_timer_config cmt4_platform_data = {
  228. .channel_offset = 0x50,
  229. .timer_bit = 4,
  230. };
  231. static struct resource cmt4_resources[] = {
  232. [0] = {
  233. .start = 0x044a0050,
  234. .end = 0x044a005b,
  235. .flags = IORESOURCE_MEM,
  236. },
  237. [1] = {
  238. .start = 104,
  239. .flags = IORESOURCE_IRQ,
  240. },
  241. };
  242. static struct platform_device cmt4_device = {
  243. .name = "sh_cmt",
  244. .id = 4,
  245. .dev = {
  246. .platform_data = &cmt4_platform_data,
  247. },
  248. .resource = cmt4_resources,
  249. .num_resources = ARRAY_SIZE(cmt4_resources),
  250. };
  251. static struct sh_timer_config tmu0_platform_data = {
  252. .channel_offset = 0x02,
  253. .timer_bit = 0,
  254. .clockevent_rating = 200,
  255. };
  256. static struct resource tmu0_resources[] = {
  257. [0] = {
  258. .start = 0xa412fe94,
  259. .end = 0xa412fe9f,
  260. .flags = IORESOURCE_MEM,
  261. },
  262. [1] = {
  263. .start = 16,
  264. .flags = IORESOURCE_IRQ,
  265. },
  266. };
  267. static struct platform_device tmu0_device = {
  268. .name = "sh_tmu",
  269. .id = 0,
  270. .dev = {
  271. .platform_data = &tmu0_platform_data,
  272. },
  273. .resource = tmu0_resources,
  274. .num_resources = ARRAY_SIZE(tmu0_resources),
  275. };
  276. static struct sh_timer_config tmu1_platform_data = {
  277. .channel_offset = 0xe,
  278. .timer_bit = 1,
  279. .clocksource_rating = 200,
  280. };
  281. static struct resource tmu1_resources[] = {
  282. [0] = {
  283. .start = 0xa412fea0,
  284. .end = 0xa412feab,
  285. .flags = IORESOURCE_MEM,
  286. },
  287. [1] = {
  288. .start = 17,
  289. .flags = IORESOURCE_IRQ,
  290. },
  291. };
  292. static struct platform_device tmu1_device = {
  293. .name = "sh_tmu",
  294. .id = 1,
  295. .dev = {
  296. .platform_data = &tmu1_platform_data,
  297. },
  298. .resource = tmu1_resources,
  299. .num_resources = ARRAY_SIZE(tmu1_resources),
  300. };
  301. static struct sh_timer_config tmu2_platform_data = {
  302. .channel_offset = 0x1a,
  303. .timer_bit = 2,
  304. };
  305. static struct resource tmu2_resources[] = {
  306. [0] = {
  307. .start = 0xa412feac,
  308. .end = 0xa412feb5,
  309. .flags = IORESOURCE_MEM,
  310. },
  311. [1] = {
  312. .start = 18,
  313. .flags = IORESOURCE_IRQ,
  314. },
  315. };
  316. static struct platform_device tmu2_device = {
  317. .name = "sh_tmu",
  318. .id = 2,
  319. .dev = {
  320. .platform_data = &tmu2_platform_data,
  321. },
  322. .resource = tmu2_resources,
  323. .num_resources = ARRAY_SIZE(tmu2_resources),
  324. };
  325. static struct platform_device *sh7720_devices[] __initdata = {
  326. &scif0_device,
  327. &scif1_device,
  328. &cmt0_device,
  329. &cmt1_device,
  330. &cmt2_device,
  331. &cmt3_device,
  332. &cmt4_device,
  333. &tmu0_device,
  334. &tmu1_device,
  335. &tmu2_device,
  336. &rtc_device,
  337. &usb_ohci_device,
  338. &usbf_device,
  339. };
  340. static int __init sh7720_devices_setup(void)
  341. {
  342. return platform_add_devices(sh7720_devices,
  343. ARRAY_SIZE(sh7720_devices));
  344. }
  345. arch_initcall(sh7720_devices_setup);
  346. static struct platform_device *sh7720_early_devices[] __initdata = {
  347. &scif0_device,
  348. &scif1_device,
  349. &cmt0_device,
  350. &cmt1_device,
  351. &cmt2_device,
  352. &cmt3_device,
  353. &cmt4_device,
  354. &tmu0_device,
  355. &tmu1_device,
  356. &tmu2_device,
  357. };
  358. void __init plat_early_device_setup(void)
  359. {
  360. early_platform_add_devices(sh7720_early_devices,
  361. ARRAY_SIZE(sh7720_early_devices));
  362. }
  363. enum {
  364. UNUSED = 0,
  365. /* interrupt sources */
  366. TMU0, TMU1, TMU2, RTC,
  367. WDT, REF_RCMI, SIM,
  368. IRQ0, IRQ1, IRQ2, IRQ3,
  369. USBF_SPD, TMU_SUNI, IRQ5, IRQ4,
  370. DMAC1, LCDC, SSL,
  371. ADC, DMAC2, USBFI, CMT,
  372. SCIF0, SCIF1,
  373. PINT07, PINT815, TPU, IIC,
  374. SIOF0, SIOF1, MMC, PCC,
  375. USBHI, AFEIF,
  376. H_UDI,
  377. };
  378. static struct intc_vect vectors[] __initdata = {
  379. /* IRQ0->5 are handled in setup-sh3.c */
  380. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  381. INTC_VECT(TMU2, 0x440), INTC_VECT(RTC, 0x480),
  382. INTC_VECT(RTC, 0x4a0), INTC_VECT(RTC, 0x4c0),
  383. INTC_VECT(SIM, 0x4e0), INTC_VECT(SIM, 0x500),
  384. INTC_VECT(SIM, 0x520), INTC_VECT(SIM, 0x540),
  385. INTC_VECT(WDT, 0x560), INTC_VECT(REF_RCMI, 0x580),
  386. /* H_UDI cannot be masked */ INTC_VECT(TMU_SUNI, 0x6c0),
  387. INTC_VECT(USBF_SPD, 0x6e0), INTC_VECT(DMAC1, 0x800),
  388. INTC_VECT(DMAC1, 0x820), INTC_VECT(DMAC1, 0x840),
  389. INTC_VECT(DMAC1, 0x860), INTC_VECT(LCDC, 0x900),
  390. #if defined(CONFIG_CPU_SUBTYPE_SH7720)
  391. INTC_VECT(SSL, 0x980),
  392. #endif
  393. INTC_VECT(USBFI, 0xa20), INTC_VECT(USBFI, 0xa40),
  394. INTC_VECT(USBHI, 0xa60),
  395. INTC_VECT(DMAC2, 0xb80), INTC_VECT(DMAC2, 0xba0),
  396. INTC_VECT(ADC, 0xbe0), INTC_VECT(SCIF0, 0xc00),
  397. INTC_VECT(SCIF1, 0xc20), INTC_VECT(PINT07, 0xc80),
  398. INTC_VECT(PINT815, 0xca0), INTC_VECT(SIOF0, 0xd00),
  399. INTC_VECT(SIOF1, 0xd20), INTC_VECT(TPU, 0xd80),
  400. INTC_VECT(TPU, 0xda0), INTC_VECT(TPU, 0xdc0),
  401. INTC_VECT(TPU, 0xde0), INTC_VECT(IIC, 0xe00),
  402. INTC_VECT(MMC, 0xe80), INTC_VECT(MMC, 0xea0),
  403. INTC_VECT(MMC, 0xec0), INTC_VECT(MMC, 0xee0),
  404. INTC_VECT(CMT, 0xf00), INTC_VECT(PCC, 0xf60),
  405. INTC_VECT(AFEIF, 0xfe0),
  406. };
  407. static struct intc_prio_reg prio_registers[] __initdata = {
  408. { 0xA414FEE2UL, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
  409. { 0xA414FEE4UL, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, SIM, 0 } },
  410. { 0xA4140016UL, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
  411. { 0xA4140018UL, 0, 16, 4, /* IPRD */ { USBF_SPD, TMU_SUNI, IRQ5, IRQ4 } },
  412. { 0xA414001AUL, 0, 16, 4, /* IPRE */ { DMAC1, 0, LCDC, SSL } },
  413. { 0xA4080000UL, 0, 16, 4, /* IPRF */ { ADC, DMAC2, USBFI, CMT } },
  414. { 0xA4080002UL, 0, 16, 4, /* IPRG */ { SCIF0, SCIF1, 0, 0 } },
  415. { 0xA4080004UL, 0, 16, 4, /* IPRH */ { PINT07, PINT815, TPU, IIC } },
  416. { 0xA4080006UL, 0, 16, 4, /* IPRI */ { SIOF0, SIOF1, MMC, PCC } },
  417. { 0xA4080008UL, 0, 16, 4, /* IPRJ */ { 0, USBHI, 0, AFEIF } },
  418. };
  419. static DECLARE_INTC_DESC(intc_desc, "sh7720", vectors, NULL,
  420. NULL, prio_registers, NULL);
  421. void __init plat_irq_setup(void)
  422. {
  423. register_intc_controller(&intc_desc);
  424. plat_irq_setup_sh3();
  425. }