setup-sh7770.c 16 KB

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