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