setup-sh7720.c 10 KB

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