setup-sh7785.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /*
  2. * SH7785 Setup
  3. *
  4. * Copyright (C) 2007 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/serial_sci.h>
  14. #include <linux/io.h>
  15. #include <linux/mm.h>
  16. #include <linux/sh_dma.h>
  17. #include <linux/sh_timer.h>
  18. #include <linux/sh_intc.h>
  19. #include <asm/mmzone.h>
  20. #include <cpu/dma-register.h>
  21. static struct plat_sci_port scif0_platform_data = {
  22. .mapbase = 0xffea0000,
  23. .flags = UPF_BOOT_AUTOCONF,
  24. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  25. .scbrr_algo_id = SCBRR_ALGO_1,
  26. .type = PORT_SCIF,
  27. .irqs = SCIx_IRQ_MUXED(evt2irq(0x700)),
  28. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  29. };
  30. static struct platform_device scif0_device = {
  31. .name = "sh-sci",
  32. .id = 0,
  33. .dev = {
  34. .platform_data = &scif0_platform_data,
  35. },
  36. };
  37. static struct plat_sci_port scif1_platform_data = {
  38. .mapbase = 0xffeb0000,
  39. .flags = UPF_BOOT_AUTOCONF,
  40. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  41. .scbrr_algo_id = SCBRR_ALGO_1,
  42. .type = PORT_SCIF,
  43. .irqs = SCIx_IRQ_MUXED(evt2irq(0x780)),
  44. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  45. };
  46. static struct platform_device scif1_device = {
  47. .name = "sh-sci",
  48. .id = 1,
  49. .dev = {
  50. .platform_data = &scif1_platform_data,
  51. },
  52. };
  53. static struct plat_sci_port scif2_platform_data = {
  54. .mapbase = 0xffec0000,
  55. .flags = UPF_BOOT_AUTOCONF,
  56. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  57. .scbrr_algo_id = SCBRR_ALGO_1,
  58. .type = PORT_SCIF,
  59. .irqs = SCIx_IRQ_MUXED(evt2irq(0x980)),
  60. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  61. };
  62. static struct platform_device scif2_device = {
  63. .name = "sh-sci",
  64. .id = 2,
  65. .dev = {
  66. .platform_data = &scif2_platform_data,
  67. },
  68. };
  69. static struct plat_sci_port scif3_platform_data = {
  70. .mapbase = 0xffed0000,
  71. .flags = UPF_BOOT_AUTOCONF,
  72. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  73. .scbrr_algo_id = SCBRR_ALGO_1,
  74. .type = PORT_SCIF,
  75. .irqs = SCIx_IRQ_MUXED(evt2irq(0x9a0)),
  76. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  77. };
  78. static struct platform_device scif3_device = {
  79. .name = "sh-sci",
  80. .id = 3,
  81. .dev = {
  82. .platform_data = &scif3_platform_data,
  83. },
  84. };
  85. static struct plat_sci_port scif4_platform_data = {
  86. .mapbase = 0xffee0000,
  87. .flags = UPF_BOOT_AUTOCONF,
  88. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  89. .scbrr_algo_id = SCBRR_ALGO_1,
  90. .type = PORT_SCIF,
  91. .irqs = SCIx_IRQ_MUXED(evt2irq(0x9c0)),
  92. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  93. };
  94. static struct platform_device scif4_device = {
  95. .name = "sh-sci",
  96. .id = 4,
  97. .dev = {
  98. .platform_data = &scif4_platform_data,
  99. },
  100. };
  101. static struct plat_sci_port scif5_platform_data = {
  102. .mapbase = 0xffef0000,
  103. .flags = UPF_BOOT_AUTOCONF,
  104. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_CKE1,
  105. .scbrr_algo_id = SCBRR_ALGO_1,
  106. .type = PORT_SCIF,
  107. .irqs = SCIx_IRQ_MUXED(evt2irq(0x9e0)),
  108. .regtype = SCIx_SH4_SCIF_FIFODATA_REGTYPE,
  109. };
  110. static struct platform_device scif5_device = {
  111. .name = "sh-sci",
  112. .id = 5,
  113. .dev = {
  114. .platform_data = &scif5_platform_data,
  115. },
  116. };
  117. static struct sh_timer_config tmu0_platform_data = {
  118. .channel_offset = 0x04,
  119. .timer_bit = 0,
  120. .clockevent_rating = 200,
  121. };
  122. static struct resource tmu0_resources[] = {
  123. [0] = {
  124. .start = 0xffd80008,
  125. .end = 0xffd80013,
  126. .flags = IORESOURCE_MEM,
  127. },
  128. [1] = {
  129. .start = evt2irq(0x580),
  130. .flags = IORESOURCE_IRQ,
  131. },
  132. };
  133. static struct platform_device tmu0_device = {
  134. .name = "sh_tmu",
  135. .id = 0,
  136. .dev = {
  137. .platform_data = &tmu0_platform_data,
  138. },
  139. .resource = tmu0_resources,
  140. .num_resources = ARRAY_SIZE(tmu0_resources),
  141. };
  142. static struct sh_timer_config tmu1_platform_data = {
  143. .channel_offset = 0x10,
  144. .timer_bit = 1,
  145. .clocksource_rating = 200,
  146. };
  147. static struct resource tmu1_resources[] = {
  148. [0] = {
  149. .start = 0xffd80014,
  150. .end = 0xffd8001f,
  151. .flags = IORESOURCE_MEM,
  152. },
  153. [1] = {
  154. .start = evt2irq(0x5a0),
  155. .flags = IORESOURCE_IRQ,
  156. },
  157. };
  158. static struct platform_device tmu1_device = {
  159. .name = "sh_tmu",
  160. .id = 1,
  161. .dev = {
  162. .platform_data = &tmu1_platform_data,
  163. },
  164. .resource = tmu1_resources,
  165. .num_resources = ARRAY_SIZE(tmu1_resources),
  166. };
  167. static struct sh_timer_config tmu2_platform_data = {
  168. .channel_offset = 0x1c,
  169. .timer_bit = 2,
  170. };
  171. static struct resource tmu2_resources[] = {
  172. [0] = {
  173. .start = 0xffd80020,
  174. .end = 0xffd8002f,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. [1] = {
  178. .start = evt2irq(0x5c0),
  179. .flags = IORESOURCE_IRQ,
  180. },
  181. };
  182. static struct platform_device tmu2_device = {
  183. .name = "sh_tmu",
  184. .id = 2,
  185. .dev = {
  186. .platform_data = &tmu2_platform_data,
  187. },
  188. .resource = tmu2_resources,
  189. .num_resources = ARRAY_SIZE(tmu2_resources),
  190. };
  191. static struct sh_timer_config tmu3_platform_data = {
  192. .channel_offset = 0x04,
  193. .timer_bit = 0,
  194. };
  195. static struct resource tmu3_resources[] = {
  196. [0] = {
  197. .start = 0xffdc0008,
  198. .end = 0xffdc0013,
  199. .flags = IORESOURCE_MEM,
  200. },
  201. [1] = {
  202. .start = evt2irq(0xe00),
  203. .flags = IORESOURCE_IRQ,
  204. },
  205. };
  206. static struct platform_device tmu3_device = {
  207. .name = "sh_tmu",
  208. .id = 3,
  209. .dev = {
  210. .platform_data = &tmu3_platform_data,
  211. },
  212. .resource = tmu3_resources,
  213. .num_resources = ARRAY_SIZE(tmu3_resources),
  214. };
  215. static struct sh_timer_config tmu4_platform_data = {
  216. .channel_offset = 0x10,
  217. .timer_bit = 1,
  218. };
  219. static struct resource tmu4_resources[] = {
  220. [0] = {
  221. .start = 0xffdc0014,
  222. .end = 0xffdc001f,
  223. .flags = IORESOURCE_MEM,
  224. },
  225. [1] = {
  226. .start = evt2irq(0xe20),
  227. .flags = IORESOURCE_IRQ,
  228. },
  229. };
  230. static struct platform_device tmu4_device = {
  231. .name = "sh_tmu",
  232. .id = 4,
  233. .dev = {
  234. .platform_data = &tmu4_platform_data,
  235. },
  236. .resource = tmu4_resources,
  237. .num_resources = ARRAY_SIZE(tmu4_resources),
  238. };
  239. static struct sh_timer_config tmu5_platform_data = {
  240. .channel_offset = 0x1c,
  241. .timer_bit = 2,
  242. };
  243. static struct resource tmu5_resources[] = {
  244. [0] = {
  245. .start = 0xffdc0020,
  246. .end = 0xffdc002b,
  247. .flags = IORESOURCE_MEM,
  248. },
  249. [1] = {
  250. .start = evt2irq(0xe40),
  251. .flags = IORESOURCE_IRQ,
  252. },
  253. };
  254. static struct platform_device tmu5_device = {
  255. .name = "sh_tmu",
  256. .id = 5,
  257. .dev = {
  258. .platform_data = &tmu5_platform_data,
  259. },
  260. .resource = tmu5_resources,
  261. .num_resources = ARRAY_SIZE(tmu5_resources),
  262. };
  263. /* DMA */
  264. static const struct sh_dmae_channel sh7785_dmae0_channels[] = {
  265. {
  266. .offset = 0,
  267. .dmars = 0,
  268. .dmars_bit = 0,
  269. }, {
  270. .offset = 0x10,
  271. .dmars = 0,
  272. .dmars_bit = 8,
  273. }, {
  274. .offset = 0x20,
  275. .dmars = 4,
  276. .dmars_bit = 0,
  277. }, {
  278. .offset = 0x30,
  279. .dmars = 4,
  280. .dmars_bit = 8,
  281. }, {
  282. .offset = 0x50,
  283. .dmars = 8,
  284. .dmars_bit = 0,
  285. }, {
  286. .offset = 0x60,
  287. .dmars = 8,
  288. .dmars_bit = 8,
  289. }
  290. };
  291. static const struct sh_dmae_channel sh7785_dmae1_channels[] = {
  292. {
  293. .offset = 0,
  294. }, {
  295. .offset = 0x10,
  296. }, {
  297. .offset = 0x20,
  298. }, {
  299. .offset = 0x30,
  300. }, {
  301. .offset = 0x50,
  302. }, {
  303. .offset = 0x60,
  304. }
  305. };
  306. static const unsigned int ts_shift[] = TS_SHIFT;
  307. static struct sh_dmae_pdata dma0_platform_data = {
  308. .channel = sh7785_dmae0_channels,
  309. .channel_num = ARRAY_SIZE(sh7785_dmae0_channels),
  310. .ts_low_shift = CHCR_TS_LOW_SHIFT,
  311. .ts_low_mask = CHCR_TS_LOW_MASK,
  312. .ts_high_shift = CHCR_TS_HIGH_SHIFT,
  313. .ts_high_mask = CHCR_TS_HIGH_MASK,
  314. .ts_shift = ts_shift,
  315. .ts_shift_num = ARRAY_SIZE(ts_shift),
  316. .dmaor_init = DMAOR_INIT,
  317. };
  318. static struct sh_dmae_pdata dma1_platform_data = {
  319. .channel = sh7785_dmae1_channels,
  320. .channel_num = ARRAY_SIZE(sh7785_dmae1_channels),
  321. .ts_low_shift = CHCR_TS_LOW_SHIFT,
  322. .ts_low_mask = CHCR_TS_LOW_MASK,
  323. .ts_high_shift = CHCR_TS_HIGH_SHIFT,
  324. .ts_high_mask = CHCR_TS_HIGH_MASK,
  325. .ts_shift = ts_shift,
  326. .ts_shift_num = ARRAY_SIZE(ts_shift),
  327. .dmaor_init = DMAOR_INIT,
  328. };
  329. static struct resource sh7785_dmae0_resources[] = {
  330. [0] = {
  331. /* Channel registers and DMAOR */
  332. .start = 0xfc808020,
  333. .end = 0xfc80808f,
  334. .flags = IORESOURCE_MEM,
  335. },
  336. [1] = {
  337. /* DMARSx */
  338. .start = 0xfc809000,
  339. .end = 0xfc80900b,
  340. .flags = IORESOURCE_MEM,
  341. },
  342. {
  343. /*
  344. * Real DMA error vector is 0x6e0, and channel
  345. * vectors are 0x620-0x6c0
  346. */
  347. .name = "error_irq",
  348. .start = evt2irq(0x620),
  349. .end = evt2irq(0x620),
  350. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE,
  351. },
  352. };
  353. static struct resource sh7785_dmae1_resources[] = {
  354. [0] = {
  355. /* Channel registers and DMAOR */
  356. .start = 0xfcc08020,
  357. .end = 0xfcc0808f,
  358. .flags = IORESOURCE_MEM,
  359. },
  360. /* DMAC1 has no DMARS */
  361. {
  362. /*
  363. * Real DMA error vector is 0x940, and channel
  364. * vectors are 0x880-0x920
  365. */
  366. .name = "error_irq",
  367. .start = evt2irq(0x880),
  368. .end = evt2irq(0x880),
  369. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE,
  370. },
  371. };
  372. static struct platform_device dma0_device = {
  373. .name = "sh-dma-engine",
  374. .id = 0,
  375. .resource = sh7785_dmae0_resources,
  376. .num_resources = ARRAY_SIZE(sh7785_dmae0_resources),
  377. .dev = {
  378. .platform_data = &dma0_platform_data,
  379. },
  380. };
  381. static struct platform_device dma1_device = {
  382. .name = "sh-dma-engine",
  383. .id = 1,
  384. .resource = sh7785_dmae1_resources,
  385. .num_resources = ARRAY_SIZE(sh7785_dmae1_resources),
  386. .dev = {
  387. .platform_data = &dma1_platform_data,
  388. },
  389. };
  390. static struct platform_device *sh7785_devices[] __initdata = {
  391. &scif0_device,
  392. &scif1_device,
  393. &scif2_device,
  394. &scif3_device,
  395. &scif4_device,
  396. &scif5_device,
  397. &tmu0_device,
  398. &tmu1_device,
  399. &tmu2_device,
  400. &tmu3_device,
  401. &tmu4_device,
  402. &tmu5_device,
  403. &dma0_device,
  404. &dma1_device,
  405. };
  406. static int __init sh7785_devices_setup(void)
  407. {
  408. return platform_add_devices(sh7785_devices,
  409. ARRAY_SIZE(sh7785_devices));
  410. }
  411. arch_initcall(sh7785_devices_setup);
  412. static struct platform_device *sh7785_early_devices[] __initdata = {
  413. &scif0_device,
  414. &scif1_device,
  415. &scif2_device,
  416. &scif3_device,
  417. &scif4_device,
  418. &scif5_device,
  419. &tmu0_device,
  420. &tmu1_device,
  421. &tmu2_device,
  422. &tmu3_device,
  423. &tmu4_device,
  424. &tmu5_device,
  425. };
  426. void __init plat_early_device_setup(void)
  427. {
  428. early_platform_add_devices(sh7785_early_devices,
  429. ARRAY_SIZE(sh7785_early_devices));
  430. }
  431. enum {
  432. UNUSED = 0,
  433. /* interrupt sources */
  434. IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  435. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  436. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  437. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL,
  438. IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,
  439. IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,
  440. IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,
  441. IRL4_HHLL, IRL4_HHLH, IRL4_HHHL,
  442. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
  443. WDT, TMU0, TMU1, TMU2, TMU2_TICPI,
  444. HUDI, DMAC0, SCIF0, SCIF1, DMAC1, HSPI,
  445. SCIF2, SCIF3, SCIF4, SCIF5,
  446. PCISERR, PCIINTA, PCIINTB, PCIINTC, PCIINTD, PCIC5,
  447. SIOF, MMCIF, DU, GDTA,
  448. TMU3, TMU4, TMU5,
  449. SSI0, SSI1,
  450. HAC0, HAC1,
  451. FLCTL, GPIO,
  452. /* interrupt groups */
  453. TMU012, TMU345
  454. };
  455. static struct intc_vect vectors[] __initdata = {
  456. INTC_VECT(WDT, 0x560),
  457. INTC_VECT(TMU0, 0x580), INTC_VECT(TMU1, 0x5a0),
  458. INTC_VECT(TMU2, 0x5c0), INTC_VECT(TMU2_TICPI, 0x5e0),
  459. INTC_VECT(HUDI, 0x600),
  460. INTC_VECT(DMAC0, 0x620), INTC_VECT(DMAC0, 0x640),
  461. INTC_VECT(DMAC0, 0x660), INTC_VECT(DMAC0, 0x680),
  462. INTC_VECT(DMAC0, 0x6a0), INTC_VECT(DMAC0, 0x6c0),
  463. INTC_VECT(DMAC0, 0x6e0),
  464. INTC_VECT(SCIF0, 0x700), INTC_VECT(SCIF0, 0x720),
  465. INTC_VECT(SCIF0, 0x740), INTC_VECT(SCIF0, 0x760),
  466. INTC_VECT(SCIF1, 0x780), INTC_VECT(SCIF1, 0x7a0),
  467. INTC_VECT(SCIF1, 0x7c0), INTC_VECT(SCIF1, 0x7e0),
  468. INTC_VECT(DMAC1, 0x880), INTC_VECT(DMAC1, 0x8a0),
  469. INTC_VECT(DMAC1, 0x8c0), INTC_VECT(DMAC1, 0x8e0),
  470. INTC_VECT(DMAC1, 0x900), INTC_VECT(DMAC1, 0x920),
  471. INTC_VECT(DMAC1, 0x940),
  472. INTC_VECT(HSPI, 0x960),
  473. INTC_VECT(SCIF2, 0x980), INTC_VECT(SCIF3, 0x9a0),
  474. INTC_VECT(SCIF4, 0x9c0), INTC_VECT(SCIF5, 0x9e0),
  475. INTC_VECT(PCISERR, 0xa00), INTC_VECT(PCIINTA, 0xa20),
  476. INTC_VECT(PCIINTB, 0xa40), INTC_VECT(PCIINTC, 0xa60),
  477. INTC_VECT(PCIINTD, 0xa80), INTC_VECT(PCIC5, 0xaa0),
  478. INTC_VECT(PCIC5, 0xac0), INTC_VECT(PCIC5, 0xae0),
  479. INTC_VECT(PCIC5, 0xb00), INTC_VECT(PCIC5, 0xb20),
  480. INTC_VECT(SIOF, 0xc00),
  481. INTC_VECT(MMCIF, 0xd00), INTC_VECT(MMCIF, 0xd20),
  482. INTC_VECT(MMCIF, 0xd40), INTC_VECT(MMCIF, 0xd60),
  483. INTC_VECT(DU, 0xd80),
  484. INTC_VECT(GDTA, 0xda0), INTC_VECT(GDTA, 0xdc0),
  485. INTC_VECT(GDTA, 0xde0),
  486. INTC_VECT(TMU3, 0xe00), INTC_VECT(TMU4, 0xe20),
  487. INTC_VECT(TMU5, 0xe40),
  488. INTC_VECT(SSI0, 0xe80), INTC_VECT(SSI1, 0xea0),
  489. INTC_VECT(HAC0, 0xec0), INTC_VECT(HAC1, 0xee0),
  490. INTC_VECT(FLCTL, 0xf00), INTC_VECT(FLCTL, 0xf20),
  491. INTC_VECT(FLCTL, 0xf40), INTC_VECT(FLCTL, 0xf60),
  492. INTC_VECT(GPIO, 0xf80), INTC_VECT(GPIO, 0xfa0),
  493. INTC_VECT(GPIO, 0xfc0), INTC_VECT(GPIO, 0xfe0),
  494. };
  495. static struct intc_group groups[] __initdata = {
  496. INTC_GROUP(TMU012, TMU0, TMU1, TMU2, TMU2_TICPI),
  497. INTC_GROUP(TMU345, TMU3, TMU4, TMU5),
  498. };
  499. static struct intc_mask_reg mask_registers[] __initdata = {
  500. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  501. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  502. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  503. { IRL0_LLLL, IRL0_LLLH, IRL0_LLHL, IRL0_LLHH,
  504. IRL0_LHLL, IRL0_LHLH, IRL0_LHHL, IRL0_LHHH,
  505. IRL0_HLLL, IRL0_HLLH, IRL0_HLHL, IRL0_HLHH,
  506. IRL0_HHLL, IRL0_HHLH, IRL0_HHHL, 0,
  507. IRL4_LLLL, IRL4_LLLH, IRL4_LLHL, IRL4_LLHH,
  508. IRL4_LHLL, IRL4_LHLH, IRL4_LHHL, IRL4_LHHH,
  509. IRL4_HLLL, IRL4_HLLH, IRL4_HLHL, IRL4_HLHH,
  510. IRL4_HHLL, IRL4_HHLH, IRL4_HHHL, 0, } },
  511. { 0xffd40038, 0xffd4003c, 32, /* INT2MSKR / INT2MSKCR */
  512. { 0, 0, 0, GDTA, DU, SSI0, SSI1, GPIO,
  513. FLCTL, MMCIF, HSPI, SIOF, PCIC5, PCIINTD, PCIINTC, PCIINTB,
  514. PCIINTA, PCISERR, HAC1, HAC0, DMAC1, DMAC0, HUDI, WDT,
  515. SCIF5, SCIF4, SCIF3, SCIF2, SCIF1, SCIF0, TMU345, TMU012 } },
  516. };
  517. static struct intc_prio_reg prio_registers[] __initdata = {
  518. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  519. IRQ4, IRQ5, IRQ6, IRQ7 } },
  520. { 0xffd40000, 0, 32, 8, /* INT2PRI0 */ { TMU0, TMU1,
  521. TMU2, TMU2_TICPI } },
  522. { 0xffd40004, 0, 32, 8, /* INT2PRI1 */ { TMU3, TMU4, TMU5, } },
  523. { 0xffd40008, 0, 32, 8, /* INT2PRI2 */ { SCIF0, SCIF1,
  524. SCIF2, SCIF3 } },
  525. { 0xffd4000c, 0, 32, 8, /* INT2PRI3 */ { SCIF4, SCIF5, WDT, } },
  526. { 0xffd40010, 0, 32, 8, /* INT2PRI4 */ { HUDI, DMAC0, DMAC1, } },
  527. { 0xffd40014, 0, 32, 8, /* INT2PRI5 */ { HAC0, HAC1,
  528. PCISERR, PCIINTA } },
  529. { 0xffd40018, 0, 32, 8, /* INT2PRI6 */ { PCIINTB, PCIINTC,
  530. PCIINTD, PCIC5 } },
  531. { 0xffd4001c, 0, 32, 8, /* INT2PRI7 */ { SIOF, HSPI, MMCIF, } },
  532. { 0xffd40020, 0, 32, 8, /* INT2PRI8 */ { FLCTL, GPIO, SSI0, SSI1, } },
  533. { 0xffd40024, 0, 32, 8, /* INT2PRI9 */ { DU, GDTA, } },
  534. };
  535. static DECLARE_INTC_DESC(intc_desc, "sh7785", vectors, groups,
  536. mask_registers, prio_registers, NULL);
  537. /* Support for external interrupt pins in IRQ mode */
  538. static struct intc_vect vectors_irq0123[] __initdata = {
  539. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  540. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  541. };
  542. static struct intc_vect vectors_irq4567[] __initdata = {
  543. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  544. INTC_VECT(IRQ6, 0x3c0), INTC_VECT(IRQ7, 0x200),
  545. };
  546. static struct intc_sense_reg sense_registers[] __initdata = {
  547. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  548. IRQ4, IRQ5, IRQ6, IRQ7 } },
  549. };
  550. static struct intc_mask_reg ack_registers[] __initdata = {
  551. { 0xffd00024, 0, 32, /* INTREQ */
  552. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
  553. };
  554. static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh7785-irq0123",
  555. vectors_irq0123, NULL, mask_registers,
  556. prio_registers, sense_registers, ack_registers);
  557. static DECLARE_INTC_DESC_ACK(intc_desc_irq4567, "sh7785-irq4567",
  558. vectors_irq4567, NULL, mask_registers,
  559. prio_registers, sense_registers, ack_registers);
  560. /* External interrupt pins in IRL mode */
  561. static struct intc_vect vectors_irl0123[] __initdata = {
  562. INTC_VECT(IRL0_LLLL, 0x200), INTC_VECT(IRL0_LLLH, 0x220),
  563. INTC_VECT(IRL0_LLHL, 0x240), INTC_VECT(IRL0_LLHH, 0x260),
  564. INTC_VECT(IRL0_LHLL, 0x280), INTC_VECT(IRL0_LHLH, 0x2a0),
  565. INTC_VECT(IRL0_LHHL, 0x2c0), INTC_VECT(IRL0_LHHH, 0x2e0),
  566. INTC_VECT(IRL0_HLLL, 0x300), INTC_VECT(IRL0_HLLH, 0x320),
  567. INTC_VECT(IRL0_HLHL, 0x340), INTC_VECT(IRL0_HLHH, 0x360),
  568. INTC_VECT(IRL0_HHLL, 0x380), INTC_VECT(IRL0_HHLH, 0x3a0),
  569. INTC_VECT(IRL0_HHHL, 0x3c0),
  570. };
  571. static struct intc_vect vectors_irl4567[] __initdata = {
  572. INTC_VECT(IRL4_LLLL, 0xb00), INTC_VECT(IRL4_LLLH, 0xb20),
  573. INTC_VECT(IRL4_LLHL, 0xb40), INTC_VECT(IRL4_LLHH, 0xb60),
  574. INTC_VECT(IRL4_LHLL, 0xb80), INTC_VECT(IRL4_LHLH, 0xba0),
  575. INTC_VECT(IRL4_LHHL, 0xbc0), INTC_VECT(IRL4_LHHH, 0xbe0),
  576. INTC_VECT(IRL4_HLLL, 0xc00), INTC_VECT(IRL4_HLLH, 0xc20),
  577. INTC_VECT(IRL4_HLHL, 0xc40), INTC_VECT(IRL4_HLHH, 0xc60),
  578. INTC_VECT(IRL4_HHLL, 0xc80), INTC_VECT(IRL4_HHLH, 0xca0),
  579. INTC_VECT(IRL4_HHHL, 0xcc0),
  580. };
  581. static DECLARE_INTC_DESC(intc_desc_irl0123, "sh7785-irl0123", vectors_irl0123,
  582. NULL, mask_registers, NULL, NULL);
  583. static DECLARE_INTC_DESC(intc_desc_irl4567, "sh7785-irl4567", vectors_irl4567,
  584. NULL, mask_registers, NULL, NULL);
  585. #define INTC_ICR0 0xffd00000
  586. #define INTC_INTMSK0 0xffd00044
  587. #define INTC_INTMSK1 0xffd00048
  588. #define INTC_INTMSK2 0xffd40080
  589. #define INTC_INTMSKCLR1 0xffd00068
  590. #define INTC_INTMSKCLR2 0xffd40084
  591. void __init plat_irq_setup(void)
  592. {
  593. /* disable IRQ3-0 + IRQ7-4 */
  594. __raw_writel(0xff000000, INTC_INTMSK0);
  595. /* disable IRL3-0 + IRL7-4 */
  596. __raw_writel(0xc0000000, INTC_INTMSK1);
  597. __raw_writel(0xfffefffe, INTC_INTMSK2);
  598. /* select IRL mode for IRL3-0 + IRL7-4 */
  599. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  600. /* disable holding function, ie enable "SH-4 Mode" */
  601. __raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  602. register_intc_controller(&intc_desc);
  603. }
  604. void __init plat_irq_setup_pins(int mode)
  605. {
  606. switch (mode) {
  607. case IRQ_MODE_IRQ7654:
  608. /* select IRQ mode for IRL7-4 */
  609. __raw_writel(__raw_readl(INTC_ICR0) | 0x00400000, INTC_ICR0);
  610. register_intc_controller(&intc_desc_irq4567);
  611. break;
  612. case IRQ_MODE_IRQ3210:
  613. /* select IRQ mode for IRL3-0 */
  614. __raw_writel(__raw_readl(INTC_ICR0) | 0x00800000, INTC_ICR0);
  615. register_intc_controller(&intc_desc_irq0123);
  616. break;
  617. case IRQ_MODE_IRL7654:
  618. /* enable IRL7-4 but don't provide any masking */
  619. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  620. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  621. break;
  622. case IRQ_MODE_IRL3210:
  623. /* enable IRL0-3 but don't provide any masking */
  624. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  625. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  626. break;
  627. case IRQ_MODE_IRL7654_MASK:
  628. /* enable IRL7-4 and mask using cpu intc controller */
  629. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  630. register_intc_controller(&intc_desc_irl4567);
  631. break;
  632. case IRQ_MODE_IRL3210_MASK:
  633. /* enable IRL0-3 and mask using cpu intc controller */
  634. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  635. register_intc_controller(&intc_desc_irl0123);
  636. break;
  637. default:
  638. BUG();
  639. }
  640. }
  641. void __init plat_mem_setup(void)
  642. {
  643. /* Register the URAM space as Node 1 */
  644. setup_bootmem_node(1, 0xe55f0000, 0xe5610000);
  645. }