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