setup-sh7785.c 16 KB

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