setup-sh7785.c 17 KB

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