setup-sh7770.c 16 KB

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