setup-sh7770.c 17 KB

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