1
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3
File: oct6100_interrupts.c
5
Copyright (c) 2001-2007 Octasic Inc.
9
This file contains the API's interrupt service routine and all of its
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.
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
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.
26
$Octasic_Release: OCT612xAPI-01.00-PR49 $
28
$Octasic_Revision: 81 $
30
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
33
/***************************** INCLUDE FILES *******************************/
37
#include "oct6100api/oct6100_defines.h"
38
#include "oct6100api/oct6100_errors.h"
39
#include "oct6100api/oct6100_apiud.h"
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"
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"
55
#include "oct6100_chip_open_priv.h"
56
#include "oct6100_miscellaneous_priv.h"
57
#include "oct6100_events_priv.h"
58
#include "oct6100_interrupts_priv.h"
60
/**************************** PUBLIC FUNCTIONS *****************************/
63
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
65
Function: Oct6100InterruptConfigure
67
Description: Configure the operation of all possible interrupt sources.
69
-------------------------------------------------------------------------------
70
| Argument | Description
71
-------------------------------------------------------------------------------
72
f_pApiInstance Pointer to API instance. This memory is used to keep
73
the present state of the chip and all its resources.
75
f_pIntrptConfig Pointer to interrupt configuration structure.
77
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
78
#if !SKIP_Oct6100InterruptConfigureDef
79
UINT32 Oct6100InterruptConfigureDef(
80
tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
82
f_pIntrptConfig->ulFatalGeneralConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
83
f_pIntrptConfig->ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
85
f_pIntrptConfig->ulErrorMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
86
f_pIntrptConfig->ulErrorOverflowToneEventsConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
87
f_pIntrptConfig->ulErrorH100Config = cOCT6100_INTERRUPT_NO_TIMEOUT;
89
f_pIntrptConfig->ulFatalMemoryTimeout = 100;
91
f_pIntrptConfig->ulErrorMemoryTimeout = 100;
92
f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = 100;
93
f_pIntrptConfig->ulErrorH100Timeout = 100;
95
return cOCT6100_ERR_OK;
100
#if !SKIP_Oct6100InterruptConfigure
101
UINT32 Oct6100InterruptConfigure(
102
tPOCT6100_INSTANCE_API f_pApiInstance,
103
tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
105
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
106
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
110
/* Set the process context of the serialize structure.*/
111
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
112
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
114
/* Create serialization object for ISR. */
115
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
116
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
117
ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
118
if ( ulResult != cOCT6100_ERR_OK )
121
/* Call serialized sub-function. */
122
ulFncRes = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
123
/* Release serialization object. */
124
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
125
ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
126
if ( ulResult != cOCT6100_ERR_OK )
129
/* Check if an error occured in sub-function. */
130
if ( ulFncRes != cOCT6100_ERR_OK )
133
return cOCT6100_ERR_OK;
138
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
140
Function: Oct6100InterruptServiceRoutine
142
Description: The API's interrupt service routine. This function clears all
143
register ROLs which have generated an interrupt and report the
144
events in the user supplied structure. Also, the tone event
145
and/or playout event buffer will be emptied if valid events
148
-------------------------------------------------------------------------------
149
| Argument | Description
150
-------------------------------------------------------------------------------
151
f_pApiInstance Pointer to API instance. This memory is used to keep
152
the present state of the chip and all its resources.
154
f_pIntFlags Pointer to structure containing event flags returned
157
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
158
#if !SKIP_Oct6100InterruptServiceRoutineDef
159
UINT32 Oct6100InterruptServiceRoutineDef(
160
tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
162
f_pIntFlags->fFatalGeneral = FALSE;
163
f_pIntFlags->ulFatalGeneralFlags = 0x0;
164
f_pIntFlags->fFatalReadTimeout = FALSE;
166
f_pIntFlags->fErrorRefreshTooLate = FALSE;
167
f_pIntFlags->fErrorPllJitter = FALSE;
169
f_pIntFlags->fErrorOverflowToneEvents = FALSE;
171
f_pIntFlags->fErrorH100OutOfSync = FALSE;
172
f_pIntFlags->fErrorH100ClkA = FALSE;
173
f_pIntFlags->fErrorH100ClkB = FALSE;
174
f_pIntFlags->fErrorH100FrameA = FALSE;
176
f_pIntFlags->fToneEventsPending = FALSE;
177
f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
179
f_pIntFlags->fApiSynch = FALSE;
183
return cOCT6100_ERR_OK;
188
#if !SKIP_Oct6100InterruptServiceRoutine
189
UINT32 Oct6100InterruptServiceRoutine(
190
tPOCT6100_INSTANCE_API f_pApiInstance,
191
tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
193
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
194
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
198
/* Set the process context of the serialize structure. */
199
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
200
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
202
/* Seize the serialization object for the ISR. */
203
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
204
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
205
ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
206
if ( ulResult == cOCT6100_ERR_OK )
208
/* Call the serialized sub-function. */
209
ulFncRes = Oct6100InterruptServiceRoutineSer( f_pApiInstance, f_pIntFlags );
216
/* Release the serialization object. */
217
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
218
ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
219
if ( ulResult != cOCT6100_ERR_OK )
222
/* Check for an error in the sub-function. */
223
if ( ulFncRes != cOCT6100_ERR_OK )
226
return cOCT6100_ERR_OK;
231
/**************************** PRIVATE FUNCTIONS ****************************/
234
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
236
Function: Oct6100ApiIsrSwInit
238
Description: Initializes portions of API instance associated to the API's
239
interrupt service routine.
241
-------------------------------------------------------------------------------
242
| Argument | Description
243
-------------------------------------------------------------------------------
244
f_pApiInstance Pointer to API instance. This memory is used to keep
245
the present state of the chip and all its resources.
247
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
248
#if !SKIP_Oct6100ApiIsrSwInit
249
UINT32 Oct6100ApiIsrSwInit(
250
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
252
tPOCT6100_SHARED_INFO pSharedInfo;
254
/* Get local pointer to shared portion of instance. */
255
pSharedInfo = f_pApiInstance->pSharedInfo;
257
/* Set the state of each interrupt group to disabled. The state will */
258
/* be updated to the true configuration once the configure interrupts function is called. */
259
pSharedInfo->IntrptManage.byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
260
pSharedInfo->IntrptManage.byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
261
pSharedInfo->IntrptManage.byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
262
pSharedInfo->IntrptManage.byErrorH100State = cOCT6100_INTRPT_DISABLED;
263
pSharedInfo->IntrptManage.byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
265
/* Indicate that the mclk interrupt is not active at the moment. */
266
pSharedInfo->IntrptManage.fMclkIntrptActive = FALSE;
268
/* Indicate that no buffer playout events are pending for the moment. */
269
pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
271
/* Indicate that no tone events are pending for the moment. */
272
pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
274
/* The ISR has never been called. */
275
pSharedInfo->IntrptManage.fIsrCalled = FALSE;
277
return cOCT6100_ERR_OK;
282
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
284
Function: Oct6100ApiIsrHwInit
286
Description: Initializes the chip's interrupt registers.
288
-------------------------------------------------------------------------------
289
| Argument | Description
290
-------------------------------------------------------------------------------
291
f_pApiInstance Pointer to API instance. This memory is used to keep
292
the present state of the chip and all its resources.
294
f_pIntrptConfig Pointer to structure defining how the interrupts
295
should be configured.
297
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
298
#if !SKIP_Oct6100ApiIsrHwInit
299
UINT32 Oct6100ApiIsrHwInit(
300
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
301
IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
303
tOCT6100_WRITE_PARAMS WriteParams;
306
/* Set some parameters of write struct. */
307
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
309
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
311
/*==================================================================================*/
312
/* Enable all the interrupts */
314
WriteParams.ulWriteAddress = 0x104;
315
WriteParams.usWriteData = 0x0001;
316
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
317
if ( ulResult != cOCT6100_ERR_OK )
320
WriteParams.ulWriteAddress = 0x204;
321
WriteParams.usWriteData = 0x1C05;
322
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
323
if ( ulResult != cOCT6100_ERR_OK )
326
WriteParams.ulWriteAddress = 0x304;
327
WriteParams.usWriteData = 0xFFFF;
328
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
329
if ( ulResult != cOCT6100_ERR_OK )
332
WriteParams.ulWriteAddress = 0x504;
333
WriteParams.usWriteData = 0x0002;
334
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
335
if ( ulResult != cOCT6100_ERR_OK )
338
WriteParams.ulWriteAddress = 0x704;
339
WriteParams.usWriteData = 0x0007;
340
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
341
if ( ulResult != cOCT6100_ERR_OK )
344
/*==================================================================================*/
346
/* Calculate the number of mclk cycles in 1 ms. */
347
f_pApiInstance->pSharedInfo->IntrptManage.ulNumMclkCyclesIn1Ms = f_pApiInstance->pSharedInfo->MiscVars.ulMclkFreq / 1000;
349
/* Configure the interrupt registers as requested by the user. */
350
ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
351
if ( ulResult != cOCT6100_ERR_OK )
354
return cOCT6100_ERR_OK;
359
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
361
Function: Oct6100InterruptConfigureSer
363
Description: Configure the operation of interrupt groups.
365
-------------------------------------------------------------------------------
366
| Argument | Description
367
-------------------------------------------------------------------------------
368
f_pApiInstance Pointer to API instance. This memory is used to keep
369
the present state of the chip and all its resources.
371
f_pIntrptConfig Pointer to interrupt configuration structure.
372
f_fCheckParams Check parameter enable flag.
374
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
375
#if !SKIP_Oct6100InterruptConfigureSer
376
UINT32 Oct6100InterruptConfigureSer(
377
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
378
IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig,
379
IN BOOL f_fCheckParams )
381
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
382
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
385
/* Check for errors. */
386
if ( f_fCheckParams == TRUE )
388
if ( f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE &&
389
f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
390
return cOCT6100_ERR_INTRPTS_FATAL_GENERAL_CONFIG;
391
if ( f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
392
f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
393
f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
394
return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_CONFIG;
395
if ( f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
396
f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
397
f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
398
return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_CONFIG;
399
if ( f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE &&
400
f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT &&
401
f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
402
return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_CONFIG;
403
if ( f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE &&
404
f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT &&
405
f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT )
406
return cOCT6100_ERR_INTRPTS_H100_ERROR_CONFIG;
408
if ( f_pIntrptConfig->ulFatalMemoryTimeout < 10 ||
409
f_pIntrptConfig->ulFatalMemoryTimeout > 10000 )
410
return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_TIMEOUT;
411
if ( f_pIntrptConfig->ulErrorMemoryTimeout < 10 ||
412
f_pIntrptConfig->ulErrorMemoryTimeout > 10000 )
413
return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_TIMEOUT;
414
if ( f_pIntrptConfig->ulErrorOverflowToneEventsTimeout < 10 ||
415
f_pIntrptConfig->ulErrorOverflowToneEventsTimeout > 10000 )
416
return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_TIMEOUT;
417
if ( f_pIntrptConfig->ulErrorH100Timeout < 10 ||
418
f_pIntrptConfig->ulErrorH100Timeout > 10000 )
419
return cOCT6100_ERR_INTRPTS_H100_ERROR_TIMEOUT;
422
/* Copy the configuration to the API instance. */
423
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
424
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
426
pIntrptConfig->byFatalGeneralConfig = (UINT8)( f_pIntrptConfig->ulFatalGeneralConfig & 0xFF );
427
pIntrptConfig->byFatalMemoryConfig = (UINT8)( f_pIntrptConfig->ulFatalMemoryConfig & 0xFF );
428
pIntrptConfig->byErrorMemoryConfig = (UINT8)( f_pIntrptConfig->ulErrorMemoryConfig & 0xFF );
429
pIntrptConfig->byErrorOverflowToneEventsConfig = (UINT8)( f_pIntrptConfig->ulErrorOverflowToneEventsConfig & 0xFF );
430
pIntrptConfig->byErrorH100Config = (UINT8)( f_pIntrptConfig->ulErrorH100Config & 0xFF );
432
f_pIntrptConfig->ulFatalMemoryTimeout = ((f_pIntrptConfig->ulFatalMemoryTimeout + 9) / 10) * 10;
433
pIntrptConfig->ulFatalMemoryTimeoutMclk = f_pIntrptConfig->ulFatalMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
435
f_pIntrptConfig->ulErrorMemoryTimeout = ((f_pIntrptConfig->ulErrorMemoryTimeout + 9) / 10) * 10;
436
pIntrptConfig->ulErrorMemoryTimeoutMclk = f_pIntrptConfig->ulErrorMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
438
f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = ((f_pIntrptConfig->ulErrorOverflowToneEventsTimeout + 9) / 10) * 10;
439
pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk = f_pIntrptConfig->ulErrorOverflowToneEventsTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
441
f_pIntrptConfig->ulErrorH100Timeout = ((f_pIntrptConfig->ulErrorH100Timeout + 9) / 10) * 10;
442
pIntrptConfig->ulErrorH100TimeoutMclk = f_pIntrptConfig->ulErrorH100Timeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
445
/*Clear all interrupts that were already enabled*/
446
ulResult = Oct6100ApiClearEnabledInterrupts( f_pApiInstance );
447
if ( ulResult != cOCT6100_ERR_OK )
450
/* Before writing the new configuration to the chip's registers, make sure that any */
451
/* interrupts which are either disabled or have no timeout period are not on the */
452
/* disabled interrupt list. */
454
/*==================================================================================*/
455
if ( pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_DISABLE )
456
pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
457
else /* pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_NO_TIMEOUT */
458
pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_ACTIVE;
460
/*==================================================================================*/
461
if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
462
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
463
else if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
464
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
465
else /* ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
467
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_DISABLED )
468
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
471
/*==================================================================================*/
472
if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
473
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
474
else if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
475
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
476
else /* (pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
478
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_DISABLED )
479
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
482
/*==================================================================================*/
483
if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_DISABLE )
484
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
485
else if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
486
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
487
else /* (pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
489
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_DISABLED )
490
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
493
/*==================================================================================*/
494
if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_DISABLE )
495
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_DISABLED;
496
else if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_NO_TIMEOUT )
497
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
498
else /* (pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT ) */
500
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_DISABLED )
501
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
505
/* Write to the interrupt registers to update the state of each interrupt group. */
506
ulResult = Oct6100ApiWriteIeRegs( f_pApiInstance );
507
if ( ulResult != cOCT6100_ERR_OK )
510
return cOCT6100_ERR_OK;
514
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
516
Function: Oct6100ApiClearEnabledInterrupts
518
Description: Disabled interruption are not reported but still available. This
519
function will clear the interrupts that were disabled and wish
522
-------------------------------------------------------------------------------
523
| Argument | Description
524
-------------------------------------------------------------------------------
525
f_pApiInstance Pointer to API instance. This memory is used to keep
526
the present state of the chip and all its resources.
528
f_pIntrptConfig Pointer to interrupt configuration structure.
529
f_pIntrptManage Pointer to interrupt manager structure.
530
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
532
#if !SKIP_Oct6100ApiClearEnabledInterrupts
533
UINT32 Oct6100ApiClearEnabledInterrupts(
534
IN tPOCT6100_INSTANCE_API f_pApiInstance )
537
tPOCT6100_SHARED_INFO pSharedInfo;
538
tOCT6100_WRITE_PARAMS WriteParams;
539
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
540
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
543
/* Get local pointer to shared portion of instance. */
544
pSharedInfo = f_pApiInstance->pSharedInfo;
546
/* Set the process context and user chip ID parameters once and for all. */
547
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
549
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
551
/* Copy the configuration to the API instance. */
552
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
553
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
555
if ( pIntrptConfig->byFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE &&
556
pIntrptManage->byFatalGeneralState != cOCT6100_INTRPT_DISABLED )
558
WriteParams.ulWriteAddress = 0x102;
559
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_102H;
560
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
561
if ( ulResult != cOCT6100_ERR_OK )
564
WriteParams.ulWriteAddress = 0x202;
565
WriteParams.usWriteData = 0x1800;
566
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
567
if ( ulResult != cOCT6100_ERR_OK )
570
WriteParams.ulWriteAddress = 0x502;
571
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_502H;
572
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
573
if ( ulResult != cOCT6100_ERR_OK )
577
if ( pIntrptConfig->byErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
578
pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
580
WriteParams.ulWriteAddress = 0x202;
581
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_202H;
582
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
583
if ( ulResult != cOCT6100_ERR_OK )
587
if ( pIntrptConfig->byErrorH100Config != cOCT6100_INTERRUPT_DISABLE &&
588
pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
590
WriteParams.ulWriteAddress = 0x302;
591
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_302H;
592
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
593
if ( ulResult != cOCT6100_ERR_OK )
597
if ( pIntrptConfig->byErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE &&
598
pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
600
WriteParams.ulWriteAddress = 0x702;
601
WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_702H;
602
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
603
if ( ulResult != cOCT6100_ERR_OK )
608
return cOCT6100_ERR_OK;
613
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
615
Function: Oct6100InterruptServiceRoutineSer
617
Description: Serialized sub-function of API's interrupt service routine.
619
-------------------------------------------------------------------------------
620
| Argument | Description
621
-------------------------------------------------------------------------------
622
f_pApiInstance Pointer to API instance. This memory is used to keep
623
the present state of the chip and all its resources.
625
f_pIntFlags Pointer to structure containing event flags returned
628
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
629
#if !SKIP_Oct6100InterruptServiceRoutineSer
630
UINT32 Oct6100InterruptServiceRoutineSer(
631
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
632
IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
634
tPOCT6100_SHARED_INFO pSharedInfo;
635
tOCT6100_READ_PARAMS ReadParams;
636
tOCT6100_WRITE_PARAMS WriteParams;
637
UINT32 ulRegister210h;
641
/* Get local pointer(s). */
642
pSharedInfo = f_pApiInstance->pSharedInfo;
644
/* Must update the statistics. Set parameters in read and write structs. */
645
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
647
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
649
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
651
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
652
ReadParams.pusReadData = &usReadData;
654
/* Set all the flags to default values to make sure the variables are initialized. */
655
f_pIntFlags->fFatalGeneral = FALSE;
656
f_pIntFlags->ulFatalGeneralFlags = 0x0;
657
f_pIntFlags->fFatalReadTimeout = FALSE;
659
f_pIntFlags->fErrorRefreshTooLate = FALSE;
660
f_pIntFlags->fErrorPllJitter = FALSE;
662
f_pIntFlags->fErrorH100OutOfSync = FALSE;
663
f_pIntFlags->fErrorH100ClkA = FALSE;
664
f_pIntFlags->fErrorH100ClkB = FALSE;
665
f_pIntFlags->fErrorH100FrameA = FALSE;
666
f_pIntFlags->fApiSynch = FALSE;
668
f_pIntFlags->fErrorOverflowToneEvents = FALSE;
670
/* Start by reading registers 210h to determine if any modules have flagged an interrupt. */
671
ReadParams.ulReadAddress = 0x210;
672
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
673
if ( ulResult != cOCT6100_ERR_OK )
675
ulRegister210h = usReadData;
677
/* Update the extended mclk counter. */
678
ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
679
if ( ulResult != cOCT6100_ERR_OK )
682
/* If the mclk interrupt is active then check which interrupt timeout periods have expired. */
683
ReadParams.ulReadAddress = 0x302;
684
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
685
if ( ulResult != cOCT6100_ERR_OK )
687
if ( (usReadData & 0x1) != 0 && pSharedInfo->IntrptManage.fMclkIntrptActive == TRUE )
689
/* Update timeout periods. */
690
ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
691
if ( ulResult != cOCT6100_ERR_OK )
694
f_pIntFlags->fApiSynch = TRUE;
696
/* Read registers 210h and 212h again to determine if any modules have flagged an interrupt. */
697
ReadParams.ulReadAddress = 0x210;
698
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
699
if ( ulResult != cOCT6100_ERR_OK )
701
ulRegister210h = usReadData;
704
/* Read the interrupt registers to determine what interrupt conditions have occured. */
705
ulResult = Oct6100ApiReadIntrptRegs( f_pApiInstance, f_pIntFlags, ulRegister210h );
706
if ( ulResult != cOCT6100_ERR_OK )
709
/* Empty the tone buffer if any events are pending. */
710
ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, FALSE );
711
if ( ulResult != cOCT6100_ERR_OK )
714
/* Set the tone events pending flag. */
715
f_pIntFlags->fToneEventsPending = pSharedInfo->IntrptManage.fToneEventsPending;
717
/* Check for buffer playout events and insert in the software queue -- if activated. */
718
if ( pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize != 0 )
720
ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, FALSE );
721
if ( ulResult != cOCT6100_ERR_OK )
724
/* Set the buffer playout events pending flag. */
725
f_pIntFlags->fBufferPlayoutEventsPending = pSharedInfo->IntrptManage.fBufferPlayoutEventsPending;
729
f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
732
/* Update the states of each interrupt group. */
733
ulResult = Oct6100ApiUpdateIntrptStates( f_pApiInstance, f_pIntFlags );
734
if ( ulResult != cOCT6100_ERR_OK )
737
/* Check the state of the NLP timestamp if required.*/
738
ulResult = Oct6100ApiCheckProcessorState( f_pApiInstance, f_pIntFlags );
739
if ( ulResult != cOCT6100_ERR_OK )
742
/* Write to the necessary IE registers. */
743
ulResult = Oct6100ApiWriteIntrptRegs( f_pApiInstance );
744
if ( ulResult != cOCT6100_ERR_OK )
747
/* Schedule the next mclk interrupt, if one is needed. */
748
ulResult = Oct6100ApiScheduleNextMclkIntrptSer( f_pApiInstance );
749
if ( ulResult != cOCT6100_ERR_OK )
752
/* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */
753
WriteParams.ulWriteAddress = 0x214;
754
WriteParams.usWriteData = 0x0000;
755
if ( pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY )
756
WriteParams.usWriteData |= 0x4000;
757
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
758
if ( ulResult != cOCT6100_ERR_OK )
761
/* Indicate that the interrupt ROLs have been treated. */
762
WriteParams.ulWriteAddress = 0x212;
763
WriteParams.usWriteData = 0x8000;
764
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
765
if ( ulResult != cOCT6100_ERR_OK )
768
return cOCT6100_ERR_OK;
773
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
775
Function: Oct6100ApiReadIntrptRegs
777
Description: Reads the interrupt registers of all modules currently
778
indicating an interrupt condition.
780
-------------------------------------------------------------------------------
781
| Argument | Description
782
-------------------------------------------------------------------------------
783
f_pApiInstance Pointer to API instance. This memory is used to keep
784
the present state of the chip and all its resources.
786
f_pIntFlags Pointer to an interrupt flag structure.
787
f_ulRegister210h Value of register 0x210.
789
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
790
#if !SKIP_Oct6100ApiReadIntrptRegs
791
UINT32 Oct6100ApiReadIntrptRegs(
792
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
793
OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags,
794
IN UINT32 f_ulRegister210h )
796
tPOCT6100_SHARED_INFO pSharedInfo;
797
tPOCT6100_API_CHIP_ERROR_STATS pErrorStats;
798
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
799
tOCT6100_READ_PARAMS ReadParams;
800
tOCT6100_WRITE_PARAMS WriteParams;
804
UINT32 ulFeatureBytesOffset;
805
UINT32 ulFeatureBitOffset;
806
UINT32 ulFeatureFieldLength;
808
UINT32 ulCounterValue;
811
/* Get local pointer(s). */
812
pSharedInfo = f_pApiInstance->pSharedInfo;
813
pErrorStats = &pSharedInfo->ErrorStats;
814
pIntrptManage = &pSharedInfo->IntrptManage;
816
/* Set some parameters of read struct. */
817
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
819
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
820
ReadParams.pusReadData = &usReadData;
822
/* Set some parameters of write struct. */
823
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
825
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
830
if ( (f_ulRegister210h & 0x00001) != 0 )
832
/*=======================================================================*/
833
/* Read registers of this module. */
834
ReadParams.ulReadAddress = 0x102;
835
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
836
if ( ulResult != cOCT6100_ERR_OK )
839
/* Check which interrupt(s) were set. */
840
if ( (usReadData & 0x0001) != 0 )
842
f_pIntFlags->fFatalReadTimeout = TRUE;
843
pErrorStats->ulInternalReadTimeoutCnt++;
846
pIntrptManage->usRegister102h = usReadData;
847
/*=======================================================================*/
851
pIntrptManage->usRegister102h = 0x0;
854
/* MAIN registers. */
855
if ( (f_ulRegister210h & 0x00002) != 0 )
857
/*=======================================================================*/
858
/* Read registers of this module. */
859
ReadParams.ulReadAddress = 0x202;
860
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
861
if ( ulResult != cOCT6100_ERR_OK )
864
/* Save current value in instance. */
865
pIntrptManage->usRegister202h = usReadData;
867
/* Check which interrupts were set. */
868
if ( (usReadData & 0x0001) != 0 )
870
f_pIntFlags->fErrorRefreshTooLate = TRUE;
871
pErrorStats->ulSdramRefreshTooLateCnt++;
873
if ( (usReadData & 0x0800) != 0 )
875
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_1;
876
f_pIntFlags->fFatalGeneral = TRUE;
877
pErrorStats->fFatalChipError = TRUE;
879
if ( (usReadData & 0x1000) != 0 )
881
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_2;
882
f_pIntFlags->fFatalGeneral = TRUE;
883
pErrorStats->fFatalChipError = TRUE;
885
if ( (usReadData & 0x0400) != 0 )
887
f_pIntFlags->fErrorPllJitter = TRUE;
888
pErrorStats->ulPllJitterErrorCnt++;
890
/* Update the PLL jitter error count here. */
891
if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
893
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
894
ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
895
ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
897
ulResult = Oct6100ApiReadDword( f_pApiInstance,
898
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
901
/* Read previous value set in the feature field. */
902
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
904
/* Update counter. */
905
ulCounterValue = ulTempData & ulMask;
906
ulCounterValue = ulCounterValue >> ulFeatureBitOffset;
908
/* Handle wrap around case. */
909
ulCounterValue &= ( 1 << ulFeatureFieldLength ) - 1;
911
/* Clear old counter value. */
912
ulTempData &= (~ulMask);
913
ulTempData |= ulCounterValue << ulFeatureBitOffset;
915
/* Write the DWORD where the field is located.*/
916
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
917
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
919
if ( ulResult != cOCT6100_ERR_OK )
924
/*=======================================================================*/
928
pIntrptManage->usRegister202h = 0x0;
931
/* H.100 registers. */
932
if ( (f_ulRegister210h & 0x00004) != 0 )
934
/*=======================================================================*/
935
/* Read registers of this module. */
936
ReadParams.ulReadAddress = 0x302;
937
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
938
if ( ulResult != cOCT6100_ERR_OK )
941
/* Check which interrupts were set. */
942
if ( (usReadData & 0x0100) != 0 )
944
f_pIntFlags->fErrorH100OutOfSync = TRUE;
945
pErrorStats->ulH100OutOfSyncCnt++;
947
if ( (usReadData & 0x1000) != 0 )
949
f_pIntFlags->fErrorH100FrameA = TRUE;
950
pErrorStats->ulH100FrameABadCnt++;
952
if ( (usReadData & 0x4000) != 0 )
954
f_pIntFlags->fErrorH100ClkA = TRUE;
955
pErrorStats->ulH100ClkABadCnt++;
957
if ( (usReadData & 0x8000) != 0 )
959
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
961
f_pIntFlags->fErrorH100ClkB = TRUE;
962
pErrorStats->ulH100ClkBBadCnt++;
966
pIntrptManage->usRegister302h = usReadData;
967
/*=======================================================================*/
971
pIntrptManage->usRegister302h = 0x0;
974
/* TDMIE registers. */
975
if ( (f_ulRegister210h & 0x00010) != 0 )
977
/*=======================================================================*/
979
ReadParams.ulReadAddress = 0x502;
980
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
981
if ( ulResult != cOCT6100_ERR_OK )
984
/* Check which interrupts were set. */
985
if ( (usReadData & 0x0002) != 0 )
987
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_3;
988
f_pIntFlags->fFatalGeneral = TRUE;
989
pErrorStats->fFatalChipError = TRUE;
992
pIntrptManage->usRegister502h = usReadData;
993
/*=======================================================================*/
997
pIntrptManage->usRegister502h = 0x0;
1000
/* PGSP registers. */
1001
if ( (f_ulRegister210h & 0x00080) != 0 )
1003
/*=======================================================================*/
1004
/* Read register. */
1005
ReadParams.ulReadAddress = 0x702;
1006
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1007
if ( ulResult != cOCT6100_ERR_OK )
1010
/* Check which interrupts were set. */
1011
if ( (usReadData & 0x0002) != 0 )
1013
f_pIntFlags->fErrorOverflowToneEvents = TRUE;
1014
pErrorStats->ulOverflowToneEventsCnt++;
1017
pIntrptManage->usRegister702h = usReadData;
1018
/*=======================================================================*/
1022
pIntrptManage->usRegister702h = 0x0;
1027
/* If this is the first time the ISR is called, clear the ISR is not called bit */
1028
/* in external memory to signal the remote client that we are called. */
1029
if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE )
1031
/* Remember that we are being called. */
1032
pSharedInfo->IntrptManage.fIsrCalled = TRUE;
1034
if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
1036
ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
1037
ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
1038
ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
1040
ulResult = Oct6100ApiReadDword( f_pApiInstance,
1041
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
1044
/* Read previous value set in the feature field. */
1045
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
1047
/* Clear the field. */
1048
ulTempData &= (~ulMask);
1050
/* Write the DWORD where the field is located.*/
1051
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
1052
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
1054
if ( ulResult != cOCT6100_ERR_OK )
1059
return cOCT6100_ERR_OK;
1064
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1066
Function: Oct6100ApiUpdateIntrptStates
1068
Description: Updates the state of all interrupt register groups.
1070
-------------------------------------------------------------------------------
1071
| Argument | Description
1072
-------------------------------------------------------------------------------
1073
f_pApiInstance Pointer to API instance. This memory is used to keep
1074
the present state of the chip and all its resources.
1076
f_pIntFlags Interrupt flags.
1078
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1079
#if !SKIP_Oct6100ApiUpdateIntrptStates
1080
UINT32 Oct6100ApiUpdateIntrptStates(
1081
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1082
IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
1084
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
1085
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1087
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
1088
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1090
/*-----------------------------------------------------------------------*/
1091
if ( ( f_pIntFlags->fFatalReadTimeout == TRUE) &&
1092
pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1093
pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1095
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
1096
pIntrptManage->ulFatalMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1097
pIntrptManage->ulFatalMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1099
/*-----------------------------------------------------------------------*/
1100
if ( (f_pIntFlags->fErrorRefreshTooLate == TRUE ||
1101
f_pIntFlags->fErrorPllJitter == TRUE ) &&
1102
pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1103
pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1105
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
1106
pIntrptManage->ulErrorMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1107
pIntrptManage->ulErrorMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1109
/*-----------------------------------------------------------------------*/
1110
if ( (f_pIntFlags->fErrorOverflowToneEvents == TRUE) &&
1111
pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT &&
1112
pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1114
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_WILL_TIMEOUT;
1115
pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1116
pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1118
/*-----------------------------------------------------------------------*/
1119
if ( (f_pIntFlags->fErrorH100OutOfSync == TRUE ||
1120
f_pIntFlags->fErrorH100ClkA == TRUE ||
1121
f_pIntFlags->fErrorH100ClkB == TRUE ||
1122
f_pIntFlags->fErrorH100FrameA == TRUE ) &&
1123
pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT &&
1124
pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1126
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_WILL_TIMEOUT;
1127
pIntrptManage->ulErrorH100DisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
1128
pIntrptManage->ulErrorH100DisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
1130
/*-----------------------------------------------------------------------*/
1132
return cOCT6100_ERR_OK;
1137
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1139
Function: Oct6100ApiWriteIntrptRegs
1141
Description: Writes to interrupt registers to clear interrupt condition, and
1142
writes to an interrupt's IE register if interrupt is to time
1145
-------------------------------------------------------------------------------
1146
| Argument | Description
1147
-------------------------------------------------------------------------------
1148
f_pApiInstance Pointer to API instance. This memory is used to keep
1149
the present state of the chip and all its resources.
1151
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1152
#if !SKIP_Oct6100ApiWriteIntrptRegs
1153
UINT32 Oct6100ApiWriteIntrptRegs(
1154
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1156
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1157
tOCT6100_WRITE_PARAMS WriteParams;
1161
/* Get some local pointers. */
1162
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1164
/* Set some parameters of write struct. */
1165
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1167
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1171
/*===========================================================================*/
1172
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
1174
WriteParams.ulWriteAddress = 0x104;
1175
WriteParams.usWriteData = 0x0000;
1177
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1178
if ( ulResult != cOCT6100_ERR_OK )
1181
if ( (pIntrptManage->usRegister102h & cOCT6100_INTRPT_MASK_REG_102H) != 0 )
1183
WriteParams.ulWriteAddress = 0x102;
1184
WriteParams.usWriteData = pIntrptManage->usRegister102h;
1185
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1186
if ( ulResult != cOCT6100_ERR_OK )
1189
/*===========================================================================*/
1191
/*===========================================================================*/
1192
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ||
1193
pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
1195
WriteParams.ulWriteAddress = 0x204;
1196
WriteParams.usWriteData = 0x0000;
1198
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1199
WriteParams.usWriteData |= 0x1800;
1201
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1202
WriteParams.usWriteData |= 0x0401;
1204
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1205
if ( ulResult != cOCT6100_ERR_OK )
1208
if ( (pIntrptManage->usRegister202h & cOCT6100_INTRPT_MASK_REG_202H) != 0 )
1210
WriteParams.ulWriteAddress = 0x202;
1211
WriteParams.usWriteData = pIntrptManage->usRegister202h;
1212
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1213
if ( ulResult != cOCT6100_ERR_OK )
1216
/*===========================================================================*/
1218
/*===========================================================================*/
1219
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_WILL_TIMEOUT )
1221
WriteParams.ulWriteAddress = 0x304;
1222
WriteParams.usWriteData = 0x0000;
1224
if ( pIntrptManage->fMclkIntrptActive == TRUE )
1225
WriteParams.usWriteData |= 0x0001;
1227
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1228
if ( ulResult != cOCT6100_ERR_OK )
1231
if ( (pIntrptManage->usRegister302h & cOCT6100_INTRPT_MASK_REG_302H) != 0 )
1233
WriteParams.ulWriteAddress = 0x302;
1234
WriteParams.usWriteData = pIntrptManage->usRegister302h;
1235
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1236
if ( ulResult != cOCT6100_ERR_OK )
1239
/*===========================================================================*/
1241
/*===========================================================================*/
1242
if ( (pIntrptManage->usRegister502h & cOCT6100_INTRPT_MASK_REG_502H) != 0 )
1244
WriteParams.ulWriteAddress = 0x502;
1245
WriteParams.usWriteData = pIntrptManage->usRegister502h;
1246
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1247
if ( ulResult != cOCT6100_ERR_OK )
1250
/*===========================================================================*/
1252
/*===========================================================================*/
1253
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_WILL_TIMEOUT )
1255
WriteParams.ulWriteAddress = 0x704;
1256
WriteParams.usWriteData = 0x0000;
1258
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1259
if ( ulResult != cOCT6100_ERR_OK )
1262
if ( (pIntrptManage->usRegister702h & cOCT6100_INTRPT_MASK_REG_702H) != 0 )
1264
WriteParams.ulWriteAddress = 0x702;
1265
WriteParams.usWriteData = pIntrptManage->usRegister702h;
1266
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1267
if ( ulResult != cOCT6100_ERR_OK )
1270
/*===========================================================================*/
1274
return cOCT6100_ERR_OK;
1279
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1281
Function: Oct6100ApiWriteIeRegs
1283
Description: Writes the IE field of each interrupt register.
1285
-------------------------------------------------------------------------------
1286
| Argument | Description
1287
-------------------------------------------------------------------------------
1288
f_pApiInstance Pointer to API instance. This memory is used to keep
1289
the present state of the chip and all its resources.
1291
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1292
#if !SKIP_Oct6100ApiWriteIeRegs
1293
UINT32 Oct6100ApiWriteIeRegs(
1294
tPOCT6100_INSTANCE_API f_pApiInstance )
1296
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1297
tOCT6100_WRITE_PARAMS WriteParams;
1298
tOCT6100_READ_PARAMS ReadParams;
1301
/* Get some local pointers. */
1302
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1304
/* Set some parameters of write struct. */
1305
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1307
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1310
/* Set some parameters of read struct. */
1311
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1313
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1315
/*==================================================================================*/
1316
WriteParams.ulWriteAddress = 0x104;
1317
WriteParams.usWriteData = 0x0000;
1319
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1320
WriteParams.usWriteData |= 0x0001;
1322
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1323
if ( ulResult != cOCT6100_ERR_OK )
1325
/*==================================================================================*/
1327
/*==================================================================================*/
1328
WriteParams.ulWriteAddress = 0x204;
1329
WriteParams.usWriteData = 0x0000;
1331
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1332
WriteParams.usWriteData |= 0x1800;
1333
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1334
WriteParams.usWriteData |= 0x0401;
1336
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1337
if ( ulResult != cOCT6100_ERR_OK )
1339
/*==================================================================================*/
1341
/*==================================================================================*/
1342
WriteParams.ulWriteAddress = 0x304;
1343
WriteParams.usWriteData = 0x0000;
1345
if ( pIntrptManage->fMclkIntrptActive == TRUE )
1346
WriteParams.usWriteData |= 0x0001;
1347
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1349
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1350
WriteParams.usWriteData |= 0xD100;
1352
WriteParams.usWriteData |= 0x5100;
1355
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1356
if ( ulResult != cOCT6100_ERR_OK )
1358
/*==================================================================================*/
1360
/*==================================================================================*/
1361
WriteParams.ulWriteAddress = 0x504;
1362
WriteParams.usWriteData = 0x0000;
1364
if ( pIntrptManage->byFatalGeneralState == cOCT6100_INTRPT_ACTIVE )
1365
WriteParams.usWriteData |= 0x0002;
1367
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1368
if ( ulResult != cOCT6100_ERR_OK )
1370
/*==================================================================================*/
1372
/*==================================================================================*/
1373
WriteParams.ulWriteAddress = 0x704;
1374
WriteParams.usWriteData = 0x0000;
1376
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1377
WriteParams.usWriteData |= 0x0002;
1379
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1380
if ( ulResult != cOCT6100_ERR_OK )
1382
/*==================================================================================*/
1385
/*==================================================================================*/
1386
/* Enable the GLOBAL IEs for the interrupt pin. */
1387
WriteParams.ulWriteAddress = 0x218;
1388
WriteParams.usWriteData = 0x00D7;
1390
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1391
if ( ulResult != cOCT6100_ERR_OK )
1393
/*==================================================================================*/
1395
return cOCT6100_ERR_OK;
1400
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1402
Function: Oct6100ApiReadChipMclkTime
1404
Description: Reads the chip's mclk cycle count to construct a chip time.
1405
The time is used to manage interrupts.
1407
-------------------------------------------------------------------------------
1408
| Argument | Description
1409
-------------------------------------------------------------------------------
1410
f_pApiInstance Pointer to API instance. This memory is used to keep
1411
the present state of the chip and all its resources.
1413
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1414
#if !SKIP_Oct6100ApiReadChipMclkTime
1415
UINT32 Oct6100ApiReadChipMclkTime(
1416
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1418
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1419
tPOCT6100_SHARED_INFO pSharedInfo;
1420
tOCT6100_READ_PARAMS ReadParams;
1426
/* Get local pointer(s). */
1427
pSharedInfo = f_pApiInstance->pSharedInfo;
1428
pIntrptManage = &pSharedInfo->IntrptManage;
1430
/* Assign memory for read data. */
1431
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1433
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1434
ReadParams.pusReadData = &usReadData;
1436
/* Perform reads. */
1437
for ( i = 0; i < 100; i++ )
1439
ReadParams.ulReadAddress = 0x306;
1440
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1441
if ( ulResult != cOCT6100_ERR_OK )
1443
pIntrptManage->ulRegMclkTimeHigh = usReadData & 0xFF;
1444
ulCheckData = usReadData;
1446
ReadParams.ulReadAddress = 0x308;
1447
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1448
if ( ulResult != cOCT6100_ERR_OK )
1450
pIntrptManage->ulRegMclkTimeLow = (usReadData & 0xFFFF) << 16;
1452
ReadParams.ulReadAddress = 0x306;
1453
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1454
if ( ulResult != cOCT6100_ERR_OK )
1456
if ( ulCheckData == usReadData )
1461
return cOCT6100_ERR_FATAL_2F;
1463
return cOCT6100_ERR_OK;
1468
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1470
Function: Oct6100ApiUpdateIntrptTimeouts
1472
Description: Checks which interrupt groups have finished their timeout
1475
-------------------------------------------------------------------------------
1476
| Argument | Description
1477
-------------------------------------------------------------------------------
1478
f_pApiInstance Pointer to API instance. This memory is used to keep
1479
the present state of the chip and all its resources.
1481
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1482
#if !SKIP_Oct6100ApiUpdateIntrptTimeouts
1483
UINT32 Oct6100ApiUpdateIntrptTimeouts(
1484
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1486
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1487
tOCT6100_WRITE_PARAMS WriteParams;
1488
UINT32 ulRegMclkTimePlus5MsHigh;
1489
UINT32 ulRegMclkTimePlus5MsLow;
1491
BOOL fFatalMemoryChange = FALSE;
1492
BOOL fDataErrMemoryChange = FALSE;
1493
BOOL fErrorOverflowToneEventsChange = FALSE;
1494
BOOL fH100ErrorChange = FALSE;
1496
/* Get local pointer to interrupt management structure. */
1497
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
1499
/* Calculate mclk time + 5 ms. */
1500
ulRegMclkTimePlus5MsLow = pIntrptManage->ulRegMclkTimeLow + (5 * pIntrptManage->ulNumMclkCyclesIn1Ms);
1501
if ( ulRegMclkTimePlus5MsLow < pIntrptManage->ulRegMclkTimeLow )
1502
ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh + 1;
1503
else /* ( ulRegMclkTimePlus5MsLow >= pIntrptManage->ulRegMclkTimeLow ) */
1504
ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh;
1506
/* Check which interrupts are timed out and need to be reenabled now. */
1507
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
1509
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulFatalMemoryDisableMclkHigh, pIntrptManage->ulFatalMemoryDisableMclkLow, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptManage->byFatalMemoryState, fFatalMemoryChange )
1511
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
1513
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorMemoryDisableMclkHigh, pIntrptManage->ulErrorMemoryDisableMclkLow, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptManage->byErrorMemoryState, fDataErrMemoryChange )
1515
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_IN_TIMEOUT )
1517
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptManage->byErrorOverflowToneEventsState, fErrorOverflowToneEventsChange )
1519
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_IN_TIMEOUT )
1521
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorH100DisableMclkHigh, pIntrptManage->ulErrorH100DisableMclkLow, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptManage->byErrorH100State, fH100ErrorChange )
1524
/* Set some parameters of write struct. */
1525
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1527
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1529
/* Write to the IE registers which have changed. */
1531
/*==================================================================================*/
1532
if ( fFatalMemoryChange == TRUE )
1534
WriteParams.ulWriteAddress = 0x104;
1535
WriteParams.usWriteData = 0x0000;
1537
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1538
WriteParams.usWriteData |= 0x0001;
1540
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1541
if ( ulResult != cOCT6100_ERR_OK )
1545
/*==================================================================================*/
1547
/*==================================================================================*/
1548
if ( fFatalMemoryChange == TRUE ||
1549
fDataErrMemoryChange == TRUE )
1551
WriteParams.ulWriteAddress = 0x204;
1552
WriteParams.usWriteData = 0x0000;
1554
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
1555
WriteParams.usWriteData |= 0x1800;
1556
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
1557
WriteParams.usWriteData |= 0x0401;
1559
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1560
if ( ulResult != cOCT6100_ERR_OK )
1564
/*==================================================================================*/
1566
/*==================================================================================*/
1567
if ( pIntrptManage->fMclkIntrptActive == TRUE ||
1568
fH100ErrorChange == TRUE )
1570
WriteParams.ulWriteAddress = 0x304;
1571
WriteParams.usWriteData = 0x0000;
1573
if ( pIntrptManage->fMclkIntrptActive == TRUE )
1574
WriteParams.usWriteData |= 0x0001;
1576
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1578
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1579
WriteParams.usWriteData |= 0xD100;
1581
WriteParams.usWriteData |= 0x5100;
1584
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1585
if ( ulResult != cOCT6100_ERR_OK )
1589
/*==================================================================================*/
1592
/*==================================================================================*/
1593
if ( fErrorOverflowToneEventsChange == TRUE )
1595
WriteParams.ulWriteAddress = 0x704;
1596
WriteParams.usWriteData = 0x0000;
1598
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
1599
WriteParams.usWriteData |= 0x0002;
1601
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1602
if ( ulResult != cOCT6100_ERR_OK )
1606
/*==================================================================================*/
1608
return cOCT6100_ERR_OK;
1613
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1615
Function: Oct6100ApiScheduleNextMclkIntrptSer
1617
Description: Serialized sub-function of Oct6100ApiScheduleNextMclkIntrpt.
1619
-------------------------------------------------------------------------------
1620
| Argument | Description
1621
-------------------------------------------------------------------------------
1622
f_pApiInstance Pointer to API instance. This memory is used to keep
1623
the present state of the chip and all its resources.
1625
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1626
#if !SKIP_Oct6100ApiScheduleNextMclkIntrptSer
1627
UINT32 Oct6100ApiScheduleNextMclkIntrptSer(
1628
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1630
tPOCT6100_SHARED_INFO pSharedInfo;
1631
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
1632
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
1633
tOCT6100_WRITE_PARAMS WriteParams;
1635
UINT32 ulRegMclkTimeHigh;
1636
UINT32 ulRegMclkTimeLow;
1638
BOOL fConditionFlag = TRUE;
1640
/* Get local pointer(s). */
1641
pSharedInfo = f_pApiInstance->pSharedInfo;
1643
/* Obtain temporary pointers to reduce indirection, thus speeding up processing. */
1644
pIntrptConfig = &pSharedInfo->IntrptConfig;
1645
pIntrptManage = &pSharedInfo->IntrptManage;
1646
ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
1647
ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
1649
/* First, check if any interrupts have just been disabled. If there are any, */
1650
/* determine the time at which they should be reenabled. */
1651
pIntrptManage->ulNextMclkIntrptTimeHigh = cOCT6100_INVALID_VALUE;
1652
pIntrptManage->ulNextMclkIntrptTimeLow = cOCT6100_INVALID_VALUE;
1654
while ( fConditionFlag )
1656
/* Indicate that no mclk interrupt is needed, yet. */
1657
ulTimeDiff = cOCT6100_INVALID_VALUE;
1659
/* Check each interrupt category to see if an mclk interrupt is needed to */
1660
/* reenable an interrupt at a later time. */
1661
if ( pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_ACTIVE &&
1662
pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_DISABLED )
1664
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byFatalMemoryState, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptConfig->ulFatalMemoryTimeoutMclk, ulTimeDiff )
1666
if ( pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_ACTIVE &&
1667
pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
1669
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorMemoryState, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptConfig->ulErrorMemoryTimeoutMclk, ulTimeDiff )
1671
if ( pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_ACTIVE &&
1672
pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
1674
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorOverflowToneEventsState, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk, ulTimeDiff )
1676
if ( pIntrptManage->byErrorH100State != cOCT6100_INTRPT_ACTIVE &&
1677
pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
1679
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorH100State, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptConfig->ulErrorH100TimeoutMclk, ulTimeDiff )
1682
/* Set some parameters of write struct. */
1683
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1685
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
1687
/* Schedule next mclk interrupt, if any is needed. */
1688
if ( ulTimeDiff != cOCT6100_INVALID_VALUE )
1690
UINT32 ulMclkTimeTest;
1691
UINT32 ulAlarmTimeTest;
1692
UINT32 ulTimeDiffTest;
1693
BOOL fAlarmTimePassed;
1695
/* Indicate that an mclk interrupt is scheduled.*/
1696
pIntrptManage->fMclkIntrptActive = TRUE;
1698
pIntrptManage->ulNextMclkIntrptTimeLow = ulRegMclkTimeLow + ulTimeDiff;
1699
if ( pIntrptManage->ulNextMclkIntrptTimeLow < ulRegMclkTimeLow )
1700
pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh + 1;
1701
else /* ( pIntrptManage->ulNextMclkIntrptTimeLow >= ulRegMclkTimeLow ) */
1702
pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh;
1704
WriteParams.ulWriteAddress = 0x30C;
1705
WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 24) & 0xFF );
1706
WriteParams.usWriteData |= (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeHigh & 0xFF) << 8 );
1707
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1708
if ( ulResult != cOCT6100_ERR_OK )
1711
WriteParams.ulWriteAddress = 0x30E;
1712
WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 8) & 0xFFFF );
1713
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1714
if ( ulResult != cOCT6100_ERR_OK )
1717
WriteParams.ulWriteAddress = 0x304;
1718
WriteParams.usWriteData = 0;
1720
if ( pIntrptManage->fMclkIntrptActive == TRUE )
1721
WriteParams.usWriteData = 0x0001;
1723
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1725
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1726
WriteParams.usWriteData |= 0xD100;
1728
WriteParams.usWriteData |= 0x5100;
1731
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1732
if ( ulResult != cOCT6100_ERR_OK )
1735
/* Disable the ROL if previously set. */
1736
WriteParams.ulWriteAddress = 0x302;
1737
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1738
if ( ulResult != cOCT6100_ERR_OK )
1741
/* Check if already passed the next interrupt time. */
1742
ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
1743
if ( ulResult != cOCT6100_ERR_OK )
1746
ulMclkTimeTest = (pIntrptManage->ulRegMclkTimeLow >> 16) & 0xFFFF;
1747
ulAlarmTimeTest = (pIntrptManage->ulNextMclkIntrptTimeLow >> 16) & 0xFFFF;
1749
/* Update the local Mlck timer values.*/
1750
ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
1751
ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
1753
fAlarmTimePassed = FALSE;
1755
if ( ulMclkTimeTest > ulAlarmTimeTest )
1757
ulTimeDiffTest = ulMclkTimeTest - ulAlarmTimeTest;
1758
if ( ulTimeDiffTest <= 0x8000 )
1759
fAlarmTimePassed = TRUE;
1761
else /* ( ulMclkTimeTest <= ulAlarmTimeTest ) */
1763
ulTimeDiffTest = ulAlarmTimeTest - ulMclkTimeTest;
1764
if ( ulTimeDiffTest > 0x8000 )
1765
fAlarmTimePassed = TRUE;
1768
if ( fAlarmTimePassed == TRUE )
1770
/* Passed the interrupt time. Schedule next interrupt (if needed). */
1771
ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
1772
if ( ulResult != cOCT6100_ERR_OK )
1779
fConditionFlag = FALSE;
1784
/* Indicate that no mclk interrupt is scheduled. */
1785
pIntrptManage->fMclkIntrptActive = FALSE;
1787
/* Insure that the mclk interrupt is not enabled. */
1788
WriteParams.ulWriteAddress = 0x304;
1789
WriteParams.usWriteData = 0x0000;
1790
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
1792
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1793
WriteParams.usWriteData |= 0xD100;
1795
WriteParams.usWriteData |= 0x5100;
1797
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
1798
if ( ulResult != cOCT6100_ERR_OK )
1801
fConditionFlag = FALSE;
1805
return cOCT6100_ERR_OK;
1810
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1812
Function: Oct6100ApiCheckProcessorState
1814
Description: This function verifies if the NLP and AF processors are operating
1817
-------------------------------------------------------------------------------
1818
| Argument | Description
1819
-------------------------------------------------------------------------------
1820
f_pApiInstance Pointer to API instance. This memory is used to keep
1821
the present state of the chip and all its resources.
1823
f_pIntFlags Pointer to a tOCT6100_INTERRUPT_FLAGS structure.
1825
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1826
#if !SKIP_Oct6100ApiCheckProcessorState
1827
UINT32 Oct6100ApiCheckProcessorState(
1828
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1829
IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
1831
tPOCT6100_SHARED_INFO pSharedInfo;
1832
tOCT6100_READ_PARAMS ReadParams;
1833
tOCT6100_READ_BURST_PARAMS ReadBurstParams;
1835
UINT32 ulNlpTimestamp;
1836
UINT32 ulAfTimestamp;
1837
UINT32 ulTimestampDiff;
1843
UINT16 ausReadData[ 2 ];
1845
UINT32 aulWaitTime[ 2 ];
1847
/* Get local pointer(s). */
1848
pSharedInfo = f_pApiInstance->pSharedInfo;
1850
/* Set some parameters of write struct. */
1851
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
1853
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1854
ReadParams.pusReadData = &usReadData;
1856
/* Set some parameters of write struct. */
1857
ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
1859
ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1860
ReadBurstParams.pusReadData = ausReadData;
1862
/*-----------------------------------------------------------------------*/
1863
/* Check if chip is in reset. */
1865
/* Read the main control register. */
1866
ReadParams.ulReadAddress = 0x100;
1868
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1869
if ( ulResult != cOCT6100_ERR_OK )
1872
if ( usReadData == 0x0000 )
1874
/* Chip was resetted. */
1875
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_4;
1876
f_pIntFlags->fFatalGeneral = TRUE;
1877
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
1880
/*-----------------------------------------------------------------------*/
1883
/*-----------------------------------------------------------------------*/
1884
/* Reading the AF timestamp.*/
1886
for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
1888
/* Read the timestamp.*/
1889
ReadBurstParams.ulReadAddress = 0x082E0008;
1890
ReadBurstParams.ulReadLength = 2;
1892
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1893
if ( ulResult != cOCT6100_ERR_OK )
1896
/* Read the high part again to make sure it didn't wrap. */
1897
ReadParams.ulReadAddress = 0x082E0008;
1899
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1900
if ( ulResult != cOCT6100_ERR_OK )
1903
/* Check if the low part wrapped. */
1904
if ( ausReadData[ 0 ] == usReadData )
1908
if ( i == cOCT6100_MAX_LOOP )
1909
return cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT;
1911
/* Save the AF timestamp. */
1912
ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1914
/*-----------------------------------------------------------------------*/
1917
/*-----------------------------------------------------------------------*/
1918
/* Reading the NLP timestamp. */
1920
for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
1922
/* Read the timestamp. */
1923
ReadBurstParams.ulReadAddress = 0x08000008;
1924
ReadBurstParams.ulReadLength = 2;
1926
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1927
if ( ulResult != cOCT6100_ERR_OK )
1930
/* Read the high part again to make sure it didn't wrap. */
1931
ReadParams.ulReadAddress = 0x08000008;
1933
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
1934
if ( ulResult != cOCT6100_ERR_OK )
1937
/* Check if the low part wrapped. */
1938
if ( ausReadData[ 0 ] == usReadData )
1942
if ( i == cOCT6100_MAX_LOOP )
1943
return cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT;
1945
/* Save the NLP timestamp. */
1946
ulNlpTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1948
/*-----------------------------------------------------------------------*/
1951
/*-----------------------------------------------------------------------*/
1952
/* Check the validity of the timestamp. */
1954
if ( ulAfTimestamp > ulNlpTimestamp )
1956
/* The NLP timestamp wrapped. */
1957
ulTimestampDiff = 0xFFFFFFFF - ulAfTimestamp + 1;
1958
ulTimestampDiff += ulNlpTimestamp;
1961
ulTimestampDiff = ulNlpTimestamp - ulAfTimestamp;
1963
if ( ulTimestampDiff > 0x2000 )
1965
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_5;
1966
f_pIntFlags->fFatalGeneral = TRUE;
1967
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
1970
/*Check if AF and NLP are both stuck*/
1971
if ( f_pIntFlags->fErrorH100ClkA == FALSE &&
1972
f_pIntFlags->fErrorH100ClkB == FALSE &&
1973
f_pIntFlags->fErrorH100FrameA == FALSE &&
1974
f_pIntFlags->fErrorH100OutOfSync == FALSE )
1977
if ( ulAfTimestamp == 0 && ulNlpTimestamp == 0 )
1979
/*Give some time to the counters*/
1980
aulWaitTime[ 0 ] = 250;
1981
aulWaitTime[ 1 ] = 0;
1982
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
1983
if ( ulResult != cOCT6100_ERR_OK )
1986
/*Let's read again the AF timestamp to be sure. Maybe they were at 0 at the same time*/
1987
ReadBurstParams.ulReadAddress = 0x082E0008;
1988
ReadBurstParams.ulReadLength = 2;
1990
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
1991
if ( ulResult != cOCT6100_ERR_OK )
1994
ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
1996
if ( ulAfTimestamp == 0 )
1998
/*TDM Clocks are ok but NLP and AF timestamps are both at 0*/
1999
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_9;
2000
f_pIntFlags->fFatalGeneral = TRUE;
2001
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
2007
/*-----------------------------------------------------------------------*/
2009
return cOCT6100_ERR_OK;