setup-sh7770.c 17 KB

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