setup-sh7770.c 17 KB

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