setup-sh7785.c 18 KB

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