Debian Codegraph @

drivers/dahdi/oct612x/octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.c

raw symbols SCIP
1 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2
3 File: oct6100_interrupts.c
4
5 Copyright (c) 2001-2007 Octasic Inc.
6
7 Description:
8
9 This file contains the API's interrupt service routine and all of its
10 sub-functions.
11
12 This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is
13 free software; you can redistribute it and/or modify it under the terms of
14 the GNU General Public License as published by the Free Software Foundation;
15 either version 2 of the License, or (at your option) any later version.
16
17 The OCT6100 GPL API is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with the OCT6100 GPL API; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
26 $Octasic_Release: OCT612xAPI-01.00-PR49 $
27
28 $Octasic_Revision: 81 $
29
30 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
31
32
33 /***************************** INCLUDE FILES *******************************/
34
35 #include "octdef.h"
36
37 #include "oct6100api/oct6100_defines.h"
38 #include "oct6100api/oct6100_errors.h"
39 #include "oct6100api/oct6100_apiud.h"
40
41 #include "oct6100api/oct6100_tlv_inst.h"
42 #include "oct6100api/oct6100_chip_open_inst.h"
43 #include "oct6100api/oct6100_chip_stats_inst.h"
44 #include "oct6100api/oct6100_interrupts_inst.h"
45 #include "oct6100api/oct6100_remote_debug_inst.h"
46 #include "oct6100api/oct6100_debug_inst.h"
47 #include "oct6100api/oct6100_api_inst.h"
48
49 #include "oct6100api/oct6100_interrupts_pub.h"
50 #include "oct6100api/oct6100_chip_open_pub.h"
51 #include "oct6100api/oct6100_events_pub.h"
52 #include "oct6100api/oct6100_channel_pub.h"
53 #include "oct6100api/oct6100_interrupts_pub.h"
54 #include "oct6100api/oct6100_channel_inst.h"
55
56 #include "oct6100_chip_open_priv.h"
57 #include "oct6100_miscellaneous_priv.h"
58 #include "oct6100_events_priv.h"
59 #include "oct6100_interrupts_priv.h"
60
61 /**************************** PUBLIC FUNCTIONS *****************************/
62
63
64 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
65
66 Function: Oct6100InterruptConfigure
67
68 Description: Configure the operation of all possible interrupt sources.
69
70 -------------------------------------------------------------------------------
71 | Argument | Description
72 -------------------------------------------------------------------------------
73 f_pApiInstance Pointer to API instance. This memory is used to keep
74 the present state of the chip and all its resources.
75
76 f_pIntrptConfig Pointer to interrupt configuration structure.
77
78 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
79 #if !SKIP_Oct6100InterruptConfigureDef
80 UINT32 Oct6100InterruptConfigureDef(
81 tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
82 {
83 f_pIntrptConfig->ulFatalGeneralConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
84 f_pIntrptConfig->ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
85
86 f_pIntrptConfig->ulErrorMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
87 f_pIntrptConfig->ulErrorOverflowToneEventsConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
88 f_pIntrptConfig->ulErrorH100Config = cOCT6100_INTERRUPT_NO_TIMEOUT;
89
90 f_pIntrptConfig->ulFatalMemoryTimeout = 100;
91
92 f_pIntrptConfig->ulErrorMemoryTimeout = 100;
93 f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = 100;
94 f_pIntrptConfig->ulErrorH100Timeout = 100;
95
96 return cOCT6100_ERR_OK;
97 }
98 #endif
99
100
101 #if !SKIP_Oct6100InterruptConfigure
102 UINT32 Oct6100InterruptConfigure(
103 tPOCT6100_INSTANCE_API f_pApiInstance,
104 tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
105 {
106 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
107 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
108 UINT32 ulResult;
109 UINT32 ulFncRes;
110
111 /* Set the process context of the serialize structure.*/
112 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
113 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
114
115 /* Create serialization object for ISR. */
116 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
117 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
118 ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
119 if ( ulResult != cOCT6100_ERR_OK )
120 return ulResult;
121
122 /* Call serialized sub-function. */
123 ulFncRes = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
124 /* Release serialization object. */
125 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
126 ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
127 if ( ulResult != cOCT6100_ERR_OK )
128 return ulResult;
129
130 /* Check if an error occured in sub-function. */
131 if ( ulFncRes != cOCT6100_ERR_OK )
132 return ulFncRes;
133
134 return cOCT6100_ERR_OK;
135 }
136 #endif
137
138
139 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
140
141 Function: Oct6100InterruptServiceRoutine
142
143 Description: The API's interrupt service routine. This function clears all
144 register ROLs which have generated an interrupt and report the
145 events in the user supplied structure. Also, the tone event
146 and/or playout event buffer will be emptied if valid events
147 are present.
148
149 -------------------------------------------------------------------------------
150 | Argument | Description
151 -------------------------------------------------------------------------------
152 f_pApiInstance Pointer to API instance. This memory is used to keep
153 the present state of the chip and all its resources.
154
155 f_pIntFlags Pointer to structure containing event flags returned
156 to user.
157
158 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
159 #if !SKIP_Oct6100InterruptServiceRoutineDef
160 UINT32 Oct6100InterruptServiceRoutineDef(
161 tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
162 {
163 f_pIntFlags->fFatalGeneral = FALSE;
164 f_pIntFlags->ulFatalGeneralFlags = 0x0;
165 f_pIntFlags->fFatalReadTimeout = FALSE;
166
167 f_pIntFlags->fErrorRefreshTooLate = FALSE;
168 f_pIntFlags->fErrorPllJitter = FALSE;
169
170 f_pIntFlags->fErrorOverflowToneEvents = FALSE;
171
172 f_pIntFlags->fErrorH100OutOfSync = FALSE;
173 f_pIntFlags->fErrorH100ClkA = FALSE;
174 f_pIntFlags->fErrorH100ClkB = FALSE;
175 f_pIntFlags->fErrorH100FrameA = FALSE;
176
177 f_pIntFlags->fToneEventsPending = FALSE;
178 f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
179
180 f_pIntFlags->fApiSynch = FALSE;
181
182
183
184 return cOCT6100_ERR_OK;
185 }
186 #endif
187
188
189 #if !SKIP_Oct6100InterruptServiceRoutine
190 UINT32 Oct6100InterruptServiceRoutine(
191 tPOCT6100_INSTANCE_API f_pApiInstance,
192 tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
193 {
194 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
195 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
196 UINT32 ulResult;
197 UINT32 ulFncRes;
198
199 /* Set the process context of the serialize structure. */
200 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
201 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
202
203 /* Seize the serialization object for the ISR. */
204 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
205 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
206 ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
207 if ( ulResult == cOCT6100_ERR_OK )
208 {
209 /* Call the serialized sub-function. */
210 ulFncRes = Oct6100InterruptServiceRoutineSer( f_pApiInstance, f_pIntFlags );
211 }
212 else
213 {
214 return ulResult;
215 }
216
217 /* Release the serialization object. */
218 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
219 ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
220 if ( ulResult != cOCT6100_ERR_OK )
221 return ulResult;
222
223 /* Check for an error in the sub-function. */
224 if ( ulFncRes != cOCT6100_ERR_OK )
225 return ulFncRes;
226
227 return cOCT6100_ERR_OK;
228 }
229 #endif
230
231
232 /**************************** PRIVATE FUNCTIONS ****************************/
233
234
235 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
236
237 Function: Oct6100ApiIsrSwInit
238
239 Description: Initializes portions of API instance associated to the API's
240 interrupt service routine.
241
242 -------------------------------------------------------------------------------
243 | Argument | Description
244 -------------------------------------------------------------------------------
245 f_pApiInstance Pointer to API instance. This memory is used to keep
246 the present state of the chip and all its resources.
247
248 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
249 #if !SKIP_Oct6100ApiIsrSwInit
250 UINT32 Oct6100ApiIsrSwInit(
251 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
252 {
253 tPOCT6100_SHARED_INFO pSharedInfo;
254
255 /* Get local pointer to shared portion of instance. */
256 pSharedInfo = f_pApiInstance->pSharedInfo;
257
258 /* Set the state of each interrupt group to disabled. The state will */
259 /* be updated to the true configuration once the configure interrupts function is called. */
260 pSharedInfo->IntrptManage.byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
261 pSharedInfo->IntrptManage.byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
262 pSharedInfo->IntrptManage.byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
263 pSharedInfo->IntrptManage.byErrorH100State = cOCT6100_INTRPT_DISABLED;
264 pSharedInfo->IntrptManage.byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
265
266 /* Indicate that the mclk interrupt is not active at the moment. */
267 pSharedInfo->IntrptManage.fMclkIntrptActive = FALSE;
268
269 /* Indicate that no buffer playout events are pending for the moment. */
270 pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
271
272 /* Indicate that no tone events are pending for the moment. */
273 pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
274
275 /* The ISR has never been called. */
276 pSharedInfo->IntrptManage.fIsrCalled = FALSE;
277
278 return cOCT6100_ERR_OK;
279 }
280 #endif
281
282
283 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
284
285 Function: Oct6100ApiIsrHwInit
286
287 Description: Initializes the chip's interrupt registers.
288
289 -------------------------------------------------------------------------------
290 | Argument | Description
291 -------------------------------------------------------------------------------
292 f_pApiInstance Pointer to API instance. This memory is used to keep
293 the present state of the chip and all its resources.
294
295 f_pIntrptConfig Pointer to structure defining how the interrupts
296 should be configured.
297
298 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
299 #if !SKIP_Oct6100ApiIsrHwInit
300 UINT32 Oct6100ApiIsrHwInit(
301 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
302 IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
303 {
304 tOCT6100_WRITE_PARAMS WriteParams;
305 UINT32 ulResult;
306
307 /* Set some parameters of write struct. */
308 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
309
310 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
311
312 /*==================================================================================*/
313 /* Enable all the interrupts */
314
315 WriteParams.ulWriteAddress = 0x104;
316 WriteParams.usWriteData = 0x0001;
317 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
318 if ( ulResult != cOCT6100_ERR_OK )
319 return ulResult;
320
321 WriteParams.ulWriteAddress = 0x204;
322 WriteParams.usWriteData = 0x1C05;
323 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
324 if ( ulResult != cOCT6100_ERR_OK )
325 return ulResult;
326
327 WriteParams.ulWriteAddress = 0x304;
328 WriteParams.usWriteData = 0xFFFF;
329 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
330 if ( ulResult != cOCT6100_ERR_OK )
331 return ulResult;
332
333 WriteParams.ulWriteAddress = 0x504;
334 WriteParams.usWriteData = 0x0002;
335 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
336 if ( ulResult != cOCT6100_ERR_OK )
337 return ulResult;
338
339 WriteParams.ulWriteAddress = 0x704;
340 WriteParams.usWriteData = 0x0007;
341 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
342 if ( ulResult != cOCT6100_ERR_OK )
343 return ulResult;
344
345 /*==================================================================================*/
346
347 /* Calculate the number of mclk cycles in 1 ms. */
348 f_pApiInstance->pSharedInfo->IntrptManage.ulNumMclkCyclesIn1Ms = f_pApiInstance->pSharedInfo->MiscVars.ulMclkFreq / 1000;
349
350 /* Configure the interrupt registers as requested by the user. */
351 ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
352 if ( ulResult != cOCT6100_ERR_OK )
353 return ulResult;
354
355 return cOCT6100_ERR_OK;
356 }
357 #endif
358
359
360 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
361
362 Function: Oct6100InterruptConfigureSer
363
364 Description: Configure the operation of interrupt groups.
365
366 -------------------------------------------------------------------------------
367 | Argument | Description
368 -------------------------------------------------------------------------------
369 f_pApiInstance Pointer to API instance. This memory is used to keep
370 the present state of the chip and all its resources.
371
372 f_pIntrptConfig Pointer to interrupt configuration structure.
373 f_fCheckParams Check parameter enable flag.
374
375 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
376 #if !SKIP_Oct6100InterruptConfigureSer
377 UINT32 Oct6100InterruptConfigureSer(
378 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
379 IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig,
380 IN BOOL f_fCheckParams )
381 {
382 tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
383 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
384 UINT32 ulResult;
385
386 /* Check for errors. */
387 if ( f_fCheckParams == TRUE )
388 {
389 if ( f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE &&
390 f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
391 return cOCT6100_ERR_INTRPTS_FATAL_GENERAL_CONFIG;
392 if ( f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
393 f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
394 f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
395 return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_CONFIG;
396 if ( f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
397 f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
398 f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
399 return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_CONFIG;
400 if ( f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE &&
401 f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT &&
402 f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
403 return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_CONFIG;
404 if ( f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE &&
405 f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT &&
406 f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT )
407 return cOCT6100_ERR_INTRPTS_H100_ERROR_CONFIG;
408
409 if ( f_pIntrptConfig->ulFatalMemoryTimeout < 10 ||
410 f_pIntrptConfig->ulFatalMemoryTimeout > 10000 )
411 return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_TIMEOUT;
412 if ( f_pIntrptConfig->ulErrorMemoryTimeout < 10 ||
413 f_pIntrptConfig->ulErrorMemoryTimeout > 10000 )
414 return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_TIMEOUT;
415 if ( f_pIntrptConfig->ulErrorOverflowToneEventsTimeout < 10 ||
416 f_pIntrptConfig->ulErrorOverflowToneEventsTimeout > 10000 )
417 return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_TIMEOUT;
418 if ( f_pIntrptConfig->ulErrorH100Timeout < 10 ||
419 f_pIntrptConfig->ulErrorH100Timeout > 10000 )
420 return cOCT6100_ERR_INTRPTS_H100_ERROR_TIMEOUT;
421 }
422
423 /* Copy the configuration to the API instance. */
424 pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
425 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
426
427 pIntrptConfig->byFatalGeneralConfig = (UINT8)( f_pIntrptConfig->ulFatalGeneralConfig & 0xFF );
428 pIntrptConfig->byFatalMemoryConfig = (UINT8)( f_pIntrptConfig->ulFatalMemoryConfig & 0xFF );
429 pIntrptConfig->byErrorMemoryConfig = (UINT8)( f_pIntrptConfig->ulErrorMemoryConfig & 0xFF );
430 pIntrptConfig->byErrorOverflowToneEventsConfig = (UINT8)( f_pIntrptConfig->ulErrorOverflowToneEventsConfig & 0xFF );
431 pIntrptConfig->byErrorH100Config = (UINT8)( f_pIntrptConfig->ulErrorH100Config & 0xFF );
432
433 f_pIntrptConfig->ulFatalMemoryTimeout = ((f_pIntrptConfig->ulFatalMemoryTimeout + 9) / 10) * 10;
434 pIntrptConfig->ulFatalMemoryTimeoutMclk = f_pIntrptConfig->ulFatalMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
435
436 f_pIntrptConfig->ulErrorMemoryTimeout = ((f_pIntrptConfig->ulErrorMemoryTimeout + 9) / 10) * 10;
437 pIntrptConfig->ulErrorMemoryTimeoutMclk = f_pIntrptConfig->ulErrorMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
438
439 f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = ((f_pIntrptConfig->ulErrorOverflowToneEventsTimeout + 9) / 10) * 10;
440 pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk = f_pIntrptConfig->ulErrorOverflowToneEventsTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
441
442 f_pIntrptConfig->ulErrorH100Timeout = ((f_pIntrptConfig->ulErrorH100Timeout + 9) / 10) * 10;
443 pIntrptConfig->ulErrorH100TimeoutMclk = f_pIntrptConfig->ulErrorH100Timeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
444
445
446 /*Clear all interrupts that were already enabled*/
447 ulResult = Oct6100ApiClearEnabledInterrupts( f_pApiInstance );
448 if ( ulResult != cOCT6100_ERR_OK )
449 return ulResult;
450
451 /* Before writing the new configuration to the chip's registers, make sure that any */
452 /* interrupts which are either disabled or have no timeout period are not on the */
453 /* disabled interrupt list. */
454
455 /*==================================================================================*/
456 if ( pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_DISABLE )
457 pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
458 else /* pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_NO_TIMEOUT */
459 pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_ACTIVE;
460
461 /*==================================================================================*/
462 if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
463 pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
464 else if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
465 pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
466 else /* ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
467 {
468 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_DISABLED )
469 pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
470 }
471
472 /*==================================================================================*/
473 if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
474 pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
475 else if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
476 pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
477 else /* (pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
478 {
479 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_DISABLED )
480 pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
481 }
482
483 /*==================================================================================*/
484 if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_DISABLE )
485 pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
486 else if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
487 pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
488 else /* (pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
489 {
490 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_DISABLED )
491 pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
492 }
493
494 /*==================================================================================*/
495 if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_DISABLE )
496 pIntrptManage->byErrorH100State = cOCT6100_INTRPT_DISABLED;
497 else if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_NO_TIMEOUT )
498 pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
499 else /* (pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT ) */
500 {
501 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_DISABLED )
502 pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
503 }
504
505
506 /* Write to the interrupt registers to update the state of each interrupt group. */
507 ulResult = Oct6100ApiWriteIeRegs( f_pApiInstance );
508 if ( ulResult != cOCT6100_ERR_OK )
509 return ulResult;
510
511 return cOCT6100_ERR_OK;
512 }
513 #endif
514
515 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
516
517 Function: Oct6100ApiClearEnabledInterrupts
518
519 Description: Disabled interruption are not reported but still available. This
520 function will clear the interrupts that were disabled and wish
521 to enable now.
522
523 -------------------------------------------------------------------------------
524 | Argument | Description
525 -------------------------------------------------------------------------------
526 f_pApiInstance Pointer to API instance. This memory is used to keep
527 the present state of the chip and all its resources.
528
529 f_pIntrptConfig Pointer to interrupt configuration structure.
530 f_pIntrptManage Pointer to interrupt manager structure.
531 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
532
533 #if !SKIP_Oct6100ApiClearEnabledInterrupts
534 UINT32 Oct6100ApiClearEnabledInterrupts(
535 IN tPOCT6100_INSTANCE_API f_pApiInstance )
536 {
537
538 tPOCT6100_SHARED_INFO pSharedInfo;
539 tOCT6100_WRITE_PARAMS WriteParams;
540 tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
541 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
542 UINT32 ulResult;
543
544 /* Get local pointer to shared portion of instance. */
545 pSharedInfo = f_pApiInstance->pSharedInfo;
546
547 /* Set the process context and user chip ID parameters once and for all. */
548 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
549
550 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
551
552 /* Copy the configuration to the API instance. */
553 pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
554 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
555
556 if ( pIntrptConfig->byFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE &&
557 pIntrptManage->byFatalGeneralState != cOCT6100_INTRPT_DISABLED )
558 {
559 WriteParams.ulWriteAddress = 0x102;
560 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_102H;
561 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
562 if ( ulResult != cOCT6100_ERR_OK )
563 return ulResult;
564
565 WriteParams.ulWriteAddress = 0x202;
566 WriteParams.usWriteData = 0x1800;
567 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
568 if ( ulResult != cOCT6100_ERR_OK )
569 return ulResult;
570
571 WriteParams.ulWriteAddress = 0x502;
572 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_502H;
573 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
574 if ( ulResult != cOCT6100_ERR_OK )
575 return ulResult;
576 }
577
578 if ( pIntrptConfig->byErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
579 pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
580 {
581 WriteParams.ulWriteAddress = 0x202;
582 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_202H;
583 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
584 if ( ulResult != cOCT6100_ERR_OK )
585 return ulResult;
586 }
587
588 if ( pIntrptConfig->byErrorH100Config != cOCT6100_INTERRUPT_DISABLE &&
589 pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
590 {
591 WriteParams.ulWriteAddress = 0x302;
592 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_302H;
593 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
594 if ( ulResult != cOCT6100_ERR_OK )
595 return ulResult;
596 }
597
598 if ( pIntrptConfig->byErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE &&
599 pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
600 {
601 WriteParams.ulWriteAddress = 0x702;
602 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_702H;
603 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
604 if ( ulResult != cOCT6100_ERR_OK )
605 return ulResult;
606 }
607
608
609 return cOCT6100_ERR_OK;
610
611 }
612 #endif
613
614 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
615
616 Function: Oct6100InterruptServiceRoutineSer
617
618 Description: Serialized sub-function of API's interrupt service routine.
619
620 -------------------------------------------------------------------------------
621 | Argument | Description
622 -------------------------------------------------------------------------------
623 f_pApiInstance Pointer to API instance. This memory is used to keep
624 the present state of the chip and all its resources.
625
626 f_pIntFlags Pointer to structure containing event flags returned
627 to user.
628
629 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
630 #if !SKIP_Oct6100InterruptServiceRoutineSer
631 UINT32 Oct6100InterruptServiceRoutineSer(
632 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
633 IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
634 {
635 tPOCT6100_SHARED_INFO pSharedInfo;
636 tOCT6100_READ_PARAMS ReadParams;
637 tOCT6100_WRITE_PARAMS WriteParams;
638 UINT32 ulRegister210h;
639 UINT32 ulResult;
640 UINT16 usReadData;
641
642 /* Get local pointer(s). */
643 pSharedInfo = f_pApiInstance->pSharedInfo;
644
645 /* Must update the statistics. Set parameters in read and write structs. */
646 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
647
648 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
649
650 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
651
652 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
653 ReadParams.pusReadData = &usReadData;
654
655 /* Set all the flags to default values to make sure the variables are initialized. */
656 f_pIntFlags->fFatalGeneral = FALSE;
657 f_pIntFlags->ulFatalGeneralFlags = 0x0;
658 f_pIntFlags->fFatalReadTimeout = FALSE;
659
660 f_pIntFlags->fErrorRefreshTooLate = FALSE;
661 f_pIntFlags->fErrorPllJitter = FALSE;
662
663 f_pIntFlags->fErrorH100OutOfSync = FALSE;
664 f_pIntFlags->fErrorH100ClkA = FALSE;
665 f_pIntFlags->fErrorH100ClkB = FALSE;
666 f_pIntFlags->fErrorH100FrameA = FALSE;
667 f_pIntFlags->fApiSynch = FALSE;
668
669 f_pIntFlags->fErrorOverflowToneEvents = FALSE;
670
671 /* Start by reading registers 210h to determine if any modules have flagged an interrupt. */
672 ReadParams.ulReadAddress = 0x210;
673 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
674 if ( ulResult != cOCT6100_ERR_OK )
675 return ulResult;
676 ulRegister210h = usReadData;
677
678 /* Update the extended mclk counter. */
679 ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
680 if ( ulResult != cOCT6100_ERR_OK )
681 return ulResult;
682
683 /* If the mclk interrupt is active then check which interrupt timeout periods have expired. */
684 ReadParams.ulReadAddress = 0x302;
685 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
686 if ( ulResult != cOCT6100_ERR_OK )
687 return ulResult;
688 if ( (usReadData & 0x1) != 0 && pSharedInfo->IntrptManage.fMclkIntrptActive == TRUE )
689 {
690 /* Update timeout periods. */
691 ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
692 if ( ulResult != cOCT6100_ERR_OK )
693 return ulResult;
694
695 f_pIntFlags->fApiSynch = TRUE;
696
697 /* Read registers 210h and 212h again to determine if any modules have flagged an interrupt. */
698 ReadParams.ulReadAddress = 0x210;
699 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
700 if ( ulResult != cOCT6100_ERR_OK )
701 return ulResult;
702 ulRegister210h = usReadData;
703 }
704
705 /* Read the interrupt registers to determine what interrupt conditions have occured. */
706 ulResult = Oct6100ApiReadIntrptRegs( f_pApiInstance, f_pIntFlags, ulRegister210h );
707 if ( ulResult != cOCT6100_ERR_OK )
708 return ulResult;
709
710 /* Empty the tone buffer if any events are pending. */
711 ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, FALSE );
712 if ( ulResult != cOCT6100_ERR_OK )
713 return ulResult;
714
715 /* Set the tone events pending flag. */
716 f_pIntFlags->fToneEventsPending = pSharedInfo->IntrptManage.fToneEventsPending;
717
718 /* Check for buffer playout events and insert in the software queue -- if activated. */
719 if ( pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize != 0 )
720 {
721 ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, FALSE );
722 if ( ulResult != cOCT6100_ERR_OK )
723 return ulResult;
724
725 /* Set the buffer playout events pending flag. */
726 f_pIntFlags->fBufferPlayoutEventsPending = pSharedInfo->IntrptManage.fBufferPlayoutEventsPending;
727 }
728 else
729 {
730 f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
731 }
732
733 /* Update the states of each interrupt group. */
734 ulResult = Oct6100ApiUpdateIntrptStates( f_pApiInstance, f_pIntFlags );
735 if ( ulResult != cOCT6100_ERR_OK )
736 return ulResult;
737
738 /* Check the state of the NLP timestamp if required.*/
739 ulResult = Oct6100ApiCheckProcessorState( f_pApiInstance, f_pIntFlags );
740 if ( ulResult != cOCT6100_ERR_OK )
741 return ulResult;
742
743 /* Write to the necessary IE registers. */
744 ulResult = Oct6100ApiWriteIntrptRegs( f_pApiInstance );
745 if ( ulResult != cOCT6100_ERR_OK )
746 return ulResult;
747
748 /* Schedule the next mclk interrupt, if one is needed. */
749 ulResult = Oct6100ApiScheduleNextMclkIntrptSer( f_pApiInstance );
750 if ( ulResult != cOCT6100_ERR_OK )
751 return ulResult;
752
753 /* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */
754 WriteParams.ulWriteAddress = 0x214;
755 WriteParams.usWriteData = 0x0000;
756 if ( pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY )
757 WriteParams.usWriteData |= 0x4000;
758 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
759 if ( ulResult != cOCT6100_ERR_OK )
760 return ulResult;
761
762 /* Indicate that the interrupt ROLs have been treated. */
763 WriteParams.ulWriteAddress = 0x212;
764 WriteParams.usWriteData = 0x8000;
765 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
766 if ( ulResult != cOCT6100_ERR_OK )
767 return ulResult;
768
769 return cOCT6100_ERR_OK;
770 }
771 #endif
772
773
774 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
775
776 Function: Oct6100ApiReadIntrptRegs
777
778 Description: Reads the interrupt registers of all modules currently
779 indicating an interrupt condition.
780
781 -------------------------------------------------------------------------------
782 | Argument | Description
783 -------------------------------------------------------------------------------
784 f_pApiInstance Pointer to API instance. This memory is used to keep
785 the present state of the chip and all its resources.
786
787 f_pIntFlags Pointer to an interrupt flag structure.
788 f_ulRegister210h Value of register 0x210.
789
790 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
791 #if !SKIP_Oct6100ApiReadIntrptRegs
792 UINT32 Oct6100ApiReadIntrptRegs(
793 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
794 OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags,
795 IN UINT32 f_ulRegister210h )
796 {
797 tPOCT6100_SHARED_INFO pSharedInfo;
798 tPOCT6100_API_CHIP_ERROR_STATS pErrorStats;
799 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
800 tOCT6100_READ_PARAMS ReadParams;
801 tOCT6100_WRITE_PARAMS WriteParams;
802
803 UINT32 ulResult;
804 UINT16 usReadData;
805 UINT32 ulFeatureBytesOffset;
806 UINT32 ulFeatureBitOffset;
807 UINT32 ulFeatureFieldLength;
808 UINT32 ulTempData;
809 UINT32 ulCounterValue;
810 UINT32 ulMask;
811
812 /* Get local pointer(s). */
813 pSharedInfo = f_pApiInstance->pSharedInfo;
814 pErrorStats = &pSharedInfo->ErrorStats;
815 pIntrptManage = &pSharedInfo->IntrptManage;
816
817 /* Set some parameters of read struct. */
818 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
819
820 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
821 ReadParams.pusReadData = &usReadData;
822
823 /* Set some parameters of write struct. */
824 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
825
826 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
827
828
829
830 /* CPU registers. */
831 if ( (f_ulRegister210h & 0x00001) != 0 )
832 {
833 /*=======================================================================*/
834 /* Read registers of this module. */
835 ReadParams.ulReadAddress = 0x102;
836 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
837 if ( ulResult != cOCT6100_ERR_OK )
838 return ulResult;
839
840 /* Check which interrupt(s) were set. */
841 if ( (usReadData & 0x0001) != 0 )
842 {
843 f_pIntFlags->fFatalReadTimeout = TRUE;
844 pErrorStats->ulInternalReadTimeoutCnt++;
845 }
846
847 pIntrptManage->usRegister102h = usReadData;
848 /*=======================================================================*/
849 }
850 else
851 {
852 pIntrptManage->usRegister102h = 0x0;
853 }
854
855 /* MAIN registers. */
856 if ( (f_ulRegister210h & 0x00002) != 0 )
857 {
858 /*=======================================================================*/
859 /* Read registers of this module. */
860 ReadParams.ulReadAddress = 0x202;
861 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
862 if ( ulResult != cOCT6100_ERR_OK )
863 return ulResult;
864
865 /* Save current value in instance. */
866 pIntrptManage->usRegister202h = usReadData;
867
868 /* Check which interrupts were set. */
869 if ( (usReadData & 0x0001) != 0 )
870 {
871 f_pIntFlags->fErrorRefreshTooLate = TRUE;
872 pErrorStats->ulSdramRefreshTooLateCnt++;
873 }
874 if ( (usReadData & 0x0800) != 0 )
875 {
876 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_1;
877 f_pIntFlags->fFatalGeneral = TRUE;
878 pErrorStats->fFatalChipError = TRUE;
879 }
880 if ( (usReadData & 0x1000) != 0 )
881 {
882 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_2;
883 f_pIntFlags->fFatalGeneral = TRUE;
884 pErrorStats->fFatalChipError = TRUE;
885 }
886 if ( (usReadData & 0x0400) != 0 )
887 {
888 f_pIntFlags->fErrorPllJitter = TRUE;
889 pErrorStats->ulPllJitterErrorCnt++;
890
891 /* Update the PLL jitter error count here. */
892 if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
893 {
894 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
895 ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
896 ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
897
898 ulResult = Oct6100ApiReadDword( f_pApiInstance,
899 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
900 &ulTempData );
901
902 /* Read previous value set in the feature field. */
903 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
904
905 /* Update counter. */
906 ulCounterValue = ulTempData & ulMask;
907 ulCounterValue = ulCounterValue >> ulFeatureBitOffset;
908 ulCounterValue ++;
909 /* Handle wrap around case. */
910 ulCounterValue &= ( 1 << ulFeatureFieldLength ) - 1;
911
912 /* Clear old counter value. */
913 ulTempData &= (~ulMask);
914 ulTempData |= ulCounterValue << ulFeatureBitOffset;
915
916 /* Write the DWORD where the field is located.*/
917 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
918 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
919 ulTempData );
920 if ( ulResult != cOCT6100_ERR_OK )
921 return ulResult;
922 }
923 }
924
925 /*=======================================================================*/
926 }
927 else
928 {
929 pIntrptManage->usRegister202h = 0x0;
930 }
931
932 /* H.100 registers. */
933 if ( (f_ulRegister210h & 0x00004) != 0 )
934 {
935 /*=======================================================================*/
936 /* Read registers of this module. */
937 ReadParams.ulReadAddress = 0x302;
938 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
939 if ( ulResult != cOCT6100_ERR_OK )
940 return ulResult;
941
942 /* Check which interrupts were set. */
943 if ( (usReadData & 0x0100) != 0 )
944 {
945 f_pIntFlags->fErrorH100OutOfSync = TRUE;
946 pErrorStats->ulH100OutOfSyncCnt++;
947 }
948 if ( (usReadData & 0x1000) != 0 )
949 {
950 f_pIntFlags->fErrorH100FrameA = TRUE;
951 pErrorStats->ulH100FrameABadCnt++;
952 }
953 if ( (usReadData & 0x4000) != 0 )
954 {
955 f_pIntFlags->fErrorH100ClkA = TRUE;
956 pErrorStats->ulH100ClkABadCnt++;
957 }
958 if ( (usReadData & 0x8000) != 0 )
959 {
960 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
961 {
962 f_pIntFlags->fErrorH100ClkB = TRUE;
963 pErrorStats->ulH100ClkBBadCnt++;
964 }
965 }
966
967 pIntrptManage->usRegister302h = usReadData;
968 /*=======================================================================*/
969 }
970 else
971 {
972 pIntrptManage->usRegister302h = 0x0;
973 }
974
975 /* TDMIE registers. */
976 if ( (f_ulRegister210h & 0x00010) != 0 )
977 {
978 /*=======================================================================*/
979 /* Read register. */
980 ReadParams.ulReadAddress = 0x502;
981 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
982 if ( ulResult != cOCT6100_ERR_OK )
983 return ulResult;
984
985 /* Check which interrupts were set. */
986 if ( (usReadData & 0x0002) != 0 )
987 {
988 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_3;
989 f_pIntFlags->fFatalGeneral = TRUE;
990 pErrorStats->fFatalChipError = TRUE;
991 }
992
993 pIntrptManage->usRegister502h = usReadData;
994 /*=======================================================================*/
995 }
996 else
997 {
998 pIntrptManage->usRegister502h = 0x0;
999 }
1000
1001 /* PGSP registers. */
1002 if ( (f_ulRegister210h & 0x00080) != 0 )
1003 {
1004 /*=======================================================================*/
1005 /* Read register. */
1006 ReadParams.ulReadAddress = 0x702;
1007 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1008 if ( ulResult != cOCT6100_ERR_OK )
1009 return ulResult;
1010
1011 /* Check which interrupts were set. */
1012 if ( (usReadData & 0x0002) != 0 )
1013 {
1014 f_pIntFlags->fErrorOverflowToneEvents = TRUE;
1015 pErrorStats->ulOverflowToneEventsCnt++;
1016 }
1017
1018 pIntrptManage->usRegister702h = usReadData;
1019 /*=======================================================================*/
1020 }
1021 else
1022 {
1023 pIntrptManage->usRegister702h = 0x0;
1024 }
1025
1026
1027
1028 /* If this is the first time the ISR is called, clear the ISR is not called bit */
1029 /* in external memory to signal the remote client that we are called. */
1030 if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE )
1031 {
1032 /* Remember that we are being called. */
1033 pSharedInfo->IntrptManage.fIsrCalled = TRUE;
1034
1035 if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
1036 {
1037 ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
1038 ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
1039 ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
1040
1041 ulResult = Oct6100ApiReadDword( f_pApiInstance,
1042 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
1043 &ulTempData );
1044
1045 /* Read previous value set in the feature field. */
1046 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
1047
1048 /* Clear the field. */
1049 ulTempData &= (~ulMask);
1050
1051 /* Write the DWORD where the field is located.*/
1052 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
1053 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
1054 ulTempData );
1055 if ( ulResult != cOCT6100_ERR_OK )
1056 return ulResult;
1057 }
1058 }
1059
1060 return cOCT6100_ERR_OK;
1061 }
1062 #endif
1063
1064
1065 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1066
1067 Function: Oct6100ApiUpdateIntrptStates
1068
1069 Description: Updates the state of all interrupt register groups.
1070
1071 -------------------------------------------------------------------------------
1072 | Argument | Description
1073 -------------------------------------------------------------------------------
1074 f_pApiInstance Pointer to API instance. This memory is used to keep
1075 the present state of the chip and all its resources.
1076
1077 f_pIntFlags Interrupt flags.
1078
1079 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1080 #if !SKIP_Oct6100ApiUpdateIntrptStates
1081 UINT32 Oct6100ApiUpdateIntrptStates(
1082 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1083 IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
1084 {
1085 tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
1086 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1087
1088 pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
1089 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1090
1091 /*-----------------------------------------------------------------------*/
1092 if ( ( f_pIntFlags->fFatalReadTimeout == TRUE) &&
1093 pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1094 pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1095 {
1096 pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
1097 pIntrptManage->ulFatalMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1098 pIntrptManage->ulFatalMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1099 }
1100 /*-----------------------------------------------------------------------*/
1101 if ( (f_pIntFlags->fErrorRefreshTooLate == TRUE ||
1102 f_pIntFlags->fErrorPllJitter == TRUE ) &&
1103 pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1104 pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1105 {
1106 pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
1107 pIntrptManage->ulErrorMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1108 pIntrptManage->ulErrorMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1109 }
1110 /*-----------------------------------------------------------------------*/
1111 if ( (f_pIntFlags->fErrorOverflowToneEvents == TRUE) &&
1112 pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1113 pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1114 {
1115 pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_WILL_TIMEOUT;
1116 pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1117 pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1118 }
1119 /*-----------------------------------------------------------------------*/
1120 if ( (f_pIntFlags->fErrorH100OutOfSync == TRUE ||
1121 f_pIntFlags->fErrorH100ClkA == TRUE ||
1122 f_pIntFlags->fErrorH100ClkB == TRUE ||
1123 f_pIntFlags->fErrorH100FrameA == TRUE ) &&
1124 pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT &&
1125 pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1126 {
1127 pIntrptManage->byErrorH100State = cOCT6100_INTRPT_WILL_TIMEOUT;
1128 pIntrptManage->ulErrorH100DisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1129 pIntrptManage->ulErrorH100DisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1130 }
1131 /*-----------------------------------------------------------------------*/
1132
1133 return cOCT6100_ERR_OK;
1134 }
1135 #endif
1136
1137
1138 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1139
1140 Function: Oct6100ApiWriteIntrptRegs
1141
1142 Description: Writes to interrupt registers to clear interrupt condition, and
1143 writes to an interrupt's IE register if interrupt is to time
1144 out.
1145
1146 -------------------------------------------------------------------------------
1147 | Argument | Description
1148 -------------------------------------------------------------------------------
1149 f_pApiInstance Pointer to API instance. This memory is used to keep
1150 the present state of the chip and all its resources.
1151
1152 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1153 #if !SKIP_Oct6100ApiWriteIntrptRegs
1154 UINT32 Oct6100ApiWriteIntrptRegs(
1155 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1156 {
1157 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1158 tOCT6100_WRITE_PARAMS WriteParams;
1159
1160 UINT32 ulResult;
1161
1162 /* Get some local pointers. */
1163 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1164
1165 /* Set some parameters of write struct. */
1166 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1167
1168 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1169
1170
1171
1172 /*===========================================================================*/
1173 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
1174 {
1175 WriteParams.ulWriteAddress = 0x104;
1176 WriteParams.usWriteData = 0x0000;
1177
1178 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1179 if ( ulResult != cOCT6100_ERR_OK )
1180 return ulResult;
1181 }
1182 if ( (pIntrptManage->usRegister102h & cOCT6100_INTRPT_MASK_REG_102H) != 0 )
1183 {
1184 WriteParams.ulWriteAddress = 0x102;
1185 WriteParams.usWriteData = pIntrptManage->usRegister102h;
1186 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1187 if ( ulResult != cOCT6100_ERR_OK )
1188 return ulResult;
1189 }
1190 /*===========================================================================*/
1191
1192 /*===========================================================================*/
1193 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ||
1194 pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
1195 {
1196 WriteParams.ulWriteAddress = 0x204;
1197 WriteParams.usWriteData = 0x0000;
1198
1199 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1200 WriteParams.usWriteData |= 0x1800;
1201
1202 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1203 WriteParams.usWriteData |= 0x0401;
1204
1205 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1206 if ( ulResult != cOCT6100_ERR_OK )
1207 return ulResult;
1208 }
1209 if ( (pIntrptManage->usRegister202h & cOCT6100_INTRPT_MASK_REG_202H) != 0 )
1210 {
1211 WriteParams.ulWriteAddress = 0x202;
1212 WriteParams.usWriteData = pIntrptManage->usRegister202h;
1213 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1214 if ( ulResult != cOCT6100_ERR_OK )
1215 return ulResult;
1216 }
1217 /*===========================================================================*/
1218
1219 /*===========================================================================*/
1220 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_WILL_TIMEOUT )
1221 {
1222 WriteParams.ulWriteAddress = 0x304;
1223 WriteParams.usWriteData = 0x0000;
1224
1225 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1226 WriteParams.usWriteData |= 0x0001;
1227
1228 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1229 if ( ulResult != cOCT6100_ERR_OK )
1230 return ulResult;
1231 }
1232 if ( (pIntrptManage->usRegister302h & cOCT6100_INTRPT_MASK_REG_302H) != 0 )
1233 {
1234 WriteParams.ulWriteAddress = 0x302;
1235 WriteParams.usWriteData = pIntrptManage->usRegister302h;
1236 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1237 if ( ulResult != cOCT6100_ERR_OK )
1238 return ulResult;
1239 }
1240 /*===========================================================================*/
1241
1242 /*===========================================================================*/
1243 if ( (pIntrptManage->usRegister502h & cOCT6100_INTRPT_MASK_REG_502H) != 0 )
1244 {
1245 WriteParams.ulWriteAddress = 0x502;
1246 WriteParams.usWriteData = pIntrptManage->usRegister502h;
1247 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1248 if ( ulResult != cOCT6100_ERR_OK )
1249 return ulResult;
1250 }
1251 /*===========================================================================*/
1252
1253 /*===========================================================================*/
1254 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_WILL_TIMEOUT )
1255 {
1256 WriteParams.ulWriteAddress = 0x704;
1257 WriteParams.usWriteData = 0x0000;
1258
1259 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1260 if ( ulResult != cOCT6100_ERR_OK )
1261 return ulResult;
1262 }
1263 if ( (pIntrptManage->usRegister702h & cOCT6100_INTRPT_MASK_REG_702H) != 0 )
1264 {
1265 WriteParams.ulWriteAddress = 0x702;
1266 WriteParams.usWriteData = pIntrptManage->usRegister702h;
1267 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1268 if ( ulResult != cOCT6100_ERR_OK )
1269 return ulResult;
1270 }
1271 /*===========================================================================*/
1272
1273
1274
1275 return cOCT6100_ERR_OK;
1276 }
1277 #endif
1278
1279
1280 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1281
1282 Function: Oct6100ApiWriteIeRegs
1283
1284 Description: Writes the IE field of each interrupt register.
1285
1286 -------------------------------------------------------------------------------
1287 | Argument | Description
1288 -------------------------------------------------------------------------------
1289 f_pApiInstance Pointer to API instance. This memory is used to keep
1290 the present state of the chip and all its resources.
1291
1292 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1293 #if !SKIP_Oct6100ApiWriteIeRegs
1294 UINT32 Oct6100ApiWriteIeRegs(
1295 tPOCT6100_INSTANCE_API f_pApiInstance )
1296 {
1297 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1298 tOCT6100_WRITE_PARAMS WriteParams;
1299 tOCT6100_READ_PARAMS ReadParams;
1300 UINT32 ulResult;
1301
1302 /* Get some local pointers. */
1303 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1304
1305 /* Set some parameters of write struct. */
1306 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1307
1308 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1309
1310
1311 /* Set some parameters of read struct. */
1312 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1313
1314 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1315
1316 /*==================================================================================*/
1317 WriteParams.ulWriteAddress = 0x104;
1318 WriteParams.usWriteData = 0x0000;
1319
1320 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1321 WriteParams.usWriteData |= 0x0001;
1322
1323 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1324 if ( ulResult != cOCT6100_ERR_OK )
1325 return ulResult;
1326 /*==================================================================================*/
1327
1328 /*==================================================================================*/
1329 WriteParams.ulWriteAddress = 0x204;
1330 WriteParams.usWriteData = 0x0000;
1331
1332 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1333 WriteParams.usWriteData |= 0x1800;
1334 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1335 WriteParams.usWriteData |= 0x0401;
1336
1337 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1338 if ( ulResult != cOCT6100_ERR_OK )
1339 return ulResult;
1340 /*==================================================================================*/
1341
1342 /*==================================================================================*/
1343 WriteParams.ulWriteAddress = 0x304;
1344 WriteParams.usWriteData = 0x0000;
1345
1346 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1347 WriteParams.usWriteData |= 0x0001;
1348 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1349 {
1350 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1351 WriteParams.usWriteData |= 0xD100;
1352 else
1353 WriteParams.usWriteData |= 0x5100;
1354 }
1355
1356 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1357 if ( ulResult != cOCT6100_ERR_OK )
1358 return ulResult;
1359 /*==================================================================================*/
1360
1361 /*==================================================================================*/
1362 WriteParams.ulWriteAddress = 0x504;
1363 WriteParams.usWriteData = 0x0000;
1364
1365 if ( pIntrptManage->byFatalGeneralState == cOCT6100_INTRPT_ACTIVE )
1366 WriteParams.usWriteData |= 0x0002;
1367
1368 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1369 if ( ulResult != cOCT6100_ERR_OK )
1370 return ulResult;
1371 /*==================================================================================*/
1372
1373 /*==================================================================================*/
1374 WriteParams.ulWriteAddress = 0x704;
1375 WriteParams.usWriteData = 0x0000;
1376
1377 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1378 WriteParams.usWriteData |= 0x0002;
1379
1380 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1381 if ( ulResult != cOCT6100_ERR_OK )
1382 return ulResult;
1383 /*==================================================================================*/
1384
1385
1386 /*==================================================================================*/
1387 /* Enable the GLOBAL IEs for the interrupt pin. */
1388 WriteParams.ulWriteAddress = 0x218;
1389 WriteParams.usWriteData = 0x00D7;
1390
1391 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1392 if ( ulResult != cOCT6100_ERR_OK )
1393 return ulResult;
1394 /*==================================================================================*/
1395
1396 return cOCT6100_ERR_OK;
1397 }
1398 #endif
1399
1400
1401 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1402
1403 Function: Oct6100ApiReadChipMclkTime
1404
1405 Description: Reads the chip's mclk cycle count to construct a chip time.
1406 The time is used to manage interrupts.
1407
1408 -------------------------------------------------------------------------------
1409 | Argument | Description
1410 -------------------------------------------------------------------------------
1411 f_pApiInstance Pointer to API instance. This memory is used to keep
1412 the present state of the chip and all its resources.
1413
1414 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1415 #if !SKIP_Oct6100ApiReadChipMclkTime
1416 UINT32 Oct6100ApiReadChipMclkTime(
1417 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1418 {
1419 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1420 tPOCT6100_SHARED_INFO pSharedInfo;
1421 tOCT6100_READ_PARAMS ReadParams;
1422 UINT32 ulCheckData;
1423 UINT32 ulResult;
1424 UINT32 i;
1425 UINT16 usReadData;
1426
1427 /* Get local pointer(s). */
1428 pSharedInfo = f_pApiInstance->pSharedInfo;
1429 pIntrptManage = &pSharedInfo->IntrptManage;
1430
1431 /* Assign memory for read data. */
1432 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1433
1434 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1435 ReadParams.pusReadData = &usReadData;
1436
1437 /* Perform reads. */
1438 for ( i = 0; i < 100; i++ )
1439 {
1440 ReadParams.ulReadAddress = 0x306;
1441 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1442 if ( ulResult != cOCT6100_ERR_OK )
1443 return ulResult;
1444 pIntrptManage->ulRegMclkTimeHigh = usReadData & 0xFF;
1445 ulCheckData = usReadData;
1446
1447 ReadParams.ulReadAddress = 0x308;
1448 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1449 if ( ulResult != cOCT6100_ERR_OK )
1450 return ulResult;
1451 pIntrptManage->ulRegMclkTimeLow = (usReadData & 0xFFFF) << 16;
1452
1453 ReadParams.ulReadAddress = 0x306;
1454 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1455 if ( ulResult != cOCT6100_ERR_OK )
1456 return ulResult;
1457 if ( ulCheckData == usReadData )
1458 break;
1459 }
1460
1461 if ( i == 100 )
1462 return cOCT6100_ERR_FATAL_2F;
1463
1464 return cOCT6100_ERR_OK;
1465 }
1466 #endif
1467
1468
1469 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1470
1471 Function: Oct6100ApiUpdateIntrptTimeouts
1472
1473 Description: Checks which interrupt groups have finished their timeout
1474 period.
1475
1476 -------------------------------------------------------------------------------
1477 | Argument | Description
1478 -------------------------------------------------------------------------------
1479 f_pApiInstance Pointer to API instance. This memory is used to keep
1480 the present state of the chip and all its resources.
1481
1482 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1483 #if !SKIP_Oct6100ApiUpdateIntrptTimeouts
1484 UINT32 Oct6100ApiUpdateIntrptTimeouts(
1485 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1486 {
1487 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1488 tOCT6100_WRITE_PARAMS WriteParams;
1489 UINT32 ulRegMclkTimePlus5MsHigh;
1490 UINT32 ulRegMclkTimePlus5MsLow;
1491 UINT32 ulResult;
1492 BOOL fFatalMemoryChange = FALSE;
1493 BOOL fDataErrMemoryChange = FALSE;
1494 BOOL fErrorOverflowToneEventsChange = FALSE;
1495 BOOL fH100ErrorChange = FALSE;
1496
1497 /* Get local pointer to interrupt management structure. */
1498 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1499
1500 /* Calculate mclk time + 5 ms. */
1501 ulRegMclkTimePlus5MsLow = pIntrptManage->ulRegMclkTimeLow + (5 * pIntrptManage->ulNumMclkCyclesIn1Ms);
1502 if ( ulRegMclkTimePlus5MsLow < pIntrptManage->ulRegMclkTimeLow )
1503 ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh + 1;
1504 else /* ( ulRegMclkTimePlus5MsLow >= pIntrptManage->ulRegMclkTimeLow ) */
1505 ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh;
1506
1507 /* Check which interrupts are timed out and need to be reenabled now. */
1508 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
1509 {
1510 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulFatalMemoryDisableMclkHigh, pIntrptManage->ulFatalMemoryDisableMclkLow, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptManage->byFatalMemoryState, fFatalMemoryChange )
1511 }
1512 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
1513 {
1514 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorMemoryDisableMclkHigh, pIntrptManage->ulErrorMemoryDisableMclkLow, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptManage->byErrorMemoryState, fDataErrMemoryChange )
1515 }
1516 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_IN_TIMEOUT )
1517 {
1518 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptManage->byErrorOverflowToneEventsState, fErrorOverflowToneEventsChange )
1519 }
1520 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_IN_TIMEOUT )
1521 {
1522 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorH100DisableMclkHigh, pIntrptManage->ulErrorH100DisableMclkLow, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptManage->byErrorH100State, fH100ErrorChange )
1523 }
1524
1525 /* Set some parameters of write struct. */
1526 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1527
1528 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1529
1530 /* Write to the IE registers which have changed. */
1531
1532 /*==================================================================================*/
1533 if ( fFatalMemoryChange == TRUE )
1534 {
1535 WriteParams.ulWriteAddress = 0x104;
1536 WriteParams.usWriteData = 0x0000;
1537
1538 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1539 WriteParams.usWriteData |= 0x0001;
1540
1541 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1542 if ( ulResult != cOCT6100_ERR_OK )
1543 return ulResult;
1544
1545 }
1546 /*==================================================================================*/
1547
1548 /*==================================================================================*/
1549 if ( fFatalMemoryChange == TRUE ||
1550 fDataErrMemoryChange == TRUE )
1551 {
1552 WriteParams.ulWriteAddress = 0x204;
1553 WriteParams.usWriteData = 0x0000;
1554
1555 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1556 WriteParams.usWriteData |= 0x1800;
1557 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1558 WriteParams.usWriteData |= 0x0401;
1559
1560 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1561 if ( ulResult != cOCT6100_ERR_OK )
1562 return ulResult;
1563
1564 }
1565 /*==================================================================================*/
1566
1567 /*==================================================================================*/
1568 if ( pIntrptManage->fMclkIntrptActive == TRUE ||
1569 fH100ErrorChange == TRUE )
1570 {
1571 WriteParams.ulWriteAddress = 0x304;
1572 WriteParams.usWriteData = 0x0000;
1573
1574 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1575 WriteParams.usWriteData |= 0x0001;
1576
1577 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1578 {
1579 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1580 WriteParams.usWriteData |= 0xD100;
1581 else
1582 WriteParams.usWriteData |= 0x5100;
1583 }
1584
1585 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1586 if ( ulResult != cOCT6100_ERR_OK )
1587 return ulResult;
1588
1589 }
1590 /*==================================================================================*/
1591
1592
1593 /*==================================================================================*/
1594 if ( fErrorOverflowToneEventsChange == TRUE )
1595 {
1596 WriteParams.ulWriteAddress = 0x704;
1597 WriteParams.usWriteData = 0x0000;
1598
1599 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1600 WriteParams.usWriteData |= 0x0002;
1601
1602 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1603 if ( ulResult != cOCT6100_ERR_OK )
1604 return ulResult;
1605
1606 }
1607 /*==================================================================================*/
1608
1609 return cOCT6100_ERR_OK;
1610 }
1611 #endif
1612
1613
1614 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1615
1616 Function: Oct6100ApiScheduleNextMclkIntrptSer
1617
1618 Description: Serialized sub-function of Oct6100ApiScheduleNextMclkIntrpt.
1619
1620 -------------------------------------------------------------------------------
1621 | Argument | Description
1622 -------------------------------------------------------------------------------
1623 f_pApiInstance Pointer to API instance. This memory is used to keep
1624 the present state of the chip and all its resources.
1625
1626 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1627 #if !SKIP_Oct6100ApiScheduleNextMclkIntrptSer
1628 UINT32 Oct6100ApiScheduleNextMclkIntrptSer(
1629 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1630 {
1631 tPOCT6100_SHARED_INFO pSharedInfo;
1632 tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
1633 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1634 tOCT6100_WRITE_PARAMS WriteParams;
1635 UINT32 ulTimeDiff;
1636 UINT32 ulRegMclkTimeHigh;
1637 UINT32 ulRegMclkTimeLow;
1638 UINT32 ulResult;
1639 BOOL fConditionFlag = TRUE;
1640
1641 /* Get local pointer(s). */
1642 pSharedInfo = f_pApiInstance->pSharedInfo;
1643
1644 /* Obtain temporary pointers to reduce indirection, thus speeding up processing. */
1645 pIntrptConfig = &pSharedInfo->IntrptConfig;
1646 pIntrptManage = &pSharedInfo->IntrptManage;
1647 ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
1648 ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
1649
1650 /* First, check if any interrupts have just been disabled. If there are any, */
1651 /* determine the time at which they should be reenabled. */
1652 pIntrptManage->ulNextMclkIntrptTimeHigh = cOCT6100_INVALID_VALUE;
1653 pIntrptManage->ulNextMclkIntrptTimeLow = cOCT6100_INVALID_VALUE;
1654
1655 while ( fConditionFlag )
1656 {
1657 /* Indicate that no mclk interrupt is needed, yet. */
1658 ulTimeDiff = cOCT6100_INVALID_VALUE;
1659
1660 /* Check each interrupt category to see if an mclk interrupt is needed to */
1661 /* reenable an interrupt at a later time. */
1662 if ( pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_ACTIVE &&
1663 pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_DISABLED )
1664 {
1665 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byFatalMemoryState, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptConfig->ulFatalMemoryTimeoutMclk, ulTimeDiff )
1666 }
1667 if ( pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_ACTIVE &&
1668 pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
1669 {
1670 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorMemoryState, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptConfig->ulErrorMemoryTimeoutMclk, ulTimeDiff )
1671 }
1672 if ( pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_ACTIVE &&
1673 pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
1674 {
1675 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorOverflowToneEventsState, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk, ulTimeDiff )
1676 }
1677 if ( pIntrptManage->byErrorH100State != cOCT6100_INTRPT_ACTIVE &&
1678 pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
1679 {
1680 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorH100State, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptConfig->ulErrorH100TimeoutMclk, ulTimeDiff )
1681 }
1682
1683 /* Set some parameters of write struct. */
1684 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1685
1686 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1687
1688 /* Schedule next mclk interrupt, if any is needed. */
1689 if ( ulTimeDiff != cOCT6100_INVALID_VALUE )
1690 {
1691 UINT32 ulMclkTimeTest;
1692 UINT32 ulAlarmTimeTest;
1693 UINT32 ulTimeDiffTest;
1694 BOOL fAlarmTimePassed;
1695
1696 /* Indicate that an mclk interrupt is scheduled.*/
1697 pIntrptManage->fMclkIntrptActive = TRUE;
1698
1699 pIntrptManage->ulNextMclkIntrptTimeLow = ulRegMclkTimeLow + ulTimeDiff;
1700 if ( pIntrptManage->ulNextMclkIntrptTimeLow < ulRegMclkTimeLow )
1701 pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh + 1;
1702 else /* ( pIntrptManage->ulNextMclkIntrptTimeLow >= ulRegMclkTimeLow ) */
1703 pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh;
1704
1705 WriteParams.ulWriteAddress = 0x30C;
1706 WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 24) & 0xFF );
1707 WriteParams.usWriteData |= (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeHigh & 0xFF) << 8 );
1708 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1709 if ( ulResult != cOCT6100_ERR_OK )
1710 return ulResult;
1711
1712 WriteParams.ulWriteAddress = 0x30E;
1713 WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 8) & 0xFFFF );
1714 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1715 if ( ulResult != cOCT6100_ERR_OK )
1716 return ulResult;
1717
1718 WriteParams.ulWriteAddress = 0x304;
1719 WriteParams.usWriteData = 0;
1720
1721 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1722 WriteParams.usWriteData = 0x0001;
1723
1724 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1725 {
1726 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1727 WriteParams.usWriteData |= 0xD100;
1728 else
1729 WriteParams.usWriteData |= 0x5100;
1730 }
1731
1732 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1733 if ( ulResult != cOCT6100_ERR_OK )
1734 return ulResult;
1735
1736 /* Disable the ROL if previously set. */
1737 WriteParams.ulWriteAddress = 0x302;
1738 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1739 if ( ulResult != cOCT6100_ERR_OK )
1740 return ulResult;
1741
1742 /* Check if already passed the next interrupt time. */
1743 ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
1744 if ( ulResult != cOCT6100_ERR_OK )
1745 return ulResult;
1746
1747 ulMclkTimeTest = (pIntrptManage->ulRegMclkTimeLow >> 16) & 0xFFFF;
1748 ulAlarmTimeTest = (pIntrptManage->ulNextMclkIntrptTimeLow >> 16) & 0xFFFF;
1749
1750 /* Update the local Mlck timer values.*/
1751 ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
1752 ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
1753
1754 fAlarmTimePassed = FALSE;
1755
1756 if ( ulMclkTimeTest > ulAlarmTimeTest )
1757 {
1758 ulTimeDiffTest = ulMclkTimeTest - ulAlarmTimeTest;
1759 if ( ulTimeDiffTest <= 0x8000 )
1760 fAlarmTimePassed = TRUE;
1761 }
1762 else /* ( ulMclkTimeTest <= ulAlarmTimeTest ) */
1763 {
1764 ulTimeDiffTest = ulAlarmTimeTest - ulMclkTimeTest;
1765 if ( ulTimeDiffTest > 0x8000 )
1766 fAlarmTimePassed = TRUE;
1767 }
1768
1769 if ( fAlarmTimePassed == TRUE )
1770 {
1771 /* Passed the interrupt time. Schedule next interrupt (if needed). */
1772 ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
1773 if ( ulResult != cOCT6100_ERR_OK )
1774 return ulResult;
1775
1776 continue;
1777 }
1778 else
1779 {
1780 fConditionFlag = FALSE;
1781 }
1782 }
1783 else
1784 {
1785 /* Indicate that no mclk interrupt is scheduled. */
1786 pIntrptManage->fMclkIntrptActive = FALSE;
1787
1788 /* Insure that the mclk interrupt is not enabled. */
1789 WriteParams.ulWriteAddress = 0x304;
1790 WriteParams.usWriteData = 0x0000;
1791 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1792 {
1793 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1794 WriteParams.usWriteData |= 0xD100;
1795 else
1796 WriteParams.usWriteData |= 0x5100;
1797 }
1798 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1799 if ( ulResult != cOCT6100_ERR_OK )
1800 return ulResult;
1801
1802 fConditionFlag = FALSE;
1803 }
1804 }
1805
1806 return cOCT6100_ERR_OK;
1807 }
1808 #endif
1809
1810
1811 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1812
1813 Function: Oct6100ApiCheckProcessorState
1814
1815 Description: This function verifies if the NLP and AF processors are operating
1816 correctly.
1817
1818 -------------------------------------------------------------------------------
1819 | Argument | Description
1820 -------------------------------------------------------------------------------
1821 f_pApiInstance Pointer to API instance. This memory is used to keep
1822 the present state of the chip and all its resources.
1823
1824 f_pIntFlags Pointer to a tOCT6100_INTERRUPT_FLAGS structure.
1825
1826 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1827 #if !SKIP_Oct6100ApiCheckProcessorState
1828 UINT32 Oct6100ApiCheckProcessorState(
1829 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1830 IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
1831 {
1832 tPOCT6100_SHARED_INFO pSharedInfo;
1833 tOCT6100_READ_PARAMS ReadParams;
1834 tOCT6100_READ_BURST_PARAMS ReadBurstParams;
1835
1836 UINT32 ulNlpTimestamp;
1837 UINT32 ulAfTimestamp;
1838 UINT32 ulTimestampDiff;
1839
1840 UINT32 ulResult;
1841 UINT32 i;
1842
1843 UINT16 usReadData;
1844 UINT16 ausReadData[ 2 ];
1845
1846 UINT32 aulWaitTime[ 2 ];
1847
1848 /* Get local pointer(s). */
1849 pSharedInfo = f_pApiInstance->pSharedInfo;
1850
1851 /* Set some parameters of write struct. */
1852 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1853
1854 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1855 ReadParams.pusReadData = &usReadData;
1856
1857 /* Set some parameters of write struct. */
1858 ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
1859
1860 ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1861 ReadBurstParams.pusReadData = ausReadData;
1862
1863 /*-----------------------------------------------------------------------*/
1864 /* Check if chip is in reset. */
1865
1866 /* Read the main control register. */
1867 ReadParams.ulReadAddress = 0x100;
1868
1869 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1870 if ( ulResult != cOCT6100_ERR_OK )
1871 return ulResult;
1872
1873 if ( usReadData == 0x0000 )
1874 {
1875 /* Chip was resetted. */
1876 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_4;
1877 f_pIntFlags->fFatalGeneral = TRUE;
1878 pSharedInfo->ErrorStats.fFatalChipError = TRUE;
1879 }
1880
1881 /*-----------------------------------------------------------------------*/
1882
1883
1884 /*-----------------------------------------------------------------------*/
1885 /* Reading the AF timestamp.*/
1886
1887 for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
1888 {
1889 /* Read the timestamp.*/
1890 ReadBurstParams.ulReadAddress = 0x082E0008;
1891 ReadBurstParams.ulReadLength = 2;
1892
1893 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1894 if ( ulResult != cOCT6100_ERR_OK )
1895 return ulResult;
1896
1897 /* Read the high part again to make sure it didn't wrap. */
1898 ReadParams.ulReadAddress = 0x082E0008;
1899
1900 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1901 if ( ulResult != cOCT6100_ERR_OK )
1902 return ulResult;
1903
1904 /* Check if the low part wrapped. */
1905 if ( ausReadData[ 0 ] == usReadData )
1906 break;
1907 }
1908
1909 if ( i == cOCT6100_MAX_LOOP )
1910 return cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT;
1911
1912 /* Save the AF timestamp. */
1913 ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1914
1915 /*-----------------------------------------------------------------------*/
1916
1917
1918 /*-----------------------------------------------------------------------*/
1919 /* Reading the NLP timestamp. */
1920
1921 for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
1922 {
1923 /* Read the timestamp. */
1924 ReadBurstParams.ulReadAddress = 0x08000008;
1925 ReadBurstParams.ulReadLength = 2;
1926
1927 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1928 if ( ulResult != cOCT6100_ERR_OK )
1929 return ulResult;
1930
1931 /* Read the high part again to make sure it didn't wrap. */
1932 ReadParams.ulReadAddress = 0x08000008;
1933
1934 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1935 if ( ulResult != cOCT6100_ERR_OK )
1936 return ulResult;
1937
1938 /* Check if the low part wrapped. */
1939 if ( ausReadData[ 0 ] == usReadData )
1940 break;
1941 }
1942
1943 if ( i == cOCT6100_MAX_LOOP )
1944 return cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT;
1945
1946 /* Save the NLP timestamp. */
1947 ulNlpTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1948
1949 /*-----------------------------------------------------------------------*/
1950
1951
1952 /*-----------------------------------------------------------------------*/
1953 /* Check the validity of the timestamp. */
1954
1955 if ( ulAfTimestamp > ulNlpTimestamp )
1956 {
1957 /* The NLP timestamp wrapped. */
1958 ulTimestampDiff = 0xFFFFFFFF - ulAfTimestamp + 1;
1959 ulTimestampDiff += ulNlpTimestamp;
1960 }
1961 else
1962 ulTimestampDiff = ulNlpTimestamp - ulAfTimestamp;
1963
1964 if ( ulTimestampDiff > 0x2000 )
1965 {
1966 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_5;
1967 f_pIntFlags->fFatalGeneral = TRUE;
1968 pSharedInfo->ErrorStats.fFatalChipError = TRUE;
1969 }
1970
1971 /*Check if AF and NLP are both stuck*/
1972 if ( f_pIntFlags->fErrorH100ClkA == FALSE &&
1973 f_pIntFlags->fErrorH100ClkB == FALSE &&
1974 f_pIntFlags->fErrorH100FrameA == FALSE &&
1975 f_pIntFlags->fErrorH100OutOfSync == FALSE )
1976
1977 {
1978 if ( ulAfTimestamp == 0 && ulNlpTimestamp == 0 )
1979 {
1980 /*Give some time to the counters*/
1981 aulWaitTime[ 0 ] = 250;
1982 aulWaitTime[ 1 ] = 0;
1983 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
1984 if ( ulResult != cOCT6100_ERR_OK )
1985 return ulResult;
1986
1987 /*Let's read again the AF timestamp to be sure. Maybe they were at 0 at the same time*/
1988 ReadBurstParams.ulReadAddress = 0x082E0008;
1989 ReadBurstParams.ulReadLength = 2;
1990
1991 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1992 if ( ulResult != cOCT6100_ERR_OK )
1993 return ulResult;
1994
1995 ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1996
1997 if ( ulAfTimestamp == 0 )
1998 {
1999 /*TDM Clocks are ok but NLP and AF timestamps are both at 0*/
2000 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_9;
2001 f_pIntFlags->fFatalGeneral = TRUE;
2002 pSharedInfo->ErrorStats.fFatalChipError = TRUE;
2003 }
2004 }
2005
2006 }
2007
2008 /*-----------------------------------------------------------------------*/
2009
2010 return cOCT6100_ERR_OK;
2011 }
2012 #endif