setup-sh7720.c 11 KB

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