setup-sh7785.c 17 KB

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