setup-sh7720.c 10 KB

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