setup-sh7785.c 19 KB

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