setup-sh7785.c 16 KB

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