Merge branch 'core-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / arch / mips / include / asm / gic.h
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2000, 07 MIPS Technologies, Inc.
7  *
8  * GIC Register Definitions
9  *
10  */
11 #ifndef _ASM_GICREGS_H
12 #define _ASM_GICREGS_H
13
14 #undef  GICISBYTELITTLEENDIAN
15 #define GICISWORDLITTLEENDIAN
16
17 /* Constants */
18 #define GIC_POL_POS                     1
19 #define GIC_POL_NEG                     0
20 #define GIC_TRIG_EDGE                   1
21 #define GIC_TRIG_LEVEL                  0
22
23 #ifdef CONFIG_SMP
24 #define GIC_NUM_INTRS                   (24 + NR_CPUS * 2)
25 #else
26 #define GIC_NUM_INTRS                   32
27 #endif
28
29 #define MSK(n) ((1 << (n)) - 1)
30 #define REG32(addr)             (*(volatile unsigned int *) (addr))
31 #define REG(base, offs)         REG32((unsigned long)(base) + offs##_##OFS)
32 #define REGP(base, phys)        REG32((unsigned long)(base) + (phys))
33
34 /* Accessors */
35 #define GIC_REG(segment, offset) \
36         REG32(_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
37 #define GIC_REG_ADDR(segment, offset) \
38         REG32(_gic_base + segment##_##SECTION_OFS + offset)
39
40 #define GIC_ABS_REG(segment, offset) \
41        (_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
42 #define GIC_REG_ABS_ADDR(segment, offset) \
43        (_gic_base + segment##_##SECTION_OFS + offset)
44
45 #ifdef GICISBYTELITTLEENDIAN
46 #define GICREAD(reg, data)      (data) = (reg), (data) = le32_to_cpu(data)
47 #define GICWRITE(reg, data)     (reg) = cpu_to_le32(data)
48 #define GICBIS(reg, bits)                       \
49         ({unsigned int data;                    \
50                 GICREAD(reg, data);             \
51                 data |= bits;                   \
52                 GICWRITE(reg, data);            \
53         })
54
55 #else
56 #define GICREAD(reg, data)      (data) = (reg)
57 #define GICWRITE(reg, data)     (reg) = (data)
58 #define GICBIS(reg, bits)       (reg) |= (bits)
59 #endif
60
61
62 /* GIC Address Space */
63 #define SHARED_SECTION_OFS              0x0000
64 #define SHARED_SECTION_SIZE             0x8000
65 #define VPE_LOCAL_SECTION_OFS           0x8000
66 #define VPE_LOCAL_SECTION_SIZE          0x4000
67 #define VPE_OTHER_SECTION_OFS           0xc000
68 #define VPE_OTHER_SECTION_SIZE          0x4000
69 #define USM_VISIBLE_SECTION_OFS         0x10000
70 #define USM_VISIBLE_SECTION_SIZE        0x10000
71
72 /* Register Map for Shared Section */
73 #if defined(CONFIG_CPU_LITTLE_ENDIAN) || defined(GICISWORDLITTLEENDIAN)
74
75 #define GIC_SH_CONFIG_OFS               0x0000
76
77 /* Shared Global Counter */
78 #define GIC_SH_COUNTER_31_00_OFS        0x0010
79 #define GIC_SH_COUNTER_63_32_OFS        0x0014
80
81 /* Interrupt Polarity */
82 #define GIC_SH_POL_31_0_OFS             0x0100
83 #define GIC_SH_POL_63_32_OFS            0x0104
84 #define GIC_SH_POL_95_64_OFS            0x0108
85 #define GIC_SH_POL_127_96_OFS           0x010c
86 #define GIC_SH_POL_159_128_OFS          0x0110
87 #define GIC_SH_POL_191_160_OFS          0x0114
88 #define GIC_SH_POL_223_192_OFS          0x0118
89 #define GIC_SH_POL_255_224_OFS          0x011c
90
91 /* Edge/Level Triggering */
92 #define GIC_SH_TRIG_31_0_OFS            0x0180
93 #define GIC_SH_TRIG_63_32_OFS           0x0184
94 #define GIC_SH_TRIG_95_64_OFS           0x0188
95 #define GIC_SH_TRIG_127_96_OFS          0x018c
96 #define GIC_SH_TRIG_159_128_OFS         0x0190
97 #define GIC_SH_TRIG_191_160_OFS         0x0194
98 #define GIC_SH_TRIG_223_192_OFS         0x0198
99 #define GIC_SH_TRIG_255_224_OFS         0x019c
100
101 /* Dual Edge Triggering */
102 #define GIC_SH_DUAL_31_0_OFS            0x0200
103 #define GIC_SH_DUAL_63_32_OFS           0x0204
104 #define GIC_SH_DUAL_95_64_OFS           0x0208
105 #define GIC_SH_DUAL_127_96_OFS          0x020c
106 #define GIC_SH_DUAL_159_128_OFS         0x0210
107 #define GIC_SH_DUAL_191_160_OFS         0x0214
108 #define GIC_SH_DUAL_223_192_OFS         0x0218
109 #define GIC_SH_DUAL_255_224_OFS         0x021c
110
111 /* Set/Clear corresponding bit in Edge Detect Register */
112 #define GIC_SH_WEDGE_OFS                0x0280
113
114 /* Reset Mask - Disables Interrupt */
115 #define GIC_SH_RMASK_31_0_OFS           0x0300
116 #define GIC_SH_RMASK_63_32_OFS          0x0304
117 #define GIC_SH_RMASK_95_64_OFS          0x0308
118 #define GIC_SH_RMASK_127_96_OFS         0x030c
119 #define GIC_SH_RMASK_159_128_OFS        0x0310
120 #define GIC_SH_RMASK_191_160_OFS        0x0314
121 #define GIC_SH_RMASK_223_192_OFS        0x0318
122 #define GIC_SH_RMASK_255_224_OFS        0x031c
123
124 /* Set Mask (WO) - Enables Interrupt */
125 #define GIC_SH_SMASK_31_0_OFS           0x0380
126 #define GIC_SH_SMASK_63_32_OFS          0x0384
127 #define GIC_SH_SMASK_95_64_OFS          0x0388
128 #define GIC_SH_SMASK_127_96_OFS         0x038c
129 #define GIC_SH_SMASK_159_128_OFS        0x0390
130 #define GIC_SH_SMASK_191_160_OFS        0x0394
131 #define GIC_SH_SMASK_223_192_OFS        0x0398
132 #define GIC_SH_SMASK_255_224_OFS        0x039c
133
134 /* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
135 #define GIC_SH_MASK_31_0_OFS            0x0400
136 #define GIC_SH_MASK_63_32_OFS           0x0404
137 #define GIC_SH_MASK_95_64_OFS           0x0408
138 #define GIC_SH_MASK_127_96_OFS          0x040c
139 #define GIC_SH_MASK_159_128_OFS         0x0410
140 #define GIC_SH_MASK_191_160_OFS         0x0414
141 #define GIC_SH_MASK_223_192_OFS         0x0418
142 #define GIC_SH_MASK_255_224_OFS         0x041c
143
144 /* Pending Global Interrupts (RO) */
145 #define GIC_SH_PEND_31_0_OFS            0x0480
146 #define GIC_SH_PEND_63_32_OFS           0x0484
147 #define GIC_SH_PEND_95_64_OFS           0x0488
148 #define GIC_SH_PEND_127_96_OFS          0x048c
149 #define GIC_SH_PEND_159_128_OFS         0x0490
150 #define GIC_SH_PEND_191_160_OFS         0x0494
151 #define GIC_SH_PEND_223_192_OFS         0x0498
152 #define GIC_SH_PEND_255_224_OFS         0x049c
153
154 #define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
155
156 /* Maps Interrupt X to a Pin */
157 #define GIC_SH_MAP_TO_PIN(intr) \
158         (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
159
160 #define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2000
161
162 /* Maps Interrupt X to a VPE */
163 #define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
164         (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + (((vpe) / 32) * 4))
165 #define GIC_SH_MAP_TO_VPE_REG_BIT(vpe)  (1 << ((vpe) % 32))
166
167 /* Polarity : Reset Value is always 0 */
168 #define GIC_SH_SET_POLARITY_OFS         0x0100
169 #define GIC_SET_POLARITY(intr, pol) \
170         GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + (((intr) / 32) * 4)), (pol) << ((intr) % 32))
171
172 /* Triggering : Reset Value is always 0 */
173 #define GIC_SH_SET_TRIGGER_OFS          0x0180
174 #define GIC_SET_TRIGGER(intr, trig) \
175         GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + (((intr) / 32) * 4)), (trig) << ((intr) % 32))
176
177 /* Mask manipulation */
178 #define GIC_SH_SMASK_OFS                0x0380
179 #define GIC_SET_INTR_MASK(intr, val) \
180         GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
181
182 #define GIC_SH_RMASK_OFS                0x0300
183 #define GIC_CLR_INTR_MASK(intr, val) \
184         GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
185
186 /* Register Map for Local Section */
187 #define GIC_VPE_CTL_OFS                 0x0000
188 #define GIC_VPE_PEND_OFS                0x0004
189 #define GIC_VPE_MASK_OFS                0x0008
190 #define GIC_VPE_RMASK_OFS               0x000c
191 #define GIC_VPE_SMASK_OFS               0x0010
192 #define GIC_VPE_WD_MAP_OFS              0x0040
193 #define GIC_VPE_COMPARE_MAP_OFS         0x0044
194 #define GIC_VPE_TIMER_MAP_OFS           0x0048
195 #define GIC_VPE_PERFCTR_MAP_OFS         0x0050
196 #define GIC_VPE_SWINT0_MAP_OFS          0x0054
197 #define GIC_VPE_SWINT1_MAP_OFS          0x0058
198 #define GIC_VPE_OTHER_ADDR_OFS          0x0080
199 #define GIC_VPE_WD_CONFIG0_OFS          0x0090
200 #define GIC_VPE_WD_COUNT0_OFS           0x0094
201 #define GIC_VPE_WD_INITIAL0_OFS         0x0098
202 #define GIC_VPE_COMPARE_LO_OFS          0x00a0
203 #define GIC_VPE_COMPARE_HI              0x00a4
204
205 #define GIC_VPE_EIC_SHADOW_SET_BASE     0x0100
206 #define GIC_VPE_EIC_SS(intr) \
207         (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
208
209 #define GIC_VPE_EIC_VEC_BASE            0x0800
210 #define GIC_VPE_EIC_VEC(intr) \
211         (GIC_VPE_EIC_VEC_BASE + (4 * intr))
212
213 #define GIC_VPE_TENABLE_NMI_OFS         0x1000
214 #define GIC_VPE_TENABLE_YQ_OFS          0x1004
215 #define GIC_VPE_TENABLE_INT_31_0_OFS    0x1080
216 #define GIC_VPE_TENABLE_INT_63_32_OFS   0x1084
217
218 /* User Mode Visible Section Register Map */
219 #define GIC_UMV_SH_COUNTER_31_00_OFS    0x0000
220 #define GIC_UMV_SH_COUNTER_63_32_OFS    0x0004
221
222 #else /* CONFIG_CPU_BIG_ENDIAN */
223
224 #define GIC_SH_CONFIG_OFS               0x0000
225
226 /* Shared Global Counter */
227 #define GIC_SH_COUNTER_31_00_OFS        0x0014
228 #define GIC_SH_COUNTER_63_32_OFS        0x0010
229
230 /* Interrupt Polarity */
231 #define GIC_SH_POL_31_0_OFS             0x0104
232 #define GIC_SH_POL_63_32_OFS            0x0100
233 #define GIC_SH_POL_95_64_OFS            0x010c
234 #define GIC_SH_POL_127_96_OFS           0x0108
235 #define GIC_SH_POL_159_128_OFS          0x0114
236 #define GIC_SH_POL_191_160_OFS          0x0110
237 #define GIC_SH_POL_223_192_OFS          0x011c
238 #define GIC_SH_POL_255_224_OFS          0x0118
239
240 /* Edge/Level Triggering */
241 #define GIC_SH_TRIG_31_0_OFS            0x0184
242 #define GIC_SH_TRIG_63_32_OFS           0x0180
243 #define GIC_SH_TRIG_95_64_OFS           0x018c
244 #define GIC_SH_TRIG_127_96_OFS          0x0188
245 #define GIC_SH_TRIG_159_128_OFS         0x0194
246 #define GIC_SH_TRIG_191_160_OFS         0x0190
247 #define GIC_SH_TRIG_223_192_OFS         0x019c
248 #define GIC_SH_TRIG_255_224_OFS         0x0198
249
250 /* Dual Edge Triggering */
251 #define GIC_SH_DUAL_31_0_OFS            0x0204
252 #define GIC_SH_DUAL_63_32_OFS           0x0200
253 #define GIC_SH_DUAL_95_64_OFS           0x020c
254 #define GIC_SH_DUAL_127_96_OFS          0x0208
255 #define GIC_SH_DUAL_159_128_OFS         0x0214
256 #define GIC_SH_DUAL_191_160_OFS         0x0210
257 #define GIC_SH_DUAL_223_192_OFS         0x021c
258 #define GIC_SH_DUAL_255_224_OFS         0x0218
259
260 /* Set/Clear corresponding bit in Edge Detect Register */
261 #define GIC_SH_WEDGE_OFS                0x0280
262
263 /* Reset Mask - Disables Interrupt */
264 #define GIC_SH_RMASK_31_0_OFS           0x0304
265 #define GIC_SH_RMASK_63_32_OFS          0x0300
266 #define GIC_SH_RMASK_95_64_OFS          0x030c
267 #define GIC_SH_RMASK_127_96_OFS         0x0308
268 #define GIC_SH_RMASK_159_128_OFS        0x0314
269 #define GIC_SH_RMASK_191_160_OFS        0x0310
270 #define GIC_SH_RMASK_223_192_OFS        0x031c
271 #define GIC_SH_RMASK_255_224_OFS        0x0318
272
273 /* Set Mask (WO) - Enables Interrupt */
274 #define GIC_SH_SMASK_31_0_OFS           0x0384
275 #define GIC_SH_SMASK_63_32_OFS          0x0380
276 #define GIC_SH_SMASK_95_64_OFS          0x038c
277 #define GIC_SH_SMASK_127_96_OFS         0x0388
278 #define GIC_SH_SMASK_159_128_OFS        0x0394
279 #define GIC_SH_SMASK_191_160_OFS        0x0390
280 #define GIC_SH_SMASK_223_192_OFS        0x039c
281 #define GIC_SH_SMASK_255_224_OFS        0x0398
282
283 /* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
284 #define GIC_SH_MASK_31_0_OFS            0x0404
285 #define GIC_SH_MASK_63_32_OFS           0x0400
286 #define GIC_SH_MASK_95_64_OFS           0x040c
287 #define GIC_SH_MASK_127_96_OFS          0x0408
288 #define GIC_SH_MASK_159_128_OFS         0x0414
289 #define GIC_SH_MASK_191_160_OFS         0x0410
290 #define GIC_SH_MASK_223_192_OFS         0x041c
291 #define GIC_SH_MASK_255_224_OFS         0x0418
292
293 /* Pending Global Interrupts (RO) */
294 #define GIC_SH_PEND_31_0_OFS            0x0484
295 #define GIC_SH_PEND_63_32_OFS           0x0480
296 #define GIC_SH_PEND_95_64_OFS           0x048c
297 #define GIC_SH_PEND_127_96_OFS          0x0488
298 #define GIC_SH_PEND_159_128_OFS         0x0494
299 #define GIC_SH_PEND_191_160_OFS         0x0490
300 #define GIC_SH_PEND_223_192_OFS         0x049c
301 #define GIC_SH_PEND_255_224_OFS         0x0498
302
303 #define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
304
305 /* Maps Interrupt X to a Pin */
306 #define GIC_SH_MAP_TO_PIN(intr) \
307         (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
308
309 #define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2004
310
311 /*
312  * Maps Interrupt X to a VPE.  This is more complex than the LE case, as
313  * odd and even registers need to be transposed.  It does work - trust me!
314  */
315 #define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
316         (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + \
317         (((((vpe) / 32) ^ 1) - 1) * 4))
318 #define GIC_SH_MAP_TO_VPE_REG_BIT(vpe)  (1 << ((vpe) % 32))
319
320 /* Polarity */
321 #define GIC_SH_SET_POLARITY_OFS         0x0100
322 #define GIC_SET_POLARITY(intr, pol) \
323         GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (pol) << ((intr) % 32))
324
325 /* Triggering */
326 #define GIC_SH_SET_TRIGGER_OFS          0x0180
327 #define GIC_SET_TRIGGER(intr, trig) \
328         GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (trig) << ((intr) % 32))
329
330 /* Mask manipulation */
331 #define GIC_SH_SMASK_OFS                0x0380
332 #define GIC_SET_INTR_MASK(intr, val) \
333         GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32)))
334
335 #define GIC_SH_RMASK_OFS                0x0300
336 #define GIC_CLR_INTR_MASK(intr, val) \
337         GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32)))
338
339 /* Register Map for Local Section */
340 #define GIC_VPE_CTL_OFS                 0x0000
341 #define GIC_VPE_PEND_OFS                0x0004
342 #define GIC_VPE_MASK_OFS                0x0008
343 #define GIC_VPE_RMASK_OFS               0x000c
344 #define GIC_VPE_SMASK_OFS               0x0010
345 #define GIC_VPE_WD_MAP_OFS              0x0040
346 #define GIC_VPE_COMPARE_MAP_OFS         0x0044
347 #define GIC_VPE_TIMER_MAP_OFS           0x0048
348 #define GIC_VPE_PERFCTR_MAP_OFS         0x0050
349 #define GIC_VPE_SWINT0_MAP_OFS          0x0054
350 #define GIC_VPE_SWINT1_MAP_OFS          0x0058
351 #define GIC_VPE_OTHER_ADDR_OFS          0x0080
352 #define GIC_VPE_WD_CONFIG0_OFS          0x0090
353 #define GIC_VPE_WD_COUNT0_OFS           0x0094
354 #define GIC_VPE_WD_INITIAL0_OFS         0x0098
355 #define GIC_VPE_COMPARE_LO_OFS          0x00a4
356 #define GIC_VPE_COMPARE_HI_OFS          0x00a0
357
358 #define GIC_VPE_EIC_SHADOW_SET_BASE     0x0100
359 #define GIC_VPE_EIC_SS(intr) \
360         (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
361
362 #define GIC_VPE_EIC_VEC_BASE            0x0800
363 #define GIC_VPE_EIC_VEC(intr) \
364         (GIC_VPE_EIC_VEC_BASE + (4 * intr))
365
366 #define GIC_VPE_TENABLE_NMI_OFS         0x1000
367 #define GIC_VPE_TENABLE_YQ_OFS          0x1004
368 #define GIC_VPE_TENABLE_INT_31_0_OFS    0x1080
369 #define GIC_VPE_TENABLE_INT_63_32_OFS   0x1084
370
371 /* User Mode Visible Section Register Map */
372 #define GIC_UMV_SH_COUNTER_31_00_OFS    0x0004
373 #define GIC_UMV_SH_COUNTER_63_32_OFS    0x0000
374
375 #endif /* !LE */
376
377 /* Masks */
378 #define GIC_SH_CONFIG_COUNTSTOP_SHF     28
379 #define GIC_SH_CONFIG_COUNTSTOP_MSK     (MSK(1) << GIC_SH_CONFIG_COUNTSTOP_SHF)
380
381 #define GIC_SH_CONFIG_COUNTBITS_SHF     24
382 #define GIC_SH_CONFIG_COUNTBITS_MSK     (MSK(4) << GIC_SH_CONFIG_COUNTBITS_SHF)
383
384 #define GIC_SH_CONFIG_NUMINTRS_SHF      16
385 #define GIC_SH_CONFIG_NUMINTRS_MSK      (MSK(8) << GIC_SH_CONFIG_NUMINTRS_SHF)
386
387 #define GIC_SH_CONFIG_NUMVPES_SHF       0
388 #define GIC_SH_CONFIG_NUMVPES_MSK       (MSK(8) << GIC_SH_CONFIG_NUMVPES_SHF)
389
390 #define GIC_SH_WEDGE_SET(intr)          (intr | (0x1 << 31))
391 #define GIC_SH_WEDGE_CLR(intr)          (intr & ~(0x1 << 31))
392
393 #define GIC_MAP_TO_PIN_SHF              31
394 #define GIC_MAP_TO_PIN_MSK              (MSK(1) << GIC_MAP_TO_PIN_SHF)
395 #define GIC_MAP_TO_NMI_SHF              30
396 #define GIC_MAP_TO_NMI_MSK              (MSK(1) << GIC_MAP_TO_NMI_SHF)
397 #define GIC_MAP_TO_YQ_SHF               29
398 #define GIC_MAP_TO_YQ_MSK               (MSK(1) << GIC_MAP_TO_YQ_SHF)
399 #define GIC_MAP_SHF                     0
400 #define GIC_MAP_MSK                     (MSK(6) << GIC_MAP_SHF)
401
402 /* GIC_VPE_CTL Masks */
403 #define GIC_VPE_CTL_PERFCNT_RTBL_SHF    2
404 #define GIC_VPE_CTL_PERFCNT_RTBL_MSK    (MSK(1) << GIC_VPE_CTL_PERFCNT_RTBL_SHF)
405 #define GIC_VPE_CTL_TIMER_RTBL_SHF      1
406 #define GIC_VPE_CTL_TIMER_RTBL_MSK      (MSK(1) << GIC_VPE_CTL_TIMER_RTBL_SHF)
407 #define GIC_VPE_CTL_EIC_MODE_SHF        0
408 #define GIC_VPE_CTL_EIC_MODE_MSK        (MSK(1) << GIC_VPE_CTL_EIC_MODE_SHF)
409
410 /* GIC_VPE_PEND Masks */
411 #define GIC_VPE_PEND_WD_SHF             0
412 #define GIC_VPE_PEND_WD_MSK             (MSK(1) << GIC_VPE_PEND_WD_SHF)
413 #define GIC_VPE_PEND_CMP_SHF            1
414 #define GIC_VPE_PEND_CMP_MSK            (MSK(1) << GIC_VPE_PEND_CMP_SHF)
415 #define GIC_VPE_PEND_TIMER_SHF          2
416 #define GIC_VPE_PEND_TIMER_MSK          (MSK(1) << GIC_VPE_PEND_TIMER_SHF)
417 #define GIC_VPE_PEND_PERFCOUNT_SHF      3
418 #define GIC_VPE_PEND_PERFCOUNT_MSK      (MSK(1) << GIC_VPE_PEND_PERFCOUNT_SHF)
419 #define GIC_VPE_PEND_SWINT0_SHF         4
420 #define GIC_VPE_PEND_SWINT0_MSK         (MSK(1) << GIC_VPE_PEND_SWINT0_SHF)
421 #define GIC_VPE_PEND_SWINT1_SHF         5
422 #define GIC_VPE_PEND_SWINT1_MSK         (MSK(1) << GIC_VPE_PEND_SWINT1_SHF)
423
424 /* GIC_VPE_RMASK Masks */
425 #define GIC_VPE_RMASK_WD_SHF            0
426 #define GIC_VPE_RMASK_WD_MSK            (MSK(1) << GIC_VPE_RMASK_WD_SHF)
427 #define GIC_VPE_RMASK_CMP_SHF           1
428 #define GIC_VPE_RMASK_CMP_MSK           (MSK(1) << GIC_VPE_RMASK_CMP_SHF)
429 #define GIC_VPE_RMASK_TIMER_SHF         2
430 #define GIC_VPE_RMASK_TIMER_MSK         (MSK(1) << GIC_VPE_RMASK_TIMER_SHF)
431 #define GIC_VPE_RMASK_PERFCNT_SHF       3
432 #define GIC_VPE_RMASK_PERFCNT_MSK       (MSK(1) << GIC_VPE_RMASK_PERFCNT_SHF)
433 #define GIC_VPE_RMASK_SWINT0_SHF        4
434 #define GIC_VPE_RMASK_SWINT0_MSK        (MSK(1) << GIC_VPE_RMASK_SWINT0_SHF)
435 #define GIC_VPE_RMASK_SWINT1_SHF        5
436 #define GIC_VPE_RMASK_SWINT1_MSK        (MSK(1) << GIC_VPE_RMASK_SWINT1_SHF)
437
438 /* GIC_VPE_SMASK Masks */
439 #define GIC_VPE_SMASK_WD_SHF            0
440 #define GIC_VPE_SMASK_WD_MSK            (MSK(1) << GIC_VPE_SMASK_WD_SHF)
441 #define GIC_VPE_SMASK_CMP_SHF           1
442 #define GIC_VPE_SMASK_CMP_MSK           (MSK(1) << GIC_VPE_SMASK_CMP_SHF)
443 #define GIC_VPE_SMASK_TIMER_SHF         2
444 #define GIC_VPE_SMASK_TIMER_MSK         (MSK(1) << GIC_VPE_SMASK_TIMER_SHF)
445 #define GIC_VPE_SMASK_PERFCNT_SHF       3
446 #define GIC_VPE_SMASK_PERFCNT_MSK       (MSK(1) << GIC_VPE_SMASK_PERFCNT_SHF)
447 #define GIC_VPE_SMASK_SWINT0_SHF        4
448 #define GIC_VPE_SMASK_SWINT0_MSK        (MSK(1) << GIC_VPE_SMASK_SWINT0_SHF)
449 #define GIC_VPE_SMASK_SWINT1_SHF        5
450 #define GIC_VPE_SMASK_SWINT1_MSK        (MSK(1) << GIC_VPE_SMASK_SWINT1_SHF)
451
452 /*
453  * Set the Mapping of Interrupt X to a VPE.
454  */
455 #define GIC_SH_MAP_TO_VPE_SMASK(intr, vpe) \
456         GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe)), \
457                  GIC_SH_MAP_TO_VPE_REG_BIT(vpe))
458
459 struct gic_pcpu_mask {
460        DECLARE_BITMAP(pcpu_mask, GIC_NUM_INTRS);
461 };
462
463 struct gic_pending_regs {
464        DECLARE_BITMAP(pending, GIC_NUM_INTRS);
465 };
466
467 struct gic_intrmask_regs {
468        DECLARE_BITMAP(intrmask, GIC_NUM_INTRS);
469 };
470
471 /*
472  * Interrupt Meta-data specification. The ipiflag helps
473  * in building ipi_map.
474  */
475 struct gic_intr_map {
476         unsigned int intrnum;   /* Ext Intr Num         */
477         unsigned int cpunum;    /* Directed to this CPU */
478         unsigned int pin;       /* Directed to this Pin */
479         unsigned int polarity;  /* Polarity : +/-       */
480         unsigned int trigtype;  /* Trigger  : Edge/Levl */
481         unsigned int ipiflag;   /* Is used for IPI ?    */
482 };
483
484 extern void gic_init(unsigned long gic_base_addr,
485         unsigned long gic_addrspace_size, struct gic_intr_map *intrmap,
486         unsigned int intrmap_size, unsigned int irqbase);
487
488 extern unsigned int gic_get_int(void);
489 extern void gic_send_ipi(unsigned int intr);
490 extern unsigned int plat_ipi_call_int_xlate(unsigned int);
491 extern unsigned int plat_ipi_resched_int_xlate(unsigned int);
492
493 #endif /* _ASM_GICREGS_H */