setup-sh7720.c 10 KB

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