setup-sh7785.c 18 KB

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