setup-sh7780.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. /*
  2. * SH7780 Setup
  3. *
  4. * Copyright (C) 2006 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/init.h>
  12. #include <linux/serial.h>
  13. #include <linux/io.h>
  14. #include <linux/serial_sci.h>
  15. #include <linux/sh_timer.h>
  16. #include <asm/dma-sh.h>
  17. static struct plat_sci_port scif0_platform_data = {
  18. .mapbase = 0xffe00000,
  19. .flags = UPF_BOOT_AUTOCONF,
  20. .type = PORT_SCIF,
  21. .irqs = { 40, 40, 40, 40 },
  22. };
  23. static struct platform_device scif0_device = {
  24. .name = "sh-sci",
  25. .id = 0,
  26. .dev = {
  27. .platform_data = &scif0_platform_data,
  28. },
  29. };
  30. static struct plat_sci_port scif1_platform_data = {
  31. .mapbase = 0xffe10000,
  32. .flags = UPF_BOOT_AUTOCONF,
  33. .type = PORT_SCIF,
  34. .irqs = { 76, 76, 76, 76 },
  35. };
  36. static struct platform_device scif1_device = {
  37. .name = "sh-sci",
  38. .id = 1,
  39. .dev = {
  40. .platform_data = &scif1_platform_data,
  41. },
  42. };
  43. static struct sh_timer_config tmu0_platform_data = {
  44. .name = "TMU0",
  45. .channel_offset = 0x04,
  46. .timer_bit = 0,
  47. .clk = "peripheral_clk",
  48. .clockevent_rating = 200,
  49. };
  50. static struct resource tmu0_resources[] = {
  51. [0] = {
  52. .name = "TMU0",
  53. .start = 0xffd80008,
  54. .end = 0xffd80013,
  55. .flags = IORESOURCE_MEM,
  56. },
  57. [1] = {
  58. .start = 28,
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. static struct platform_device tmu0_device = {
  63. .name = "sh_tmu",
  64. .id = 0,
  65. .dev = {
  66. .platform_data = &tmu0_platform_data,
  67. },
  68. .resource = tmu0_resources,
  69. .num_resources = ARRAY_SIZE(tmu0_resources),
  70. };
  71. static struct sh_timer_config tmu1_platform_data = {
  72. .name = "TMU1",
  73. .channel_offset = 0x10,
  74. .timer_bit = 1,
  75. .clk = "peripheral_clk",
  76. .clocksource_rating = 200,
  77. };
  78. static struct resource tmu1_resources[] = {
  79. [0] = {
  80. .name = "TMU1",
  81. .start = 0xffd80014,
  82. .end = 0xffd8001f,
  83. .flags = IORESOURCE_MEM,
  84. },
  85. [1] = {
  86. .start = 29,
  87. .flags = IORESOURCE_IRQ,
  88. },
  89. };
  90. static struct platform_device tmu1_device = {
  91. .name = "sh_tmu",
  92. .id = 1,
  93. .dev = {
  94. .platform_data = &tmu1_platform_data,
  95. },
  96. .resource = tmu1_resources,
  97. .num_resources = ARRAY_SIZE(tmu1_resources),
  98. };
  99. static struct sh_timer_config tmu2_platform_data = {
  100. .name = "TMU2",
  101. .channel_offset = 0x1c,
  102. .timer_bit = 2,
  103. .clk = "peripheral_clk",
  104. };
  105. static struct resource tmu2_resources[] = {
  106. [0] = {
  107. .name = "TMU2",
  108. .start = 0xffd80020,
  109. .end = 0xffd8002f,
  110. .flags = IORESOURCE_MEM,
  111. },
  112. [1] = {
  113. .start = 30,
  114. .flags = IORESOURCE_IRQ,
  115. },
  116. };
  117. static struct platform_device tmu2_device = {
  118. .name = "sh_tmu",
  119. .id = 2,
  120. .dev = {
  121. .platform_data = &tmu2_platform_data,
  122. },
  123. .resource = tmu2_resources,
  124. .num_resources = ARRAY_SIZE(tmu2_resources),
  125. };
  126. static struct sh_timer_config tmu3_platform_data = {
  127. .name = "TMU3",
  128. .channel_offset = 0x04,
  129. .timer_bit = 0,
  130. .clk = "peripheral_clk",
  131. };
  132. static struct resource tmu3_resources[] = {
  133. [0] = {
  134. .name = "TMU3",
  135. .start = 0xffdc0008,
  136. .end = 0xffdc0013,
  137. .flags = IORESOURCE_MEM,
  138. },
  139. [1] = {
  140. .start = 96,
  141. .flags = IORESOURCE_IRQ,
  142. },
  143. };
  144. static struct platform_device tmu3_device = {
  145. .name = "sh_tmu",
  146. .id = 3,
  147. .dev = {
  148. .platform_data = &tmu3_platform_data,
  149. },
  150. .resource = tmu3_resources,
  151. .num_resources = ARRAY_SIZE(tmu3_resources),
  152. };
  153. static struct sh_timer_config tmu4_platform_data = {
  154. .name = "TMU4",
  155. .channel_offset = 0x10,
  156. .timer_bit = 1,
  157. .clk = "peripheral_clk",
  158. };
  159. static struct resource tmu4_resources[] = {
  160. [0] = {
  161. .name = "TMU4",
  162. .start = 0xffdc0014,
  163. .end = 0xffdc001f,
  164. .flags = IORESOURCE_MEM,
  165. },
  166. [1] = {
  167. .start = 97,
  168. .flags = IORESOURCE_IRQ,
  169. },
  170. };
  171. static struct platform_device tmu4_device = {
  172. .name = "sh_tmu",
  173. .id = 4,
  174. .dev = {
  175. .platform_data = &tmu4_platform_data,
  176. },
  177. .resource = tmu4_resources,
  178. .num_resources = ARRAY_SIZE(tmu4_resources),
  179. };
  180. static struct sh_timer_config tmu5_platform_data = {
  181. .name = "TMU5",
  182. .channel_offset = 0x1c,
  183. .timer_bit = 2,
  184. .clk = "peripheral_clk",
  185. };
  186. static struct resource tmu5_resources[] = {
  187. [0] = {
  188. .name = "TMU5",
  189. .start = 0xffdc0020,
  190. .end = 0xffdc002b,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. [1] = {
  194. .start = 98,
  195. .flags = IORESOURCE_IRQ,
  196. },
  197. };
  198. static struct platform_device tmu5_device = {
  199. .name = "sh_tmu",
  200. .id = 5,
  201. .dev = {
  202. .platform_data = &tmu5_platform_data,
  203. },
  204. .resource = tmu5_resources,
  205. .num_resources = ARRAY_SIZE(tmu5_resources),
  206. };
  207. static struct resource rtc_resources[] = {
  208. [0] = {
  209. .start = 0xffe80000,
  210. .end = 0xffe80000 + 0x58 - 1,
  211. .flags = IORESOURCE_IO,
  212. },
  213. [1] = {
  214. /* Shared Period/Carry/Alarm IRQ */
  215. .start = 20,
  216. .flags = IORESOURCE_IRQ,
  217. },
  218. };
  219. static struct platform_device rtc_device = {
  220. .name = "sh-rtc",
  221. .id = -1,
  222. .num_resources = ARRAY_SIZE(rtc_resources),
  223. .resource = rtc_resources,
  224. };
  225. static struct sh_dmae_pdata dma_platform_data = {
  226. .mode = (SHDMA_MIX_IRQ | SHDMA_DMAOR1),
  227. };
  228. static struct platform_device dma_device = {
  229. .name = "sh-dma-engine",
  230. .id = -1,
  231. .dev = {
  232. .platform_data = &dma_platform_data,
  233. },
  234. };
  235. static struct platform_device *sh7780_devices[] __initdata = {
  236. &scif0_device,
  237. &scif1_device,
  238. &tmu0_device,
  239. &tmu1_device,
  240. &tmu2_device,
  241. &tmu3_device,
  242. &tmu4_device,
  243. &tmu5_device,
  244. &rtc_device,
  245. &dma_device,
  246. };
  247. static int __init sh7780_devices_setup(void)
  248. {
  249. return platform_add_devices(sh7780_devices,
  250. ARRAY_SIZE(sh7780_devices));
  251. }
  252. arch_initcall(sh7780_devices_setup);
  253. static struct platform_device *sh7780_early_devices[] __initdata = {
  254. &scif0_device,
  255. &scif1_device,
  256. &tmu0_device,
  257. &tmu1_device,
  258. &tmu2_device,
  259. &tmu3_device,
  260. &tmu4_device,
  261. &tmu5_device,
  262. };
  263. void __init plat_early_device_setup(void)
  264. {
  265. early_platform_add_devices(sh7780_early_devices,
  266. ARRAY_SIZE(sh7780_early_devices));
  267. }
  268. enum {
  269. UNUSED = 0,
  270. /* interrupt sources */
  271. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  272. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  273. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  274. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  275. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  276. RTC, WDT, TMU0, TMU1, TMU2, TMU2_TICPI,
  277. HUDI, DMAC0, SCIF0, DMAC1, CMT, HAC,
  278. PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,
  279. SCIF1, SIOF, HSPI, MMCIF, TMU3, TMU4, TMU5, SSI, FLCTL, GPIO,
  280. /* interrupt groups */
  281. TMU012, TMU345,
  282. };
  283. static struct intc_vect vectors[] __initdata = {
  284. INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
  285. INTC_VECT(RTC, 0x4c0),
  286. INTC_VECT(WDT, 0x560),
  287. INTC_VECT(TMU0, 0x580), INTC_VECT(TMU1, 0x5a0),
  288. INTC_VECT(TMU2, 0x5c0), INTC_VECT(TMU2_TICPI, 0x5e0),
  289. INTC_VECT(HUDI, 0x600),
  290. INTC_VECT(DMAC0, 0x640), INTC_VECT(DMAC0, 0x660),
  291. INTC_VECT(DMAC0, 0x680), INTC_VECT(DMAC0, 0x6a0),
  292. INTC_VECT(DMAC0, 0x6c0),
  293. INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),
  294. INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),
  295. INTC_VECT(DMAC0, 0x780), INTC_VECT(DMAC0, 0x7a0),
  296. INTC_VECT(DMAC1, 0x7c0), INTC_VECT(DMAC1, 0x7e0),
  297. INTC_VECT(CMT, 0x900), INTC_VECT(HAC, 0x980),
  298. INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),
  299. INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),
  300. INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),
  301. INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),
  302. INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),
  303. INTC_VECT(SCIF1, 0xb80), INTC_VECT(SCIF1, 0xba0),
  304. INTC_VECT(SCIF1, 0xbc0), INTC_VECT(SCIF1, 0xbe0),
  305. INTC_VECT(SIOF, 0xc00), INTC_VECT(HSPI, 0xc80),
  306. INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),
  307. INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),
  308. INTC_VECT(DMAC1, 0xd80), INTC_VECT(DMAC1, 0xda0),
  309. INTC_VECT(DMAC1, 0xdc0), INTC_VECT(DMAC1, 0xde0),
  310. INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),
  311. INTC_VECT(TMU5, 0xe40),
  312. INTC_VECT(SSI, 0xe80),
  313. INTC_VECT(FLCTL, 0xf00), INTC_VECT(FLCTL, 0xf20),
  314. INTC_VECT(FLCTL, 0xf40), INTC_VECT(FLCTL, 0xf60),
  315. INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),
  316. INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),
  317. };
  318. static struct intc_group groups[] __initdata = {
  319. INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),
  320. INTC_GROUP(TMU345, TMU3, TMU4, TMU5),
  321. };
  322. static struct intc_mask_reg mask_registers[] __initdata = {
  323. { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */
  324. { 0, 0, 0, 0, 0, 0, GPIO, FLCTL,
  325. SSI, MMCIF, HSPI, SIOF, PCIC5, PCIINTD, PCIINTC, PCIINTB,
  326. PCIINTA, PCISERR, HAC, CMT, 0, 0, DMAC1, DMAC0,
  327. HUDI, 0, WDT, SCIF1, SCIF0, RTC, TMU345, TMU012 } },
  328. };
  329. static struct intc_prio_reg prio_registers[] __initdata = {
  330. { 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,
  331. TMU2, TMU2_TICPI } },
  332. { 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, RTC } },
  333. { 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1, WDT } },
  334. { 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { HUDI, DMAC0, DMAC1 } },
  335. { 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { CMT, HAC,
  336. PCISERR, PCIINTA, } },
  337. { 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { PCIINTB, PCIINTC,
  338. PCIINTD, PCIC5 } },
  339. { 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { SIOF, HSPI, MMCIF, SSI } },
  340. { 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { FLCTL, GPIO } },
  341. };
  342. static DECLARE_INTC_DESC(intc_desc, "sh7780", vectors, groups,
  343. mask_registers, prio_registers, NULL);
  344. /* Support for external interrupt pins in IRQ mode */
  345. static struct intc_vect irq_vectors[] __initdata = {
  346. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  347. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  348. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  349. INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),
  350. };
  351. static struct intc_mask_reg irq_mask_registers[] __initdata = {
  352. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  353. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  354. };
  355. static struct intc_prio_reg irq_prio_registers[] __initdata = {
  356. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  357. IRQ4, IRQ5, IRQ6, IRQ7 } },
  358. };
  359. static struct intc_sense_reg irq_sense_registers[] __initdata = {
  360. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  361. IRQ4, IRQ5, IRQ6, IRQ7 } },
  362. };
  363. static struct intc_mask_reg irq_ack_registers[] __initdata = {
  364. { 0xffd00024, 0, 32, /* INTREQ */
  365. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  366. };
  367. static DECLARE_INTC_DESC_ACK(intc_irq_desc, "sh7780-irq", irq_vectors,
  368. NULL, irq_mask_registers, irq_prio_registers,
  369. irq_sense_registers, irq_ack_registers);
  370. /* External interrupt pins in IRL mode */
  371. static struct intc_vect irl_vectors[] __initdata = {
  372. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  373. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  374. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  375. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  376. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  377. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  378. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  379. INTC_VECT(IRL_HHHL, 0x3c0),
  380. };
  381. static struct intc_mask_reg irl3210_mask_registers[] __initdata = {
  382. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  383. { IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  384. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  385. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  386. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  387. };
  388. static struct intc_mask_reg irl7654_mask_registers[] __initdata = {
  389. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  390. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  391. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  392. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  393. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  394. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  395. };
  396. static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7780-irl7654", irl_vectors,
  397. NULL, irl7654_mask_registers, NULL, NULL);
  398. static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7780-irl3210", irl_vectors,
  399. NULL, irl3210_mask_registers, NULL, NULL);
  400. #define INTC_ICR0 0xffd00000
  401. #define INTC_INTMSK0 0xffd00044
  402. #define INTC_INTMSK1 0xffd00048
  403. #define INTC_INTMSK2 0xffd40080
  404. #define INTC_INTMSKCLR1 0xffd00068
  405. #define INTC_INTMSKCLR2 0xffd40084
  406. void __init plat_irq_setup(void)
  407. {
  408. /* disable IRQ7-0 */
  409. ctrl_outl(0xff000000, INTC_INTMSK0);
  410. /* disable IRL3-0 + IRL7-4 */
  411. ctrl_outl(0xc0000000, INTC_INTMSK1);
  412. ctrl_outl(0xfffefffe, INTC_INTMSK2);
  413. /* select IRL mode for IRL3-0 + IRL7-4 */
  414. ctrl_outl(ctrl_inl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  415. /* disable holding function, ie enable "SH-4 Mode" */
  416. ctrl_outl(ctrl_inl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  417. register_intc_controller(&intc_desc);
  418. }
  419. void __init plat_irq_setup_pins(int mode)
  420. {
  421. switch (mode) {
  422. case IRQ_MODE_IRQ:
  423. /* select IRQ mode for IRL3-0 + IRL7-4 */
  424. ctrl_outl(ctrl_inl(INTC_ICR0) | 0x00c00000, INTC_ICR0);
  425. register_intc_controller(&intc_irq_desc);
  426. break;
  427. case IRQ_MODE_IRL7654:
  428. /* enable IRL7-4 but don't provide any masking */
  429. ctrl_outl(0x40000000, INTC_INTMSKCLR1);
  430. ctrl_outl(0x0000fffe, INTC_INTMSKCLR2);
  431. break;
  432. case IRQ_MODE_IRL3210:
  433. /* enable IRL0-3 but don't provide any masking */
  434. ctrl_outl(0x80000000, INTC_INTMSKCLR1);
  435. ctrl_outl(0xfffe0000, INTC_INTMSKCLR2);
  436. break;
  437. case IRQ_MODE_IRL7654_MASK:
  438. /* enable IRL7-4 and mask using cpu intc controller */
  439. ctrl_outl(0x40000000, INTC_INTMSKCLR1);
  440. register_intc_controller(&intc_irl7654_desc);
  441. break;
  442. case IRQ_MODE_IRL3210_MASK:
  443. /* enable IRL0-3 and mask using cpu intc controller */
  444. ctrl_outl(0x80000000, INTC_INTMSKCLR1);
  445. register_intc_controller(&intc_irl3210_desc);
  446. break;
  447. default:
  448. BUG();
  449. }
  450. }