setup-sh7720.c 11 KB

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