intc-r8a7740.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*
  2. * R8A7740 processor support
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/irq.h>
  24. #include <linux/io.h>
  25. #include <linux/sh_intc.h>
  26. #include <mach/intc.h>
  27. #include <mach/irqs.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. /*
  31. * INTCA
  32. */
  33. enum {
  34. UNUSED_INTCA = 0,
  35. /* interrupt sources INTCA */
  36. DIRC,
  37. ATAPI,
  38. IIC1_ALI, IIC1_TACKI, IIC1_WAITI, IIC1_DTEI,
  39. AP_ARM_COMMTX, AP_ARM_COMMRX,
  40. MFI, MFIS,
  41. BBIF1, BBIF2,
  42. USBHSDMAC,
  43. USBF_OUL_SOF, USBF_IXL_INT,
  44. SGX540,
  45. CMT1_0, CMT1_1, CMT1_2, CMT1_3,
  46. CMT2,
  47. CMT3,
  48. KEYSC,
  49. SCIFA0, SCIFA1, SCIFA2, SCIFA3,
  50. MSIOF2, MSIOF1,
  51. SCIFA4, SCIFA5, SCIFB,
  52. FLCTL_FLSTEI, FLCTL_FLTENDI, FLCTL_FLTREQ0I, FLCTL_FLTREQ1I,
  53. SDHI0_0, SDHI0_1, SDHI0_2, SDHI0_3,
  54. SDHI1_0, SDHI1_1, SDHI1_2, SDHI1_3,
  55. AP_ARM_L2CINT,
  56. IRDA,
  57. TPU0,
  58. SCIFA6, SCIFA7,
  59. GbEther,
  60. ICBS0,
  61. DDM,
  62. SDHI2_0, SDHI2_1, SDHI2_2, SDHI2_3,
  63. RWDT0,
  64. DMAC1_1_DEI0, DMAC1_1_DEI1, DMAC1_1_DEI2, DMAC1_1_DEI3,
  65. DMAC1_2_DEI4, DMAC1_2_DEI5, DMAC1_2_DADERR,
  66. DMAC2_1_DEI0, DMAC2_1_DEI1, DMAC2_1_DEI2, DMAC2_1_DEI3,
  67. DMAC2_2_DEI4, DMAC2_2_DEI5, DMAC2_2_DADERR,
  68. DMAC3_1_DEI0, DMAC3_1_DEI1, DMAC3_1_DEI2, DMAC3_1_DEI3,
  69. DMAC3_2_DEI4, DMAC3_2_DEI5, DMAC3_2_DADERR,
  70. SHWYSTAT_RT, SHWYSTAT_HS, SHWYSTAT_COM,
  71. USBH_INT, USBH_OHCI, USBH_EHCI, USBH_PME, USBH_BIND,
  72. RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF,
  73. SPU2_0, SPU2_1,
  74. FSI, FMSI,
  75. IPMMU,
  76. AP_ARM_CTIIRQ, AP_ARM_PMURQ,
  77. MFIS2,
  78. CPORTR2S,
  79. CMT14, CMT15,
  80. MMCIF_0, MMCIF_1, MMCIF_2,
  81. SIM_ERI, SIM_RXI, SIM_TXI, SIM_TEI,
  82. STPRO_0, STPRO_1, STPRO_2, STPRO_3, STPRO_4,
  83. /* interrupt groups INTCA */
  84. DMAC1_1, DMAC1_2,
  85. DMAC2_1, DMAC2_2,
  86. DMAC3_1, DMAC3_2,
  87. AP_ARM1, AP_ARM2,
  88. SDHI0, SDHI1, SDHI2,
  89. SHWYSTAT,
  90. USBF, USBH1, USBH2,
  91. RSPI, SPU2, FLCTL, IIC1,
  92. };
  93. static struct intc_vect intca_vectors[] __initdata = {
  94. INTC_VECT(DIRC, 0x0560),
  95. INTC_VECT(ATAPI, 0x05E0),
  96. INTC_VECT(IIC1_ALI, 0x0780),
  97. INTC_VECT(IIC1_TACKI, 0x07A0),
  98. INTC_VECT(IIC1_WAITI, 0x07C0),
  99. INTC_VECT(IIC1_DTEI, 0x07E0),
  100. INTC_VECT(AP_ARM_COMMTX, 0x0840),
  101. INTC_VECT(AP_ARM_COMMRX, 0x0860),
  102. INTC_VECT(MFI, 0x0900),
  103. INTC_VECT(MFIS, 0x0920),
  104. INTC_VECT(BBIF1, 0x0940),
  105. INTC_VECT(BBIF2, 0x0960),
  106. INTC_VECT(USBHSDMAC, 0x0A00),
  107. INTC_VECT(USBF_OUL_SOF, 0x0A20),
  108. INTC_VECT(USBF_IXL_INT, 0x0A40),
  109. INTC_VECT(SGX540, 0x0A60),
  110. INTC_VECT(CMT1_0, 0x0B00),
  111. INTC_VECT(CMT1_1, 0x0B20),
  112. INTC_VECT(CMT1_2, 0x0B40),
  113. INTC_VECT(CMT1_3, 0x0B60),
  114. INTC_VECT(CMT2, 0x0B80),
  115. INTC_VECT(CMT3, 0x0BA0),
  116. INTC_VECT(KEYSC, 0x0BE0),
  117. INTC_VECT(SCIFA0, 0x0C00),
  118. INTC_VECT(SCIFA1, 0x0C20),
  119. INTC_VECT(SCIFA2, 0x0C40),
  120. INTC_VECT(SCIFA3, 0x0C60),
  121. INTC_VECT(MSIOF2, 0x0C80),
  122. INTC_VECT(MSIOF1, 0x0D00),
  123. INTC_VECT(SCIFA4, 0x0D20),
  124. INTC_VECT(SCIFA5, 0x0D40),
  125. INTC_VECT(SCIFB, 0x0D60),
  126. INTC_VECT(FLCTL_FLSTEI, 0x0D80),
  127. INTC_VECT(FLCTL_FLTENDI, 0x0DA0),
  128. INTC_VECT(FLCTL_FLTREQ0I, 0x0DC0),
  129. INTC_VECT(FLCTL_FLTREQ1I, 0x0DE0),
  130. INTC_VECT(SDHI0_0, 0x0E00),
  131. INTC_VECT(SDHI0_1, 0x0E20),
  132. INTC_VECT(SDHI0_2, 0x0E40),
  133. INTC_VECT(SDHI0_3, 0x0E60),
  134. INTC_VECT(SDHI1_0, 0x0E80),
  135. INTC_VECT(SDHI1_1, 0x0EA0),
  136. INTC_VECT(SDHI1_2, 0x0EC0),
  137. INTC_VECT(SDHI1_3, 0x0EE0),
  138. INTC_VECT(AP_ARM_L2CINT, 0x0FA0),
  139. INTC_VECT(IRDA, 0x0480),
  140. INTC_VECT(TPU0, 0x04A0),
  141. INTC_VECT(SCIFA6, 0x04C0),
  142. INTC_VECT(SCIFA7, 0x04E0),
  143. INTC_VECT(GbEther, 0x0500),
  144. INTC_VECT(ICBS0, 0x0540),
  145. INTC_VECT(DDM, 0x1140),
  146. INTC_VECT(SDHI2_0, 0x1200),
  147. INTC_VECT(SDHI2_1, 0x1220),
  148. INTC_VECT(SDHI2_2, 0x1240),
  149. INTC_VECT(SDHI2_3, 0x1260),
  150. INTC_VECT(RWDT0, 0x1280),
  151. INTC_VECT(DMAC1_1_DEI0, 0x2000),
  152. INTC_VECT(DMAC1_1_DEI1, 0x2020),
  153. INTC_VECT(DMAC1_1_DEI2, 0x2040),
  154. INTC_VECT(DMAC1_1_DEI3, 0x2060),
  155. INTC_VECT(DMAC1_2_DEI4, 0x2080),
  156. INTC_VECT(DMAC1_2_DEI5, 0x20A0),
  157. INTC_VECT(DMAC1_2_DADERR, 0x20C0),
  158. INTC_VECT(DMAC2_1_DEI0, 0x2100),
  159. INTC_VECT(DMAC2_1_DEI1, 0x2120),
  160. INTC_VECT(DMAC2_1_DEI2, 0x2140),
  161. INTC_VECT(DMAC2_1_DEI3, 0x2160),
  162. INTC_VECT(DMAC2_2_DEI4, 0x2180),
  163. INTC_VECT(DMAC2_2_DEI5, 0x21A0),
  164. INTC_VECT(DMAC2_2_DADERR, 0x21C0),
  165. INTC_VECT(DMAC3_1_DEI0, 0x2200),
  166. INTC_VECT(DMAC3_1_DEI1, 0x2220),
  167. INTC_VECT(DMAC3_1_DEI2, 0x2240),
  168. INTC_VECT(DMAC3_1_DEI3, 0x2260),
  169. INTC_VECT(DMAC3_2_DEI4, 0x2280),
  170. INTC_VECT(DMAC3_2_DEI5, 0x22A0),
  171. INTC_VECT(DMAC3_2_DADERR, 0x22C0),
  172. INTC_VECT(SHWYSTAT_RT, 0x1300),
  173. INTC_VECT(SHWYSTAT_HS, 0x1320),
  174. INTC_VECT(SHWYSTAT_COM, 0x1340),
  175. INTC_VECT(USBH_INT, 0x1540),
  176. INTC_VECT(USBH_OHCI, 0x1560),
  177. INTC_VECT(USBH_EHCI, 0x1580),
  178. INTC_VECT(USBH_PME, 0x15A0),
  179. INTC_VECT(USBH_BIND, 0x15C0),
  180. INTC_VECT(RSPI_OVRF, 0x1780),
  181. INTC_VECT(RSPI_SPTEF, 0x17A0),
  182. INTC_VECT(RSPI_SPRF, 0x17C0),
  183. INTC_VECT(SPU2_0, 0x1800),
  184. INTC_VECT(SPU2_1, 0x1820),
  185. INTC_VECT(FSI, 0x1840),
  186. INTC_VECT(FMSI, 0x1860),
  187. INTC_VECT(IPMMU, 0x1920),
  188. INTC_VECT(AP_ARM_CTIIRQ, 0x1980),
  189. INTC_VECT(AP_ARM_PMURQ, 0x19A0),
  190. INTC_VECT(MFIS2, 0x1A00),
  191. INTC_VECT(CPORTR2S, 0x1A20),
  192. INTC_VECT(CMT14, 0x1A40),
  193. INTC_VECT(CMT15, 0x1A60),
  194. INTC_VECT(MMCIF_0, 0x1AA0),
  195. INTC_VECT(MMCIF_1, 0x1AC0),
  196. INTC_VECT(MMCIF_2, 0x1AE0),
  197. INTC_VECT(SIM_ERI, 0x1C00),
  198. INTC_VECT(SIM_RXI, 0x1C20),
  199. INTC_VECT(SIM_TXI, 0x1C40),
  200. INTC_VECT(SIM_TEI, 0x1C60),
  201. INTC_VECT(STPRO_0, 0x1C80),
  202. INTC_VECT(STPRO_1, 0x1CA0),
  203. INTC_VECT(STPRO_2, 0x1CC0),
  204. INTC_VECT(STPRO_3, 0x1CE0),
  205. INTC_VECT(STPRO_4, 0x1D00),
  206. };
  207. static struct intc_group intca_groups[] __initdata = {
  208. INTC_GROUP(DMAC1_1,
  209. DMAC1_1_DEI0, DMAC1_1_DEI1, DMAC1_1_DEI2, DMAC1_1_DEI3),
  210. INTC_GROUP(DMAC1_2,
  211. DMAC1_2_DEI4, DMAC1_2_DEI5, DMAC1_2_DADERR),
  212. INTC_GROUP(DMAC2_1,
  213. DMAC2_1_DEI0, DMAC2_1_DEI1, DMAC2_1_DEI2, DMAC2_1_DEI3),
  214. INTC_GROUP(DMAC2_2,
  215. DMAC2_2_DEI4, DMAC2_2_DEI5, DMAC2_2_DADERR),
  216. INTC_GROUP(DMAC3_1,
  217. DMAC3_1_DEI0, DMAC3_1_DEI1, DMAC3_1_DEI2, DMAC3_1_DEI3),
  218. INTC_GROUP(DMAC3_2,
  219. DMAC3_2_DEI4, DMAC3_2_DEI5, DMAC3_2_DADERR),
  220. INTC_GROUP(AP_ARM1,
  221. AP_ARM_COMMTX, AP_ARM_COMMRX),
  222. INTC_GROUP(AP_ARM2,
  223. AP_ARM_CTIIRQ, AP_ARM_PMURQ),
  224. INTC_GROUP(USBF,
  225. USBF_OUL_SOF, USBF_IXL_INT),
  226. INTC_GROUP(SDHI0,
  227. SDHI0_0, SDHI0_1, SDHI0_2, SDHI0_3),
  228. INTC_GROUP(SDHI1,
  229. SDHI1_0, SDHI1_1, SDHI1_2, SDHI1_3),
  230. INTC_GROUP(SDHI2,
  231. SDHI2_0, SDHI2_1, SDHI2_2, SDHI2_3),
  232. INTC_GROUP(SHWYSTAT,
  233. SHWYSTAT_RT, SHWYSTAT_HS, SHWYSTAT_COM),
  234. INTC_GROUP(USBH1, /* FIXME */
  235. USBH_INT, USBH_OHCI),
  236. INTC_GROUP(USBH2, /* FIXME */
  237. USBH_EHCI,
  238. USBH_PME, USBH_BIND),
  239. INTC_GROUP(RSPI,
  240. RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF),
  241. INTC_GROUP(SPU2,
  242. SPU2_0, SPU2_1),
  243. INTC_GROUP(FLCTL,
  244. FLCTL_FLSTEI, FLCTL_FLTENDI, FLCTL_FLTREQ0I, FLCTL_FLTREQ1I),
  245. INTC_GROUP(IIC1,
  246. IIC1_ALI, IIC1_TACKI, IIC1_WAITI, IIC1_DTEI),
  247. };
  248. static struct intc_mask_reg intca_mask_registers[] __initdata = {
  249. { /* IMR0A / IMCR0A */ 0xe6940080, 0xe69400c0, 8,
  250. { DMAC2_1_DEI3, DMAC2_1_DEI2, DMAC2_1_DEI1, DMAC2_1_DEI0,
  251. 0, 0, AP_ARM_COMMTX, AP_ARM_COMMRX } },
  252. { /* IMR1A / IMCR1A */ 0xe6940084, 0xe69400c4, 8,
  253. { ATAPI, 0, DIRC, 0,
  254. DMAC1_1_DEI3, DMAC1_1_DEI2, DMAC1_1_DEI1, DMAC1_1_DEI0 } },
  255. { /* IMR2A / IMCR2A */ 0xe6940088, 0xe69400c8, 8,
  256. { 0, 0, 0, 0,
  257. BBIF1, BBIF2, MFIS, MFI } },
  258. { /* IMR3A / IMCR3A */ 0xe694008c, 0xe69400cc, 8,
  259. { DMAC3_1_DEI3, DMAC3_1_DEI2, DMAC3_1_DEI1, DMAC3_1_DEI0,
  260. DMAC3_2_DADERR, DMAC3_2_DEI5, DMAC3_2_DEI4, IRDA } },
  261. { /* IMR4A / IMCR4A */ 0xe6940090, 0xe69400d0, 8,
  262. { DDM, 0, 0, 0,
  263. 0, 0, 0, 0 } },
  264. { /* IMR5A / IMCR5A */ 0xe6940094, 0xe69400d4, 8,
  265. { KEYSC, DMAC1_2_DADERR, DMAC1_2_DEI5, DMAC1_2_DEI4,
  266. SCIFA3, SCIFA2, SCIFA1, SCIFA0 } },
  267. { /* IMR6A / IMCR6A */ 0xe6940098, 0xe69400d8, 8,
  268. { SCIFB, SCIFA5, SCIFA4, MSIOF1,
  269. 0, 0, MSIOF2, 0 } },
  270. { /* IMR7A / IMCR7A */ 0xe694009c, 0xe69400dc, 8,
  271. { SDHI0_3, SDHI0_2, SDHI0_1, SDHI0_0,
  272. FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLTENDI, FLCTL_FLSTEI } },
  273. { /* IMR8A / IMCR8A */ 0xe69400a0, 0xe69400e0, 8,
  274. { SDHI1_3, SDHI1_2, SDHI1_1, SDHI1_0,
  275. 0, USBHSDMAC, 0, AP_ARM_L2CINT } },
  276. { /* IMR9A / IMCR9A */ 0xe69400a4, 0xe69400e4, 8,
  277. { CMT1_3, CMT1_2, CMT1_1, CMT1_0,
  278. CMT2, USBF_IXL_INT, USBF_OUL_SOF, SGX540 } },
  279. { /* IMR10A / IMCR10A */ 0xe69400a8, 0xe69400e8, 8,
  280. { 0, DMAC2_2_DADERR, DMAC2_2_DEI5, DMAC2_2_DEI4,
  281. 0, 0, 0, 0 } },
  282. { /* IMR11A / IMCR11A */ 0xe69400ac, 0xe69400ec, 8,
  283. { IIC1_DTEI, IIC1_WAITI, IIC1_TACKI, IIC1_ALI,
  284. ICBS0, 0, 0, 0 } },
  285. { /* IMR12A / IMCR12A */ 0xe69400b0, 0xe69400f0, 8,
  286. { 0, 0, TPU0, SCIFA6,
  287. SCIFA7, GbEther, 0, 0 } },
  288. { /* IMR13A / IMCR13A */ 0xe69400b4, 0xe69400f4, 8,
  289. { SDHI2_3, SDHI2_2, SDHI2_1, SDHI2_0,
  290. 0, CMT3, 0, RWDT0 } },
  291. { /* IMR0A3 / IMCR0A3 */ 0xe6950080, 0xe69500c0, 8,
  292. { SHWYSTAT_RT, SHWYSTAT_HS, SHWYSTAT_COM, 0,
  293. 0, 0, 0, 0 } },
  294. /* IMR1A3 / IMCR1A3 */
  295. { /* IMR2A3 / IMCR2A3 */ 0xe6950088, 0xe69500c8, 8,
  296. { 0, 0, USBH_INT, USBH_OHCI,
  297. USBH_EHCI, USBH_PME, USBH_BIND, 0 } },
  298. /* IMR3A3 / IMCR3A3 */
  299. { /* IMR4A3 / IMCR4A3 */ 0xe6950090, 0xe69500d0, 8,
  300. { 0, 0, 0, 0,
  301. RSPI_OVRF, RSPI_SPTEF, RSPI_SPRF, 0 } },
  302. { /* IMR5A3 / IMCR5A3 */ 0xe6950094, 0xe69500d4, 8,
  303. { SPU2_0, SPU2_1, FSI, FMSI,
  304. 0, 0, 0, 0 } },
  305. { /* IMR6A3 / IMCR6A3 */ 0xe6950098, 0xe69500d8, 8,
  306. { 0, IPMMU, 0, 0,
  307. AP_ARM_CTIIRQ, AP_ARM_PMURQ, 0, 0 } },
  308. { /* IMR7A3 / IMCR7A3 */ 0xe695009c, 0xe69500dc, 8,
  309. { MFIS2, CPORTR2S, CMT14, CMT15,
  310. 0, MMCIF_0, MMCIF_1, MMCIF_2 } },
  311. /* IMR8A3 / IMCR8A3 */
  312. { /* IMR9A3 / IMCR9A3 */ 0xe69500a4, 0xe69500e4, 8,
  313. { SIM_ERI, SIM_RXI, SIM_TXI, SIM_TEI,
  314. STPRO_0, STPRO_1, STPRO_2, STPRO_3 } },
  315. { /* IMR10A3 / IMCR10A3 */ 0xe69500a8, 0xe69500e8, 8,
  316. { STPRO_4, 0, 0, 0,
  317. 0, 0, 0, 0 } },
  318. };
  319. static struct intc_prio_reg intca_prio_registers[] __initdata = {
  320. { 0xe6940000, 0, 16, 4, /* IPRAA */ { DMAC3_1, DMAC3_2, CMT2, ICBS0 } },
  321. { 0xe6940004, 0, 16, 4, /* IPRBA */ { IRDA, 0, BBIF1, BBIF2 } },
  322. { 0xe6940008, 0, 16, 4, /* IPRCA */ { ATAPI, 0, CMT1_1, AP_ARM1 } },
  323. { 0xe694000c, 0, 16, 4, /* IPRDA */ { 0, 0, CMT1_2, 0 } },
  324. { 0xe6940010, 0, 16, 4, /* IPREA */ { DMAC1_1, MFIS, MFI, USBF } },
  325. { 0xe6940014, 0, 16, 4, /* IPRFA */ { KEYSC, DMAC1_2,
  326. SGX540, CMT1_0 } },
  327. { 0xe6940018, 0, 16, 4, /* IPRGA */ { SCIFA0, SCIFA1,
  328. SCIFA2, SCIFA3 } },
  329. { 0xe694001c, 0, 16, 4, /* IPRGH */ { MSIOF2, USBHSDMAC,
  330. FLCTL, SDHI0 } },
  331. { 0xe6940020, 0, 16, 4, /* IPRIA */ { MSIOF1, SCIFA4, 0, IIC1 } },
  332. { 0xe6940024, 0, 16, 4, /* IPRJA */ { DMAC2_1, DMAC2_2,
  333. AP_ARM_L2CINT, 0 } },
  334. { 0xe6940028, 0, 16, 4, /* IPRKA */ { 0, CMT1_3, 0, SDHI1 } },
  335. { 0xe694002c, 0, 16, 4, /* IPRLA */ { TPU0, SCIFA6,
  336. SCIFA7, GbEther } },
  337. { 0xe6940030, 0, 16, 4, /* IPRMA */ { 0, CMT3, 0, RWDT0 } },
  338. { 0xe6940034, 0, 16, 4, /* IPRNA */ { SCIFB, SCIFA5, 0, DDM } },
  339. { 0xe6940038, 0, 16, 4, /* IPROA */ { 0, 0, DIRC, SDHI2 } },
  340. { 0xe6950000, 0, 16, 4, /* IPRAA3 */ { SHWYSTAT, 0, 0, 0 } },
  341. /* IPRBA3 */
  342. /* IPRCA3 */
  343. /* IPRDA3 */
  344. { 0xe6950010, 0, 16, 4, /* IPREA3 */ { USBH1, 0, 0, 0 } },
  345. { 0xe6950014, 0, 16, 4, /* IPRFA3 */ { USBH2, 0, 0, 0 } },
  346. /* IPRGA3 */
  347. /* IPRHA3 */
  348. /* IPRIA3 */
  349. { 0xe6950024, 0, 16, 4, /* IPRJA3 */ { RSPI, 0, 0, 0 } },
  350. { 0xe6950028, 0, 16, 4, /* IPRKA3 */ { SPU2, 0, FSI, FMSI } },
  351. /* IPRLA3 */
  352. { 0xe6950030, 0, 16, 4, /* IPRMA3 */ { IPMMU, 0, 0, 0 } },
  353. { 0xe6950034, 0, 16, 4, /* IPRNA3 */ { AP_ARM2, 0, 0, 0 } },
  354. { 0xe6950038, 0, 16, 4, /* IPROA3 */ { MFIS2, CPORTR2S,
  355. CMT14, CMT15 } },
  356. { 0xe695003c, 0, 16, 4, /* IPRPA3 */ { 0, MMCIF_0, MMCIF_1, MMCIF_2 } },
  357. /* IPRQA3 */
  358. /* IPRRA3 */
  359. { 0xe6950048, 0, 16, 4, /* IPRSA3 */ { SIM_ERI, SIM_RXI,
  360. SIM_TXI, SIM_TEI } },
  361. { 0xe695004c, 0, 16, 4, /* IPRTA3 */ { STPRO_0, STPRO_1,
  362. STPRO_2, STPRO_3 } },
  363. { 0xe6950050, 0, 16, 4, /* IPRUA3 */ { STPRO_4, 0, 0, 0 } },
  364. };
  365. static DECLARE_INTC_DESC(intca_desc, "r8a7740-intca",
  366. intca_vectors, intca_groups,
  367. intca_mask_registers, intca_prio_registers,
  368. NULL);
  369. INTC_IRQ_PINS_32(intca_irq_pins, 0xe6900000,
  370. INTC_VECT, "r8a7740-intca-irq-pins");
  371. /*
  372. * INTCS
  373. */
  374. enum {
  375. UNUSED_INTCS = 0,
  376. INTCS,
  377. /* interrupt sources INTCS */
  378. /* HUDI */
  379. /* STPRO */
  380. /* RTDMAC(1) */
  381. VPU5HA2,
  382. _2DG_TRAP, _2DG_GPM_INT, _2DG_CER_INT,
  383. /* MFI */
  384. /* BBIF2 */
  385. VPU5F,
  386. _2DG_BRK_INT,
  387. /* SGX540 */
  388. /* 2DDMAC */
  389. /* IPMMU */
  390. /* RTDMAC 2 */
  391. /* KEYSC */
  392. /* MSIOF */
  393. IIC0_ALI, IIC0_TACKI, IIC0_WAITI, IIC0_DTEI,
  394. TMU0_0, TMU0_1, TMU0_2,
  395. CMT0,
  396. /* CMT2 */
  397. LMB,
  398. CTI,
  399. VOU,
  400. /* RWDT0 */
  401. ICB,
  402. VIO6C,
  403. CEU20, CEU21,
  404. JPU,
  405. LCDC0,
  406. LCRC,
  407. /* RTDMAC2(1) */
  408. /* RTDMAC2(2) */
  409. LCDC1,
  410. /* SPU2 */
  411. /* FSI */
  412. /* FMSI */
  413. TMU1_0, TMU1_1, TMU1_2,
  414. CMT4,
  415. DISP,
  416. DSRV,
  417. /* MFIS2 */
  418. CPORTS2R,
  419. /* interrupt groups INTCS */
  420. _2DG1,
  421. IIC0, TMU1,
  422. };
  423. static struct intc_vect intcs_vectors[] = {
  424. /* HUDI */
  425. /* STPRO */
  426. /* RTDMAC(1) */
  427. INTCS_VECT(VPU5HA2, 0x0880),
  428. INTCS_VECT(_2DG_TRAP, 0x08A0),
  429. INTCS_VECT(_2DG_GPM_INT, 0x08C0),
  430. INTCS_VECT(_2DG_CER_INT, 0x08E0),
  431. /* MFI */
  432. /* BBIF2 */
  433. INTCS_VECT(VPU5F, 0x0980),
  434. INTCS_VECT(_2DG_BRK_INT, 0x09A0),
  435. /* SGX540 */
  436. /* 2DDMAC */
  437. /* IPMMU */
  438. /* RTDMAC(2) */
  439. /* KEYSC */
  440. /* MSIOF */
  441. INTCS_VECT(IIC0_ALI, 0x0E00),
  442. INTCS_VECT(IIC0_TACKI, 0x0E20),
  443. INTCS_VECT(IIC0_WAITI, 0x0E40),
  444. INTCS_VECT(IIC0_DTEI, 0x0E60),
  445. INTCS_VECT(TMU0_0, 0x0E80),
  446. INTCS_VECT(TMU0_1, 0x0EA0),
  447. INTCS_VECT(TMU0_2, 0x0EC0),
  448. INTCS_VECT(CMT0, 0x0F00),
  449. /* CMT2 */
  450. INTCS_VECT(LMB, 0x0F60),
  451. INTCS_VECT(CTI, 0x0400),
  452. INTCS_VECT(VOU, 0x0420),
  453. /* RWDT0 */
  454. INTCS_VECT(ICB, 0x0480),
  455. INTCS_VECT(VIO6C, 0x04E0),
  456. INTCS_VECT(CEU20, 0x0500),
  457. INTCS_VECT(CEU21, 0x0520),
  458. INTCS_VECT(JPU, 0x0560),
  459. INTCS_VECT(LCDC0, 0x0580),
  460. INTCS_VECT(LCRC, 0x05A0),
  461. /* RTDMAC2(1) */
  462. /* RTDMAC2(2) */
  463. INTCS_VECT(LCDC1, 0x1780),
  464. /* SPU2 */
  465. /* FSI */
  466. /* FMSI */
  467. INTCS_VECT(TMU1_0, 0x1900),
  468. INTCS_VECT(TMU1_1, 0x1920),
  469. INTCS_VECT(TMU1_2, 0x1940),
  470. INTCS_VECT(CMT4, 0x1980),
  471. INTCS_VECT(DISP, 0x19A0),
  472. INTCS_VECT(DSRV, 0x19C0),
  473. /* MFIS2 */
  474. INTCS_VECT(CPORTS2R, 0x1A20),
  475. INTC_VECT(INTCS, 0xf80),
  476. };
  477. static struct intc_group intcs_groups[] __initdata = {
  478. INTC_GROUP(_2DG1, /*FIXME*/
  479. _2DG_CER_INT, _2DG_GPM_INT, _2DG_TRAP),
  480. INTC_GROUP(IIC0,
  481. IIC0_DTEI, IIC0_WAITI, IIC0_TACKI, IIC0_ALI),
  482. INTC_GROUP(TMU1,
  483. TMU1_0, TMU1_1, TMU1_2),
  484. };
  485. static struct intc_mask_reg intcs_mask_registers[] = {
  486. /* IMR0SA / IMCR0SA */ /* all 0 */
  487. { /* IMR1SA / IMCR1SA */ 0xffd20184, 0xffd201c4, 8,
  488. { _2DG_CER_INT, _2DG_GPM_INT, _2DG_TRAP, VPU5HA2,
  489. 0, 0, 0, 0 /*STPRO*/ } },
  490. { /* IMR2SA / IMCR2SA */ 0xffd20188, 0xffd201c8, 8,
  491. { 0/*STPRO*/, 0, CEU21, VPU5F,
  492. 0/*BBIF2*/, 0, 0, 0/*MFI*/ } },
  493. { /* IMR3SA / IMCR3SA */ 0xffd2018c, 0xffd201cc, 8,
  494. { 0, 0, 0, 0, /*2DDMAC*/
  495. VIO6C, 0, 0, ICB } },
  496. { /* IMR4SA / IMCR4SA */ 0xffd20190, 0xffd201d0, 8,
  497. { 0, 0, VOU, CTI,
  498. JPU, 0, LCRC, LCDC0 } },
  499. /* IMR5SA / IMCR5SA */ /*KEYSC/RTDMAC2/RTDMAC1*/
  500. /* IMR6SA / IMCR6SA */ /*MSIOF/SGX540*/
  501. { /* IMR7SA / IMCR7SA */ 0xffd2019c, 0xffd201dc, 8,
  502. { 0, TMU0_2, TMU0_1, TMU0_0,
  503. 0, 0, 0, 0 } },
  504. { /* IMR8SA / IMCR8SA */ 0xffd201a0, 0xffd201e0, 8,
  505. { 0, 0, 0, 0,
  506. CEU20, 0, 0, 0 } },
  507. { /* IMR9SA / IMCR9SA */ 0xffd201a4, 0xffd201e4, 8,
  508. { 0, 0/*RWDT0*/, 0/*CMT2*/, CMT0,
  509. 0, 0, 0, 0 } },
  510. /* IMR10SA / IMCR10SA */ /*IPMMU*/
  511. { /* IMR11SA / IMCR11SA */ 0xffd201ac, 0xffd201ec, 8,
  512. { IIC0_DTEI, IIC0_WAITI, IIC0_TACKI, IIC0_ALI,
  513. 0, _2DG_BRK_INT, LMB, 0 } },
  514. /* IMR12SA / IMCR12SA */
  515. /* IMR13SA / IMCR13SA */
  516. /* IMR0SA3 / IMCR0SA3 */ /*RTDMAC2(1)/RTDMAC2(2)*/
  517. /* IMR1SA3 / IMCR1SA3 */
  518. /* IMR2SA3 / IMCR2SA3 */
  519. /* IMR3SA3 / IMCR3SA3 */
  520. { /* IMR4SA3 / IMCR4SA3 */ 0xffd50190, 0xffd501d0, 8,
  521. { 0, 0, 0, 0,
  522. LCDC1, 0, 0, 0 } },
  523. /* IMR5SA3 / IMCR5SA3 */ /* SPU2/FSI/FMSI */
  524. { /* IMR6SA3 / IMCR6SA3 */ 0xffd50198, 0xffd501d8, 8,
  525. { TMU1_0, TMU1_1, TMU1_2, 0,
  526. CMT4, DISP, DSRV, 0 } },
  527. { /* IMR7SA3 / IMCR7SA3 */ 0xffd5019c, 0xffd501dc, 8,
  528. { 0/*MFIS2*/, CPORTS2R, 0, 0,
  529. 0, 0, 0, 0 } },
  530. { /* INTAMASK */ 0xffd20104, 0, 16,
  531. { 0, 0, 0, 0, 0, 0, 0, 0,
  532. 0, 0, 0, 0, 0, 0, 0, INTCS } },
  533. };
  534. /* Priority is needed for INTCA to receive the INTCS interrupt */
  535. static struct intc_prio_reg intcs_prio_registers[] = {
  536. { 0xffd20000, 0, 16, 4, /* IPRAS */ { CTI, VOU, 0/*2DDMAC*/, ICB } },
  537. { 0xffd20004, 0, 16, 4, /* IPRBS */ { JPU, LCDC0, 0, LCRC } },
  538. /* IPRCS */ /*BBIF2*/
  539. /* IPRDS */
  540. { 0xffd20010, 0, 16, 4, /* IPRES */ { 0/*RTDMAC(1)*/, VPU5HA2,
  541. 0/*MFI*/, VPU5F } },
  542. { 0xffd20014, 0, 16, 4, /* IPRFS */ { 0/*KEYSC*/, 0/*RTDMAC(2)*/,
  543. 0/*CMT2*/, CMT0 } },
  544. { 0xffd20018, 0, 16, 4, /* IPRGS */ { TMU0_0, TMU0_1,
  545. TMU0_2, _2DG1 } },
  546. { 0xffd2001c, 0, 16, 4, /* IPRHS */ { 0, 0/*STPRO*/, 0/*STPRO*/,
  547. _2DG_BRK_INT/*FIXME*/ } },
  548. { 0xffd20020, 0, 16, 4, /* IPRIS */ { 0, 0/*MSIOF*/, 0, IIC0 } },
  549. { 0xffd20024, 0, 16, 4, /* IPRJS */ { CEU20, 0/*SGX540*/, 0, 0 } },
  550. { 0xffd20028, 0, 16, 4, /* IPRKS */ { VIO6C, 0, LMB, 0 } },
  551. { 0xffd2002c, 0, 16, 4, /* IPRLS */ { 0/*IPMMU*/, 0, CEU21, 0 } },
  552. /* IPRMS */ /*RWDT0*/
  553. /* IPRAS3 */ /*RTDMAC2(1)*/
  554. /* IPRBS3 */ /*RTDMAC2(2)*/
  555. /* IPRCS3 */
  556. /* IPRDS3 */
  557. /* IPRES3 */
  558. /* IPRFS3 */
  559. /* IPRGS3 */
  560. /* IPRHS3 */
  561. /* IPRIS3 */
  562. { 0xffd50024, 0, 16, 4, /* IPRJS3 */ { LCDC1, 0, 0, 0 } },
  563. /* IPRKS3 */ /*SPU2/FSI/FMSi*/
  564. /* IPRLS3 */
  565. { 0xffd50030, 0, 16, 4, /* IPRMS3 */ { TMU1, 0, 0, 0 } },
  566. { 0xffd50034, 0, 16, 4, /* IPRNS3 */ { CMT4, DISP, DSRV, 0 } },
  567. { 0xffd50038, 0, 16, 4, /* IPROS3 */ { 0/*MFIS2*/, CPORTS2R, 0, 0 } },
  568. /* IPRPS3 */
  569. };
  570. static struct resource intcs_resources[] __initdata = {
  571. [0] = {
  572. .start = 0xffd20000,
  573. .end = 0xffd201ff,
  574. .flags = IORESOURCE_MEM,
  575. },
  576. [1] = {
  577. .start = 0xffd50000,
  578. .end = 0xffd501ff,
  579. .flags = IORESOURCE_MEM,
  580. }
  581. };
  582. static struct intc_desc intcs_desc __initdata = {
  583. .name = "r8a7740-intcs",
  584. .resource = intcs_resources,
  585. .num_resources = ARRAY_SIZE(intcs_resources),
  586. .hw = INTC_HW_DESC(intcs_vectors, intcs_groups, intcs_mask_registers,
  587. intcs_prio_registers, NULL, NULL),
  588. };
  589. static void intcs_demux(unsigned int irq, struct irq_desc *desc)
  590. {
  591. void __iomem *reg = (void *)irq_get_handler_data(irq);
  592. unsigned int evtcodeas = ioread32(reg);
  593. generic_handle_irq(intcs_evt2irq(evtcodeas));
  594. }
  595. void __init r8a7740_init_irq(void)
  596. {
  597. void __iomem *intevtsa = ioremap_nocache(0xffd20100, PAGE_SIZE);
  598. register_intc_controller(&intca_desc);
  599. register_intc_controller(&intca_irq_pins_desc);
  600. register_intc_controller(&intcs_desc);
  601. /* demux using INTEVTSA */
  602. irq_set_handler_data(evt2irq(0xf80), (void *)intevtsa);
  603. irq_set_chained_handler(evt2irq(0xf80), intcs_demux);
  604. }