setup-sh7720.c 10 KB

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