setup-sh7720.c 10 KB

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