setup-sh7785.c 18 KB

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