1 /******************************************************************************\
2 * Copyright (C) 1999-2000 Texas Instruments Incorporated.
3 * All Rights Reserved
4 *------------------------------------------------------------------------------
5 * FILENAME...... csl_irq.h
6 * DATE CREATED.. 06/09/1999
7 * LAST MODIFIED. 08/02/2004 - Adding support for C6418
8 * 07/24/2004 - Re-introducing BIOS components from CSL due to compatibility issues.
9 * 02/05/2004 Removed bios related components
10 * 10/03/2001
11 * - CHIP_RSET()/CHIP_RGET() replaced by CHIP_CRSET()/CHIP_CRGET()
12 \******************************************************************************/
13 #ifndef _CSL_IRQ_H_
14 #define _CSL_IRQ_H_
16 #include <csl_stdinc.h>
17 #include <csl_chip.h>
18 #include <csl_irqhal.h>
21 #if (IRQ_SUPPORT)
22 /******************************************************************************\
23 * scope and inline control macros
24 \******************************************************************************/
25 #ifdef __cplusplus
26 #define CSLAPI extern "C" far
27 #else
28 #define CSLAPI extern far
29 #endif
31 #undef USEDEFS
32 #undef IDECL
33 #undef IDEF
35 #ifdef _IRQ_MOD_
36 #define IDECL CSLAPI
37 #define USEDEFS
38 #define IDEF
39 #else
40 #ifdef _INLINE
41 #define IDECL static inline
42 #define USEDEFS
43 #define IDEF static inline
44 #else
45 #define IDECL CSLAPI
46 #endif
47 #endif
50 /******************************************************************************\
51 * global macro declarations
52 \******************************************************************************/
54 /* misc global settings */
55 #define IRQ_INT_CNT 16
56 #define IRQ_EVENT_CNT 32
58 #define IRQ_EVT_NA IRQ_EVENT_CNT
60 /* event id definitions */
61 #if (CHIP_6410 | CHIP_6413 | CHIP_6418)
63 #define IRQ_EVT_DSPINT 0
64 #define IRQ_EVT_TINT0 1
65 #define IRQ_EVT_TINT1 2
66 #define IRQ_EVT_SDINTA 3
67 #define IRQ_EVT_EXTINT4 4
68 #define IRQ_EVT_GPINT4 4
69 #define IRQ_EVT_EXTINT5 5
70 #define IRQ_EVT_GPINT5 5
71 #define IRQ_EVT_EXTINT6 6
72 #define IRQ_EVT_GPINT6 6
73 #define IRQ_EVT_EXTINT7 7
74 #define IRQ_EVT_GPINT7 7
75 #define IRQ_EVT_EDMAINT 8
76 #define IRQ_EVT_EMUDTDMA 9
77 #define IRQ_EVT_EMURTDXRX 10
78 #define IRQ_EVT_EMURTDXTX 11
79 #define IRQ_EVT_XINT0 12
80 #define IRQ_EVT_RINT0 13
81 #define IRQ_EVT_XINT1 14
82 #define IRQ_EVT_RINT1 15
83 #define IRQ_EVT_GPINT0 16
84 #define IRQ_EVT_TINT2 19
85 #define IRQ_EVT_I2CINT0 22
86 #define IRQ_EVT_I2CINT1 23
87 #define IRQ_EVT_AXINT1 24
88 #define IRQ_EVT_ARINT1 25
89 #define IRQ_EVT_AXINT0 28
90 #define IRQ_EVT_ARINT0 29
92 #if (CHIP_6418)
93 #define IRQ_EVT_VCPINT 30
94 #endif
96 #else
98 #if (CHIP_DM642 | CHIP_DM641 | CHIP_DM640 | CHIP_6412)
100 #define IRQ_EVT_DSPINT 0
101 #define IRQ_EVT_TINT0 1
102 #define IRQ_EVT_TINT1 2
103 #define IRQ_EVT_SDINTA 3
104 #define IRQ_EVT_EXTINT4 4
105 #define IRQ_EVT_GPINT4 4
106 #define IRQ_EVT_EXTINT5 5
107 #define IRQ_EVT_GPINT5 5
108 #define IRQ_EVT_EXTINT6 6
109 #define IRQ_EVT_GPINT6 6
110 #define IRQ_EVT_EXTINT7 7
111 #define IRQ_EVT_GPINT7 7
112 #define IRQ_EVT_EDMAINT 8
113 #define IRQ_EVT_EMUDTDMA 9
114 #define IRQ_EVT_EMURTDXRX 10
115 #define IRQ_EVT_EMURTDXTX 11
116 #define IRQ_EVT_XINT0 12
117 #define IRQ_EVT_RINT0 13
118 #define IRQ_EVT_XINT1 14
119 #define IRQ_EVT_RINT1 15
120 #define IRQ_EVT_GPINT0 16
121 #define IRQ_EVT_TINT2 19
122 #define IRQ_EVT_I2CINT0 22
123 #define IRQ_EVT_MACINT 24
125 #if !(CHIP_6412)
126 #define IRQ_EVT_VINT0 25
127 #define IRQ_EVT_VINT1 26
128 #endif
130 #if (CHIP_DM642)
131 #define IRQ_EVT_VINT2 27
132 #endif
134 #if !(CHIP_6412)
135 #define IRQ_EVT_AXINT0 28
136 #define IRQ_EVT_ARINT0 29
137 #endif
139 #else
141 #define IRQ_EVT_DSPINT 0
142 #define IRQ_EVT_TINT0 1
143 #define IRQ_EVT_TINT1 2
144 #define IRQ_EVT_SDINT 3
145 #define IRQ_EVT_SDINTA 3
146 #define IRQ_EVT_EXTINT4 4
147 #define IRQ_EVT_GPINT4 4
148 #define IRQ_EVT_EXTINT5 5
149 #define IRQ_EVT_GPINT5 5
150 #define IRQ_EVT_EXTINT6 6
151 #define IRQ_EVT_GPINT6 6
152 #define IRQ_EVT_EXTINT7 7
153 #define IRQ_EVT_GPINT7 7
154 #define IRQ_EVT_EDMAINT 8
155 #define IRQ_EVT_DMAINT0 8
156 #define IRQ_EVT_EMUDTDMA 9
157 #define IRQ_EVT_DMAINT1 9
158 #define IRQ_EVT_EMURTDXRX 10
159 #define IRQ_EVT_DMAINT2 10
160 #define IRQ_EVT_EMURTDXTX 11
161 #define IRQ_EVT_DMAINT3 11
162 #define IRQ_EVT_XINT0 12
163 #define IRQ_EVT_RINT0 13
164 #define IRQ_EVT_XINT1 14
165 #define IRQ_EVT_RINT1 15
166 #define IRQ_EVT_GPINT0 16
167 #define IRQ_EVT_XINT2 17
168 #define IRQ_EVT_RINT2 18
169 #define IRQ_EVT_TINT2 19
170 #define IRQ_EVT_SDINTB 20
171 #define IRQ_EVT_PCIWAKE 21
172 #define IRQ_EVT_MDIO 21
173 #define IRQ_EVT_QDMAERR 22
174 #define IRQ_EVT_I2CINT0 22 /* 6713 */
175 #define IRQ_EVT_UINT 23
176 #define IRQ_EVT_I2CINT1 23 /* 6713 */
177 #define IRQ_EVT_I2CINT2 23
178 #define IRQ_EVT_I2CINT3 22
179 #define IRQ_EVT_I2CINT4 23
181 #define IRQ_EVT_MACINT 24 /* DM642 */
182 #define IRQ_EVT_VINT0 25 /* DM642 */
183 #define IRQ_EVT_VINT1 26 /* DM642 */
184 #define IRQ_EVT_VINT2 27 /* DM642 */
185 #define IRQ_EVT_AXINT0 28 /* 6713 / DM642 */
186 #define IRQ_EVT_ARINT0 29 /* 6713 / DM642 */
187 #define IRQ_EVT_AXINT3 IRQ_EVT_EXTINT4 /* 6713 */
188 #define IRQ_EVT_ARINT3 IRQ_EVT_EXTINT5 /* 6713 */
189 #define IRQ_EVT_VCPINT 30
190 #define IRQ_EVT_AXINT1 30 /* 6713 */
192 #define IRQ_EVT_AXINT2 30 /* 6713 */
193 #define IRQ_EVT_AXINT4 IRQ_EVT_EXTINT6
194 #define IRQ_EVT_TCPINT 31
195 #define IRQ_EVT_ARINT1 31 /* 6713 */
197 #define IRQ_EVT_ARINT2 31 /* 6713 */
198 #define IRQ_EVT_ARINT4 IRQ_EVT_EXTINT7
200 #endif
202 #endif
203 /* interrupt masks */
204 #define IRQ_MASK_NA 0x00000000
205 #define IRQ_MASK_00 0x00000001
206 #define IRQ_MASK_01 0x00000002
207 #define IRQ_MASK_02 0x00000004
208 #define IRQ_MASK_03 0x00000008
209 #define IRQ_MASK_04 0x00000010
210 #define IRQ_MASK_05 0x00000020
211 #define IRQ_MASK_06 0x00000040
212 #define IRQ_MASK_07 0x00000080
213 #define IRQ_MASK_08 0x00000100
214 #define IRQ_MASK_09 0x00000200
215 #define IRQ_MASK_10 0x00000400
216 #define IRQ_MASK_11 0x00000800
217 #define IRQ_MASK_12 0x00001000
218 #define IRQ_MASK_13 0x00002000
219 #define IRQ_MASK_14 0x00004000
220 #define IRQ_MASK_15 0x00008000
222 /* defines used with the dispatcher functions */
223 #define IRQ_CCMASK_NONE 0x00000001u
224 #define IRQ_CCMASK_PCC_MAPPED 0x00000000u
225 #define IRQ_CCMASK_PCC_ENABLE 0x00000040u
226 #define IRQ_CCMASK_PCC_FREEZE 0x00000060u
227 #define IRQ_CCMASK_PCC_BYPASS 0x00000080u
228 #define IRQ_CCMASK_DCC_MAPPED 0x00000000u
229 #define IRQ_CCMASK_DCC_ENABLE 0x00000008u
230 #define IRQ_CCMASK_DCC_FREEZE 0x0000000Cu
231 #define IRQ_CCMASK_DCC_BYPASS 0x00000010u
232 #define IRQ_CCMASK_DEFAULT IRQ_CCMASK_NONE
233 #define IRQ_IEMASK_SELF 0x80000000u
234 #define IRQ_IEMASK_ALL 0x0000FFFFu
235 #define IRQ_IEMASK_DEFAULT IRQ_IEMASK_SELF
238 /* private stuff */
239 #define _IRQ_DISPATCHTABLE_CNT (IRQ_INT_CNT)
240 #define _IRQ_EVENT2INTTABLE_CNT (IRQ_EVENT_CNT+1)
241 #define _IRQ_INT2EVENTTABLE_CNT (IRQ_INT_CNT)
244 /******************************************************************************\
245 * global typedef declarations
246 \******************************************************************************/
247 typedef struct {
248 void *funcAddr;
249 Uint32 ieMask;
250 Uint32 ccMask;
251 Uint32 funcArg;
252 } _IRQ_Dispatch;
254 typedef struct {
255 void *funcAddr;
256 Uint32 funcArg;
257 Uint32 ccMask;
258 Uint32 ieMask;
259 } IRQ_Config;
262 /******************************************************************************\
263 * global variable declarations
264 \******************************************************************************/
266 /* private vars */
267 extern far Uint32 _IRQ_eventTable[IRQ_EVENT_CNT+1];
268 extern far Uint32 _IRQ_intTable[IRQ_INT_CNT];
269 extern far _IRQ_Dispatch _IRQ_internalDispatchTable[_IRQ_DISPATCHTABLE_CNT];
270 extern far _IRQ_Dispatch *_IRQ_dispatchTable;
272 /******************************************************************************\
273 * global function declarations
274 \******************************************************************************/
276 /* private functions */
277 CSLAPI void _IRQ_init(Uint32 biosPresent, _IRQ_Dispatch *dispatchTable);
279 /* API functions */
280 CSLAPI void IRQ_map(Uint32 eventId, Uint32 intNumber);
281 CSLAPI void *IRQ_setVecs(void *vecs);
282 CSLAPI Uint32 IRQ_biosPresent();
283 CSLAPI void IRQ_hook(int intNum, void *func);
285 /* These functions only work with the DSP/BIOS HWI dispatcher */
286 CSLAPI void IRQ_config(Uint32 eventId, IRQ_Config *config);
287 CSLAPI void IRQ_configArgs(Uint32 eventId, void *funcAddr, Uint32 funcArg,
288 Uint32 ccMask, Uint32 ieMask);
289 CSLAPI void IRQ_getConfig(Uint32 eventId, IRQ_Config *config);
290 CSLAPI Uint32 IRQ_getArg(Uint32 eventId);
291 CSLAPI void IRQ_setArg(Uint32 eventId, Uint32 arg);
294 /******************************************************************************\
295 * inline function declarations
296 \******************************************************************************/
297 IDECL void IRQ_enable(Uint32 eventId);
298 IDECL Uint32 IRQ_disable(Uint32 eventId);
299 IDECL void IRQ_restore(Uint32 eventId, Uint32 ie);
300 IDECL void IRQ_set(Uint32 eventId);
301 IDECL void IRQ_clear(Uint32 eventId);
302 IDECL Uint32 IRQ_test(Uint32 eventId);
303 IDECL void IRQ_reset(Uint32 eventId);
304 IDECL void IRQ_resetAll();
306 IDECL void IRQ_globalEnable();
307 IDECL Uint32 IRQ_globalDisable();
308 IDECL void IRQ_globalRestore(Uint32 gie);
310 IDECL void IRQ_nmiEnable();
311 IDECL void IRQ_nmiDisable();
314 /******************************************************************************\
315 * inline function definitions
316 \******************************************************************************/
317 #ifdef USEDEFS
318 /*----------------------------------------------------------------------------*/
319 IDEF void IRQ_enable(Uint32 eventId) {
320 IER |= _IRQ_eventTable[eventId];
321 }
322 /*----------------------------------------------------------------------------*/
323 IDEF Uint32 IRQ_disable(Uint32 eventId) {
324 Uint32 ie = IER & _IRQ_eventTable[eventId];
325 IER &= ~_IRQ_eventTable[eventId];
326 return ie;
327 }
328 /*----------------------------------------------------------------------------*/
329 IDEF void IRQ_restore(Uint32 eventId, Uint32 ie) {
330 if (ie) {
331 IER |= _IRQ_eventTable[eventId];
332 } else {
333 IER &= ~_IRQ_eventTable[eventId];
334 }
335 }
336 /*----------------------------------------------------------------------------*/
337 IDEF void IRQ_set(Uint32 eventId) {
338 ISR = _IRQ_eventTable[eventId];
339 }
340 /*----------------------------------------------------------------------------*/
341 IDEF void IRQ_clear(Uint32 eventId) {
342 ICR = _IRQ_eventTable[eventId];
343 }
344 /*----------------------------------------------------------------------------*/
345 IDEF Uint32 IRQ_test(Uint32 eventId) {
346 return (Uint32)((IFR & _IRQ_eventTable[eventId]) ? 1 : 0);
347 }
348 /*----------------------------------------------------------------------------*/
349 IDEF void IRQ_globalEnable() {
350 CHIP_FSET(CSR,GIE,1);
351 }
352 /*----------------------------------------------------------------------------*/
353 IDEF Uint32 IRQ_globalDisable() {
354 Uint32 gie = CHIP_FGET(CSR,GIE);
355 CHIP_FSET(CSR,GIE,0);
356 return gie;
357 }
358 /*----------------------------------------------------------------------------*/
359 IDEF void IRQ_globalRestore(Uint32 gie) {
360 CHIP_FSET(CSR,GIE,gie);
361 }
362 /*----------------------------------------------------------------------------*/
363 IDEF void IRQ_reset(Uint32 eventId) {
364 IER &= ~_IRQ_eventTable[eventId];
365 ICR = _IRQ_eventTable[eventId];
366 }
367 /*----------------------------------------------------------------------------*/
368 IDEF void IRQ_resetAll() {
369 CHIP_FSET(CSR,GIE,0);
370 CHIP_CRSET(IER,0x00000000);
371 CHIP_CRSET(ICR,0xFFFFFFFF);
372 }
373 /*----------------------------------------------------------------------------*/
374 IDEF void IRQ_nmiEnable() {
375 IER |= 0x00000002;
376 }
377 /*----------------------------------------------------------------------------*/
378 IDEF void IRQ_nmiDisable() {
379 IER &= ~0x00000002;
380 }
381 /*----------------------------------------------------------------------------*/
382 #endif /* USEDEFS */
385 #endif /* IRQ_SUPPORT */
386 #endif /* _CSL_IRQ_H_ */
387 /******************************************************************************\
388 * End of csl_irq.h
389 \******************************************************************************/