setup-sh7770.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /*
  2. * SH7770 Setup
  3. *
  4. * Copyright (C) 2006 - 2008 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/sh_timer.h>
  15. #include <linux/io.h>
  16. static struct plat_sci_port scif0_platform_data = {
  17. .mapbase = 0xff923000,
  18. .flags = UPF_BOOT_AUTOCONF,
  19. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  20. .scbrr_algo_id = SCBRR_ALGO_2,
  21. .type = PORT_SCIF,
  22. .irqs = { 61, 61, 61, 61 },
  23. };
  24. static struct platform_device scif0_device = {
  25. .name = "sh-sci",
  26. .id = 0,
  27. .dev = {
  28. .platform_data = &scif0_platform_data,
  29. },
  30. };
  31. static struct plat_sci_port scif1_platform_data = {
  32. .mapbase = 0xff924000,
  33. .flags = UPF_BOOT_AUTOCONF,
  34. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  35. .scbrr_algo_id = SCBRR_ALGO_2,
  36. .type = PORT_SCIF,
  37. .irqs = { 62, 62, 62, 62 },
  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 = 0xff925000,
  48. .flags = UPF_BOOT_AUTOCONF,
  49. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  50. .scbrr_algo_id = SCBRR_ALGO_2,
  51. .type = PORT_SCIF,
  52. .irqs = { 63, 63, 63, 63 },
  53. };
  54. static struct platform_device scif2_device = {
  55. .name = "sh-sci",
  56. .id = 2,
  57. .dev = {
  58. .platform_data = &scif2_platform_data,
  59. },
  60. };
  61. static struct plat_sci_port scif3_platform_data = {
  62. .mapbase = 0xff926000,
  63. .flags = UPF_BOOT_AUTOCONF,
  64. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  65. .scbrr_algo_id = SCBRR_ALGO_2,
  66. .type = PORT_SCIF,
  67. .irqs = { 64, 64, 64, 64 },
  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 = 0xff927000,
  78. .flags = UPF_BOOT_AUTOCONF,
  79. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  80. .scbrr_algo_id = SCBRR_ALGO_2,
  81. .type = PORT_SCIF,
  82. .irqs = { 65, 65, 65, 65 },
  83. };
  84. static struct platform_device scif4_device = {
  85. .name = "sh-sci",
  86. .id = 4,
  87. .dev = {
  88. .platform_data = &scif4_platform_data,
  89. },
  90. };
  91. static struct plat_sci_port scif5_platform_data = {
  92. .mapbase = 0xff928000,
  93. .flags = UPF_BOOT_AUTOCONF,
  94. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  95. .scbrr_algo_id = SCBRR_ALGO_2,
  96. .type = PORT_SCIF,
  97. .irqs = { 66, 66, 66, 66 },
  98. };
  99. static struct platform_device scif5_device = {
  100. .name = "sh-sci",
  101. .id = 5,
  102. .dev = {
  103. .platform_data = &scif5_platform_data,
  104. },
  105. };
  106. static struct plat_sci_port scif6_platform_data = {
  107. .mapbase = 0xff929000,
  108. .flags = UPF_BOOT_AUTOCONF,
  109. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  110. .scbrr_algo_id = SCBRR_ALGO_2,
  111. .type = PORT_SCIF,
  112. .irqs = { 67, 67, 67, 67 },
  113. };
  114. static struct platform_device scif6_device = {
  115. .name = "sh-sci",
  116. .id = 6,
  117. .dev = {
  118. .platform_data = &scif6_platform_data,
  119. },
  120. };
  121. static struct plat_sci_port scif7_platform_data = {
  122. .mapbase = 0xff92a000,
  123. .flags = UPF_BOOT_AUTOCONF,
  124. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  125. .scbrr_algo_id = SCBRR_ALGO_2,
  126. .type = PORT_SCIF,
  127. .irqs = { 68, 68, 68, 68 },
  128. };
  129. static struct platform_device scif7_device = {
  130. .name = "sh-sci",
  131. .id = 7,
  132. .dev = {
  133. .platform_data = &scif7_platform_data,
  134. },
  135. };
  136. static struct plat_sci_port scif8_platform_data = {
  137. .mapbase = 0xff92b000,
  138. .flags = UPF_BOOT_AUTOCONF,
  139. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  140. .scbrr_algo_id = SCBRR_ALGO_2,
  141. .type = PORT_SCIF,
  142. .irqs = { 69, 69, 69, 69 },
  143. };
  144. static struct platform_device scif8_device = {
  145. .name = "sh-sci",
  146. .id = 8,
  147. .dev = {
  148. .platform_data = &scif8_platform_data,
  149. },
  150. };
  151. static struct plat_sci_port scif9_platform_data = {
  152. .mapbase = 0xff92c000,
  153. .flags = UPF_BOOT_AUTOCONF,
  154. .scscr = SCSCR_RE | SCSCR_TE | SCSCR_REIE | SCSCR_TOIE,
  155. .scbrr_algo_id = SCBRR_ALGO_2,
  156. .type = PORT_SCIF,
  157. .irqs = { 70, 70, 70, 70 },
  158. };
  159. static struct platform_device scif9_device = {
  160. .name = "sh-sci",
  161. .id = 9,
  162. .dev = {
  163. .platform_data = &scif9_platform_data,
  164. },
  165. };
  166. static struct sh_timer_config tmu0_platform_data = {
  167. .channel_offset = 0x04,
  168. .timer_bit = 0,
  169. .clockevent_rating = 200,
  170. };
  171. static struct resource tmu0_resources[] = {
  172. [0] = {
  173. .start = 0xffd80008,
  174. .end = 0xffd80013,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. [1] = {
  178. .start = 16,
  179. .flags = IORESOURCE_IRQ,
  180. },
  181. };
  182. static struct platform_device tmu0_device = {
  183. .name = "sh_tmu",
  184. .id = 0,
  185. .dev = {
  186. .platform_data = &tmu0_platform_data,
  187. },
  188. .resource = tmu0_resources,
  189. .num_resources = ARRAY_SIZE(tmu0_resources),
  190. };
  191. static struct sh_timer_config tmu1_platform_data = {
  192. .channel_offset = 0x10,
  193. .timer_bit = 1,
  194. .clocksource_rating = 200,
  195. };
  196. static struct resource tmu1_resources[] = {
  197. [0] = {
  198. .start = 0xffd80014,
  199. .end = 0xffd8001f,
  200. .flags = IORESOURCE_MEM,
  201. },
  202. [1] = {
  203. .start = 17,
  204. .flags = IORESOURCE_IRQ,
  205. },
  206. };
  207. static struct platform_device tmu1_device = {
  208. .name = "sh_tmu",
  209. .id = 1,
  210. .dev = {
  211. .platform_data = &tmu1_platform_data,
  212. },
  213. .resource = tmu1_resources,
  214. .num_resources = ARRAY_SIZE(tmu1_resources),
  215. };
  216. static struct sh_timer_config tmu2_platform_data = {
  217. .channel_offset = 0x1c,
  218. .timer_bit = 2,
  219. };
  220. static struct resource tmu2_resources[] = {
  221. [0] = {
  222. .start = 0xffd80020,
  223. .end = 0xffd8002f,
  224. .flags = IORESOURCE_MEM,
  225. },
  226. [1] = {
  227. .start = 18,
  228. .flags = IORESOURCE_IRQ,
  229. },
  230. };
  231. static struct platform_device tmu2_device = {
  232. .name = "sh_tmu",
  233. .id = 2,
  234. .dev = {
  235. .platform_data = &tmu2_platform_data,
  236. },
  237. .resource = tmu2_resources,
  238. .num_resources = ARRAY_SIZE(tmu2_resources),
  239. };
  240. static struct sh_timer_config tmu3_platform_data = {
  241. .channel_offset = 0x04,
  242. .timer_bit = 0,
  243. };
  244. static struct resource tmu3_resources[] = {
  245. [0] = {
  246. .start = 0xffd81008,
  247. .end = 0xffd81013,
  248. .flags = IORESOURCE_MEM,
  249. },
  250. [1] = {
  251. .start = 19,
  252. .flags = IORESOURCE_IRQ,
  253. },
  254. };
  255. static struct platform_device tmu3_device = {
  256. .name = "sh_tmu",
  257. .id = 3,
  258. .dev = {
  259. .platform_data = &tmu3_platform_data,
  260. },
  261. .resource = tmu3_resources,
  262. .num_resources = ARRAY_SIZE(tmu3_resources),
  263. };
  264. static struct sh_timer_config tmu4_platform_data = {
  265. .channel_offset = 0x10,
  266. .timer_bit = 1,
  267. };
  268. static struct resource tmu4_resources[] = {
  269. [0] = {
  270. .start = 0xffd81014,
  271. .end = 0xffd8101f,
  272. .flags = IORESOURCE_MEM,
  273. },
  274. [1] = {
  275. .start = 20,
  276. .flags = IORESOURCE_IRQ,
  277. },
  278. };
  279. static struct platform_device tmu4_device = {
  280. .name = "sh_tmu",
  281. .id = 4,
  282. .dev = {
  283. .platform_data = &tmu4_platform_data,
  284. },
  285. .resource = tmu4_resources,
  286. .num_resources = ARRAY_SIZE(tmu4_resources),
  287. };
  288. static struct sh_timer_config tmu5_platform_data = {
  289. .channel_offset = 0x1c,
  290. .timer_bit = 2,
  291. };
  292. static struct resource tmu5_resources[] = {
  293. [0] = {
  294. .start = 0xffd81020,
  295. .end = 0xffd8102f,
  296. .flags = IORESOURCE_MEM,
  297. },
  298. [1] = {
  299. .start = 21,
  300. .flags = IORESOURCE_IRQ,
  301. },
  302. };
  303. static struct platform_device tmu5_device = {
  304. .name = "sh_tmu",
  305. .id = 5,
  306. .dev = {
  307. .platform_data = &tmu5_platform_data,
  308. },
  309. .resource = tmu5_resources,
  310. .num_resources = ARRAY_SIZE(tmu5_resources),
  311. };
  312. static struct sh_timer_config tmu6_platform_data = {
  313. .channel_offset = 0x04,
  314. .timer_bit = 0,
  315. };
  316. static struct resource tmu6_resources[] = {
  317. [0] = {
  318. .start = 0xffd82008,
  319. .end = 0xffd82013,
  320. .flags = IORESOURCE_MEM,
  321. },
  322. [1] = {
  323. .start = 22,
  324. .flags = IORESOURCE_IRQ,
  325. },
  326. };
  327. static struct platform_device tmu6_device = {
  328. .name = "sh_tmu",
  329. .id = 6,
  330. .dev = {
  331. .platform_data = &tmu6_platform_data,
  332. },
  333. .resource = tmu6_resources,
  334. .num_resources = ARRAY_SIZE(tmu6_resources),
  335. };
  336. static struct sh_timer_config tmu7_platform_data = {
  337. .channel_offset = 0x10,
  338. .timer_bit = 1,
  339. };
  340. static struct resource tmu7_resources[] = {
  341. [0] = {
  342. .start = 0xffd82014,
  343. .end = 0xffd8201f,
  344. .flags = IORESOURCE_MEM,
  345. },
  346. [1] = {
  347. .start = 23,
  348. .flags = IORESOURCE_IRQ,
  349. },
  350. };
  351. static struct platform_device tmu7_device = {
  352. .name = "sh_tmu",
  353. .id = 7,
  354. .dev = {
  355. .platform_data = &tmu7_platform_data,
  356. },
  357. .resource = tmu7_resources,
  358. .num_resources = ARRAY_SIZE(tmu7_resources),
  359. };
  360. static struct sh_timer_config tmu8_platform_data = {
  361. .channel_offset = 0x1c,
  362. .timer_bit = 2,
  363. };
  364. static struct resource tmu8_resources[] = {
  365. [0] = {
  366. .start = 0xffd82020,
  367. .end = 0xffd8202b,
  368. .flags = IORESOURCE_MEM,
  369. },
  370. [1] = {
  371. .start = 24,
  372. .flags = IORESOURCE_IRQ,
  373. },
  374. };
  375. static struct platform_device tmu8_device = {
  376. .name = "sh_tmu",
  377. .id = 8,
  378. .dev = {
  379. .platform_data = &tmu8_platform_data,
  380. },
  381. .resource = tmu8_resources,
  382. .num_resources = ARRAY_SIZE(tmu8_resources),
  383. };
  384. static struct platform_device *sh7770_devices[] __initdata = {
  385. &scif0_device,
  386. &scif1_device,
  387. &scif2_device,
  388. &scif3_device,
  389. &scif4_device,
  390. &scif5_device,
  391. &scif6_device,
  392. &scif7_device,
  393. &scif8_device,
  394. &scif9_device,
  395. &tmu0_device,
  396. &tmu1_device,
  397. &tmu2_device,
  398. &tmu3_device,
  399. &tmu4_device,
  400. &tmu5_device,
  401. &tmu6_device,
  402. &tmu7_device,
  403. &tmu8_device,
  404. };
  405. static int __init sh7770_devices_setup(void)
  406. {
  407. return platform_add_devices(sh7770_devices,
  408. ARRAY_SIZE(sh7770_devices));
  409. }
  410. arch_initcall(sh7770_devices_setup);
  411. static struct platform_device *sh7770_early_devices[] __initdata = {
  412. &scif0_device,
  413. &scif1_device,
  414. &scif2_device,
  415. &scif3_device,
  416. &scif4_device,
  417. &scif5_device,
  418. &scif6_device,
  419. &scif7_device,
  420. &scif8_device,
  421. &scif9_device,
  422. &tmu0_device,
  423. &tmu1_device,
  424. &tmu2_device,
  425. &tmu3_device,
  426. &tmu4_device,
  427. &tmu5_device,
  428. &tmu6_device,
  429. &tmu7_device,
  430. &tmu8_device,
  431. };
  432. void __init plat_early_device_setup(void)
  433. {
  434. early_platform_add_devices(sh7770_early_devices,
  435. ARRAY_SIZE(sh7770_early_devices));
  436. }
  437. enum {
  438. UNUSED = 0,
  439. /* interrupt sources */
  440. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  441. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  442. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  443. IRL_HHLL, IRL_HHLH, IRL_HHHL,
  444. IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
  445. GPIO,
  446. TMU0, TMU1, TMU2, TMU2_TICPI,
  447. TMU3, TMU4, TMU5, TMU5_TICPI,
  448. TMU6, TMU7, TMU8,
  449. HAC, IPI, SPDIF, HUDI, I2C,
  450. DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2,
  451. I2S0, I2S1, I2S2, I2S3,
  452. SRC_RX, SRC_TX, SRC_SPDIF,
  453. DU, VIDEO_IN, REMOTE, YUV, USB, ATAPI, CAN, GPS, GFX2D,
  454. GFX3D_MBX, GFX3D_DMAC,
  455. EXBUS_ATA,
  456. SPI0, SPI1,
  457. SCIF089, SCIF1234, SCIF567,
  458. ADC,
  459. BBDMAC_0_3, BBDMAC_4_7, BBDMAC_8_10, BBDMAC_11_14,
  460. BBDMAC_15_18, BBDMAC_19_22, BBDMAC_23_26, BBDMAC_27,
  461. BBDMAC_28, BBDMAC_29, BBDMAC_30, BBDMAC_31,
  462. /* interrupt groups */
  463. TMU, DMAC, I2S, SRC, GFX3D, SPI, SCIF, BBDMAC,
  464. };
  465. static struct intc_vect vectors[] __initdata = {
  466. INTC_VECT(GPIO, 0x3e0),
  467. INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
  468. INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2_TICPI, 0x460),
  469. INTC_VECT(TMU3, 0x480), INTC_VECT(TMU4, 0x4a0),
  470. INTC_VECT(TMU5, 0x4c0), INTC_VECT(TMU5_TICPI, 0x4e0),
  471. INTC_VECT(TMU6, 0x500), INTC_VECT(TMU7, 0x520),
  472. INTC_VECT(TMU8, 0x540),
  473. INTC_VECT(HAC, 0x580), INTC_VECT(IPI, 0x5c0),
  474. INTC_VECT(SPDIF, 0x5e0),
  475. INTC_VECT(HUDI, 0x600), INTC_VECT(I2C, 0x620),
  476. INTC_VECT(DMAC0_DMINT0, 0x640), INTC_VECT(DMAC0_DMINT1, 0x660),
  477. INTC_VECT(DMAC0_DMINT2, 0x680),
  478. INTC_VECT(I2S0, 0x6a0), INTC_VECT(I2S1, 0x6c0),
  479. INTC_VECT(I2S2, 0x6e0), INTC_VECT(I2S3, 0x700),
  480. INTC_VECT(SRC_RX, 0x720), INTC_VECT(SRC_TX, 0x740),
  481. INTC_VECT(SRC_SPDIF, 0x760),
  482. INTC_VECT(DU, 0x780), INTC_VECT(VIDEO_IN, 0x7a0),
  483. INTC_VECT(REMOTE, 0x7c0), INTC_VECT(YUV, 0x7e0),
  484. INTC_VECT(USB, 0x840), INTC_VECT(ATAPI, 0x860),
  485. INTC_VECT(CAN, 0x880), INTC_VECT(GPS, 0x8a0),
  486. INTC_VECT(GFX2D, 0x8c0),
  487. INTC_VECT(GFX3D_MBX, 0x900), INTC_VECT(GFX3D_DMAC, 0x920),
  488. INTC_VECT(EXBUS_ATA, 0x940),
  489. INTC_VECT(SPI0, 0x960), INTC_VECT(SPI1, 0x980),
  490. INTC_VECT(SCIF089, 0x9a0), INTC_VECT(SCIF1234, 0x9c0),
  491. INTC_VECT(SCIF1234, 0x9e0), INTC_VECT(SCIF1234, 0xa00),
  492. INTC_VECT(SCIF1234, 0xa20), INTC_VECT(SCIF567, 0xa40),
  493. INTC_VECT(SCIF567, 0xa60), INTC_VECT(SCIF567, 0xa80),
  494. INTC_VECT(SCIF089, 0xaa0), INTC_VECT(SCIF089, 0xac0),
  495. INTC_VECT(ADC, 0xb20),
  496. INTC_VECT(BBDMAC_0_3, 0xba0), INTC_VECT(BBDMAC_0_3, 0xbc0),
  497. INTC_VECT(BBDMAC_0_3, 0xbe0), INTC_VECT(BBDMAC_0_3, 0xc00),
  498. INTC_VECT(BBDMAC_4_7, 0xc20), INTC_VECT(BBDMAC_4_7, 0xc40),
  499. INTC_VECT(BBDMAC_4_7, 0xc60), INTC_VECT(BBDMAC_4_7, 0xc80),
  500. INTC_VECT(BBDMAC_8_10, 0xca0), INTC_VECT(BBDMAC_8_10, 0xcc0),
  501. INTC_VECT(BBDMAC_8_10, 0xce0), INTC_VECT(BBDMAC_11_14, 0xd00),
  502. INTC_VECT(BBDMAC_11_14, 0xd20), INTC_VECT(BBDMAC_11_14, 0xd40),
  503. INTC_VECT(BBDMAC_11_14, 0xd60), INTC_VECT(BBDMAC_15_18, 0xd80),
  504. INTC_VECT(BBDMAC_15_18, 0xda0), INTC_VECT(BBDMAC_15_18, 0xdc0),
  505. INTC_VECT(BBDMAC_15_18, 0xde0), INTC_VECT(BBDMAC_19_22, 0xe00),
  506. INTC_VECT(BBDMAC_19_22, 0xe20), INTC_VECT(BBDMAC_19_22, 0xe40),
  507. INTC_VECT(BBDMAC_19_22, 0xe60), INTC_VECT(BBDMAC_23_26, 0xe80),
  508. INTC_VECT(BBDMAC_23_26, 0xea0), INTC_VECT(BBDMAC_23_26, 0xec0),
  509. INTC_VECT(BBDMAC_23_26, 0xee0), INTC_VECT(BBDMAC_27, 0xf00),
  510. INTC_VECT(BBDMAC_28, 0xf20), INTC_VECT(BBDMAC_29, 0xf40),
  511. INTC_VECT(BBDMAC_30, 0xf60), INTC_VECT(BBDMAC_31, 0xf80),
  512. };
  513. static struct intc_group groups[] __initdata = {
  514. INTC_GROUP(TMU, TMU0, TMU1, TMU2, TMU2_TICPI, TMU3, TMU4, TMU5,
  515. TMU5_TICPI, TMU6, TMU7, TMU8),
  516. INTC_GROUP(DMAC, DMAC0_DMINT0, DMAC0_DMINT1, DMAC0_DMINT2),
  517. INTC_GROUP(I2S, I2S0, I2S1, I2S2, I2S3),
  518. INTC_GROUP(SRC, SRC_RX, SRC_TX, SRC_SPDIF),
  519. INTC_GROUP(GFX3D, GFX3D_MBX, GFX3D_DMAC),
  520. INTC_GROUP(SPI, SPI0, SPI1),
  521. INTC_GROUP(SCIF, SCIF089, SCIF1234, SCIF567),
  522. INTC_GROUP(BBDMAC,
  523. BBDMAC_0_3, BBDMAC_4_7, BBDMAC_8_10, BBDMAC_11_14,
  524. BBDMAC_15_18, BBDMAC_19_22, BBDMAC_23_26, BBDMAC_27,
  525. BBDMAC_28, BBDMAC_29, BBDMAC_30, BBDMAC_31),
  526. };
  527. static struct intc_mask_reg mask_registers[] __initdata = {
  528. { 0xffe00040, 0xffe00044, 32, /* INT2MSKR / INT2MSKCR */
  529. { 0, BBDMAC, ADC, SCIF, SPI, EXBUS_ATA, GFX3D, GFX2D,
  530. GPS, CAN, ATAPI, USB, YUV, REMOTE, VIDEO_IN, DU, SRC, I2S,
  531. DMAC, I2C, HUDI, SPDIF, IPI, HAC, TMU, GPIO } },
  532. };
  533. static struct intc_prio_reg prio_registers[] __initdata = {
  534. { 0xffe00000, 0, 32, 8, /* INT2PRI0 */ { GPIO, TMU0, 0, HAC } },
  535. { 0xffe00004, 0, 32, 8, /* INT2PRI1 */ { IPI, SPDIF, HUDI, I2C } },
  536. { 0xffe00008, 0, 32, 8, /* INT2PRI2 */ { DMAC, I2S, SRC, DU } },
  537. { 0xffe0000c, 0, 32, 8, /* INT2PRI3 */ { VIDEO_IN, REMOTE, YUV, USB } },
  538. { 0xffe00010, 0, 32, 8, /* INT2PRI4 */ { ATAPI, CAN, GPS, GFX2D } },
  539. { 0xffe00014, 0, 32, 8, /* INT2PRI5 */ { 0, GFX3D, EXBUS_ATA, SPI } },
  540. { 0xffe00018, 0, 32, 8, /* INT2PRI6 */ { SCIF1234, SCIF567, SCIF089 } },
  541. { 0xffe0001c, 0, 32, 8, /* INT2PRI7 */ { ADC, 0, 0, BBDMAC_0_3 } },
  542. { 0xffe00020, 0, 32, 8, /* INT2PRI8 */
  543. { BBDMAC_4_7, BBDMAC_8_10, BBDMAC_11_14, BBDMAC_15_18 } },
  544. { 0xffe00024, 0, 32, 8, /* INT2PRI9 */
  545. { BBDMAC_19_22, BBDMAC_23_26, BBDMAC_27, BBDMAC_28 } },
  546. { 0xffe00028, 0, 32, 8, /* INT2PRI10 */
  547. { BBDMAC_29, BBDMAC_30, BBDMAC_31 } },
  548. { 0xffe0002c, 0, 32, 8, /* INT2PRI11 */
  549. { TMU1, TMU2, TMU2_TICPI, TMU3 } },
  550. { 0xffe00030, 0, 32, 8, /* INT2PRI12 */
  551. { TMU4, TMU5, TMU5_TICPI, TMU6 } },
  552. { 0xffe00034, 0, 32, 8, /* INT2PRI13 */
  553. { TMU7, TMU8 } },
  554. };
  555. static DECLARE_INTC_DESC(intc_desc, "sh7770", vectors, groups,
  556. mask_registers, prio_registers, NULL);
  557. /* Support for external interrupt pins in IRQ mode */
  558. static struct intc_vect irq_vectors[] __initdata = {
  559. INTC_VECT(IRQ0, 0x240), INTC_VECT(IRQ1, 0x280),
  560. INTC_VECT(IRQ2, 0x2c0), INTC_VECT(IRQ3, 0x300),
  561. INTC_VECT(IRQ4, 0x340), INTC_VECT(IRQ5, 0x380),
  562. };
  563. static struct intc_mask_reg irq_mask_registers[] __initdata = {
  564. { 0xffd00044, 0xffd00064, 32, /* INTMSK0 / INTMSKCLR0 */
  565. { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, } },
  566. };
  567. static struct intc_prio_reg irq_prio_registers[] __initdata = {
  568. { 0xffd00010, 0, 32, 4, /* INTPRI */ { IRQ0, IRQ1, IRQ2, IRQ3,
  569. IRQ4, IRQ5, } },
  570. };
  571. static struct intc_sense_reg irq_sense_registers[] __initdata = {
  572. { 0xffd0001c, 32, 2, /* ICR1 */ { IRQ0, IRQ1, IRQ2, IRQ3,
  573. IRQ4, IRQ5, } },
  574. };
  575. static DECLARE_INTC_DESC(intc_irq_desc, "sh7770-irq", irq_vectors,
  576. NULL, irq_mask_registers, irq_prio_registers,
  577. irq_sense_registers);
  578. /* External interrupt pins in IRL mode */
  579. static struct intc_vect irl_vectors[] __initdata = {
  580. INTC_VECT(IRL_LLLL, 0x200), INTC_VECT(IRL_LLLH, 0x220),
  581. INTC_VECT(IRL_LLHL, 0x240), INTC_VECT(IRL_LLHH, 0x260),
  582. INTC_VECT(IRL_LHLL, 0x280), INTC_VECT(IRL_LHLH, 0x2a0),
  583. INTC_VECT(IRL_LHHL, 0x2c0), INTC_VECT(IRL_LHHH, 0x2e0),
  584. INTC_VECT(IRL_HLLL, 0x300), INTC_VECT(IRL_HLLH, 0x320),
  585. INTC_VECT(IRL_HLHL, 0x340), INTC_VECT(IRL_HLHH, 0x360),
  586. INTC_VECT(IRL_HHLL, 0x380), INTC_VECT(IRL_HHLH, 0x3a0),
  587. INTC_VECT(IRL_HHHL, 0x3c0),
  588. };
  589. static struct intc_mask_reg irl3210_mask_registers[] __initdata = {
  590. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  591. { IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  592. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  593. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  594. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  595. };
  596. static struct intc_mask_reg irl7654_mask_registers[] __initdata = {
  597. { 0xffd40080, 0xffd40084, 32, /* INTMSK2 / INTMSKCLR2 */
  598. { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  599. IRL_LLLL, IRL_LLLH, IRL_LLHL, IRL_LLHH,
  600. IRL_LHLL, IRL_LHLH, IRL_LHHL, IRL_LHHH,
  601. IRL_HLLL, IRL_HLLH, IRL_HLHL, IRL_HLHH,
  602. IRL_HHLL, IRL_HHLH, IRL_HHHL, } },
  603. };
  604. static DECLARE_INTC_DESC(intc_irl7654_desc, "sh7780-irl7654", irl_vectors,
  605. NULL, irl7654_mask_registers, NULL, NULL);
  606. static DECLARE_INTC_DESC(intc_irl3210_desc, "sh7780-irl3210", irl_vectors,
  607. NULL, irl3210_mask_registers, NULL, NULL);
  608. #define INTC_ICR0 0xffd00000
  609. #define INTC_INTMSK0 0xffd00044
  610. #define INTC_INTMSK1 0xffd00048
  611. #define INTC_INTMSK2 0xffd40080
  612. #define INTC_INTMSKCLR1 0xffd00068
  613. #define INTC_INTMSKCLR2 0xffd40084
  614. void __init plat_irq_setup(void)
  615. {
  616. /* disable IRQ7-0 */
  617. __raw_writel(0xff000000, INTC_INTMSK0);
  618. /* disable IRL3-0 + IRL7-4 */
  619. __raw_writel(0xc0000000, INTC_INTMSK1);
  620. __raw_writel(0xfffefffe, INTC_INTMSK2);
  621. /* select IRL mode for IRL3-0 + IRL7-4 */
  622. __raw_writel(__raw_readl(INTC_ICR0) & ~0x00c00000, INTC_ICR0);
  623. /* disable holding function, ie enable "SH-4 Mode" */
  624. __raw_writel(__raw_readl(INTC_ICR0) | 0x00200000, INTC_ICR0);
  625. register_intc_controller(&intc_desc);
  626. }
  627. void __init plat_irq_setup_pins(int mode)
  628. {
  629. switch (mode) {
  630. case IRQ_MODE_IRQ:
  631. /* select IRQ mode for IRL3-0 + IRL7-4 */
  632. __raw_writel(__raw_readl(INTC_ICR0) | 0x00c00000, INTC_ICR0);
  633. register_intc_controller(&intc_irq_desc);
  634. break;
  635. case IRQ_MODE_IRL7654:
  636. /* enable IRL7-4 but don't provide any masking */
  637. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  638. __raw_writel(0x0000fffe, INTC_INTMSKCLR2);
  639. break;
  640. case IRQ_MODE_IRL3210:
  641. /* enable IRL0-3 but don't provide any masking */
  642. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  643. __raw_writel(0xfffe0000, INTC_INTMSKCLR2);
  644. break;
  645. case IRQ_MODE_IRL7654_MASK:
  646. /* enable IRL7-4 and mask using cpu intc controller */
  647. __raw_writel(0x40000000, INTC_INTMSKCLR1);
  648. register_intc_controller(&intc_irl7654_desc);
  649. break;
  650. case IRQ_MODE_IRL3210_MASK:
  651. /* enable IRL0-3 and mask using cpu intc controller */
  652. __raw_writel(0x80000000, INTC_INTMSKCLR1);
  653. register_intc_controller(&intc_irl3210_desc);
  654. break;
  655. default:
  656. BUG();
  657. }
  658. }