Debian Codegraph @

xpp/oct612x/octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.c

raw
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
802 UINT32 ulResult;
803 UINT16 usReadData;
804 UINT32 ulFeatureBytesOffset;
805 UINT32 ulFeatureBitOffset;
806 UINT32 ulFeatureFieldLength;
807 UINT32 ulTempData;
808 UINT32 ulCounterValue;
809 UINT32 ulMask;
810
811 /* Get local pointer(s). */
812 pSharedInfo = f_pApiInstance->pSharedInfo;
813 pErrorStats = &pSharedInfo->ErrorStats;
814 pIntrptManage = &pSharedInfo->IntrptManage;
815
816 /* Set some parameters of read struct. */
817 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
818
819 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
820 ReadParams.pusReadData = &usReadData;
821
822 /* CPU registers. */
823 if ( (f_ulRegister210h & 0x00001) != 0 )
824 {
825 /*=======================================================================*/
826 /* Read registers of this module. */
827 ReadParams.ulReadAddress = 0x102;
828 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
829 if ( ulResult != cOCT6100_ERR_OK )
830 return ulResult;
831
832 /* Check which interrupt(s) were set. */
833 if ( (usReadData & 0x0001) != 0 )
834 {
835 f_pIntFlags->fFatalReadTimeout = TRUE;
836 pErrorStats->ulInternalReadTimeoutCnt++;
837 }
838
839 pIntrptManage->usRegister102h = usReadData;
840 /*=======================================================================*/
841 }
842 else
843 {
844 pIntrptManage->usRegister102h = 0x0;
845 }
846
847 /* MAIN registers. */
848 if ( (f_ulRegister210h & 0x00002) != 0 )
849 {
850 /*=======================================================================*/
851 /* Read registers of this module. */
852 ReadParams.ulReadAddress = 0x202;
853 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
854 if ( ulResult != cOCT6100_ERR_OK )
855 return ulResult;
856
857 /* Save current value in instance. */
858 pIntrptManage->usRegister202h = usReadData;
859
860 /* Check which interrupts were set. */
861 if ( (usReadData & 0x0001) != 0 )
862 {
863 f_pIntFlags->fErrorRefreshTooLate = TRUE;
864 pErrorStats->ulSdramRefreshTooLateCnt++;
865 }
866 if ( (usReadData & 0x0800) != 0 )
867 {
868 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_1;
869 f_pIntFlags->fFatalGeneral = TRUE;
870 pErrorStats->fFatalChipError = TRUE;
871 }
872 if ( (usReadData & 0x1000) != 0 )
873 {
874 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_2;
875 f_pIntFlags->fFatalGeneral = TRUE;
876 pErrorStats->fFatalChipError = TRUE;
877 }
878 if ( (usReadData & 0x0400) != 0 )
879 {
880 f_pIntFlags->fErrorPllJitter = TRUE;
881 pErrorStats->ulPllJitterErrorCnt++;
882
883 /* Update the PLL jitter error count here. */
884 if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
885 {
886 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
887 ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
888 ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
889
890 ulResult = Oct6100ApiReadDword( f_pApiInstance,
891 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
892 &ulTempData );
893
894 /* Read previous value set in the feature field. */
895 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
896
897 /* Update counter. */
898 ulCounterValue = ulTempData & ulMask;
899 ulCounterValue = ulCounterValue >> ulFeatureBitOffset;
900 ulCounterValue ++;
901 /* Handle wrap around case. */
902 ulCounterValue &= ( 1 << ulFeatureFieldLength ) - 1;
903
904 /* Clear old counter value. */
905 ulTempData &= (~ulMask);
906 ulTempData |= ulCounterValue << ulFeatureBitOffset;
907
908 /* Write the DWORD where the field is located.*/
909 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
910 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
911 ulTempData );
912 if ( ulResult != cOCT6100_ERR_OK )
913 return ulResult;
914 }
915 }
916
917 /*=======================================================================*/
918 }
919 else
920 {
921 pIntrptManage->usRegister202h = 0x0;
922 }
923
924 /* H.100 registers. */
925 if ( (f_ulRegister210h & 0x00004) != 0 )
926 {
927 /*=======================================================================*/
928 /* Read registers of this module. */
929 ReadParams.ulReadAddress = 0x302;
930 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
931 if ( ulResult != cOCT6100_ERR_OK )
932 return ulResult;
933
934 /* Check which interrupts were set. */
935 if ( (usReadData & 0x0100) != 0 )
936 {
937 f_pIntFlags->fErrorH100OutOfSync = TRUE;
938 pErrorStats->ulH100OutOfSyncCnt++;
939 }
940 if ( (usReadData & 0x1000) != 0 )
941 {
942 f_pIntFlags->fErrorH100FrameA = TRUE;
943 pErrorStats->ulH100FrameABadCnt++;
944 }
945 if ( (usReadData & 0x4000) != 0 )
946 {
947 f_pIntFlags->fErrorH100ClkA = TRUE;
948 pErrorStats->ulH100ClkABadCnt++;
949 }
950 if ( (usReadData & 0x8000) != 0 )
951 {
952 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
953 {
954 f_pIntFlags->fErrorH100ClkB = TRUE;
955 pErrorStats->ulH100ClkBBadCnt++;
956 }
957 }
958
959 pIntrptManage->usRegister302h = usReadData;
960 /*=======================================================================*/
961 }
962 else
963 {
964 pIntrptManage->usRegister302h = 0x0;
965 }
966
967 /* TDMIE registers. */
968 if ( (f_ulRegister210h & 0x00010) != 0 )
969 {
970 /*=======================================================================*/
971 /* Read register. */
972 ReadParams.ulReadAddress = 0x502;
973 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
974 if ( ulResult != cOCT6100_ERR_OK )
975 return ulResult;
976
977 /* Check which interrupts were set. */
978 if ( (usReadData & 0x0002) != 0 )
979 {
980 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_3;
981 f_pIntFlags->fFatalGeneral = TRUE;
982 pErrorStats->fFatalChipError = TRUE;
983 }
984
985 pIntrptManage->usRegister502h = usReadData;
986 /*=======================================================================*/
987 }
988 else
989 {
990 pIntrptManage->usRegister502h = 0x0;
991 }
992
993 /* PGSP registers. */
994 if ( (f_ulRegister210h & 0x00080) != 0 )
995 {
996 /*=======================================================================*/
997 /* Read register. */
998 ReadParams.ulReadAddress = 0x702;
999 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1000 if ( ulResult != cOCT6100_ERR_OK )
1001 return ulResult;
1002
1003 /* Check which interrupts were set. */
1004 if ( (usReadData & 0x0002) != 0 )
1005 {
1006 f_pIntFlags->fErrorOverflowToneEvents = TRUE;
1007 pErrorStats->ulOverflowToneEventsCnt++;
1008 }
1009
1010 pIntrptManage->usRegister702h = usReadData;
1011 /*=======================================================================*/
1012 }
1013 else
1014 {
1015 pIntrptManage->usRegister702h = 0x0;
1016 }
1017
1018
1019
1020 /* If this is the first time the ISR is called, clear the ISR is not called bit */
1021 /* in external memory to signal the remote client that we are called. */
1022 if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE )
1023 {
1024 /* Remember that we are being called. */
1025 pSharedInfo->IntrptManage.fIsrCalled = TRUE;
1026
1027 if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
1028 {
1029 ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
1030 ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
1031 ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
1032
1033 ulResult = Oct6100ApiReadDword( f_pApiInstance,
1034 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
1035 &ulTempData );
1036
1037 /* Read previous value set in the feature field. */
1038 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
1039
1040 /* Clear the field. */
1041 ulTempData &= (~ulMask);
1042
1043 /* Write the DWORD where the field is located.*/
1044 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
1045 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
1046 ulTempData );
1047 if ( ulResult != cOCT6100_ERR_OK )
1048 return ulResult;
1049 }
1050 }
1051
1052 return cOCT6100_ERR_OK;
1053 }
1054 #endif
1055
1056
1057 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1058
1059 Function: Oct6100ApiUpdateIntrptStates
1060
1061 Description: Updates the state of all interrupt register groups.
1062
1063 -------------------------------------------------------------------------------
1064 | Argument | Description
1065 -------------------------------------------------------------------------------
1066 f_pApiInstance Pointer to API instance. This memory is used to keep
1067 the present state of the chip and all its resources.
1068
1069 f_pIntFlags Interrupt flags.
1070
1071 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1072 #if !SKIP_Oct6100ApiUpdateIntrptStates
1073 UINT32 Oct6100ApiUpdateIntrptStates(
1074 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1075 IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
1076 {
1077 tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
1078 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1079
1080 pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
1081 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1082
1083 /*-----------------------------------------------------------------------*/
1084 if ( ( f_pIntFlags->fFatalReadTimeout == TRUE) &&
1085 pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1086 pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1087 {
1088 pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
1089 pIntrptManage->ulFatalMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1090 pIntrptManage->ulFatalMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1091 }
1092 /*-----------------------------------------------------------------------*/
1093 if ( (f_pIntFlags->fErrorRefreshTooLate == TRUE ||
1094 f_pIntFlags->fErrorPllJitter == TRUE ) &&
1095 pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1096 pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1097 {
1098 pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
1099 pIntrptManage->ulErrorMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1100 pIntrptManage->ulErrorMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1101 }
1102 /*-----------------------------------------------------------------------*/
1103 if ( (f_pIntFlags->fErrorOverflowToneEvents == TRUE) &&
1104 pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1105 pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1106 {
1107 pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_WILL_TIMEOUT;
1108 pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1109 pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1110 }
1111 /*-----------------------------------------------------------------------*/
1112 if ( (f_pIntFlags->fErrorH100OutOfSync == TRUE ||
1113 f_pIntFlags->fErrorH100ClkA == TRUE ||
1114 f_pIntFlags->fErrorH100ClkB == TRUE ||
1115 f_pIntFlags->fErrorH100FrameA == TRUE ) &&
1116 pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT &&
1117 pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1118 {
1119 pIntrptManage->byErrorH100State = cOCT6100_INTRPT_WILL_TIMEOUT;
1120 pIntrptManage->ulErrorH100DisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1121 pIntrptManage->ulErrorH100DisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1122 }
1123 /*-----------------------------------------------------------------------*/
1124
1125 return cOCT6100_ERR_OK;
1126 }
1127 #endif
1128
1129
1130 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1131
1132 Function: Oct6100ApiWriteIntrptRegs
1133
1134 Description: Writes to interrupt registers to clear interrupt condition, and
1135 writes to an interrupt's IE register if interrupt is to time
1136 out.
1137
1138 -------------------------------------------------------------------------------
1139 | Argument | Description
1140 -------------------------------------------------------------------------------
1141 f_pApiInstance Pointer to API instance. This memory is used to keep
1142 the present state of the chip and all its resources.
1143
1144 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1145 #if !SKIP_Oct6100ApiWriteIntrptRegs
1146 UINT32 Oct6100ApiWriteIntrptRegs(
1147 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1148 {
1149 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1150 tOCT6100_WRITE_PARAMS WriteParams;
1151
1152 UINT32 ulResult;
1153
1154 /* Get some local pointers. */
1155 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1156
1157 /* Set some parameters of write struct. */
1158 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1159
1160 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1161
1162
1163
1164 /*===========================================================================*/
1165 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
1166 {
1167 WriteParams.ulWriteAddress = 0x104;
1168 WriteParams.usWriteData = 0x0000;
1169
1170 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1171 if ( ulResult != cOCT6100_ERR_OK )
1172 return ulResult;
1173 }
1174 if ( (pIntrptManage->usRegister102h & cOCT6100_INTRPT_MASK_REG_102H) != 0 )
1175 {
1176 WriteParams.ulWriteAddress = 0x102;
1177 WriteParams.usWriteData = pIntrptManage->usRegister102h;
1178 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1179 if ( ulResult != cOCT6100_ERR_OK )
1180 return ulResult;
1181 }
1182 /*===========================================================================*/
1183
1184 /*===========================================================================*/
1185 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ||
1186 pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
1187 {
1188 WriteParams.ulWriteAddress = 0x204;
1189 WriteParams.usWriteData = 0x0000;
1190
1191 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1192 WriteParams.usWriteData |= 0x1800;
1193
1194 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1195 WriteParams.usWriteData |= 0x0401;
1196
1197 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1198 if ( ulResult != cOCT6100_ERR_OK )
1199 return ulResult;
1200 }
1201 if ( (pIntrptManage->usRegister202h & cOCT6100_INTRPT_MASK_REG_202H) != 0 )
1202 {
1203 WriteParams.ulWriteAddress = 0x202;
1204 WriteParams.usWriteData = pIntrptManage->usRegister202h;
1205 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1206 if ( ulResult != cOCT6100_ERR_OK )
1207 return ulResult;
1208 }
1209 /*===========================================================================*/
1210
1211 /*===========================================================================*/
1212 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_WILL_TIMEOUT )
1213 {
1214 WriteParams.ulWriteAddress = 0x304;
1215 WriteParams.usWriteData = 0x0000;
1216
1217 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1218 WriteParams.usWriteData |= 0x0001;
1219
1220 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1221 if ( ulResult != cOCT6100_ERR_OK )
1222 return ulResult;
1223 }
1224 if ( (pIntrptManage->usRegister302h & cOCT6100_INTRPT_MASK_REG_302H) != 0 )
1225 {
1226 WriteParams.ulWriteAddress = 0x302;
1227 WriteParams.usWriteData = pIntrptManage->usRegister302h;
1228 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1229 if ( ulResult != cOCT6100_ERR_OK )
1230 return ulResult;
1231 }
1232 /*===========================================================================*/
1233
1234 /*===========================================================================*/
1235 if ( (pIntrptManage->usRegister502h & cOCT6100_INTRPT_MASK_REG_502H) != 0 )
1236 {
1237 WriteParams.ulWriteAddress = 0x502;
1238 WriteParams.usWriteData = pIntrptManage->usRegister502h;
1239 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1240 if ( ulResult != cOCT6100_ERR_OK )
1241 return ulResult;
1242 }
1243 /*===========================================================================*/
1244
1245 /*===========================================================================*/
1246 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_WILL_TIMEOUT )
1247 {
1248 WriteParams.ulWriteAddress = 0x704;
1249 WriteParams.usWriteData = 0x0000;
1250
1251 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1252 if ( ulResult != cOCT6100_ERR_OK )
1253 return ulResult;
1254 }
1255 if ( (pIntrptManage->usRegister702h & cOCT6100_INTRPT_MASK_REG_702H) != 0 )
1256 {
1257 WriteParams.ulWriteAddress = 0x702;
1258 WriteParams.usWriteData = pIntrptManage->usRegister702h;
1259 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1260 if ( ulResult != cOCT6100_ERR_OK )
1261 return ulResult;
1262 }
1263 /*===========================================================================*/
1264
1265
1266
1267 return cOCT6100_ERR_OK;
1268 }
1269 #endif
1270
1271
1272 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1273
1274 Function: Oct6100ApiWriteIeRegs
1275
1276 Description: Writes the IE field of each interrupt register.
1277
1278 -------------------------------------------------------------------------------
1279 | Argument | Description
1280 -------------------------------------------------------------------------------
1281 f_pApiInstance Pointer to API instance. This memory is used to keep
1282 the present state of the chip and all its resources.
1283
1284 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1285 #if !SKIP_Oct6100ApiWriteIeRegs
1286 UINT32 Oct6100ApiWriteIeRegs(
1287 tPOCT6100_INSTANCE_API f_pApiInstance )
1288 {
1289 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1290 tOCT6100_WRITE_PARAMS WriteParams;
1291 UINT32 ulResult;
1292
1293 /* Get some local pointers. */
1294 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1295
1296 /* Set some parameters of write struct. */
1297 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1298
1299 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1300
1301 /*==================================================================================*/
1302 WriteParams.ulWriteAddress = 0x104;
1303 WriteParams.usWriteData = 0x0000;
1304
1305 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1306 WriteParams.usWriteData |= 0x0001;
1307
1308 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1309 if ( ulResult != cOCT6100_ERR_OK )
1310 return ulResult;
1311 /*==================================================================================*/
1312
1313 /*==================================================================================*/
1314 WriteParams.ulWriteAddress = 0x204;
1315 WriteParams.usWriteData = 0x0000;
1316
1317 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1318 WriteParams.usWriteData |= 0x1800;
1319 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1320 WriteParams.usWriteData |= 0x0401;
1321
1322 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1323 if ( ulResult != cOCT6100_ERR_OK )
1324 return ulResult;
1325 /*==================================================================================*/
1326
1327 /*==================================================================================*/
1328 WriteParams.ulWriteAddress = 0x304;
1329 WriteParams.usWriteData = 0x0000;
1330
1331 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1332 WriteParams.usWriteData |= 0x0001;
1333 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1334 {
1335 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1336 WriteParams.usWriteData |= 0xD100;
1337 else
1338 WriteParams.usWriteData |= 0x5100;
1339 }
1340
1341 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1342 if ( ulResult != cOCT6100_ERR_OK )
1343 return ulResult;
1344 /*==================================================================================*/
1345
1346 /*==================================================================================*/
1347 WriteParams.ulWriteAddress = 0x504;
1348 WriteParams.usWriteData = 0x0000;
1349
1350 if ( pIntrptManage->byFatalGeneralState == cOCT6100_INTRPT_ACTIVE )
1351 WriteParams.usWriteData |= 0x0002;
1352
1353 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1354 if ( ulResult != cOCT6100_ERR_OK )
1355 return ulResult;
1356 /*==================================================================================*/
1357
1358 /*==================================================================================*/
1359 WriteParams.ulWriteAddress = 0x704;
1360 WriteParams.usWriteData = 0x0000;
1361
1362 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1363 WriteParams.usWriteData |= 0x0002;
1364
1365 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1366 if ( ulResult != cOCT6100_ERR_OK )
1367 return ulResult;
1368 /*==================================================================================*/
1369
1370
1371 /*==================================================================================*/
1372 /* Enable the GLOBAL IEs for the interrupt pin. */
1373 WriteParams.ulWriteAddress = 0x218;
1374 WriteParams.usWriteData = 0x00D7;
1375
1376 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1377 if ( ulResult != cOCT6100_ERR_OK )
1378 return ulResult;
1379 /*==================================================================================*/
1380
1381 return cOCT6100_ERR_OK;
1382 }
1383 #endif
1384
1385
1386 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1387
1388 Function: Oct6100ApiReadChipMclkTime
1389
1390 Description: Reads the chip's mclk cycle count to construct a chip time.
1391 The time is used to manage interrupts.
1392
1393 -------------------------------------------------------------------------------
1394 | Argument | Description
1395 -------------------------------------------------------------------------------
1396 f_pApiInstance Pointer to API instance. This memory is used to keep
1397 the present state of the chip and all its resources.
1398
1399 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1400 #if !SKIP_Oct6100ApiReadChipMclkTime
1401 UINT32 Oct6100ApiReadChipMclkTime(
1402 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1403 {
1404 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1405 tPOCT6100_SHARED_INFO pSharedInfo;
1406 tOCT6100_READ_PARAMS ReadParams;
1407 UINT32 ulCheckData;
1408 UINT32 ulResult;
1409 UINT32 i;
1410 UINT16 usReadData;
1411
1412 /* Get local pointer(s). */
1413 pSharedInfo = f_pApiInstance->pSharedInfo;
1414 pIntrptManage = &pSharedInfo->IntrptManage;
1415
1416 /* Assign memory for read data. */
1417 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1418
1419 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1420 ReadParams.pusReadData = &usReadData;
1421
1422 /* Perform reads. */
1423 for ( i = 0; i < 100; i++ )
1424 {
1425 ReadParams.ulReadAddress = 0x306;
1426 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1427 if ( ulResult != cOCT6100_ERR_OK )
1428 return ulResult;
1429 pIntrptManage->ulRegMclkTimeHigh = usReadData & 0xFF;
1430 ulCheckData = usReadData;
1431
1432 ReadParams.ulReadAddress = 0x308;
1433 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1434 if ( ulResult != cOCT6100_ERR_OK )
1435 return ulResult;
1436 pIntrptManage->ulRegMclkTimeLow = (usReadData & 0xFFFF) << 16;
1437
1438 ReadParams.ulReadAddress = 0x306;
1439 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1440 if ( ulResult != cOCT6100_ERR_OK )
1441 return ulResult;
1442 if ( ulCheckData == usReadData )
1443 break;
1444 }
1445
1446 if ( i == 100 )
1447 return cOCT6100_ERR_FATAL_2F;
1448
1449 return cOCT6100_ERR_OK;
1450 }
1451 #endif
1452
1453
1454 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1455
1456 Function: Oct6100ApiUpdateIntrptTimeouts
1457
1458 Description: Checks which interrupt groups have finished their timeout
1459 period.
1460
1461 -------------------------------------------------------------------------------
1462 | Argument | Description
1463 -------------------------------------------------------------------------------
1464 f_pApiInstance Pointer to API instance. This memory is used to keep
1465 the present state of the chip and all its resources.
1466
1467 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1468 #if !SKIP_Oct6100ApiUpdateIntrptTimeouts
1469 UINT32 Oct6100ApiUpdateIntrptTimeouts(
1470 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1471 {
1472 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1473 tOCT6100_WRITE_PARAMS WriteParams;
1474 UINT32 ulRegMclkTimePlus5MsHigh;
1475 UINT32 ulRegMclkTimePlus5MsLow;
1476 UINT32 ulResult;
1477 BOOL fFatalMemoryChange = FALSE;
1478 BOOL fDataErrMemoryChange = FALSE;
1479 BOOL fErrorOverflowToneEventsChange = FALSE;
1480 BOOL fH100ErrorChange = FALSE;
1481
1482 /* Get local pointer to interrupt management structure. */
1483 pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1484
1485 /* Calculate mclk time + 5 ms. */
1486 ulRegMclkTimePlus5MsLow = pIntrptManage->ulRegMclkTimeLow + (5 * pIntrptManage->ulNumMclkCyclesIn1Ms);
1487 if ( ulRegMclkTimePlus5MsLow < pIntrptManage->ulRegMclkTimeLow )
1488 ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh + 1;
1489 else /* ( ulRegMclkTimePlus5MsLow >= pIntrptManage->ulRegMclkTimeLow ) */
1490 ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh;
1491
1492 /* Check which interrupts are timed out and need to be reenabled now. */
1493 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
1494 {
1495 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulFatalMemoryDisableMclkHigh, pIntrptManage->ulFatalMemoryDisableMclkLow, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptManage->byFatalMemoryState, fFatalMemoryChange )
1496 }
1497 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
1498 {
1499 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorMemoryDisableMclkHigh, pIntrptManage->ulErrorMemoryDisableMclkLow, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptManage->byErrorMemoryState, fDataErrMemoryChange )
1500 }
1501 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_IN_TIMEOUT )
1502 {
1503 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptManage->byErrorOverflowToneEventsState, fErrorOverflowToneEventsChange )
1504 }
1505 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_IN_TIMEOUT )
1506 {
1507 mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorH100DisableMclkHigh, pIntrptManage->ulErrorH100DisableMclkLow, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptManage->byErrorH100State, fH100ErrorChange )
1508 }
1509
1510 /* Set some parameters of write struct. */
1511 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1512
1513 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1514
1515 /* Write to the IE registers which have changed. */
1516
1517 /*==================================================================================*/
1518 if ( fFatalMemoryChange == TRUE )
1519 {
1520 WriteParams.ulWriteAddress = 0x104;
1521 WriteParams.usWriteData = 0x0000;
1522
1523 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1524 WriteParams.usWriteData |= 0x0001;
1525
1526 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1527 if ( ulResult != cOCT6100_ERR_OK )
1528 return ulResult;
1529
1530 }
1531 /*==================================================================================*/
1532
1533 /*==================================================================================*/
1534 if ( fFatalMemoryChange == TRUE ||
1535 fDataErrMemoryChange == TRUE )
1536 {
1537 WriteParams.ulWriteAddress = 0x204;
1538 WriteParams.usWriteData = 0x0000;
1539
1540 if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1541 WriteParams.usWriteData |= 0x1800;
1542 if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1543 WriteParams.usWriteData |= 0x0401;
1544
1545 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1546 if ( ulResult != cOCT6100_ERR_OK )
1547 return ulResult;
1548
1549 }
1550 /*==================================================================================*/
1551
1552 /*==================================================================================*/
1553 if ( pIntrptManage->fMclkIntrptActive == TRUE ||
1554 fH100ErrorChange == TRUE )
1555 {
1556 WriteParams.ulWriteAddress = 0x304;
1557 WriteParams.usWriteData = 0x0000;
1558
1559 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1560 WriteParams.usWriteData |= 0x0001;
1561
1562 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1563 {
1564 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1565 WriteParams.usWriteData |= 0xD100;
1566 else
1567 WriteParams.usWriteData |= 0x5100;
1568 }
1569
1570 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1571 if ( ulResult != cOCT6100_ERR_OK )
1572 return ulResult;
1573
1574 }
1575 /*==================================================================================*/
1576
1577
1578 /*==================================================================================*/
1579 if ( fErrorOverflowToneEventsChange == TRUE )
1580 {
1581 WriteParams.ulWriteAddress = 0x704;
1582 WriteParams.usWriteData = 0x0000;
1583
1584 if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1585 WriteParams.usWriteData |= 0x0002;
1586
1587 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1588 if ( ulResult != cOCT6100_ERR_OK )
1589 return ulResult;
1590
1591 }
1592 /*==================================================================================*/
1593
1594 return cOCT6100_ERR_OK;
1595 }
1596 #endif
1597
1598
1599 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1600
1601 Function: Oct6100ApiScheduleNextMclkIntrptSer
1602
1603 Description: Serialized sub-function of Oct6100ApiScheduleNextMclkIntrpt.
1604
1605 -------------------------------------------------------------------------------
1606 | Argument | Description
1607 -------------------------------------------------------------------------------
1608 f_pApiInstance Pointer to API instance. This memory is used to keep
1609 the present state of the chip and all its resources.
1610
1611 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1612 #if !SKIP_Oct6100ApiScheduleNextMclkIntrptSer
1613 UINT32 Oct6100ApiScheduleNextMclkIntrptSer(
1614 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1615 {
1616 tPOCT6100_SHARED_INFO pSharedInfo;
1617 tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
1618 tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1619 tOCT6100_WRITE_PARAMS WriteParams;
1620 UINT32 ulTimeDiff;
1621 UINT32 ulRegMclkTimeHigh;
1622 UINT32 ulRegMclkTimeLow;
1623 UINT32 ulResult;
1624 BOOL fConditionFlag = TRUE;
1625
1626 /* Get local pointer(s). */
1627 pSharedInfo = f_pApiInstance->pSharedInfo;
1628
1629 /* Obtain temporary pointers to reduce indirection, thus speeding up processing. */
1630 pIntrptConfig = &pSharedInfo->IntrptConfig;
1631 pIntrptManage = &pSharedInfo->IntrptManage;
1632 ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
1633 ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
1634
1635 /* First, check if any interrupts have just been disabled. If there are any, */
1636 /* determine the time at which they should be reenabled. */
1637 pIntrptManage->ulNextMclkIntrptTimeHigh = cOCT6100_INVALID_VALUE;
1638 pIntrptManage->ulNextMclkIntrptTimeLow = cOCT6100_INVALID_VALUE;
1639
1640 while ( fConditionFlag )
1641 {
1642 /* Indicate that no mclk interrupt is needed, yet. */
1643 ulTimeDiff = cOCT6100_INVALID_VALUE;
1644
1645 /* Check each interrupt category to see if an mclk interrupt is needed to */
1646 /* reenable an interrupt at a later time. */
1647 if ( pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_ACTIVE &&
1648 pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_DISABLED )
1649 {
1650 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byFatalMemoryState, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptConfig->ulFatalMemoryTimeoutMclk, ulTimeDiff )
1651 }
1652 if ( pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_ACTIVE &&
1653 pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
1654 {
1655 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorMemoryState, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptConfig->ulErrorMemoryTimeoutMclk, ulTimeDiff )
1656 }
1657 if ( pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_ACTIVE &&
1658 pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
1659 {
1660 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorOverflowToneEventsState, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk, ulTimeDiff )
1661 }
1662 if ( pIntrptManage->byErrorH100State != cOCT6100_INTRPT_ACTIVE &&
1663 pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
1664 {
1665 mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorH100State, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptConfig->ulErrorH100TimeoutMclk, ulTimeDiff )
1666 }
1667
1668 /* Set some parameters of write struct. */
1669 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1670
1671 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1672
1673 /* Schedule next mclk interrupt, if any is needed. */
1674 if ( ulTimeDiff != cOCT6100_INVALID_VALUE )
1675 {
1676 UINT32 ulMclkTimeTest;
1677 UINT32 ulAlarmTimeTest;
1678 UINT32 ulTimeDiffTest;
1679 BOOL fAlarmTimePassed;
1680
1681 /* Indicate that an mclk interrupt is scheduled.*/
1682 pIntrptManage->fMclkIntrptActive = TRUE;
1683
1684 pIntrptManage->ulNextMclkIntrptTimeLow = ulRegMclkTimeLow + ulTimeDiff;
1685 if ( pIntrptManage->ulNextMclkIntrptTimeLow < ulRegMclkTimeLow )
1686 pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh + 1;
1687 else /* ( pIntrptManage->ulNextMclkIntrptTimeLow >= ulRegMclkTimeLow ) */
1688 pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh;
1689
1690 WriteParams.ulWriteAddress = 0x30C;
1691 WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 24) & 0xFF );
1692 WriteParams.usWriteData |= (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeHigh & 0xFF) << 8 );
1693 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1694 if ( ulResult != cOCT6100_ERR_OK )
1695 return ulResult;
1696
1697 WriteParams.ulWriteAddress = 0x30E;
1698 WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 8) & 0xFFFF );
1699 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1700 if ( ulResult != cOCT6100_ERR_OK )
1701 return ulResult;
1702
1703 WriteParams.ulWriteAddress = 0x304;
1704 WriteParams.usWriteData = 0;
1705
1706 if ( pIntrptManage->fMclkIntrptActive == TRUE )
1707 WriteParams.usWriteData = 0x0001;
1708
1709 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1710 {
1711 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1712 WriteParams.usWriteData |= 0xD100;
1713 else
1714 WriteParams.usWriteData |= 0x5100;
1715 }
1716
1717 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1718 if ( ulResult != cOCT6100_ERR_OK )
1719 return ulResult;
1720
1721 /* Disable the ROL if previously set. */
1722 WriteParams.ulWriteAddress = 0x302;
1723 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1724 if ( ulResult != cOCT6100_ERR_OK )
1725 return ulResult;
1726
1727 /* Check if already passed the next interrupt time. */
1728 ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
1729 if ( ulResult != cOCT6100_ERR_OK )
1730 return ulResult;
1731
1732 ulMclkTimeTest = (pIntrptManage->ulRegMclkTimeLow >> 16) & 0xFFFF;
1733 ulAlarmTimeTest = (pIntrptManage->ulNextMclkIntrptTimeLow >> 16) & 0xFFFF;
1734
1735 /* Update the local Mlck timer values.*/
1736 ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
1737 ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
1738
1739 fAlarmTimePassed = FALSE;
1740
1741 if ( ulMclkTimeTest > ulAlarmTimeTest )
1742 {
1743 ulTimeDiffTest = ulMclkTimeTest - ulAlarmTimeTest;
1744 if ( ulTimeDiffTest <= 0x8000 )
1745 fAlarmTimePassed = TRUE;
1746 }
1747 else /* ( ulMclkTimeTest <= ulAlarmTimeTest ) */
1748 {
1749 ulTimeDiffTest = ulAlarmTimeTest - ulMclkTimeTest;
1750 if ( ulTimeDiffTest > 0x8000 )
1751 fAlarmTimePassed = TRUE;
1752 }
1753
1754 if ( fAlarmTimePassed == TRUE )
1755 {
1756 /* Passed the interrupt time. Schedule next interrupt (if needed). */
1757 ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
1758 if ( ulResult != cOCT6100_ERR_OK )
1759 return ulResult;
1760
1761 continue;
1762 }
1763 else
1764 {
1765 fConditionFlag = FALSE;
1766 }
1767 }
1768 else
1769 {
1770 /* Indicate that no mclk interrupt is scheduled. */
1771 pIntrptManage->fMclkIntrptActive = FALSE;
1772
1773 /* Insure that the mclk interrupt is not enabled. */
1774 WriteParams.ulWriteAddress = 0x304;
1775 WriteParams.usWriteData = 0x0000;
1776 if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1777 {
1778 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1779 WriteParams.usWriteData |= 0xD100;
1780 else
1781 WriteParams.usWriteData |= 0x5100;
1782 }
1783 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1784 if ( ulResult != cOCT6100_ERR_OK )
1785 return ulResult;
1786
1787 fConditionFlag = FALSE;
1788 }
1789 }
1790
1791 return cOCT6100_ERR_OK;
1792 }
1793 #endif
1794
1795
1796 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1797
1798 Function: Oct6100ApiCheckProcessorState
1799
1800 Description: This function verifies if the NLP and AF processors are operating
1801 correctly.
1802
1803 -------------------------------------------------------------------------------
1804 | Argument | Description
1805 -------------------------------------------------------------------------------
1806 f_pApiInstance Pointer to API instance. This memory is used to keep
1807 the present state of the chip and all its resources.
1808
1809 f_pIntFlags Pointer to a tOCT6100_INTERRUPT_FLAGS structure.
1810
1811 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1812 #if !SKIP_Oct6100ApiCheckProcessorState
1813 UINT32 Oct6100ApiCheckProcessorState(
1814 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1815 IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
1816 {
1817 tPOCT6100_SHARED_INFO pSharedInfo;
1818 tOCT6100_READ_PARAMS ReadParams;
1819 tOCT6100_READ_BURST_PARAMS ReadBurstParams;
1820
1821 UINT32 ulNlpTimestamp;
1822 UINT32 ulAfTimestamp;
1823 UINT32 ulTimestampDiff;
1824
1825 UINT32 ulResult;
1826 UINT32 i;
1827
1828 UINT16 usReadData;
1829 UINT16 ausReadData[ 2 ];
1830
1831 UINT32 aulWaitTime[ 2 ];
1832
1833 /* Get local pointer(s). */
1834 pSharedInfo = f_pApiInstance->pSharedInfo;
1835
1836 /* Set some parameters of write struct. */
1837 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1838
1839 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1840 ReadParams.pusReadData = &usReadData;
1841
1842 /* Set some parameters of write struct. */
1843 ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
1844
1845 ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1846 ReadBurstParams.pusReadData = ausReadData;
1847
1848 /*-----------------------------------------------------------------------*/
1849 /* Check if chip is in reset. */
1850
1851 /* Read the main control register. */
1852 ReadParams.ulReadAddress = 0x100;
1853
1854 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1855 if ( ulResult != cOCT6100_ERR_OK )
1856 return ulResult;
1857
1858 if ( usReadData == 0x0000 )
1859 {
1860 /* Chip was resetted. */
1861 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_4;
1862 f_pIntFlags->fFatalGeneral = TRUE;
1863 pSharedInfo->ErrorStats.fFatalChipError = TRUE;
1864 }
1865
1866 /*-----------------------------------------------------------------------*/
1867
1868
1869 /*-----------------------------------------------------------------------*/
1870 /* Reading the AF timestamp.*/
1871
1872 for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
1873 {
1874 /* Read the timestamp.*/
1875 ReadBurstParams.ulReadAddress = 0x082E0008;
1876 ReadBurstParams.ulReadLength = 2;
1877
1878 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1879 if ( ulResult != cOCT6100_ERR_OK )
1880 return ulResult;
1881
1882 /* Read the high part again to make sure it didn't wrap. */
1883 ReadParams.ulReadAddress = 0x082E0008;
1884
1885 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1886 if ( ulResult != cOCT6100_ERR_OK )
1887 return ulResult;
1888
1889 /* Check if the low part wrapped. */
1890 if ( ausReadData[ 0 ] == usReadData )
1891 break;
1892 }
1893
1894 if ( i == cOCT6100_MAX_LOOP )
1895 return cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT;
1896
1897 /* Save the AF timestamp. */
1898 ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1899
1900 /*-----------------------------------------------------------------------*/
1901
1902
1903 /*-----------------------------------------------------------------------*/
1904 /* Reading the NLP timestamp. */
1905
1906 for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
1907 {
1908 /* Read the timestamp. */
1909 ReadBurstParams.ulReadAddress = 0x08000008;
1910 ReadBurstParams.ulReadLength = 2;
1911
1912 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1913 if ( ulResult != cOCT6100_ERR_OK )
1914 return ulResult;
1915
1916 /* Read the high part again to make sure it didn't wrap. */
1917 ReadParams.ulReadAddress = 0x08000008;
1918
1919 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1920 if ( ulResult != cOCT6100_ERR_OK )
1921 return ulResult;
1922
1923 /* Check if the low part wrapped. */
1924 if ( ausReadData[ 0 ] == usReadData )
1925 break;
1926 }
1927
1928 if ( i == cOCT6100_MAX_LOOP )
1929 return cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT;
1930
1931 /* Save the NLP timestamp. */
1932 ulNlpTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1933
1934 /*-----------------------------------------------------------------------*/
1935
1936
1937 /*-----------------------------------------------------------------------*/
1938 /* Check the validity of the timestamp. */
1939
1940 if ( ulAfTimestamp > ulNlpTimestamp )
1941 {
1942 /* The NLP timestamp wrapped. */
1943 ulTimestampDiff = 0xFFFFFFFF - ulAfTimestamp + 1;
1944 ulTimestampDiff += ulNlpTimestamp;
1945 }
1946 else
1947 ulTimestampDiff = ulNlpTimestamp - ulAfTimestamp;
1948
1949 if ( ulTimestampDiff > 0x2000 )
1950 {
1951 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_5;
1952 f_pIntFlags->fFatalGeneral = TRUE;
1953 pSharedInfo->ErrorStats.fFatalChipError = TRUE;
1954 }
1955
1956 /*Check if AF and NLP are both stuck*/
1957 if ( f_pIntFlags->fErrorH100ClkA == FALSE &&
1958 f_pIntFlags->fErrorH100ClkB == FALSE &&
1959 f_pIntFlags->fErrorH100FrameA == FALSE &&
1960 f_pIntFlags->fErrorH100OutOfSync == FALSE )
1961
1962 {
1963 if ( ulAfTimestamp == 0 && ulNlpTimestamp == 0 )
1964 {
1965 /*Give some time to the counters*/
1966 aulWaitTime[ 0 ] = 250;
1967 aulWaitTime[ 1 ] = 0;
1968 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
1969 if ( ulResult != cOCT6100_ERR_OK )
1970 return ulResult;
1971
1972 /*Let's read again the AF timestamp to be sure. Maybe they were at 0 at the same time*/
1973 ReadBurstParams.ulReadAddress = 0x082E0008;
1974 ReadBurstParams.ulReadLength = 2;
1975
1976 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1977 if ( ulResult != cOCT6100_ERR_OK )
1978 return ulResult;
1979
1980 ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1981
1982 if ( ulAfTimestamp == 0 )
1983 {
1984 /*TDM Clocks are ok but NLP and AF timestamps are both at 0*/
1985 f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_9;
1986 f_pIntFlags->fFatalGeneral = TRUE;
1987 pSharedInfo->ErrorStats.fFatalChipError = TRUE;
1988 }
1989 }
1990
1991 }
1992
1993 /*-----------------------------------------------------------------------*/
1994
1995 return cOCT6100_ERR_OK;
1996 }
1997 #endif