Debian Codegraph @

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

raw
1 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2
3 File: oct6100_chip_open.c
4
5 Copyright (c) 2001-2007 Octasic Inc.
6
7 Description:
8
9 This file contains the functions used to power-up the chip according to the
10 user's configuration. Also, the API instance is initialized to reflect the
11 desired configuration.
12
13 This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is
14 free software; you can redistribute it and/or modify it under the terms of
15 the GNU General Public License as published by the Free Software Foundation;
16 either version 2 of the License, or (at your option) any later version.
17
18 The OCT6100 GPL API is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with the OCT6100 GPL API; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26
27 $Octasic_Release: OCT612xAPI-01.00-PR49 $
28
29 $Octasic_Revision: 347 $
30
31 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
32
33
34 /***************************** INCLUDE FILES *******************************/
35
36 #if defined(__FreeBSD__)
37 #include <sys/types.h>
38 #include <dahdi/compat/bsd.h>
39 #else
40 #ifndef __KERNEL__
41 #include <stdlib.h>
42 #define kmalloc(size, type) malloc(size)
43 #define kfree(ptr) free(ptr)
44 #define GFP_ATOMIC 0 /*Dummy */
45 #else
46 #include <linux/slab.h>
47 #include <linux/kernel.h>
48 #endif
49 #endif
50
51 #include "octdef.h"
52
53 #include "oct6100api/oct6100_defines.h"
54 #include "oct6100api/oct6100_errors.h"
55
56 #include "apilib/octapi_bt0.h"
57 #include "apilib/octapi_llman.h"
58
59 #include "oct6100api/oct6100_apiud.h"
60 #include "oct6100api/oct6100_chip_stats_inst.h"
61 #include "oct6100api/oct6100_tsi_cnct_inst.h"
62 #include "oct6100api/oct6100_events_inst.h"
63 #include "oct6100api/oct6100_conf_bridge_inst.h"
64 #include "oct6100api/oct6100_playout_buf_inst.h"
65
66 #include "oct6100api/oct6100_mixer_inst.h"
67 #include "oct6100api/oct6100_channel_inst.h"
68 #include "oct6100api/oct6100_adpcm_chan_inst.h"
69 #include "oct6100api/oct6100_phasing_tsst_inst.h"
70 #include "oct6100api/oct6100_interrupts_inst.h"
71 #include "oct6100api/oct6100_remote_debug_inst.h"
72 #include "oct6100api/oct6100_debug_inst.h"
73 #include "oct6100api/oct6100_tlv_inst.h"
74 #include "oct6100api/oct6100_chip_open_inst.h"
75 #include "oct6100api/oct6100_api_inst.h"
76
77 #include "oct6100api/oct6100_chip_stats_pub.h"
78 #include "oct6100api/oct6100_interrupts_pub.h"
79 #include "oct6100api/oct6100_tsi_cnct_pub.h"
80 #include "oct6100api/oct6100_events_pub.h"
81 #include "oct6100api/oct6100_conf_bridge_pub.h"
82 #include "oct6100api/oct6100_playout_buf_pub.h"
83
84 #include "oct6100api/oct6100_channel_pub.h"
85 #include "oct6100api/oct6100_adpcm_chan_pub.h"
86 #include "oct6100api/oct6100_phasing_tsst_pub.h"
87 #include "oct6100api/oct6100_remote_debug_pub.h"
88 #include "oct6100api/oct6100_chip_open_pub.h"
89 #include "oct6100api/oct6100_mixer_pub.h"
90 #include "oct6100api/oct6100_channel_pub.h"
91 #include "oct6100api/oct6100_debug_pub.h"
92
93 #include "oct6100_chip_open_priv.h"
94 #include "oct6100_interrupts_priv.h"
95 #include "oct6100_chip_stats_priv.h"
96 #include "octrpc/rpc_protocol.h"
97 #include "oct6100_remote_debug_priv.h"
98 #include "oct6100_miscellaneous_priv.h"
99 #include "oct6100_memory_priv.h"
100 #include "oct6100_tsst_priv.h"
101 #include "oct6100_tsi_cnct_priv.h"
102 #include "oct6100_mixer_priv.h"
103 #include "oct6100_events_priv.h"
104 #include "oct6100_conf_bridge_priv.h"
105 #include "oct6100_playout_buf_priv.h"
106
107 #include "oct6100_channel_priv.h"
108 #include "oct6100_adpcm_chan_priv.h"
109 #include "oct6100_phasing_tsst_priv.h"
110 #include "oct6100_tlv_priv.h"
111 #include "oct6100_debug_priv.h"
112 #include "oct6100_version.h"
113
114
115 /**************************** PUBLIC FUNCTIONS *****************************/
116
117
118 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
119
120 Function: Oct6100GetInstanceSizeDef
121
122 Description: Retrieves the size of the required API instance structure.
123
124 -------------------------------------------------------------------------------
125 | Argument | Description
126 -------------------------------------------------------------------------------
127 f_pApiInstance Pointer to API instance. This memory is used to keep the
128 present state of the chip and all its resources.
129
130 f_pGetSize Structure containing API instance size.
131
132 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
133 #if !SKIP_Oct6100GetInstanceSizeDef
134 UINT32 Oct6100GetInstanceSizeDef(
135 tPOCT6100_GET_INSTANCE_SIZE f_pGetSize )
136 {
137 return cOCT6100_ERR_OK;
138 }
139 #endif
140
141 #if !SKIP_Oct6100GetInstanceSize
142 UINT32 Oct6100GetInstanceSize(
143 tPOCT6100_CHIP_OPEN f_pChipOpen,
144 tPOCT6100_GET_INSTANCE_SIZE f_pGetSize )
145 {
146 tOCT6100_API_INSTANCE_SIZES InstanceSizes;
147 UINT32 ulResult;
148
149 /* Check user configuration for errors and conflicts. */
150 ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen );
151 if ( ulResult != cOCT6100_ERR_OK )
152 return ulResult;
153
154 /* Calculate the instance size required for user's configuration. */
155 ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes );
156 if ( ulResult != cOCT6100_ERR_OK )
157 return ulResult;
158
159 /* Return required size to user. */
160 f_pGetSize->ulApiInstanceSize = InstanceSizes.ulApiInstTotal;
161
162 return cOCT6100_ERR_OK;
163 }
164 #endif
165
166
167 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
168
169 Function: Oct6100ChipOpenDef
170
171 Description: Inserts default chip configuration parameters into the
172 structure pointed to by f_pChipOpen.
173
174 -------------------------------------------------------------------------------
175 | Argument | Description
176 -------------------------------------------------------------------------------
177
178 f_pChipOpen Structure containing user chip configuration.
179
180 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
181 #if !SKIP_Oct6100ChipOpenDef
182 UINT32 Oct6100ChipOpenDef(
183 tPOCT6100_CHIP_OPEN f_pChipOpen )
184 {
185 UINT32 i;
186
187 f_pChipOpen->ulUserChipId = 0;
188 f_pChipOpen->fMultiProcessSystem = FALSE;
189 f_pChipOpen->pProcessContext = NULL;
190
191 f_pChipOpen->ulMaxRwAccesses = 8;
192
193 f_pChipOpen->pbyImageFile = NULL;
194 f_pChipOpen->ulImageSize = 0;
195
196 f_pChipOpen->ulMemClkFreq = 133000000; /* 133 Mhz */
197 f_pChipOpen->ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ; /* 33.33 Mhz */
198 f_pChipOpen->fEnableMemClkOut = TRUE;
199
200 f_pChipOpen->ulMemoryType = cOCT6100_MEM_TYPE_DDR;
201 f_pChipOpen->ulNumMemoryChips = 1;
202 f_pChipOpen->ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_64MB;
203
204 /* Set the tail displacement to zero. */
205 f_pChipOpen->ulTailDisplacement = 0;
206
207 /* Disable acoustic echo by default. */
208 f_pChipOpen->fEnableAcousticEcho = FALSE;
209
210 /* Resource allocation parameters. */
211 f_pChipOpen->ulMaxChannels = 256;
212 f_pChipOpen->ulMaxTsiCncts = 0;
213 f_pChipOpen->ulMaxBiDirChannels = 0;
214 f_pChipOpen->ulMaxConfBridges = 0;
215 f_pChipOpen->ulMaxFlexibleConfParticipants = 0;
216 f_pChipOpen->ulMaxPlayoutBuffers = 0;
217
218 f_pChipOpen->ulMaxPhasingTssts = 0;
219 f_pChipOpen->ulMaxAdpcmChannels = 0;
220 f_pChipOpen->ulMaxTdmStreams = 32;
221 f_pChipOpen->fUseSynchTimestamp = FALSE;
222 for ( i = 0; i < 4; i++ )
223 {
224 f_pChipOpen->aulTimestampTimeslots[ i ] = cOCT6100_INVALID_TIMESLOT;
225 f_pChipOpen->aulTimestampStreams[ i ] = cOCT6100_INVALID_STREAM;
226 }
227 f_pChipOpen->fEnableFastH100Mode = FALSE;
228
229 /* Configure the soft tone event buffer. */
230 f_pChipOpen->ulSoftToneEventsBufSize = 128;
231 f_pChipOpen->fEnableExtToneDetection = FALSE;
232 f_pChipOpen->fEnable2100StopEvent = FALSE;
233
234 /* Configure the soft playout event buffer. */
235 f_pChipOpen->ulSoftBufferPlayoutEventsBufSize = cOCT6100_INVALID_VALUE;
236
237 /* Interrupt configuration. */
238 f_pChipOpen->ulInterruptPolarity = cOCT6100_ACTIVE_LOW_POLARITY;
239
240 f_pChipOpen->InterruptConfig.ulErrorMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
241 f_pChipOpen->InterruptConfig.ulFatalGeneralConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
242 f_pChipOpen->InterruptConfig.ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
243 f_pChipOpen->InterruptConfig.ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
244 f_pChipOpen->InterruptConfig.ulErrorH100Config = cOCT6100_INTERRUPT_NO_TIMEOUT;
245 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
246
247 f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout = 100;
248 f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout = 100;
249 f_pChipOpen->InterruptConfig.ulErrorH100Timeout = 100;
250 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout = 100;
251 f_pChipOpen->ulMaxRemoteDebugSessions = 0;
252 f_pChipOpen->ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_3_QUARTERS;
253 for ( i = 0; i < cOCT6100_TDM_STREAM_MAX_GROUPS; i++ )
254 f_pChipOpen->aulTdmStreamFreqs[ i ] = cOCT6100_TDM_STREAM_FREQ_8MHZ;
255
256
257
258 f_pChipOpen->fEnableChannelRecording = FALSE;
259 f_pChipOpen->fEnableProductionBist = FALSE;
260 f_pChipOpen->ulProductionBistMode = cOCT6100_PRODUCTION_BIST_STANDARD;
261 f_pChipOpen->ulNumProductionBistLoops = 1;
262
263 return cOCT6100_ERR_OK;
264 }
265 #endif
266
267
268 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
269
270 Function: Oct6100ChipOpen
271
272 Description: Configures the chip according to the user specified
273 configuration f_pChipOpen. This function will perform all I/O
274 accesses necessary and initialize the API instance to reflect
275 the configuration.
276
277 -------------------------------------------------------------------------------
278 | Argument | Description
279 -------------------------------------------------------------------------------
280 f_pApiInstance Pointer to API instance. This memory is used to keep the
281 present state of the chip and all its resources.
282
283 f_pChipOpen Structure containing user chip configuration.
284
285 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
286 #if !SKIP_Oct6100ChipOpen
287 UINT32 Oct6100ChipOpen(
288 tPOCT6100_INSTANCE_API f_pApiInstance,
289 tPOCT6100_CHIP_OPEN f_pChipOpen )
290 {
291 tOCT6100_API_INSTANCE_SIZES *InstanceSizes;
292 UINT32 ulStructSize;
293 UINT32 ulResult;
294 UINT32 ulTempVar;
295
296 /* Check user chip configuration parameters for errors. */
297 ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen );
298 if ( ulResult != cOCT6100_ERR_OK )
299 return ulResult;
300
301 /* Check if the host system is multi-process or not and adjust instance accordingly. */
302 if ( f_pChipOpen->fMultiProcessSystem != TRUE )
303 {
304 /* Set pointer to tOCT6100_SHARED_INFO structure within instance. */
305 ulStructSize = sizeof( tOCT6100_INSTANCE_API );
306 mOCT6100_ROUND_MEMORY_SIZE( ulStructSize, ulTempVar )
307
308 f_pApiInstance->pSharedInfo = ( tPOCT6100_SHARED_INFO )(( PUINT8 )f_pApiInstance + ulStructSize);
309
310 /* Save the process context specified by the user. */
311 f_pApiInstance->pProcessContext = f_pChipOpen->pProcessContext;
312
313 /* Create serialization object handles. */
314 ulResult = Oct6100ApiCreateSerializeObjects( f_pApiInstance, f_pChipOpen->ulUserChipId );
315 if ( ulResult != cOCT6100_ERR_OK )
316 return ulResult;
317 }
318
319 /* Copy the configuration structure. */
320 ulResult = Oct6100ApiCopyChipConfiguration( f_pApiInstance, f_pChipOpen );
321 if ( ulResult != cOCT6100_ERR_OK )
322 return ulResult;
323
324 /* Perform various calculations based on user chip configuration. */
325 ulResult = Oct6100ApiInitializeMiscellaneousVariables( f_pApiInstance );
326 if ( ulResult != cOCT6100_ERR_OK )
327 return ulResult;
328
329 InstanceSizes = kmalloc(sizeof(tOCT6100_API_INSTANCE_SIZES), GFP_ATOMIC);
330 if (!InstanceSizes)
331 return cOCT6100_ERR_FATAL_0;
332
333 /* Calculate the amount of memory needed for the API instance structure. */
334 ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, InstanceSizes );
335 if ( ulResult != cOCT6100_ERR_OK ) {
336 kfree(InstanceSizes);
337 return ulResult;
338 }
339
340 /* Allocate the memory for the API instance structure internal pointers. */
341 ulResult = Oct6100ApiAllocateInstanceMemory( f_pApiInstance, InstanceSizes );
342 kfree(InstanceSizes);
343
344 if ( ulResult != cOCT6100_ERR_OK )
345 return ulResult;
346
347 /* Initialize the allocated instance structure memory. */
348 ulResult = Oct6100ApiInitializeInstanceMemory( f_pApiInstance );
349 if ( ulResult != cOCT6100_ERR_OK )
350 return ulResult;
351
352 /* Initialize the tone information structure. */
353 ulResult = Oct6100ApiInitToneInfo( f_pApiInstance );
354 if ( ulResult != cOCT6100_ERR_OK )
355 return ulResult;
356
357 /* Test the CPU registers. */
358 ulResult = Oct6100ApiCpuRegisterBist( f_pApiInstance );
359 if ( ulResult != cOCT6100_ERR_OK )
360 return ulResult;
361
362 /* Boot the FC2 PLL. */
363 ulResult = Oct6100ApiBootFc2Pll( f_pApiInstance );
364 if ( ulResult != cOCT6100_ERR_OK )
365 return ulResult;
366
367 /* Program the FC1 PLL. */
368 ulResult = Oct6100ApiProgramFc1Pll( f_pApiInstance );
369 if ( ulResult != cOCT6100_ERR_OK )
370 return ulResult;
371
372 /* Decode the key and bist internal memories. */
373 ulResult = Oct6100ApiDecodeKeyAndBist( f_pApiInstance );
374 if ( ulResult != cOCT6100_ERR_OK )
375 return ulResult;
376
377 /* Boot the FC1 PLL. */
378 ulResult = Oct6100ApiBootFc1Pll( f_pApiInstance );
379 if ( ulResult != cOCT6100_ERR_OK )
380 return ulResult;
381
382 /* Boot the SDRAM. */
383 ulResult = Oct6100ApiBootSdram( f_pApiInstance );
384 if ( ulResult != cOCT6100_ERR_OK )
385 return ulResult;
386
387 /* Bist the external memory. */
388 ulResult = Oct6100ApiExternalMemoryBist( f_pApiInstance );
389 if ( ulResult != cOCT6100_ERR_OK )
390 return ulResult;
391
392 /* Initialize the external memory. */
393 ulResult = Oct6100ApiExternalMemoryInit( f_pApiInstance );
394 if ( ulResult != cOCT6100_ERR_OK )
395 return ulResult;
396
397 /* Load the image into the chip. */
398 ulResult = Oct6100ApiLoadImage( f_pApiInstance );
399 if ( ulResult != cOCT6100_ERR_OK )
400 return ulResult;
401
402 /* Write the clock distribution registers. */
403 ulResult = Oct6100ApiEnableClocks( f_pApiInstance );
404 if ( ulResult != cOCT6100_ERR_OK )
405 return ulResult;
406
407 /* Program the NLP processor. */
408 ulResult = Oct6100ApiProgramNLP( f_pApiInstance );
409 if ( ulResult != cOCT6100_ERR_OK )
410 {
411 if ( ulResult == cOCT6100_ERR_OPEN_EGO_TIMEOUT )
412 ulResult = Oct6100ApiProgramNLP( f_pApiInstance );
413 }
414 if ( ulResult != cOCT6100_ERR_OK )
415 return ulResult;
416
417 if ( f_pChipOpen->fEnableProductionBist == FALSE )
418 {
419 /* Read all TLV fields present in external memory. */
420 ulResult = Oct6100ApiProcessTlvRegion( f_pApiInstance );
421 if ( ulResult != cOCT6100_ERR_OK )
422 return ulResult;
423
424 /* Configure the H.100 interface. */
425 ulResult = Oct6100ApiSetH100Register( f_pApiInstance );
426 if ( ulResult != cOCT6100_ERR_OK )
427 return ulResult;
428 }
429
430 /* Write miscellaneous registers. */
431 ulResult = Oct6100ApiWriteMiscellaneousRegisters( f_pApiInstance );
432 if ( ulResult != cOCT6100_ERR_OK )
433 return ulResult;
434
435 /* Proceed with the rest only if the production BIST has not been requested. */
436 if ( f_pChipOpen->fEnableProductionBist == FALSE )
437 {
438 /* Initialize the errors counters. */
439 ulResult = Oct6100ApiChipStatsSwInit( f_pApiInstance );
440 if ( ulResult != cOCT6100_ERR_OK )
441 return ulResult;
442
443 /* Get revision number of chip. */
444 ulResult = Oct6100ApiGetChipRevisionNum( f_pApiInstance );
445 if ( ulResult != cOCT6100_ERR_OK )
446 return ulResult;
447
448
449
450
451
452 /* Initialize the channels. */
453 ulResult = Oct6100ApiInitChannels( f_pApiInstance );
454 if ( ulResult != cOCT6100_ERR_OK )
455 return ulResult;
456
457 /* Initialize the mixer memory. */
458 ulResult = Oct6100ApiInitMixer( f_pApiInstance );
459 if ( ulResult != cOCT6100_ERR_OK )
460 return ulResult;
461
462 /* Initialize the mixer memory. */
463 ulResult = Oct6100ApiInitRecordResources( f_pApiInstance );
464 if ( ulResult != cOCT6100_ERR_OK )
465 return ulResult;
466
467 /* Initialize free external memory for buffer playout. */
468 ulResult = Oct6100ApiBufferPlayoutMemorySwInit( f_pApiInstance );
469 if ( ulResult != cOCT6100_ERR_OK )
470 return ulResult;
471
472
473
474
475 /*Clear all interrupts that could have occured during startup*/
476 ulResult = Oct6100ApiClearInterrupts( f_pApiInstance );
477 if ( ulResult != cOCT6100_ERR_OK )
478 return ulResult;
479
480 /* Configure the interrupt registers. */
481 ulResult = Oct6100ApiIsrHwInit( f_pApiInstance, &f_pChipOpen->InterruptConfig );
482 if ( ulResult != cOCT6100_ERR_OK )
483 return ulResult;
484 }
485
486 return cOCT6100_ERR_OK;
487 }
488 #endif
489
490
491 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
492
493 Function: Oct6100ChipCloseDef
494
495 Description: Puts the chip into soft reset.
496
497 -------------------------------------------------------------------------------
498 | Argument | Description
499 -------------------------------------------------------------------------------
500 f_pApiInstance Pointer to API instance. This memory is used to keep the
501 present state of the chip and all its resources.
502
503 f_pChipClose Pointer to a tOCT6100_CHIP_CLOSE structure.
504
505 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
506 #if !SKIP_Oct6100ChipCloseDef
507 UINT32 Oct6100ChipCloseDef(
508 tPOCT6100_CHIP_CLOSE f_pChipClose )
509 {
510 f_pChipClose->ulDummyVariable = 0;
511
512 return cOCT6100_ERR_OK;
513 }
514 #endif
515
516 #if !SKIP_Oct6100ChipClose
517 UINT32 Oct6100ChipClose(
518 tPOCT6100_INSTANCE_API f_pApiInstance,
519 tPOCT6100_CHIP_CLOSE f_pChipClose )
520 {
521 tOCT6100_WRITE_PARAMS WriteParams;
522 UINT32 ulResult;
523
524 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
525
526 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
527 WriteParams.ulWriteAddress = 0x100;
528 WriteParams.usWriteData = 0x0000;
529 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
530 if ( ulResult != cOCT6100_ERR_OK )
531 return ulResult;
532
533 /* Destroy the allocated ressources used for serialization. */
534 ulResult = Oct6100ApiDestroySerializeObjects( f_pApiInstance );
535 if ( ulResult != cOCT6100_ERR_OK )
536 return ulResult;
537
538 return cOCT6100_ERR_OK;
539 }
540 #endif
541
542
543 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
544
545 Function: Oct6100CreateLocalInstance
546
547 Description: Creates a local instance for a process in a multi-process
548 host system.
549
550 -------------------------------------------------------------------------------
551 | Argument | Description
552 -------------------------------------------------------------------------------
553 f_pCreateLocal Structure used to create process' local instance.
554
555 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
556 #if !SKIP_Oct6100CreateLocalInstanceDef
557 UINT32 Oct6100CreateLocalInstanceDef(
558 tPOCT6100_CREATE_LOCAL_INSTANCE f_pCreateLocal )
559 {
560 f_pCreateLocal->pApiInstShared = NULL;
561 f_pCreateLocal->pApiInstLocal = NULL;
562 f_pCreateLocal->pProcessContext = NULL;
563 f_pCreateLocal->ulUserChipId = 0;
564
565 return cOCT6100_ERR_OK;
566 }
567 #endif
568
569
570 #if !SKIP_Oct6100CreateLocalInstance
571 UINT32 Oct6100CreateLocalInstance(
572 tPOCT6100_CREATE_LOCAL_INSTANCE f_pCreateLocal )
573 {
574 tPOCT6100_INSTANCE_API pApiInstLocal;
575 UINT32 ulApiInstSize;
576 UINT32 ulTempVar;
577 UINT32 ulResult;
578
579 /* Check user's structure for errors. */
580 if ( f_pCreateLocal->pApiInstShared == NULL )
581 return cOCT6100_ERR_MULTIPROC_API_INST_SHARED;
582
583 if ( f_pCreateLocal->pApiInstLocal == NULL )
584 return cOCT6100_ERR_MULTIPROC_API_INST_LOCAL;
585
586 /* Get local pointer to local instance. */
587 pApiInstLocal = f_pCreateLocal->pApiInstLocal;
588
589 /* Assign pointers to local structure. */
590 ulApiInstSize = sizeof( tOCT6100_INSTANCE_API );
591 mOCT6100_ROUND_MEMORY_SIZE( ulApiInstSize, ulTempVar )
592
593 pApiInstLocal->pSharedInfo = ( tPOCT6100_SHARED_INFO )(( PUINT8 )f_pCreateLocal->pApiInstShared + ulApiInstSize);
594 pApiInstLocal->pProcessContext = f_pCreateLocal->pProcessContext;
595
596 /* Create serialization object handles needed. */
597 ulResult = Oct6100ApiCreateSerializeObjects( pApiInstLocal, f_pCreateLocal->ulUserChipId );
598 if ( ulResult != cOCT6100_ERR_OK )
599 return ulResult;
600
601 return cOCT6100_ERR_OK;
602 }
603 #endif
604
605
606 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
607
608 Function: Oct6100DestroyLocalInstance
609
610 Description: Release local instance for a process in a multi-process
611 host system.
612
613 -------------------------------------------------------------------------------
614 | Argument | Description
615 -------------------------------------------------------------------------------
616 f_pApiInstance Pointer to API instance. This memory is used to keep
617 the present state of the chip and all its resources.
618
619 f_pDestroyLocal Structure used to destroy the process' local instance.
620
621 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
622 #if !SKIP_Oct6100DestroyLocalInstanceDef
623 UINT32 Oct6100DestroyLocalInstanceDef(
624 tPOCT6100_DESTROY_LOCAL_INSTANCE f_pDestroyLocal )
625 {
626 f_pDestroyLocal->ulDummy = 0;
627
628 return cOCT6100_ERR_OK;
629 }
630 #endif
631
632 #if !SKIP_Oct6100DestroyLocalInstance
633 UINT32 Oct6100DestroyLocalInstance(
634 tPOCT6100_INSTANCE_API f_pApiInstance,
635 tPOCT6100_DESTROY_LOCAL_INSTANCE f_pDestroyLocal )
636 {
637 UINT32 ulResult;
638
639 /* Destroy the allocated ressources used for serialization. */
640 ulResult = Oct6100ApiDestroySerializeObjects( f_pApiInstance );
641 if ( ulResult != cOCT6100_ERR_OK )
642 return ulResult;
643
644 return cOCT6100_ERR_OK;
645 }
646 #endif
647
648
649 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
650
651 Function: Oct6100GetHwRevision
652
653 Description: Gets the hardware revision number of the chip.
654
655 -------------------------------------------------------------------------------
656 | Argument | Description
657 -------------------------------------------------------------------------------
658 f_pGetHwRev Pointer to user structure in which to return revision
659 number.
660
661 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
662 #if !SKIP_Oct6100GetHwRevisionDef
663 UINT32 Oct6100GetHwRevisionDef(
664 tPOCT6100_GET_HW_REVISION f_pGetHwRev )
665 {
666 f_pGetHwRev->ulUserChipId = cOCT6100_INVALID_CHIP_ID;
667 f_pGetHwRev->pProcessContext = NULL;
668 f_pGetHwRev->ulRevisionNum = cOCT6100_INVALID_VALUE;
669
670 return cOCT6100_ERR_OK;
671 }
672 #endif
673
674
675 #if !SKIP_Oct6100GetHwRevision
676 UINT32 Oct6100GetHwRevision(
677 tPOCT6100_GET_HW_REVISION f_pGetHwRev )
678 {
679 tOCT6100_READ_PARAMS ReadParams;
680 UINT32 ulResult;
681 UINT16 usReadData;
682
683 /* Read the hardware revision register. */
684 ReadParams.pProcessContext = f_pGetHwRev->pProcessContext;
685
686 ReadParams.ulUserChipId = f_pGetHwRev->ulUserChipId;
687 ReadParams.pusReadData = &usReadData;
688 ReadParams.ulReadAddress = 0x17E;
689 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
690 if ( ulResult != cOCT6100_ERR_OK )
691 return ulResult;
692
693 f_pGetHwRev->ulRevisionNum = ( usReadData >> 8 ) & 0xFF;
694
695 return cOCT6100_ERR_OK;
696 }
697 #endif
698
699
700 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
701
702 Function: Oct6100FreeResources
703
704 Description: This function closes all opened channels and frees all
705 specified global resources used by the chip.
706
707 -------------------------------------------------------------------------------
708 | Argument | Description
709 -------------------------------------------------------------------------------
710 f_pApiInstance Pointer to API instance. This memory is used to keep
711 the present state of the chip and all its resources.
712
713 f_pFreeResources Pointer to user structure in which to choose what
714 to free.
715
716 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
717 #if !SKIP_Oct6100FreeResourcesDef
718 UINT32 Oct6100FreeResourcesDef(
719 tPOCT6100_FREE_RESOURCES f_pFreeResources )
720 {
721 f_pFreeResources->fFreeTsiConnections = FALSE;
722 f_pFreeResources->fFreeConferenceBridges = FALSE;
723 f_pFreeResources->fFreePlayoutBuffers = FALSE;
724 f_pFreeResources->fFreePhasingTssts = FALSE;
725 f_pFreeResources->fFreeAdpcmChannels = FALSE;
726
727 return cOCT6100_ERR_OK;
728 }
729 #endif
730
731
732 #if !SKIP_Oct6100FreeResources
733 UINT32 Oct6100FreeResources(
734 tPOCT6100_INSTANCE_API f_pApiInstance,
735 tPOCT6100_FREE_RESOURCES f_pFreeResources )
736 {
737 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
738 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
739 UINT32 ulSerRes = cOCT6100_ERR_OK;
740 UINT32 ulFncRes = cOCT6100_ERR_OK;
741
742 /* Set the process context of the serialize structure. */
743 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
744 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
745
746 /* Seize all list semaphores needed by this function. */
747 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
748 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
749 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
750 if ( ulSerRes == cOCT6100_ERR_OK )
751 {
752 /* Call the serialized function. */
753 ulFncRes = Oct6100FreeResourcesSer( f_pApiInstance, f_pFreeResources );
754 }
755 else
756 {
757 return ulSerRes;
758 }
759
760 /* Release the seized semaphores. */
761 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
762 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
763
764 /* If an error occured then return the error code. */
765 if ( ulSerRes != cOCT6100_ERR_OK )
766 return ulSerRes;
767 if ( ulFncRes != cOCT6100_ERR_OK )
768 return ulFncRes;
769
770 return cOCT6100_ERR_OK;
771 }
772 #endif
773
774
775 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
776
777 Function: Oct6100ProductionBist
778
779 Description: This function retrieves the current BIST status of the
780 firmware.
781
782 -------------------------------------------------------------------------------
783 | Argument | Description
784 -------------------------------------------------------------------------------
785 f_pApiInstance Pointer to API instance. This memory is used to keep
786 the present state of the chip and all its resources.
787
788 f_pProductionBist Pointer to user structure where the bist information
789 will be returned.
790
791 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
792 #if !SKIP_Oct6100ProductionBistDef
793 UINT32 Oct6100ProductionBistDef(
794 tPOCT6100_PRODUCTION_BIST f_pProductionBist )
795 {
796 f_pProductionBist->ulCurrentAddress = cOCT6100_INVALID_VALUE;
797 f_pProductionBist->ulCurrentLoop = cOCT6100_INVALID_VALUE;
798 f_pProductionBist->ulFailedAddress = cOCT6100_INVALID_VALUE;
799 f_pProductionBist->ulReadValue = cOCT6100_INVALID_VALUE;
800 f_pProductionBist->ulExpectedValue = cOCT6100_INVALID_VALUE;
801 f_pProductionBist->ulBistStatus = cOCT6100_BIST_IN_PROGRESS;
802 f_pProductionBist->ulCurrentTest = cOCT6100_INVALID_VALUE;
803
804 return cOCT6100_ERR_OK;
805 }
806 #endif
807
808
809 #if !SKIP_Oct6100ProductionBist
810 UINT32 Oct6100ProductionBist(
811 tPOCT6100_INSTANCE_API f_pApiInstance,
812 tPOCT6100_PRODUCTION_BIST f_pProductionBist )
813 {
814 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
815 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
816 UINT32 ulSerRes = cOCT6100_ERR_OK;
817 UINT32 ulFncRes = cOCT6100_ERR_OK;
818
819 /* Set the process context of the serialize structure. */
820 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
821 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
822
823 /* Seize all list semaphores needed by this function. */
824 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
825 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
826 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
827 if ( ulSerRes == cOCT6100_ERR_OK )
828 {
829 /* Call the serialized function. */
830 ulFncRes = Oct6100ProductionBistSer( f_pApiInstance, f_pProductionBist );
831 }
832 else
833 {
834 return ulSerRes;
835 }
836
837 /* Release the seized semaphores. */
838 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
839 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
840
841 /* If an error occured then return the error code. */
842 if ( ulSerRes != cOCT6100_ERR_OK )
843 return ulSerRes;
844 if ( ulFncRes != cOCT6100_ERR_OK )
845 return ulFncRes;
846
847 return cOCT6100_ERR_OK;
848 }
849 #endif
850
851
852 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
853
854 Function: Oct6100ApiGetVersion
855
856 Description: Retrieves the API version.
857
858 -------------------------------------------------------------------------------
859 | Argument | Description
860 -------------------------------------------------------------------------------
861
862 f_pApiGetVersion Pointer to structure that will receive version information.
863
864 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
865 #if !SKIP_Oct6100ApiGetVersionDef
866 UINT32 Oct6100ApiGetVersionDef(
867 tPOCT6100_API_GET_VERSION f_pApiGetVersion )
868 {
869 UINT32 i;
870
871 /* Initialize the string. */
872 for ( i = 0; i < cOCT6100_API_VERSION_STRING_LENGTH; i++ )
873 f_pApiGetVersion->achApiVersion[ i ] = 0;
874
875 return cOCT6100_ERR_OK;
876 }
877 #endif
878
879 #if !SKIP_Oct6100ApiGetVersion
880 UINT32 Oct6100ApiGetVersion(
881 tPOCT6100_API_GET_VERSION f_pApiGetVersion )
882 {
883 /* Copy API version information to user. */
884 Oct6100UserMemCopy( f_pApiGetVersion->achApiVersion, cOCT6100_API_VERSION, sizeof(cOCT6100_API_VERSION) );
885
886 return cOCT6100_ERR_OK;
887 }
888 #endif
889
890 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
891
892 Function: Oct6100ApiGetCapacityPins
893
894 Description: Retrieves the Capcity Pins value.
895
896 -------------------------------------------------------------------------------
897 | Argument | Description
898 -------------------------------------------------------------------------------
899
900 f_pGetCapacityPins Pointer to the parameters structure needed
901 by GetCapacityPins().
902
903 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
904 #if !SKIP_Oct6100ApiGetCapacityPinsDef
905 UINT32 Oct6100ApiGetCapacityPinsDef(
906 tPOCT6100_API_GET_CAPACITY_PINS f_pGetCapacityPins)
907 {
908
909 f_pGetCapacityPins->pProcessContext = NULL;
910 f_pGetCapacityPins->ulUserChipId = 0;
911 f_pGetCapacityPins->ulMemoryType = cOCT6100_MEM_TYPE_DDR;
912 f_pGetCapacityPins->ulCapacityValue = cOCT6100_INVALID_VALUE;
913 f_pGetCapacityPins->fEnableMemClkOut = TRUE;
914 f_pGetCapacityPins->ulMemClkFreq = 133000000;
915
916 return cOCT6100_ERR_OK;
917 }
918 #endif
919
920 #if !SKIP_Oct6100ApiGetCapacityPins
921 UINT32 Oct6100ApiGetCapacityPins(
922 tPOCT6100_API_GET_CAPACITY_PINS f_pGetCapacityPins )
923 {
924
925 UINT32 ulResult;
926
927 tOCT6100_INSTANCE_API ApiInstance;
928
929 Oct6100UserMemSet(&ApiInstance,0,sizeof(tOCT6100_INSTANCE_API));
930
931 /*Check parameters*/
932 if ( f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_133_MHZ &&
933 f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_125_MHZ &&
934 f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_117_MHZ &&
935 f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_108_MHZ &&
936 f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_100_MHZ &&
937 f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_92_MHZ &&
938 f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_83_MHZ &&
939 f_pGetCapacityPins->ulMemClkFreq != cOCT6100_MCLK_FREQ_75_MHZ )
940 return cOCT6100_ERR_OPEN_MEM_CLK_FREQ;
941
942 if ( f_pGetCapacityPins->fEnableMemClkOut != TRUE &&
943 f_pGetCapacityPins->fEnableMemClkOut != FALSE )
944 return cOCT6100_ERR_OPEN_ENABLE_MEM_CLK_OUT;
945
946 if ( f_pGetCapacityPins->ulMemoryType != cOCT6100_MEM_TYPE_SDR &&
947 f_pGetCapacityPins->ulMemoryType != cOCT6100_MEM_TYPE_DDR &&
948 f_pGetCapacityPins->ulMemoryType != cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
949 return cOCT6100_ERR_OPEN_MEMORY_TYPE;
950
951
952
953 ApiInstance.pProcessContext = f_pGetCapacityPins->pProcessContext;
954
955
956
957 ulResult = Oct6100ApiReadCapacity(&ApiInstance, f_pGetCapacityPins);
958
959
960
961 return ulResult;
962 }
963 #endif
964
965 /*************************** PRIVATE FUNCTIONS *****************************/
966 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
967
968 Function: Oct6100ApiReadCapacity
969
970 Description: Read the capacity pins using modified functions from the openchip.
971
972 -------------------------------------------------------------------------------
973 | Argument | Description
974 -------------------------------------------------------------------------------
975
976 f_pChipOpen Pointer to chip configuration structure.
977
978 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
979 #if !SKIP_OCT6100ApiReadCapacity
980 UINT32 Oct6100ApiReadCapacity( IN tPOCT6100_INSTANCE_API f_pApiInstance,
981 IN tPOCT6100_API_GET_CAPACITY_PINS f_pGetCapacityPins)
982 {
983 UINT32 ulResult;
984 tOCT6100_READ_PARAMS ReadParams;
985 UINT16 usReadData;
986
987 /*Read capacity Pins*/
988
989
990 ReadParams.pProcessContext = f_pGetCapacityPins->pProcessContext;
991 ReadParams.ulUserChipId = f_pGetCapacityPins->ulUserChipId;
992 ReadParams.pusReadData = &usReadData;
993
994 /*Check the Reset register*/
995 ReadParams.ulReadAddress = 0x100;
996 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
997 if ( ulResult != cOCT6100_ERR_OK )
998 return ulResult;
999
1000 if ((usReadData & 0xFFFF) != 0x0000)
1001 return cOCT6100_ERR_CAP_PINS_INVALID_CHIP_STATE;
1002
1003 /* Test the CPU registers. */
1004 ulResult = Oct6100ApiCpuRegisterBistReadCap( f_pApiInstance, f_pGetCapacityPins );
1005 if ( ulResult != cOCT6100_ERR_OK )
1006 return ulResult;
1007
1008 /* Boot the FC2 PLL. */
1009 ulResult = Oct6100ApiBootFc2PllReadCap( f_pApiInstance,f_pGetCapacityPins );
1010 if ( ulResult != cOCT6100_ERR_OK )
1011 return ulResult;
1012
1013 /* Program the FC1 PLL. */
1014 ulResult = Oct6100ApiProgramFc1PllReadCap( f_pApiInstance,f_pGetCapacityPins );
1015 if ( ulResult != cOCT6100_ERR_OK )
1016 return ulResult;
1017
1018 if ( (f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR) ||
1019 (f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
1020 {
1021 ReadParams.ulReadAddress = 0x168;
1022 }
1023 else
1024 ReadParams.ulReadAddress = 0x166;
1025
1026 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
1027 if ( ulResult != cOCT6100_ERR_OK )
1028 return ulResult;
1029
1030 switch (usReadData & 0xF)
1031 {
1032 case 0x9:
1033 f_pGetCapacityPins->ulCapacityValue = 16;
1034 break;
1035 case 0x8:
1036 f_pGetCapacityPins->ulCapacityValue = 32;
1037 break;
1038 case 0xE:
1039 f_pGetCapacityPins->ulCapacityValue = 64;
1040 break;
1041 case 0x0:
1042 f_pGetCapacityPins->ulCapacityValue = 128;
1043 break;
1044 case 0x2:
1045 f_pGetCapacityPins->ulCapacityValue = 256;
1046 break;
1047 case 0x5:
1048 f_pGetCapacityPins->ulCapacityValue = 512;
1049 break;
1050 case 0x6:
1051 f_pGetCapacityPins->ulCapacityValue = 672;
1052 break;
1053 default:
1054 f_pGetCapacityPins->ulCapacityValue = (usReadData & 0xF);
1055 return cOCT6100_ERR_CAP_PINS_INVALID_CAPACITY_VALUE;
1056 }
1057
1058 return cOCT6100_ERR_OK;
1059 }
1060 #endif
1061
1062 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1063
1064 Function: Oct6100ApiCheckChipConfiguration
1065
1066 Description: Checks the user chip configuration structure for errors.
1067
1068 -------------------------------------------------------------------------------
1069 | Argument | Description
1070 -------------------------------------------------------------------------------
1071
1072 f_pChipOpen Pointer to chip configuration structure.
1073
1074 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1075 #if !SKIP_Oct6100ApiCheckChipConfiguration
1076 UINT32 Oct6100ApiCheckChipConfiguration(
1077 IN tPOCT6100_CHIP_OPEN f_pChipOpen )
1078 {
1079 UINT32 ulTempVar;
1080 UINT32 i;
1081
1082 /*-----------------------------------------------------------------------------*/
1083 /* Check general parameters. */
1084 if ( f_pChipOpen->fMultiProcessSystem != TRUE &&
1085 f_pChipOpen->fMultiProcessSystem != FALSE )
1086 return cOCT6100_ERR_OPEN_MULTI_PROCESS_SYSTEM;
1087
1088 if ( f_pChipOpen->ulMaxRwAccesses < 1 ||
1089 f_pChipOpen->ulMaxRwAccesses > 1024)
1090 return cOCT6100_ERR_OPEN_MAX_RW_ACCESSES;
1091
1092 /* Check the clocks. */
1093 if ( f_pChipOpen->ulUpclkFreq != cOCT6100_UPCLK_FREQ_33_33_MHZ )
1094 return cOCT6100_ERR_OPEN_UP_CLK_FREQ;
1095
1096 if ( f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_133_MHZ )
1097 return cOCT6100_ERR_OPEN_MEM_CLK_FREQ;
1098
1099 if ( f_pChipOpen->fEnableMemClkOut != TRUE &&
1100 f_pChipOpen->fEnableMemClkOut != FALSE )
1101 return cOCT6100_ERR_OPEN_ENABLE_MEM_CLK_OUT;
1102
1103 /* Check the image file. */
1104 if ( f_pChipOpen->ulImageSize < cOCT6100_MIN_IMAGE_SIZE ||
1105 f_pChipOpen->ulImageSize > cOCT6100_MAX_IMAGE_SIZE )
1106 return cOCT6100_ERR_OPEN_IMAGE_SIZE;
1107
1108 if ( f_pChipOpen->pbyImageFile == NULL )
1109 return cOCT6100_ERR_OPEN_IMAGE_FILE;
1110
1111 ulTempVar = Oct6100ApiCheckImageFileHeader(f_pChipOpen);
1112 if (ulTempVar != cOCT6100_ERR_OK)
1113 return ulTempVar;
1114
1115 /* Check the acoustic echo activation flag. */
1116 if ( f_pChipOpen->fEnableAcousticEcho != TRUE &&
1117 f_pChipOpen->fEnableAcousticEcho != FALSE )
1118 return cOCT6100_ERR_OPEN_ENABLE_ACOUSTIC_ECHO;
1119
1120 /* Check the tail displacement parameter. */
1121 if ( f_pChipOpen->ulTailDisplacement > cOCT6100_MAX_TAIL_DISPLACEMENT )
1122 return cOCT6100_ERR_OPEN_TAIL_DISPLACEMENT;
1123
1124 /*-----------------------------------------------------------------------------*/
1125 /* Check TDM bus configuration parameters. */
1126 for ( i = 0; i < 8; i++ )
1127 {
1128 if ( f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_2MHZ &&
1129 f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_4MHZ &&
1130 f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_8MHZ)
1131 return cOCT6100_ERR_OPEN_TDM_STREAM_FREQS;
1132 }
1133
1134 if ( f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_3_QUARTERS &&
1135 f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_RISING_EDGE &&
1136 f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE )
1137 return cOCT6100_ERR_OPEN_TDM_SAMPLING;
1138
1139 if ( f_pChipOpen->fEnableFastH100Mode != TRUE &&
1140 f_pChipOpen->fEnableFastH100Mode != FALSE )
1141 return cOCT6100_ERR_OPEN_FAST_H100_MODE;
1142
1143 /*-----------------------------------------------------------------------------*/
1144 /* Check external memory configuration parameters. */
1145 if ( f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_SDR &&
1146 f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_DDR &&
1147 f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
1148 return cOCT6100_ERR_OPEN_MEMORY_TYPE;
1149
1150 if ( f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_8MB &&
1151 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_16MB &&
1152 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_32MB &&
1153 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_64MB &&
1154 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_128MB )
1155 return cOCT6100_ERR_OPEN_MEMORY_CHIP_SIZE;
1156
1157 if ( f_pChipOpen->ulMemoryChipSize == cOCT6100_MEMORY_CHIP_SIZE_8MB &&
1158 f_pChipOpen->ulMemoryType == cOCT6100_MEM_TYPE_DDR )
1159 return cOCT6100_ERR_OPEN_MEMORY_CHIP_SIZE;
1160
1161 if ( f_pChipOpen->ulNumMemoryChips < 1 ||
1162 f_pChipOpen->ulNumMemoryChips > cOCT6100_MAX_NUM_MEMORY_CHIP )
1163 return cOCT6100_ERR_OPEN_MEMORY_CHIPS_NUMBER;
1164
1165 /* Check the total memory size. */
1166 ulTempVar = f_pChipOpen->ulMemoryChipSize * f_pChipOpen->ulNumMemoryChips;
1167 if ( ulTempVar < cOCT6100_MEMORY_CHIP_SIZE_16MB ||
1168 ulTempVar > cOCT6100_MEMORY_CHIP_SIZE_128MB )
1169 return cOCT6100_ERR_OPEN_TOTAL_MEMORY_SIZE;
1170
1171 if ( f_pChipOpen->ulMaxTdmStreams != 4 &&
1172 f_pChipOpen->ulMaxTdmStreams != 8 &&
1173 f_pChipOpen->ulMaxTdmStreams != 16 &&
1174 f_pChipOpen->ulMaxTdmStreams != 32 )
1175 return cOCT6100_ERR_OPEN_MAX_TDM_STREAM;
1176
1177 if ( f_pChipOpen->ulMaxTdmStreams > 8 &&
1178 f_pChipOpen->ulMemClkFreq == cOCT6100_MCLK_FREQ_75_MHZ )
1179 return cOCT6100_ERR_OPEN_MAX_TDM_STREAM;
1180
1181 if ( f_pChipOpen->fUseSynchTimestamp != TRUE &&
1182 f_pChipOpen->fUseSynchTimestamp != FALSE )
1183 return cOCT6100_ERR_OPEN_USE_SYNCH_TIMESTAMP;
1184
1185 if ( f_pChipOpen->fUseSynchTimestamp == TRUE )
1186 {
1187 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_USE_SYNCH_TIMESTAMP;
1188 }
1189
1190 /*-----------------------------------------------------------------------------*/
1191 /* Check soft buffer for tone events size. */
1192 if (f_pChipOpen->ulSoftToneEventsBufSize < 64 ||
1193 f_pChipOpen->ulSoftToneEventsBufSize > cOCT6100_ABSOLUTE_MAX_NUM_PGSP_EVENT_OUT )
1194 return cOCT6100_ERR_OPEN_SOFT_TONE_EVENT_SIZE;
1195
1196 if ( f_pChipOpen->fEnableExtToneDetection != TRUE &&
1197 f_pChipOpen->fEnableExtToneDetection != FALSE )
1198 return cOCT6100_ERR_OPEN_ENABLE_EXT_TONE_DETECTION;
1199
1200 if ( f_pChipOpen->fEnable2100StopEvent != TRUE &&
1201 f_pChipOpen->fEnable2100StopEvent != FALSE)
1202 return cOCT6100_ERR_OPEN_ENABLE_2100_STOP_EVENT;
1203
1204 /* Check soft buffer for playout events size. */
1205 if ( ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE )
1206 && ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize < cOCT6100_MIN_BUFFER_PLAYOUT_EVENT ||
1207 f_pChipOpen->ulSoftBufferPlayoutEventsBufSize > cOCT6100_MAX_BUFFER_PLAYOUT_EVENT ) )
1208 return cOCT6100_ERR_OPEN_SOFT_PLAYOUT_STOP_EVENT_SIZE;
1209
1210 /*-----------------------------------------------------------------------------*/
1211 /* Check interrupt configuration parameters. */
1212 if ( f_pChipOpen->ulInterruptPolarity != cOCT6100_ACTIVE_LOW_POLARITY &&
1213 f_pChipOpen->ulInterruptPolarity != cOCT6100_ACTIVE_HIGH_POLARITY )
1214 return cOCT6100_ERR_OPEN_INTERRUPT_POLARITY;
1215
1216 if ( f_pChipOpen->InterruptConfig.ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
1217 f_pChipOpen->InterruptConfig.ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE )
1218 return cOCT6100_ERR_OPEN_FATAL_GENERAL_CONFIG;
1219
1220 if ( f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
1221 f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
1222 f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE )
1223 return cOCT6100_ERR_OPEN_FATAL_MEMORY_CONFIG;
1224
1225 if ( f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
1226 f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
1227 f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE )
1228 return cOCT6100_ERR_OPEN_ERROR_MEMORY_CONFIG;
1229
1230 if ( f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
1231 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT &&
1232 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE )
1233 return cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_CONFIG;
1234
1235 if ( f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT &&
1236 f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT &&
1237 f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE )
1238 return cOCT6100_ERR_OPEN_ERROR_H100_CONFIG;
1239
1240 /* Check the timeout value. */
1241 if ( f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout < 10 ||
1242 f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout > 10000 )
1243 return cOCT6100_ERR_OPEN_FATAL_MEMORY_TIMEOUT;
1244
1245 if ( f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout < 10 ||
1246 f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout > 10000 )
1247 return cOCT6100_ERR_OPEN_ERROR_MEMORY_TIMEOUT;
1248
1249 if ( f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout < 10 ||
1250 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout > 10000 )
1251 return cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_TIMEOUT;
1252
1253 if ( f_pChipOpen->InterruptConfig.ulErrorH100Timeout < 10 ||
1254 f_pChipOpen->InterruptConfig.ulErrorH100Timeout > 10000 )
1255 return cOCT6100_ERR_OPEN_ERROR_H100_TIMEOUT;
1256
1257 /*-----------------------------------------------------------------------------*/
1258 /* Check maximum resources. */
1259
1260 switch ( f_pChipOpen->ulMemClkFreq )
1261 {
1262 case 133000000:
1263 ulTempVar = 672;
1264 break;
1265 case 125000000:
1266 ulTempVar = 624;
1267 break;
1268 case 117000000:
1269 ulTempVar = 576;
1270 break;
1271 case 108000000:
1272 ulTempVar = 528;
1273 break;
1274 case 100000000:
1275 ulTempVar = 480;
1276 break;
1277 case 92000000:
1278 ulTempVar = 432;
1279 break;
1280 case 83000000:
1281 ulTempVar = 384;
1282 break;
1283 case 75000000:
1284 ulTempVar = 336;
1285 break;
1286 default:
1287 return cOCT6100_ERR_FATAL_DA;
1288 }
1289
1290 if ( f_pChipOpen->ulMaxChannels > ulTempVar )
1291 return cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS;
1292
1293 if ( f_pChipOpen->ulMaxTsiCncts > cOCT6100_MAX_TSI_CNCTS )
1294 return cOCT6100_ERR_OPEN_MAX_TSI_CNCTS;
1295
1296
1297 if ( f_pChipOpen->ulMaxBiDirChannels > 255 )
1298 return cOCT6100_ERR_OPEN_MAX_BIDIR_CHANNELS;
1299
1300 if ( f_pChipOpen->ulMaxBiDirChannels > (f_pChipOpen->ulMaxChannels / 2) )
1301 return cOCT6100_ERR_OPEN_MAX_BIDIR_CHANNELS;
1302
1303 if ( f_pChipOpen->ulMaxConfBridges > cOCT6100_MAX_CONF_BRIDGE )
1304 return cOCT6100_ERR_OPEN_MAX_CONF_BRIDGES;
1305
1306 if ( f_pChipOpen->ulMaxFlexibleConfParticipants > cOCT6100_MAX_FLEX_CONF_PARTICIPANTS )
1307 return cOCT6100_ERR_OPEN_MAX_FLEXIBLE_CONF_PARTICIPANTS;
1308
1309 if ( f_pChipOpen->ulMaxPlayoutBuffers > cOCT6100_MAX_PLAYOUT_BUFFERS )
1310 return cOCT6100_ERR_OPEN_MAX_PLAYOUT_BUFFERS;
1311
1312
1313
1314 if ( f_pChipOpen->ulMaxPhasingTssts > cOCT6100_MAX_PHASING_TSST )
1315 return cOCT6100_ERR_OPEN_MAX_PHASING_TSSTS;
1316
1317 if ( f_pChipOpen->ulMaxAdpcmChannels > cOCT6100_MAX_ADPCM_CHANNELS )
1318 return cOCT6100_ERR_OPEN_MAX_ADPCM_CHANNELS;
1319
1320 if ( f_pChipOpen->ulMaxRemoteDebugSessions > 256 )
1321 return cOCT6100_ERR_OPEN_MAX_REMOTE_DEBUG_SESSIONS;
1322
1323
1324
1325
1326
1327 /* Check the channel recording flag. */
1328 if ( f_pChipOpen->fEnableChannelRecording != TRUE &&
1329 f_pChipOpen->fEnableChannelRecording != FALSE )
1330 return cOCT6100_ERR_OPEN_DEBUG_CHANNEL_RECORDING;
1331
1332 /* Check the enable production BIST flag. */
1333 if ( ( f_pChipOpen->fEnableProductionBist != TRUE )
1334 && ( f_pChipOpen->fEnableProductionBist != FALSE ) )
1335 return cOCT6100_ERR_OPEN_ENABLE_PRODUCTION_BIST;
1336
1337 /* Check number of loops for the production BIST. */
1338 if ( f_pChipOpen->fEnableProductionBist == TRUE )
1339 {
1340 if ( f_pChipOpen->ulNumProductionBistLoops == 0 )
1341 return cOCT6100_ERR_OPEN_NUM_PRODUCTION_BIST_LOOPS;
1342
1343 if ( (f_pChipOpen->ulProductionBistMode != cOCT6100_PRODUCTION_BIST_STANDARD) &&
1344 (f_pChipOpen->ulProductionBistMode != cOCT6100_PRODUCTION_BIST_SHORT) )
1345 return cOCT6100_ERR_OPEN_PRODUCTION_BIST_MODE;
1346 }
1347
1348 /* If the production BIST has been requested, make sure all */
1349 /* other resources are disabled. */
1350 if ( f_pChipOpen->fEnableProductionBist == TRUE )
1351 {
1352 /* All must be disabled. */
1353 f_pChipOpen->ulMaxChannels = 0;
1354 f_pChipOpen->ulMaxTsiCncts = 0;
1355 f_pChipOpen->fEnableChannelRecording = FALSE;
1356 f_pChipOpen->ulMaxBiDirChannels = 0;
1357 f_pChipOpen->ulMaxConfBridges = 0;
1358 f_pChipOpen->ulMaxPlayoutBuffers = 0;
1359 f_pChipOpen->ulSoftBufferPlayoutEventsBufSize = cOCT6100_INVALID_VALUE;
1360 f_pChipOpen->ulMaxPhasingTssts = 0;
1361 f_pChipOpen->ulMaxAdpcmChannels = 0;
1362
1363
1364 }
1365
1366 return cOCT6100_ERR_OK;
1367 }
1368 #endif
1369
1370
1371 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1372
1373 Function: Oct6100ApiCopyChipConfiguration
1374
1375 Description: Copies the chip configuration from the user supplied config
1376 structure to the instance structure.
1377
1378 -------------------------------------------------------------------------------
1379 | Argument | Description
1380 -------------------------------------------------------------------------------
1381 f_pApiInstance Pointer to API instance. This memory is used to keep the
1382 present state of the chip and all its resources.
1383
1384 f_pChipOpen Pointer to chip configuration structure.
1385
1386 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1387 #if !SKIP_Oct6100ApiCopyChipConfiguration
1388 UINT32 Oct6100ApiCopyChipConfiguration(
1389 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1390 IN tPOCT6100_CHIP_OPEN f_pChipOpen )
1391 {
1392 tPOCT6100_SHARED_INFO pSharedInfo;
1393 UINT32 i;
1394
1395 /* Get local pointer to shared portion of instance. */
1396 pSharedInfo = f_pApiInstance->pSharedInfo;
1397
1398 pSharedInfo->ChipConfig.ulUserChipId = f_pChipOpen->ulUserChipId;
1399 pSharedInfo->ChipConfig.fMultiProcessSystem = (UINT8)( f_pChipOpen->fMultiProcessSystem & 0xFF );
1400
1401 pSharedInfo->ChipConfig.usMaxRwAccesses = (UINT16)( f_pChipOpen->ulMaxRwAccesses & 0xFFFF );
1402
1403 pSharedInfo->ChipConfig.pbyImageFile = f_pChipOpen->pbyImageFile;
1404 pSharedInfo->ChipConfig.ulImageSize = f_pChipOpen->ulImageSize;
1405
1406 pSharedInfo->ChipConfig.ulMemClkFreq = f_pChipOpen->ulMemClkFreq;
1407 pSharedInfo->ChipConfig.ulUpclkFreq = f_pChipOpen->ulUpclkFreq;
1408
1409 pSharedInfo->ChipConfig.byMemoryType = (UINT8)( f_pChipOpen->ulMemoryType & 0xFF );
1410 pSharedInfo->ChipConfig.byNumMemoryChips = (UINT8)( f_pChipOpen->ulNumMemoryChips & 0xFF );
1411 pSharedInfo->ChipConfig.ulMemoryChipSize = f_pChipOpen->ulMemoryChipSize;
1412
1413 pSharedInfo->ChipConfig.usTailDisplacement = (UINT16)( f_pChipOpen->ulTailDisplacement & 0xFFFF );
1414 pSharedInfo->ChipConfig.fEnableAcousticEcho = (UINT8)( f_pChipOpen->fEnableAcousticEcho & 0xFF );
1415 /* Resource allocation parameters. */
1416 if ( f_pChipOpen->fEnableChannelRecording == TRUE && f_pChipOpen->ulMaxChannels == 672 )
1417 pSharedInfo->ChipConfig.usMaxChannels = (UINT16)( ( f_pChipOpen->ulMaxChannels - 1 ) & 0xFFFF );
1418 else
1419 pSharedInfo->ChipConfig.usMaxChannels = (UINT16)( f_pChipOpen->ulMaxChannels & 0xFFFF );
1420 pSharedInfo->ChipConfig.usMaxTsiCncts = (UINT16)( f_pChipOpen->ulMaxTsiCncts & 0xFFFF );
1421 pSharedInfo->ChipConfig.usMaxBiDirChannels = (UINT16)( f_pChipOpen->ulMaxBiDirChannels & 0xFFFF );
1422 pSharedInfo->ChipConfig.usMaxConfBridges = (UINT16)( f_pChipOpen->ulMaxConfBridges & 0xFFFF );
1423 pSharedInfo->ChipConfig.usMaxFlexibleConfParticipants = (UINT16)( f_pChipOpen->ulMaxFlexibleConfParticipants & 0xFFFF );
1424 pSharedInfo->ChipConfig.usMaxPlayoutBuffers = (UINT16)( f_pChipOpen->ulMaxPlayoutBuffers & 0xFFFF );
1425
1426 pSharedInfo->ChipConfig.usMaxPhasingTssts = (UINT16)( f_pChipOpen->ulMaxPhasingTssts & 0xFFFF );
1427 pSharedInfo->ChipConfig.usMaxAdpcmChannels = (UINT16)( f_pChipOpen->ulMaxAdpcmChannels & 0xFFFF );
1428 pSharedInfo->ChipConfig.byMaxTdmStreams = (UINT8)( f_pChipOpen->ulMaxTdmStreams & 0xFF );
1429 pSharedInfo->ChipConfig.fUseSynchTimestamp = (UINT8)( f_pChipOpen->fUseSynchTimestamp & 0xFF );
1430 for ( i = 0; i < 4; i++ )
1431 {
1432 pSharedInfo->ChipConfig.ausTimestampTimeslots[ i ] = (UINT16)( f_pChipOpen->aulTimestampTimeslots[ i ] & 0xFFFF );
1433 pSharedInfo->ChipConfig.ausTimestampStreams[ i ] = (UINT16)( f_pChipOpen->aulTimestampStreams[ i ] & 0xFFFF );
1434 }
1435 pSharedInfo->ChipConfig.byInterruptPolarity = (UINT8)( f_pChipOpen->ulInterruptPolarity & 0xFF );
1436
1437 pSharedInfo->ChipConfig.byTdmSampling = (UINT8)( f_pChipOpen->ulTdmSampling & 0xFF );
1438 pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF );
1439
1440 for ( i = 0; i < cOCT6100_TDM_STREAM_MAX_GROUPS; i++ )
1441 {
1442 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
1443 pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = cOCT6100_TDM_STREAM_FREQ_16MHZ;
1444 else
1445 pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = f_pChipOpen->aulTdmStreamFreqs[ i ];
1446 }
1447
1448 pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF );
1449 pSharedInfo->ChipConfig.fEnableMemClkOut = (UINT8)( f_pChipOpen->fEnableMemClkOut & 0xFF );
1450
1451 /* Add 1 to the circular buffer such that all user requested events can fit in the circular queue. */
1452 pSharedInfo->ChipConfig.ulSoftToneEventsBufSize = f_pChipOpen->ulSoftToneEventsBufSize + 1;
1453 pSharedInfo->ChipConfig.fEnableExtToneDetection = (UINT8)( f_pChipOpen->fEnableExtToneDetection & 0xFF );
1454 pSharedInfo->ChipConfig.fEnable2100StopEvent = (UINT8)( f_pChipOpen->fEnable2100StopEvent & 0xFF );
1455
1456 if ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE )
1457 pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = f_pChipOpen->ulSoftBufferPlayoutEventsBufSize + 1;
1458 else
1459 pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = 0;
1460 pSharedInfo->ChipConfig.usMaxRemoteDebugSessions = (UINT16)( f_pChipOpen->ulMaxRemoteDebugSessions & 0xFFFF );
1461
1462 pSharedInfo->ChipConfig.fEnableChannelRecording = (UINT8)( f_pChipOpen->fEnableChannelRecording & 0xFF );
1463
1464
1465
1466 pSharedInfo->ChipConfig.fEnableProductionBist = (UINT8)( f_pChipOpen->fEnableProductionBist & 0xFF );
1467 pSharedInfo->ChipConfig.ulProductionBistMode = f_pChipOpen->ulProductionBistMode;
1468 pSharedInfo->ChipConfig.ulNumProductionBistLoops = f_pChipOpen->ulNumProductionBistLoops;
1469
1470 return cOCT6100_ERR_OK;
1471 }
1472 #endif
1473
1474
1475 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1476
1477 Function: Oct6100ApiInitializeMiscellaneousVariables
1478
1479 Description: Function where all the various parameters from the API instance
1480 are set to their defaults value.
1481
1482 -------------------------------------------------------------------------------
1483 | Argument | Description
1484 -------------------------------------------------------------------------------
1485 f_pApiInstance Pointer to API instance. This memory is used to keep the
1486 present state of the chip and all its resources.
1487
1488 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1489 #if !SKIP_Oct6100ApiInitializeMiscellaneousVariables
1490 UINT32 Oct6100ApiInitializeMiscellaneousVariables(
1491 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1492 {
1493 tPOCT6100_SHARED_INFO pSharedInfo;
1494 UINT32 i;
1495
1496 /* Obtain pointer to shared portion of instance. */
1497 pSharedInfo = f_pApiInstance->pSharedInfo;
1498
1499 /* Calculate the total memory available. */
1500 pSharedInfo->MiscVars.ulTotalMemSize = pSharedInfo->ChipConfig.ulMemoryChipSize * pSharedInfo->ChipConfig.byNumMemoryChips;
1501
1502 /* Software buffers initialization. */
1503
1504 /* Tones */
1505 pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
1506 pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = 0;
1507 pSharedInfo->SoftBufs.ulToneEventBufferSize = pSharedInfo->ChipConfig.ulSoftToneEventsBufSize;
1508 pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0;
1509
1510 /* Playout */
1511 pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr = 0;
1512 pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr = 0;
1513 pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize = pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize;
1514 pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt = 0;
1515
1516 /* Set the number of conference bridges opened to zero. */
1517 pSharedInfo->MiscVars.usNumBridgesOpened = 0;
1518 pSharedInfo->MiscVars.usFirstBridge = cOCT6100_INVALID_INDEX;
1519
1520 /* Set the H.100 slave mode. */
1521 pSharedInfo->MiscVars.ulH100SlaveMode = cOCT6100_H100_TRACKA;
1522
1523 /* Save the Mclk value.*/
1524 pSharedInfo->MiscVars.ulMclkFreq = pSharedInfo->ChipConfig.ulMemClkFreq;
1525
1526 /* Init the NLP params. */
1527 pSharedInfo->MiscVars.usCodepoint = 0;
1528 pSharedInfo->MiscVars.usCpuLsuWritePtr = 0;
1529
1530 /* Pouch counter not present until TLVs are read. */
1531 pSharedInfo->DebugInfo.fPouchCounter = FALSE;
1532 pSharedInfo->DebugInfo.fIsIsrCalledField = FALSE;
1533
1534 /* Initialize the image info parameters */
1535 pSharedInfo->ImageInfo.fAdaptiveNoiseReduction = FALSE;
1536 pSharedInfo->ImageInfo.fSoutNoiseBleaching = FALSE;
1537 pSharedInfo->ImageInfo.fComfortNoise = FALSE;
1538 pSharedInfo->ImageInfo.fBufferPlayout = TRUE;
1539 pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip = FALSE;
1540 pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip = FALSE;
1541 pSharedInfo->ImageInfo.fNlpControl = FALSE;
1542 pSharedInfo->ImageInfo.fRinAutoLevelControl = FALSE;
1543 pSharedInfo->ImageInfo.fSoutAutoLevelControl = FALSE;
1544 pSharedInfo->ImageInfo.fRinHighLevelCompensation = FALSE;
1545 pSharedInfo->ImageInfo.fSoutHighLevelCompensation = FALSE;
1546 pSharedInfo->ImageInfo.fAlcHlcStatus = FALSE;
1547 pSharedInfo->ImageInfo.fRinDcOffsetRemoval = FALSE;
1548 pSharedInfo->ImageInfo.fSilenceSuppression = FALSE;
1549 pSharedInfo->ImageInfo.fSinDcOffsetRemoval = FALSE;
1550 pSharedInfo->ImageInfo.fToneDisabler = FALSE;
1551 pSharedInfo->ImageInfo.fAdpcm = FALSE;
1552 pSharedInfo->ImageInfo.fTailDisplacement = FALSE;
1553 pSharedInfo->ImageInfo.fConferencing = FALSE;
1554 pSharedInfo->ImageInfo.fConferencingNoiseReduction = FALSE;
1555 pSharedInfo->ImageInfo.fDominantSpeakerEnabled = FALSE;
1556 pSharedInfo->ImageInfo.fAecEnabled = FALSE;
1557 pSharedInfo->ImageInfo.fAcousticEcho = FALSE;
1558 pSharedInfo->ImageInfo.fToneRemoval = FALSE;
1559
1560 pSharedInfo->ImageInfo.fDefaultErl = FALSE;
1561 pSharedInfo->ImageInfo.fMaxEchoPoint = FALSE;
1562 pSharedInfo->ImageInfo.fNonLinearityBehaviorA = FALSE;
1563 pSharedInfo->ImageInfo.fNonLinearityBehaviorB = FALSE;
1564 pSharedInfo->ImageInfo.fPerChannelTailDisplacement = FALSE;
1565 pSharedInfo->ImageInfo.fPerChannelTailLength = FALSE;
1566 pSharedInfo->ImageInfo.fAfTailDisplacement = FALSE;
1567 pSharedInfo->ImageInfo.fMusicProtection = FALSE;
1568 pSharedInfo->ImageInfo.fAftControl = FALSE;
1569 pSharedInfo->ImageInfo.fSinVoiceDetectedStat = FALSE;
1570 pSharedInfo->ImageInfo.fRinAppliedGainStat = FALSE;
1571 pSharedInfo->ImageInfo.fSoutAppliedGainStat = FALSE;
1572 pSharedInfo->ImageInfo.fListenerEnhancement = FALSE;
1573 pSharedInfo->ImageInfo.fRoutNoiseReduction = FALSE;
1574 pSharedInfo->ImageInfo.fRoutNoiseReductionLevel = FALSE;
1575 pSharedInfo->ImageInfo.fAnrSnrEnhancement = FALSE;
1576 pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation = FALSE;
1577 pSharedInfo->ImageInfo.fRinMute = FALSE;
1578 pSharedInfo->ImageInfo.fSinMute = FALSE;
1579 pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay = FALSE;
1580 pSharedInfo->ImageInfo.fAecTailLength = FALSE;
1581 pSharedInfo->ImageInfo.fMusicProtectionConfiguration= FALSE;
1582 pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents = FALSE;
1583 pSharedInfo->ImageInfo.fRinEnergyStat = FALSE;
1584 pSharedInfo->ImageInfo.fSoutEnergyStat = FALSE;
1585 pSharedInfo->ImageInfo.fDoubleTalkBehavior = FALSE;
1586 pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst = FALSE;
1587 pSharedInfo->ImageInfo.fIdleCodeDetection = TRUE;
1588 pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration = FALSE;
1589 pSharedInfo->ImageInfo.fSinLevel = TRUE;
1590
1591 pSharedInfo->ImageInfo.usMaxNumberOfChannels = 0;
1592 pSharedInfo->ImageInfo.ulToneProfileNumber = cOCT6100_INVALID_VALUE;
1593 pSharedInfo->ImageInfo.ulBuildId = cOCT6100_INVALID_VALUE;
1594 pSharedInfo->ImageInfo.byImageType = cOCT6100_IMAGE_TYPE_WIRELINE;
1595 pSharedInfo->ImageInfo.usMaxTailDisplacement = 0;
1596 pSharedInfo->ImageInfo.usMaxTailLength = cOCT6100_TAIL_LENGTH_128MS;
1597 pSharedInfo->DebugInfo.ulDebugEventSize = 0x100;
1598 pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents = 32;
1599 pSharedInfo->DebugInfo.ulMatrixBaseAddress = cOCT6100_MATRIX_DWORD_BASE;
1600 pSharedInfo->DebugInfo.ulDebugChanStatsByteSize = cOCT6100_DEBUG_CHAN_STATS_EVENT_BYTE_SIZE;
1601 pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize = cOCT6100_DEBUG_CHAN_STATS_LITE_EVENT_BYTE_SIZE;
1602 pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress= cOCT6100_MATRIX_CHAN_SELECT_DWORD_ADD;
1603 pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress = cOCT6100_MATRIX_TIMESTAMP_DWORD_ADD;
1604 pSharedInfo->DebugInfo.ulMatrixWpBaseAddress = cOCT6100_MATRIX_WRITE_PTR_DWORD_ADD;
1605 pSharedInfo->DebugInfo.ulAfWritePtrByteOffset = 206;
1606 pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize = 4096;
1607 pSharedInfo->DebugInfo.ulAfEventCbByteSize = 0x100000;
1608
1609 /* Set all tones to invalid. */
1610 pSharedInfo->ImageInfo.byNumToneDetectors = 0;
1611 for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
1612 {
1613 pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID = cOCT6100_INVALID_VALUE;
1614 pSharedInfo->ImageInfo.aToneInfo[ i ].ulDetectionPort = cOCT6100_INVALID_PORT;
1615 Oct6100UserMemSet( pSharedInfo->ImageInfo.aToneInfo[ i ].aszToneName, 0x00, cOCT6100_TLV_MAX_TONE_NAME_SIZE );
1616 }
1617 /* Initialize the channel recording info. */
1618 pSharedInfo->DebugInfo.usRecordChanIndex = pSharedInfo->ChipConfig.usMaxChannels;
1619 pSharedInfo->DebugInfo.usRecordMemIndex = cOCT6100_INVALID_INDEX;
1620
1621 pSharedInfo->DebugInfo.usCurrentDebugChanIndex = cOCT6100_INVALID_INDEX;
1622 /* Initialize the mixer information. */
1623 pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX;
1624 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = cOCT6100_INVALID_INDEX;
1625 pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = cOCT6100_INVALID_INDEX;
1626 pSharedInfo->MixerInfo.usLastBridgeEventPtr = cOCT6100_INVALID_INDEX;
1627 pSharedInfo->MixerInfo.usLastSinCopyEventPtr = cOCT6100_INVALID_INDEX;
1628 pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = cOCT6100_INVALID_INDEX;
1629
1630 pSharedInfo->MixerInfo.usRecordCopyEventIndex = cOCT6100_INVALID_INDEX;
1631 pSharedInfo->MixerInfo.usRecordSinEventIndex = cOCT6100_INVALID_INDEX;
1632
1633 return cOCT6100_ERR_OK;
1634 }
1635 #endif
1636
1637
1638 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1639
1640 Function: Oct6100ApiCalculateInstanceSizes
1641
1642 Description: Calculates the amount of memory needed for the instance
1643 structure memory block based on the user's configuration.
1644
1645 -------------------------------------------------------------------------------
1646 | Argument | Description
1647 -------------------------------------------------------------------------------
1648 f_pChipOpen Pointer to user chip configuration structure.
1649
1650 f_pInstSizes Pointer to structure containing the size of memory needed
1651 by all pointers internal to the API instance. The memory
1652 is needed to keep track of the present state of all the
1653 chip's resources.
1654
1655 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1656 #if !SKIP_Oct6100ApiCalculateInstanceSizes
1657 UINT32 Oct6100ApiCalculateInstanceSizes(
1658 IN OUT tPOCT6100_CHIP_OPEN f_pChipOpen,
1659 OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
1660 {
1661 UINT32 ulApiInstProcessSpecific;
1662 UINT32 ulTempVar;
1663 UINT32 ulResult;
1664
1665 /* Start with all instance sizes set to 0. */
1666 Oct6100UserMemSet( f_pInstSizes, 0x00, sizeof( tOCT6100_API_INSTANCE_SIZES ) );
1667
1668 /* All memory sizes are rounded up to the next multiple of 64 bytes. */
1669
1670 /*-----------------------------------------------------------------------------*/
1671 /* Obtain size of static members of API instance. */
1672 f_pInstSizes->ulApiInstStatic = sizeof( tOCT6100_SHARED_INFO );
1673 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulApiInstStatic, ulTempVar )
1674
1675 /* Calculate memory needed by pointers internal to the API instance. */
1676
1677 /*-----------------------------------------------------------------------------*/
1678 /* Calculate memory needed for the EC channels. */
1679 ulResult = Oct6100ApiGetChannelsEchoSwSizes( f_pChipOpen, f_pInstSizes );
1680 if ( ulResult != cOCT6100_ERR_OK )
1681 return ulResult;
1682 /*-----------------------------------------------------------------------------*/
1683 /* Memory needed by the TSI structures. */
1684 ulResult = Oct6100ApiGetTsiCnctSwSizes( f_pChipOpen, f_pInstSizes );
1685 if ( ulResult != cOCT6100_ERR_OK )
1686 return ulResult;
1687 /*-----------------------------------------------------------------------------*/
1688 /* Calculate memory needed for the conference bridges. */
1689 ulResult = Oct6100ApiGetConfBridgeSwSizes( f_pChipOpen, f_pInstSizes );
1690 /* Calculate memory needed for list and allocation software serialization. */
1691 if ( ulResult != cOCT6100_ERR_OK )
1692 return ulResult;
1693
1694 /*-----------------------------------------------------------------------------*/
1695 /* Memory needed by the buffer playout structures. */
1696 ulResult = Oct6100ApiGetPlayoutBufferSwSizes( f_pChipOpen, f_pInstSizes );
1697 if ( ulResult != cOCT6100_ERR_OK )
1698 return ulResult;
1699
1700 /*-----------------------------------------------------------------------------*/
1701 /* Memory needed by soft Rx Event buffers. */
1702 ulResult = Oct6100ApiGetEventsSwSizes( f_pChipOpen, f_pInstSizes );
1703 if ( ulResult != cOCT6100_ERR_OK )
1704 return ulResult;
1705
1706 /*-----------------------------------------------------------------------------*/
1707 /* Calculate memory needed for phasing tssts. */
1708 ulResult = Oct6100ApiGetPhasingTsstSwSizes( f_pChipOpen, f_pInstSizes );
1709 if ( ulResult != cOCT6100_ERR_OK )
1710 return ulResult;
1711 /*-----------------------------------------------------------------------------*/
1712 /* Calculate memory needed for the ADPCM channels. */
1713 ulResult = Oct6100ApiGetAdpcmChanSwSizes( f_pChipOpen, f_pInstSizes );
1714 if ( ulResult != cOCT6100_ERR_OK )
1715 return ulResult;
1716
1717 /*-----------------------------------------------------------------------------*/
1718 /* Calculate memory needed for the management of TSSTs. */
1719 ulResult = Oct6100ApiGetTsstSwSizes( f_pInstSizes );
1720 if ( ulResult != cOCT6100_ERR_OK )
1721 return ulResult;
1722
1723 /*-----------------------------------------------------------------------------*/
1724 /* Calculate memory needed for the management of the mixer. */
1725 ulResult = Oct6100ApiGetMixerSwSizes( f_pChipOpen, f_pInstSizes );
1726 if ( ulResult != cOCT6100_ERR_OK )
1727 return ulResult;
1728
1729 /*-----------------------------------------------------------------------------*/
1730 /* Determine amount of memory needed for memory allocation softwares. These
1731 pieces of software will be responsible for the allocation of the chip's
1732 external memory and API memory. */
1733 ulResult = Oct6100ApiGetMemorySwSizes( f_pChipOpen, f_pInstSizes );
1734 if ( ulResult != cOCT6100_ERR_OK )
1735 return ulResult;
1736
1737 /*-----------------------------------------------------------------------------*/
1738 /* Memory needed for remote debugging sessions. */
1739 ulResult = Oct6100ApiGetRemoteDebugSwSizes( f_pChipOpen, f_pInstSizes );
1740 if ( ulResult != cOCT6100_ERR_OK )
1741 return ulResult;
1742
1743 /*-----------------------------------------------------------------------------*/
1744 /* Calculate total memory needed by pointers internal to API instance. The
1745 total contains both the process specific portion of the instance
1746 (tOCT6100_INSTANCE_API) and the shared portion (tOCT6100_SHARED_INFO). The
1747 process specific portion will be used only in the case where the host system
1748 is a single-process one. */
1749
1750 ulApiInstProcessSpecific = sizeof( tOCT6100_INSTANCE_API );
1751 mOCT6100_ROUND_MEMORY_SIZE( ulApiInstProcessSpecific, ulTempVar )
1752 f_pInstSizes->ulApiInstTotal =
1753 f_pInstSizes->ulChannelList +
1754 f_pInstSizes->ulChannelAlloc +
1755 f_pInstSizes->ulTsiCnctList +
1756 f_pInstSizes->ulTsiCnctAlloc +
1757 f_pInstSizes->ulSoftToneEventsBuffer +
1758 f_pInstSizes->ulSoftBufPlayoutEventsBuffer +
1759 f_pInstSizes->ulBiDirChannelList +
1760 f_pInstSizes->ulBiDirChannelAlloc +
1761 f_pInstSizes->ulConfBridgeList +
1762 f_pInstSizes->ulConfBridgeAlloc +
1763 f_pInstSizes->ulFlexConfParticipantsList +
1764 f_pInstSizes->ulFlexConfParticipantsAlloc +
1765 f_pInstSizes->ulPlayoutBufList +
1766 f_pInstSizes->ulPlayoutBufAlloc +
1767 f_pInstSizes->ulPlayoutBufMemoryNodeList +
1768
1769 f_pInstSizes->ulCopyEventList +
1770 f_pInstSizes->ulCopyEventAlloc +
1771 f_pInstSizes->ulMixerEventList +
1772 f_pInstSizes->ulMixerEventAlloc +
1773 f_pInstSizes->ulPhasingTsstList +
1774 f_pInstSizes->ulPhasingTsstAlloc +
1775 f_pInstSizes->ulAdpcmChannelList +
1776 f_pInstSizes->ulAdpcmChannelAlloc +
1777 f_pInstSizes->ulConversionMemoryAlloc +
1778 f_pInstSizes->ulTsiMemoryAlloc +
1779 f_pInstSizes->ulRemoteDebugList +
1780 f_pInstSizes->ulRemoteDebugTree +
1781 f_pInstSizes->ulRemoteDebugPktCache +
1782 f_pInstSizes->ulRemoteDebugDataBuf +
1783 f_pInstSizes->ulTsstEntryList +
1784 f_pInstSizes->ulTsstEntryAlloc +
1785 f_pInstSizes->ulTsstAlloc +
1786 f_pInstSizes->ulApiInstStatic +
1787 ulApiInstProcessSpecific;
1788
1789 return cOCT6100_ERR_OK;
1790 }
1791 #endif
1792
1793
1794 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1795
1796 Function: Oct6100ApiAllocateInstanceMemory
1797
1798 Description: Allocates the API instance memory to the various members of
1799 the structure f_pApiInstance according to the sizes contained
1800 in f_pInstSizes. No initialization of this memory is
1801 performed.
1802
1803 -------------------------------------------------------------------------------
1804 | Argument | Description
1805 -------------------------------------------------------------------------------
1806 f_pApiInstance Pointer to API instance. This memory is used to keep the
1807 present state of the chip and all its resources.
1808
1809 f_pInstSizes Pointer to structure containing the size of memory needed
1810 by all pointers internal to the API instance. The memory
1811 is needed to keep track of the present state of all the
1812 chip's resources.
1813
1814 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1815 #if !SKIP_Oct6100ApiAllocateInstanceMemory
1816 UINT32 Oct6100ApiAllocateInstanceMemory(
1817 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
1818 IN tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
1819 {
1820 tPOCT6100_SHARED_INFO pSharedInfo;
1821 UINT32 ulOffset;
1822
1823 /* Get local pointer to shared portion of instance. */
1824 pSharedInfo = f_pApiInstance->pSharedInfo;
1825
1826 /* Get address of first UINT32 of memory in API instance structure following */
1827 /* the static members of the API instance structure. */
1828 ulOffset = f_pInstSizes->ulApiInstStatic;
1829
1830 /*===================================================================*/
1831 /* Allocate memory for the echo channels.*/
1832 pSharedInfo->ulChannelListOfst = ulOffset;
1833 ulOffset += f_pInstSizes->ulChannelList;
1834 pSharedInfo->ulChannelAllocOfst = ulOffset;
1835 ulOffset += f_pInstSizes->ulChannelAlloc;
1836
1837 /*===================================================================*/
1838 /* Allocate memory for the TSI connections */
1839 pSharedInfo->ulTsiCnctListOfst = ulOffset;
1840 ulOffset += f_pInstSizes->ulTsiCnctList;
1841 pSharedInfo->ulTsiCnctAllocOfst = ulOffset;
1842 ulOffset += f_pInstSizes->ulTsiCnctAlloc;
1843 pSharedInfo->ulMixerEventListOfst = ulOffset;
1844 ulOffset += f_pInstSizes->ulMixerEventList;
1845 pSharedInfo->ulMixerEventAllocOfst = ulOffset;
1846 ulOffset += f_pInstSizes->ulMixerEventAlloc;
1847
1848 pSharedInfo->ulBiDirChannelListOfst = ulOffset;
1849 ulOffset += f_pInstSizes->ulBiDirChannelList;
1850 pSharedInfo->ulBiDirChannelAllocOfst = ulOffset;
1851 ulOffset += f_pInstSizes->ulBiDirChannelAlloc;
1852 pSharedInfo->ulCopyEventListOfst = ulOffset;
1853 ulOffset += f_pInstSizes->ulCopyEventList;
1854 pSharedInfo->ulCopyEventAllocOfst = ulOffset;
1855 ulOffset += f_pInstSizes->ulCopyEventAlloc;
1856
1857 /*===================================================================*/
1858 /* Allocate memory for the conference bridges */
1859 pSharedInfo->ulConfBridgeListOfst = ulOffset;
1860 ulOffset += f_pInstSizes->ulConfBridgeList;
1861 pSharedInfo->ulConfBridgeAllocOfst = ulOffset;
1862 ulOffset += f_pInstSizes->ulConfBridgeAlloc;
1863
1864 /*===================================================================*/
1865 /* Allocate memory for the flexible conferencing participants. */
1866 pSharedInfo->ulFlexConfParticipantListOfst = ulOffset;
1867 ulOffset += f_pInstSizes->ulFlexConfParticipantsList;
1868 pSharedInfo->ulFlexConfParticipantAllocOfst = ulOffset;
1869 ulOffset += f_pInstSizes->ulFlexConfParticipantsAlloc;
1870
1871 /*===================================================================*/
1872 /* Allocate memory for the play-out buffers */
1873 pSharedInfo->ulPlayoutBufListOfst = ulOffset;
1874 ulOffset += f_pInstSizes->ulPlayoutBufList;
1875 pSharedInfo->ulPlayoutBufAllocOfst = ulOffset;
1876 ulOffset += f_pInstSizes->ulPlayoutBufAlloc;
1877 pSharedInfo->ulPlayoutBufMemoryNodeListOfst = ulOffset;
1878 ulOffset += f_pInstSizes->ulPlayoutBufMemoryNodeList;
1879
1880
1881
1882 /*===================================================================*/
1883 /* Allocate memory for the phasing TSSTs */
1884 pSharedInfo->ulPhasingTsstListOfst = ulOffset;
1885 ulOffset += f_pInstSizes->ulPhasingTsstList;
1886 pSharedInfo->ulPhasingTsstAllocOfst = ulOffset;
1887 ulOffset += f_pInstSizes->ulPhasingTsstAlloc;
1888
1889 /*===================================================================*/
1890 /* Allocate memory for the ADPCM channel */
1891 pSharedInfo->ulAdpcmChanAllocOfst = ulOffset;
1892 ulOffset += f_pInstSizes->ulAdpcmChannelAlloc;
1893 pSharedInfo->ulAdpcmChanListOfst = ulOffset;
1894 ulOffset += f_pInstSizes->ulAdpcmChannelList;
1895
1896 /*===================================================================*/
1897 /* Allocate memory for the conversion memory */
1898 pSharedInfo->ulConversionMemoryAllocOfst = ulOffset;
1899 ulOffset += f_pInstSizes->ulConversionMemoryAlloc;
1900
1901 /*===================================================================*/
1902 /* Allocate memory for the TSI chariot memory */
1903 pSharedInfo->ulTsiMemoryAllocOfst = ulOffset;
1904 ulOffset += f_pInstSizes->ulTsiMemoryAlloc;
1905
1906 /*===================================================================*/
1907 /* Allocate memory for the TSST management */
1908 pSharedInfo->ulTsstAllocOfst = ulOffset;
1909 ulOffset += f_pInstSizes->ulTsstAlloc;
1910 pSharedInfo->ulTsstListOfst = ulOffset;
1911 ulOffset += f_pInstSizes->ulTsstEntryList;
1912 pSharedInfo->ulTsstListAllocOfst = ulOffset;
1913 ulOffset += f_pInstSizes->ulTsstEntryAlloc;
1914
1915 /*===================================================================*/
1916 pSharedInfo->SoftBufs.ulToneEventBufferMemOfst = ulOffset;
1917 ulOffset += f_pInstSizes->ulSoftToneEventsBuffer;
1918
1919 pSharedInfo->SoftBufs.ulBufPlayoutEventBufferMemOfst = ulOffset;
1920 ulOffset += f_pInstSizes->ulSoftBufPlayoutEventsBuffer;
1921 /*===================================================================*/
1922 pSharedInfo->RemoteDebugInfo.ulSessionListOfst = ulOffset;
1923 ulOffset += f_pInstSizes->ulRemoteDebugList;
1924
1925 pSharedInfo->RemoteDebugInfo.ulSessionTreeOfst = ulOffset;
1926 ulOffset += f_pInstSizes->ulRemoteDebugTree;
1927
1928 pSharedInfo->RemoteDebugInfo.ulDataBufOfst = ulOffset;
1929 ulOffset += f_pInstSizes->ulRemoteDebugDataBuf;
1930
1931 pSharedInfo->RemoteDebugInfo.ulPktCacheOfst = ulOffset;
1932 ulOffset += f_pInstSizes->ulRemoteDebugPktCache;
1933 /*===================================================================*/
1934
1935 return cOCT6100_ERR_OK;
1936 }
1937 #endif
1938
1939
1940 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1941
1942 Function: Oct6100ApiInitializeInstanceMemory
1943
1944 Description: Initializes the various members of the structure f_pApiInstance
1945 to reflect the current state of the chip and its resources.
1946
1947 -------------------------------------------------------------------------------
1948 | Argument | Description
1949 -------------------------------------------------------------------------------
1950 f_pApiInstance Pointer to API instance. This memory is used to keep the
1951 present state of the chip and all its resources.
1952
1953 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1954 #if !SKIP_Oct6100ApiInitializeInstanceMemory
1955 UINT32 Oct6100ApiInitializeInstanceMemory(
1956 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
1957 {
1958 UINT32 ulResult;
1959
1960 /*-----------------------------------------------------------------------------*/
1961 /* Initialize API EC channels. */
1962 ulResult = Oct6100ApiChannelsEchoSwInit( f_pApiInstance );
1963 if ( ulResult != cOCT6100_ERR_OK )
1964 return ulResult;
1965 /*-----------------------------------------------------------------------------*/
1966 /* Initialize the API TSI connection structures. */
1967 ulResult = Oct6100ApiTsiCnctSwInit( f_pApiInstance );
1968 if ( ulResult != cOCT6100_ERR_OK )
1969 return ulResult;
1970 /*-----------------------------------------------------------------------------*/
1971 /* Initialize the API conference bridges. */
1972 ulResult = Oct6100ApiConfBridgeSwInit( f_pApiInstance );
1973 if ( ulResult != cOCT6100_ERR_OK )
1974 return ulResult;
1975
1976 /*-----------------------------------------------------------------------------*/
1977 /* Initialize the API buffer playout structures. */
1978 ulResult = Oct6100ApiPlayoutBufferSwInit( f_pApiInstance );
1979 if ( ulResult != cOCT6100_ERR_OK )
1980 return ulResult;
1981
1982 /*-----------------------------------------------------------------------------*/
1983 /* Initialize the API phasing tssts. */
1984 ulResult = Oct6100ApiPhasingTsstSwInit( f_pApiInstance );
1985 if ( ulResult != cOCT6100_ERR_OK )
1986 return ulResult;
1987 /*-----------------------------------------------------------------------------*/
1988 /* Initialize the API ADPCM channels. */
1989 ulResult = Oct6100ApiAdpcmChanSwInit( f_pApiInstance );
1990 if ( ulResult != cOCT6100_ERR_OK )
1991 return ulResult;
1992
1993 /*-----------------------------------------------------------------------------*/
1994 /* Initialize the external memory management structures. */
1995 ulResult = Oct6100ApiMemorySwInit( f_pApiInstance );
1996 if ( ulResult != cOCT6100_ERR_OK )
1997 return ulResult;
1998
1999 /*-----------------------------------------------------------------------------*/
2000 /* Initialize TSST management stuctures. */
2001 ulResult = Oct6100ApiTsstSwInit( f_pApiInstance );
2002 if ( ulResult != cOCT6100_ERR_OK )
2003 return ulResult;
2004
2005 /*-----------------------------------------------------------------------------*/
2006 /* Initialize the mixer management stuctures. */
2007 ulResult = Oct6100ApiMixerSwInit( f_pApiInstance );
2008 if ( ulResult != cOCT6100_ERR_OK )
2009 return ulResult;
2010
2011 /*-----------------------------------------------------------------------------*/
2012 /* Initialize the remote debugging session management variables. */
2013 ulResult = Oct6100ApiRemoteDebuggingSwInit( f_pApiInstance );
2014 if ( ulResult != cOCT6100_ERR_OK )
2015 return ulResult;
2016
2017 /*-----------------------------------------------------------------------------*/
2018 /* Configure the interrupt registers. */
2019 ulResult = Oct6100ApiIsrSwInit( f_pApiInstance );
2020 if ( ulResult != cOCT6100_ERR_OK )
2021 return ulResult;
2022
2023 return cOCT6100_ERR_OK;
2024 }
2025 #endif
2026
2027
2028 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2029
2030 Function: Oct6100ApiGetChipRevisionNum
2031
2032 Description: Reads the chip's revision number register.
2033
2034 -------------------------------------------------------------------------------
2035 | Argument | Description
2036 -------------------------------------------------------------------------------
2037 f_pApiInstance Pointer to API instance. This memory is used to keep
2038 the present state of the chip and all its resources.
2039
2040 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2041 #if !SKIP_Oct6100ApiGetChipRevisionNum
2042 UINT32 Oct6100ApiGetChipRevisionNum(
2043 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
2044 {
2045 tPOCT6100_SHARED_INFO pSharedInfo;
2046 tOCT6100_READ_PARAMS ReadParams;
2047 UINT32 ulResult;
2048 UINT16 usReadData;
2049
2050 /* Get local pointer to shared portion of instance. */
2051 pSharedInfo = f_pApiInstance->pSharedInfo;
2052
2053 /* Get the chip revision number. */
2054 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
2055
2056 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
2057 ReadParams.ulReadAddress = cOCT6100_CHIP_ID_REVISION_REG;
2058 ReadParams.pusReadData = &usReadData;
2059
2060 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
2061 if ( ulResult != cOCT6100_ERR_OK )
2062 return ulResult;
2063
2064 /* Save the info in the API miscellaneous structure. */
2065 pSharedInfo->MiscVars.usChipId = (UINT16)( usReadData & 0xFF );
2066 pSharedInfo->MiscVars.usChipRevision = (UINT16)( usReadData >> 8 );
2067
2068 return cOCT6100_ERR_OK;
2069 }
2070 #endif
2071
2072 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2073
2074 Function: Oct6100ApiCheckImageFileHeader
2075
2076 Description: This function check if the image loaded is valid
2077
2078 -------------------------------------------------------------------------------
2079 | Argument | Description
2080 -------------------------------------------------------------------------------
2081 f_pApiInstance Pointer to API instance. This memory is used to keep the
2082 present state of the chip and all its resources.
2083
2084 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2085 #if !SKIP_Oct6100ApiCheckImageFileHeader
2086 UINT32 Oct6100ApiCheckImageFileHeader(
2087 IN tPOCT6100_CHIP_OPEN f_pChipOpen )
2088 {
2089
2090 PUINT8 pszImageInfoStart = NULL;
2091 UINT32 ulStrLen;
2092
2093 ulStrLen = Oct6100ApiStrLen( (PUINT8)cOCT6100_IMAGE_START_STRING );
2094 pszImageInfoStart = (PUINT8) Oct6100ApiStrStr(f_pChipOpen->pbyImageFile,(PUINT8)cOCT6100_IMAGE_START_STRING,
2095 f_pChipOpen->pbyImageFile + ulStrLen);
2096 if (pszImageInfoStart == NULL)
2097 return cOCT6100_ERR_OPEN_IMAGE_FILE;
2098
2099 return cOCT6100_ERR_OK;
2100 }
2101 #endif
2102
2103 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2104
2105 Function: Oct6100ApiDecodeKeyAndBist
2106
2107 Description: This function decodes the key and runs the automatic BIST.
2108
2109 -------------------------------------------------------------------------------
2110 | Argument | Description
2111 -------------------------------------------------------------------------------
2112 f_pApiInstance Pointer to API instance. This memory is used to keep the
2113 present state of the chip and all its resources.
2114
2115 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2116 #if !SKIP_Oct6100ApiDecodeKeyAndBist
2117 UINT32 Oct6100ApiDecodeKeyAndBist(
2118 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
2119 {
2120 tPOCT6100_SHARED_INFO pSharedInfo;
2121 tPOCT6100_API_CHIP_CONFIG pChipConfig;
2122 tOCT6100_WRITE_PARAMS WriteParams;
2123 tOCT6100_READ_PARAMS ReadParams;
2124 UINT16 ausBistData[ 3 ];
2125 UINT16 usReadData;
2126 UINT32 ulResult;
2127 BOOL fBitEqual;
2128 UINT32 i;
2129
2130 /* Get local pointer to shared portion of instance. */
2131 pSharedInfo = f_pApiInstance->pSharedInfo;
2132
2133 /* Obtain a local pointer to the chip config structure */
2134 /* contained in the instance structure. */
2135 pChipConfig = &pSharedInfo->ChipConfig;
2136
2137 /* Set the process context and user chip ID parameters once and for all. */
2138 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2139
2140 WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
2141
2142 /* Set the process context and user chip ID parameters once and for all. */
2143 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
2144
2145 ReadParams.ulUserChipId = pChipConfig->ulUserChipId;
2146
2147 /* Write key in CPU internal memory. */
2148 for(i=0; i<8; i++)
2149 {
2150 WriteParams.ulWriteAddress = 0x150;
2151 WriteParams.usWriteData = 0x0000;
2152 if (( i % 2 ) == 0)
2153 {
2154 WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 2]) << 8;
2155 WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 3]) << 0;
2156 }
2157 else
2158 {
2159 WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 0]) << 8;
2160 WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 1]) << 0;
2161 }
2162
2163 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2164 if ( ulResult != cOCT6100_ERR_OK )
2165 return ulResult;
2166
2167 WriteParams.ulWriteAddress = 0x152;
2168 WriteParams.usWriteData = (UINT16)( 0x8000 | i );
2169
2170 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2171 if ( ulResult != cOCT6100_ERR_OK )
2172 return ulResult;
2173 }
2174
2175 /* Write one in CPU internal memory. */
2176 for(i=0; i<8; i++)
2177 {
2178 WriteParams.ulWriteAddress = 0x150;
2179 if (i == 0)
2180 {
2181 WriteParams.usWriteData = 0x0001;
2182 }
2183 else
2184 {
2185 WriteParams.usWriteData = 0x0000;
2186 }
2187
2188 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2189 if ( ulResult != cOCT6100_ERR_OK )
2190 return ulResult;
2191
2192 WriteParams.ulWriteAddress = 0x152;
2193 WriteParams.usWriteData = (UINT16)( 0x8000 | ( i + 8 ));
2194
2195 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2196 if ( ulResult != cOCT6100_ERR_OK )
2197 return ulResult;
2198 }
2199
2200 /* Clear memory access registers: */
2201 WriteParams.ulWriteAddress = 0x150;
2202 WriteParams.usWriteData = 0x0000;
2203
2204 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2205 if ( ulResult != cOCT6100_ERR_OK )
2206 return ulResult;
2207
2208 WriteParams.ulWriteAddress = 0x152;
2209
2210 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2211 if ( ulResult != cOCT6100_ERR_OK )
2212 return ulResult;
2213
2214 /* Run BISTs and key decode. */
2215 WriteParams.ulWriteAddress = 0x160;
2216 WriteParams.usWriteData = 0x0081;
2217
2218 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2219 if ( ulResult != cOCT6100_ERR_OK )
2220 return ulResult;
2221
2222 /* Wait for the key decode PC to clear. */
2223 ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x160, 0, 0, 100000, &fBitEqual );
2224 if ( TRUE != fBitEqual )
2225 return cOCT6100_ERR_FATAL_13;
2226
2227 /* Read the key valid bit to make sure everything is ok. */
2228 ReadParams.ulReadAddress = 0x160;
2229 ReadParams.pusReadData = &usReadData;
2230
2231 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
2232 if ( ulResult != cOCT6100_ERR_OK )
2233 return ulResult;
2234
2235 /* Either the firmware image was not loaded correctly (from pointer given by user) */
2236 /* or the channel capacity pins of the chip do not match what the firmware is expecting. */
2237 if ( ( usReadData & 0x4 ) == 0 )
2238 return cOCT6100_ERR_OPEN_INVALID_FIRMWARE_OR_CAPACITY_PINS;
2239
2240 /* Read the result of the internal memory bist. */
2241 ReadParams.ulReadAddress = 0x110;
2242 ReadParams.pusReadData = &ausBistData[ 0 ];
2243
2244 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
2245 if ( ulResult != cOCT6100_ERR_OK )
2246 return ulResult;
2247
2248 ReadParams.ulReadAddress = 0x114;
2249 ReadParams.pusReadData = &ausBistData[ 1 ];
2250
2251 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
2252 if ( ulResult != cOCT6100_ERR_OK )
2253 return ulResult;
2254
2255 ReadParams.ulReadAddress = 0x118;
2256 ReadParams.pusReadData = &ausBistData[ 2 ];
2257
2258 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
2259 if ( ulResult != cOCT6100_ERR_OK )
2260 return ulResult;
2261
2262 /* Check if an error was reported. */
2263 if (ausBistData[0] != 0x0000 || ausBistData[1] != 0x0000 || ausBistData[2] != 0x0000)
2264 return cOCT6100_ERR_OPEN_INTERNAL_MEMORY_BIST;
2265
2266 /* Put key decoder in powerdown. */
2267 WriteParams.ulWriteAddress = 0x160;
2268 WriteParams.usWriteData = 0x008A;
2269
2270 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2271 if ( ulResult != cOCT6100_ERR_OK )
2272 return ulResult;
2273
2274 return cOCT6100_ERR_OK;
2275 }
2276 #endif
2277
2278 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2279
2280 Function: Oct6100ApiBootFc2PllReadCap
2281
2282 Description: Configures the chip's FC2 PLL. Special version for GetcapacityPins.
2283
2284 -------------------------------------------------------------------------------
2285 | Argument | Description
2286 -------------------------------------------------------------------------------
2287 f_pApiInstance Pointer to API instance. This memory is used to keep the
2288 present state of the chip and all its resources.
2289
2290 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2291 UINT32 Oct6100ApiBootFc2PllReadCap(
2292 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2293 IN tPOCT6100_API_GET_CAPACITY_PINS f_pGetCapacityPins)
2294 {
2295 tOCT6100_WRITE_PARAMS WriteParams;
2296 UINT32 aulWaitTime[ 2 ];
2297 UINT32 ulResult;
2298 UINT32 ulFc2PllDivisor = 0;
2299 UINT32 ulMtDivisor = 0;
2300 UINT32 ulFcDivisor = 0;
2301
2302 /* Set the process context and user chip ID parameters once and for all. */
2303 WriteParams.pProcessContext = f_pGetCapacityPins->pProcessContext;
2304
2305 WriteParams.ulUserChipId = f_pGetCapacityPins->ulUserChipId;
2306
2307 /* First put the chip and main registers in soft-reset. */
2308 WriteParams.ulWriteAddress = 0x100;
2309 WriteParams.usWriteData = 0x0;
2310
2311 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2312 if ( ulResult != cOCT6100_ERR_OK )
2313 return ulResult;
2314
2315 ulFc2PllDivisor = 0x1050;
2316 ulMtDivisor = 0x4300;
2317 ulFcDivisor = 0x4043;
2318
2319 /* Setup delay chains. */
2320 if ( (f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR) || (f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
2321 {
2322 /* SDRAM */
2323 WriteParams.ulWriteAddress = 0x1B0;
2324 WriteParams.usWriteData = 0x1003;
2325
2326 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2327 if ( ulResult != cOCT6100_ERR_OK )
2328 return ulResult;
2329
2330 WriteParams.ulWriteAddress = 0x1B2;
2331 WriteParams.usWriteData = 0x0021;
2332
2333 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2334 if ( ulResult != cOCT6100_ERR_OK )
2335 return ulResult;
2336
2337 WriteParams.ulWriteAddress = 0x1B4;
2338 WriteParams.usWriteData = 0x4030;
2339
2340 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2341 if ( ulResult != cOCT6100_ERR_OK )
2342 return ulResult;
2343
2344 WriteParams.ulWriteAddress = 0x1B6;
2345 WriteParams.usWriteData = 0x0021;
2346
2347 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2348 if ( ulResult != cOCT6100_ERR_OK )
2349 return ulResult;
2350 }
2351 else /* if ( cOCT6100_MEM_TYPE_DDR == pChipConfig->byMemoryType ) */
2352 {
2353 /* DDR */
2354 WriteParams.ulWriteAddress = 0x1B0;
2355 WriteParams.usWriteData = 0x201F;
2356
2357 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2358 if ( ulResult != cOCT6100_ERR_OK )
2359 return ulResult;
2360
2361 WriteParams.ulWriteAddress = 0x1B2;
2362 WriteParams.usWriteData = 0x0021;
2363
2364 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2365 if ( ulResult != cOCT6100_ERR_OK )
2366 return ulResult;
2367
2368 WriteParams.ulWriteAddress = 0x1B4;
2369 WriteParams.usWriteData = 0x1000;
2370
2371 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2372 if ( ulResult != cOCT6100_ERR_OK )
2373 return ulResult;
2374
2375 WriteParams.ulWriteAddress = 0x1B6;
2376 WriteParams.usWriteData = 0x0021;
2377
2378 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2379 if ( ulResult != cOCT6100_ERR_OK )
2380 return ulResult;
2381 }
2382
2383 /* udqs */
2384 WriteParams.ulWriteAddress = 0x1B8;
2385 WriteParams.usWriteData = 0x1003;
2386
2387 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2388 if ( ulResult != cOCT6100_ERR_OK )
2389 return ulResult;
2390
2391 WriteParams.ulWriteAddress = 0x1BA;
2392 WriteParams.usWriteData = 0x0021;
2393
2394 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2395 if ( ulResult != cOCT6100_ERR_OK )
2396 return ulResult;
2397
2398 /* ldqs */
2399 WriteParams.ulWriteAddress = 0x1BC;
2400 WriteParams.usWriteData = 0x1000;
2401
2402 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2403 if ( ulResult != cOCT6100_ERR_OK )
2404 return ulResult;
2405
2406 WriteParams.ulWriteAddress = 0x1BE;
2407 WriteParams.usWriteData = 0x0021;
2408
2409 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2410 if ( ulResult != cOCT6100_ERR_OK )
2411 return ulResult;
2412
2413 WriteParams.ulWriteAddress = 0x12C;
2414 WriteParams.usWriteData = 0x0000;
2415
2416 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2417 if ( ulResult != cOCT6100_ERR_OK )
2418 return ulResult;
2419
2420 WriteParams.ulWriteAddress = 0x12E;
2421 WriteParams.usWriteData = 0x0000;
2422
2423 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2424 if ( ulResult != cOCT6100_ERR_OK )
2425 return ulResult;
2426
2427 /* Select fc2pll for fast_clk and mtsclk sources. Select mem_clk_i for afclk. */
2428 WriteParams.ulWriteAddress = 0x140;
2429 WriteParams.usWriteData = (UINT16)ulMtDivisor;
2430
2431 if ( f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
2432 WriteParams.usWriteData |= 0x0001;
2433 else
2434 WriteParams.usWriteData |= 0x0004;
2435
2436 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2437 if ( ulResult != cOCT6100_ERR_OK )
2438 return ulResult;
2439
2440 WriteParams.ulWriteAddress = 0x144;
2441 WriteParams.usWriteData = (UINT16)ulFcDivisor;
2442
2443 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2444 if ( ulResult != cOCT6100_ERR_OK )
2445 return ulResult;
2446
2447 WriteParams.ulWriteAddress = 0x13E;
2448 WriteParams.usWriteData = 0x0001; /* Remove reset from above divisors */
2449
2450 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2451 if ( ulResult != cOCT6100_ERR_OK )
2452 return ulResult;
2453
2454 /* Select upclk directly as ref source for fc2pll. */
2455 WriteParams.ulWriteAddress = 0x134;
2456 WriteParams.usWriteData = 0x0001;
2457
2458 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2459 if ( ulResult != cOCT6100_ERR_OK )
2460 return ulResult;
2461
2462 /* Setup fc2pll. */
2463 WriteParams.ulWriteAddress = 0x132;
2464 WriteParams.usWriteData = (UINT16)ulFc2PllDivisor;
2465
2466 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2467 if ( ulResult != cOCT6100_ERR_OK )
2468 return ulResult;
2469
2470 WriteParams.usWriteData |= 0x02; /* Raise fb divisor reset. */
2471 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2472 if ( ulResult != cOCT6100_ERR_OK )
2473 return ulResult;
2474
2475 WriteParams.usWriteData |= 0x80; /* Raise IDDTN signal.*/
2476 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2477 if ( ulResult != cOCT6100_ERR_OK )
2478 return ulResult;
2479
2480 /* Wait for fc2pll to stabilize. */
2481 aulWaitTime[ 0 ] = 2000;
2482 aulWaitTime[ 1 ] = 0;
2483 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
2484 if ( ulResult != cOCT6100_ERR_OK )
2485 return ulResult;
2486
2487 /* Drive mem_clk_o out on proper interface. */
2488 if ( TRUE == f_pGetCapacityPins->fEnableMemClkOut )
2489 {
2490 if ( (f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR) || (f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
2491 {
2492 WriteParams.ulWriteAddress = 0x128;
2493 WriteParams.usWriteData = 0x0301;
2494
2495 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2496 if ( ulResult != cOCT6100_ERR_OK )
2497 return ulResult;
2498 }
2499
2500 if ( f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_DDR || f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
2501 {
2502 WriteParams.ulWriteAddress = 0x12A;
2503 WriteParams.usWriteData = 0x000F;
2504
2505 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2506 if ( ulResult != cOCT6100_ERR_OK )
2507 return ulResult;
2508 }
2509 }
2510
2511 return cOCT6100_ERR_OK;
2512 }
2513 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2514
2515 Function: Oct6100ApiBootFc2Pll
2516
2517 Description: Configures the chip's FC2 PLL.
2518
2519 -------------------------------------------------------------------------------
2520 | Argument | Description
2521 -------------------------------------------------------------------------------
2522 f_pApiInstance Pointer to API instance. This memory is used to keep the
2523 present state of the chip and all its resources.
2524
2525 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2526 #if !SKIP_Oct6100ApiBootFc2Pll
2527 UINT32 Oct6100ApiBootFc2Pll(
2528 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
2529 {
2530 tPOCT6100_SHARED_INFO pSharedInfo;
2531 tPOCT6100_API_CHIP_CONFIG pChipConfig;
2532 tOCT6100_WRITE_PARAMS WriteParams;
2533 UINT32 aulWaitTime[ 2 ];
2534 UINT32 ulResult;
2535 UINT32 ulFc2PllDivisor = 0;
2536 UINT32 ulMtDivisor = 0;
2537 UINT32 ulFcDivisor = 0;
2538
2539 /* Get local pointer to shared portion of instance. */
2540 pSharedInfo = f_pApiInstance->pSharedInfo;
2541
2542 /* Obtain local pointer to chip configuration structure. */
2543 pChipConfig = &pSharedInfo->ChipConfig;
2544
2545 /* Set the process context and user chip ID parameters once and for all. */
2546 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2547
2548 WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
2549
2550 /* First put the chip and main registers in soft-reset. */
2551 WriteParams.ulWriteAddress = 0x100;
2552 WriteParams.usWriteData = 0x0;
2553
2554 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
2555 if ( ulResult != cOCT6100_ERR_OK )
2556 return ulResult;
2557
2558 /* Select register configuration based on the memory frequency. */
2559 switch ( f_pApiInstance->pSharedInfo->ChipConfig.ulMemClkFreq )
2560 {
2561 case 133000000:
2562 ulFc2PllDivisor = 0x1050;
2563 ulMtDivisor = 0x4300;
2564 ulFcDivisor = 0x4043;
2565 pSharedInfo->MiscVars.usMaxNumberOfChannels = 672;
2566 pSharedInfo->MiscVars.usMaxH100Speed = 124;
2567
2568 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2569 pSharedInfo->MiscVars.usTdmClkBoundary = 0x050B;
2570 else
2571 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0516;
2572
2573 break;
2574 case 125000000:
2575 ulFc2PllDivisor = 0x0F50;
2576 ulMtDivisor = 0x4300;
2577 ulFcDivisor = 0x4043;
2578 pSharedInfo->MiscVars.usMaxNumberOfChannels = 624;
2579 pSharedInfo->MiscVars.usMaxH100Speed = 116;
2580
2581 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2582 pSharedInfo->MiscVars.usTdmClkBoundary = 0x04CA;
2583 else
2584 pSharedInfo->MiscVars.usTdmClkBoundary = 0x04D4;
2585
2586 break;
2587 case 117000000:
2588 ulFc2PllDivisor = 0x0E50;
2589 ulMtDivisor = 0x4300;
2590 ulFcDivisor = 0x4043;
2591 pSharedInfo->MiscVars.usMaxNumberOfChannels = 576;
2592 pSharedInfo->MiscVars.usMaxH100Speed = 108;
2593
2594 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2595 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0489;
2596 else
2597 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0492;
2598
2599 break;
2600 case 108000000:
2601 ulFc2PllDivisor = 0x0D50;
2602 ulMtDivisor = 0x4300;
2603 ulFcDivisor = 0x4043;
2604 pSharedInfo->MiscVars.usMaxNumberOfChannels = 528;
2605 pSharedInfo->MiscVars.usMaxH100Speed = 99;
2606
2607 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2608 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0408;
2609 else
2610 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0410;
2611
2612 break;
2613 case 100000000:
2614 ulFc2PllDivisor = 0x0C50;
2615 ulMtDivisor = 0x4300;
2616 ulFcDivisor = 0x4043;
2617 pSharedInfo->MiscVars.usMaxNumberOfChannels = 480;
2618 pSharedInfo->MiscVars.usMaxH100Speed = 91;
2619
2620 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2621 pSharedInfo->MiscVars.usTdmClkBoundary = 0x03C8;
2622 else
2623 pSharedInfo->MiscVars.usTdmClkBoundary = 0x03D0;
2624
2625 break;
2626 case 92000000:
2627 ulFc2PllDivisor = 0x0B50;
2628 ulMtDivisor = 0x4300;
2629 ulFcDivisor = 0x4043;
2630 pSharedInfo->MiscVars.usMaxNumberOfChannels = 432;
2631 pSharedInfo->MiscVars.usMaxH100Speed = 83;
2632
2633 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2634 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0387;
2635 else
2636 pSharedInfo->MiscVars.usTdmClkBoundary = 0x038E;
2637
2638 break;
2639 case 83000000:
2640 ulFc2PllDivisor = 0x0A50;
2641 ulMtDivisor = 0x4300;
2642 ulFcDivisor = 0x4043;
2643 pSharedInfo->MiscVars.usMaxNumberOfChannels = 384;
2644 pSharedInfo->MiscVars.usMaxH100Speed = 74;
2645
2646 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2647 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0346;
2648 else
2649 pSharedInfo->MiscVars.usTdmClkBoundary = 0x034C;
2650
2651 break;
2652 case 75000000:
2653 ulFc2PllDivisor = 0x0950;
2654 ulMtDivisor = 0x4200;
2655 ulFcDivisor = 0x4043;
2656 pSharedInfo->MiscVars.usMaxNumberOfChannels = 336;
2657 pSharedInfo->MiscVars.usMaxH100Speed = 64;
2658
2659 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
2660 pSharedInfo->MiscVars.usTdmClkBoundary = 0x0306;
2661 else
2662 pSharedInfo->MiscVars.usTdmClkBoundary = 0x030C;
2663
2664 break;
2665 default:
2666 return cOCT6100_ERR_FATAL_DB;
2667 }
2668
2669 /* Verify that the max channel is not too big based on the chip frequency. */
2670 if ( pSharedInfo->ChipConfig.usMaxChannels > pSharedInfo->MiscVars.usMaxNumberOfChannels )
2671 return cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS;
2672
2673 /* Setup delay chains. */
2674 if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
2675 {
2676 /* SDRAM */
2677 WriteParams.ulWriteAddress = 0x1B0;
2678 WriteParams.usWriteData = 0x1003;
2679
2680 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2681 if ( ulResult != cOCT6100_ERR_OK )
2682 return ulResult;
2683
2684 WriteParams.ulWriteAddress = 0x1B2;
2685 WriteParams.usWriteData = 0x0021;
2686
2687 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2688 if ( ulResult != cOCT6100_ERR_OK )
2689 return ulResult;
2690
2691 WriteParams.ulWriteAddress = 0x1B4;
2692 WriteParams.usWriteData = 0x4030;
2693
2694 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2695 if ( ulResult != cOCT6100_ERR_OK )
2696 return ulResult;
2697
2698 WriteParams.ulWriteAddress = 0x1B6;
2699 WriteParams.usWriteData = 0x0021;
2700
2701 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2702 if ( ulResult != cOCT6100_ERR_OK )
2703 return ulResult;
2704 }
2705 else /* if ( cOCT6100_MEM_TYPE_DDR == pChipConfig->byMemoryType ) */
2706 {
2707 /* DDR */
2708 WriteParams.ulWriteAddress = 0x1B0;
2709 WriteParams.usWriteData = 0x201F;
2710
2711 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2712 if ( ulResult != cOCT6100_ERR_OK )
2713 return ulResult;
2714
2715 WriteParams.ulWriteAddress = 0x1B2;
2716 WriteParams.usWriteData = 0x0021;
2717
2718 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2719 if ( ulResult != cOCT6100_ERR_OK )
2720 return ulResult;
2721
2722 WriteParams.ulWriteAddress = 0x1B4;
2723 WriteParams.usWriteData = 0x1000;
2724
2725 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2726 if ( ulResult != cOCT6100_ERR_OK )
2727 return ulResult;
2728
2729 WriteParams.ulWriteAddress = 0x1B6;
2730 WriteParams.usWriteData = 0x0021;
2731
2732 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2733 if ( ulResult != cOCT6100_ERR_OK )
2734 return ulResult;
2735 }
2736
2737 /* udqs */
2738 WriteParams.ulWriteAddress = 0x1B8;
2739 WriteParams.usWriteData = 0x1003;
2740
2741 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2742 if ( ulResult != cOCT6100_ERR_OK )
2743 return ulResult;
2744
2745 WriteParams.ulWriteAddress = 0x1BA;
2746 WriteParams.usWriteData = 0x0021;
2747
2748 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2749 if ( ulResult != cOCT6100_ERR_OK )
2750 return ulResult;
2751
2752 /* ldqs */
2753 WriteParams.ulWriteAddress = 0x1BC;
2754 WriteParams.usWriteData = 0x1000;
2755
2756 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2757 if ( ulResult != cOCT6100_ERR_OK )
2758 return ulResult;
2759
2760 WriteParams.ulWriteAddress = 0x1BE;
2761 WriteParams.usWriteData = 0x0021;
2762
2763 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2764 if ( ulResult != cOCT6100_ERR_OK )
2765 return ulResult;
2766
2767 WriteParams.ulWriteAddress = 0x12C;
2768 WriteParams.usWriteData = 0x0000;
2769
2770 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2771 if ( ulResult != cOCT6100_ERR_OK )
2772 return ulResult;
2773
2774 WriteParams.ulWriteAddress = 0x12E;
2775 WriteParams.usWriteData = 0x0000;
2776
2777 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2778 if ( ulResult != cOCT6100_ERR_OK )
2779 return ulResult;
2780
2781 /* Select fc2pll for fast_clk and mtsclk sources. Select mem_clk_i for afclk. */
2782 WriteParams.ulWriteAddress = 0x140;
2783 WriteParams.usWriteData = (UINT16)ulMtDivisor;
2784
2785 if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
2786 WriteParams.usWriteData |= 0x0001;
2787 else
2788 WriteParams.usWriteData |= 0x0004;
2789
2790 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2791 if ( ulResult != cOCT6100_ERR_OK )
2792 return ulResult;
2793
2794 WriteParams.ulWriteAddress = 0x144;
2795 WriteParams.usWriteData = (UINT16)ulFcDivisor;
2796
2797 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2798 if ( ulResult != cOCT6100_ERR_OK )
2799 return ulResult;
2800
2801 WriteParams.ulWriteAddress = 0x13E;
2802 WriteParams.usWriteData = 0x0001; /* Remove reset from above divisors */
2803
2804 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2805 if ( ulResult != cOCT6100_ERR_OK )
2806 return ulResult;
2807
2808 /* Select upclk directly as ref source for fc2pll. */
2809 WriteParams.ulWriteAddress = 0x134;
2810 WriteParams.usWriteData = 0x0001;
2811
2812 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2813 if ( ulResult != cOCT6100_ERR_OK )
2814 return ulResult;
2815
2816 /* Setup fc2pll. */
2817 WriteParams.ulWriteAddress = 0x132;
2818 WriteParams.usWriteData = (UINT16)ulFc2PllDivisor;
2819
2820 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2821 if ( ulResult != cOCT6100_ERR_OK )
2822 return ulResult;
2823
2824 WriteParams.usWriteData |= 0x02; /* Raise fb divisor reset. */
2825 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2826 if ( ulResult != cOCT6100_ERR_OK )
2827 return ulResult;
2828
2829 WriteParams.usWriteData |= 0x80; /* Raise IDDTN signal.*/
2830 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2831 if ( ulResult != cOCT6100_ERR_OK )
2832 return ulResult;
2833
2834 /* Wait for fc2pll to stabilize. */
2835 aulWaitTime[ 0 ] = 2000;
2836 aulWaitTime[ 1 ] = 0;
2837 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
2838 if ( ulResult != cOCT6100_ERR_OK )
2839 return ulResult;
2840
2841 /* Drive mem_clk_o out on proper interface. */
2842 if ( TRUE == pChipConfig->fEnableMemClkOut )
2843 {
2844 if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
2845 {
2846 WriteParams.ulWriteAddress = 0x128;
2847 WriteParams.usWriteData = 0x0301;
2848
2849 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2850 if ( ulResult != cOCT6100_ERR_OK )
2851 return ulResult;
2852 }
2853
2854 if ( pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_DDR || pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
2855 {
2856 WriteParams.ulWriteAddress = 0x12A;
2857 WriteParams.usWriteData = 0x000F;
2858
2859 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2860 if ( ulResult != cOCT6100_ERR_OK )
2861 return ulResult;
2862 }
2863 }
2864
2865 return cOCT6100_ERR_OK;
2866 }
2867 #endif
2868
2869 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2870
2871 Function: Oct6100ApiProgramFc1PllReadCap
2872
2873 Description: Configures the chip's FC1 PLL. Special version for getCapacityPins.
2874
2875 -------------------------------------------------------------------------------
2876 | Argument | Description
2877 -------------------------------------------------------------------------------
2878 f_pApiInstance Pointer to API instance. This memory is used to keep the
2879 present state of the chip and all its resources.
2880
2881 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2882 UINT32 Oct6100ApiProgramFc1PllReadCap(
2883 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2884 IN tPOCT6100_API_GET_CAPACITY_PINS f_pGetCapacityPins)
2885 {
2886 tOCT6100_WRITE_PARAMS WriteParams;
2887 UINT32 aulWaitTime[ 2 ];
2888 UINT32 ulResult;
2889
2890 /* Set the process context and user chip ID parameters once and for all. */
2891 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2892
2893 WriteParams.ulUserChipId = f_pGetCapacityPins->ulUserChipId;
2894
2895 /* Programm P/Z bits. */
2896 WriteParams.ulWriteAddress = 0x130;
2897
2898 if ( f_pGetCapacityPins->ulMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
2899 WriteParams.usWriteData = 0x0041;
2900 else
2901 WriteParams.usWriteData = 0x0040;
2902
2903 WriteParams.usWriteData |= ( f_pGetCapacityPins->ulMemoryType << 8 );
2904
2905 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2906 if ( ulResult != cOCT6100_ERR_OK )
2907 return ulResult;
2908
2909 /* Raise FB divisor. */
2910 WriteParams.usWriteData |= 0x0002;
2911
2912 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2913 if ( ulResult != cOCT6100_ERR_OK )
2914 return ulResult;
2915
2916 /* Raise IDDTN. */
2917 WriteParams.usWriteData |= 0x0080;
2918
2919 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2920 if ( ulResult != cOCT6100_ERR_OK )
2921 return ulResult;
2922
2923 /* Wait for fc1pll to stabilize. */
2924 aulWaitTime[ 0 ] = 2000;
2925 aulWaitTime[ 1 ] = 0;
2926 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
2927 if ( ulResult != cOCT6100_ERR_OK )
2928 return ulResult;
2929
2930 /* Enable all the clock domains to do reset procedure. */
2931 WriteParams.ulWriteAddress = 0x186;
2932 WriteParams.usWriteData = 0x015F;
2933
2934 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2935 if ( ulResult != cOCT6100_ERR_OK )
2936 return ulResult;
2937
2938 aulWaitTime[ 0 ] = 15000;
2939 aulWaitTime[ 1 ] = 0;
2940 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
2941 if ( ulResult != cOCT6100_ERR_OK )
2942 return ulResult;
2943
2944 return cOCT6100_ERR_OK;
2945 }
2946 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2947
2948 Function: Oct6100ApiProgramFc1Pll
2949
2950 Description: Configures the chip's FC1 PLL.
2951
2952 -------------------------------------------------------------------------------
2953 | Argument | Description
2954 -------------------------------------------------------------------------------
2955 f_pApiInstance Pointer to API instance. This memory is used to keep the
2956 present state of the chip and all its resources.
2957
2958 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2959 #if !SKIP_Oct6100ApiProgramFc1Pll
2960 UINT32 Oct6100ApiProgramFc1Pll(
2961 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
2962 {
2963 tPOCT6100_SHARED_INFO pSharedInfo;
2964 tPOCT6100_API_CHIP_CONFIG pChipConfig;
2965 tOCT6100_WRITE_PARAMS WriteParams;
2966 UINT32 aulWaitTime[ 2 ];
2967 UINT32 ulResult;
2968
2969 /* Get local pointer to shared portion of instance. */
2970 pSharedInfo = f_pApiInstance->pSharedInfo;
2971
2972 /* Obtain local pointer to chip configuration structure. */
2973 pChipConfig = &pSharedInfo->ChipConfig;
2974
2975 /* Set the process context and user chip ID parameters once and for all. */
2976 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2977
2978 WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
2979
2980 /* Programm P/Z bits. */
2981 WriteParams.ulWriteAddress = 0x130;
2982
2983 if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
2984 WriteParams.usWriteData = 0x0041;
2985 else
2986 WriteParams.usWriteData = 0x0040;
2987
2988 WriteParams.usWriteData |= ( pChipConfig->byMemoryType << 8 );
2989
2990 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2991 if ( ulResult != cOCT6100_ERR_OK )
2992 return ulResult;
2993
2994 /* Raise FB divisor. */
2995 WriteParams.usWriteData |= 0x0002;
2996
2997 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2998 if ( ulResult != cOCT6100_ERR_OK )
2999 return ulResult;
3000
3001 /* Raise IDDTN. */
3002 WriteParams.usWriteData |= 0x0080;
3003
3004 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3005 if ( ulResult != cOCT6100_ERR_OK )
3006 return ulResult;
3007
3008 /* Wait for fc1pll to stabilize. */
3009 aulWaitTime[ 0 ] = 2000;
3010 aulWaitTime[ 1 ] = 0;
3011 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
3012 if ( ulResult != cOCT6100_ERR_OK )
3013 return ulResult;
3014
3015 /* Enable all the clock domains to do reset procedure. */
3016 WriteParams.ulWriteAddress = 0x186;
3017 WriteParams.usWriteData = 0x015F;
3018
3019 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3020 if ( ulResult != cOCT6100_ERR_OK )
3021 return ulResult;
3022
3023 aulWaitTime[ 0 ] = 15000;
3024 aulWaitTime[ 1 ] = 0;
3025 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
3026 if ( ulResult != cOCT6100_ERR_OK )
3027 return ulResult;
3028
3029 return cOCT6100_ERR_OK;
3030 }
3031 #endif
3032
3033
3034 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3035
3036 Function: Oct6100ApiBootFc1Pll
3037
3038 Description: Boot the chip's FC1 PLL.
3039
3040 -------------------------------------------------------------------------------
3041 | Argument | Description
3042 -------------------------------------------------------------------------------
3043 f_pApiInstance Pointer to API instance. This memory is used to keep the
3044 present state of the chip and all its resources.
3045
3046 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3047 #if !SKIP_Oct6100ApiBootFc1Pll
3048 UINT32 Oct6100ApiBootFc1Pll(
3049 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
3050 {
3051 tPOCT6100_SHARED_INFO pSharedInfo;
3052 tPOCT6100_API_CHIP_CONFIG pChipConfig;
3053 tOCT6100_WRITE_PARAMS WriteParams;
3054 UINT32 aulWaitTime[ 2 ];
3055 UINT32 ulResult;
3056
3057 /* Get local pointer to shared portion of instance. */
3058 pSharedInfo = f_pApiInstance->pSharedInfo;
3059
3060 /* Obtain local pointer to chip configuration structure. */
3061 pChipConfig = &pSharedInfo->ChipConfig;
3062
3063 /* Set the process context and user chip ID parameters once and for all. */
3064 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
3065
3066 WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
3067
3068 /* Force bist_clk also (it too is used on resetable flops). */
3069 WriteParams.ulWriteAddress = 0x160;
3070 WriteParams.usWriteData = 0x0188;
3071
3072 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3073 if ( ulResult != cOCT6100_ERR_OK )
3074 return ulResult;
3075
3076 /* Force all cpu clocks on chariot controllers. */
3077 WriteParams.ulWriteAddress = 0x182;
3078 WriteParams.usWriteData = 0x0002;
3079
3080 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3081 if ( ulResult != cOCT6100_ERR_OK )
3082 return ulResult;
3083
3084 WriteParams.ulWriteAddress = 0x184;
3085 WriteParams.usWriteData = 0x0202;
3086
3087 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3088 if ( ulResult != cOCT6100_ERR_OK )
3089 return ulResult;
3090
3091 aulWaitTime[ 0 ] = 1000;
3092 aulWaitTime[ 1 ] = 0;
3093 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
3094 if ( ulResult != cOCT6100_ERR_OK )
3095 return ulResult;
3096
3097 /* Remove the reset on the entire chip and disable CPU access caching. */
3098 WriteParams.ulWriteAddress = 0x100;
3099 WriteParams.usWriteData = 0x2003;
3100
3101 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3102 if ( ulResult != cOCT6100_ERR_OK )
3103 return ulResult;
3104
3105 /* Remove the bist_clk. It is no longer needed.*/
3106 WriteParams.ulWriteAddress = 0x160;
3107 WriteParams.usWriteData = 0x0088;
3108
3109 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3110 if ( ulResult != cOCT6100_ERR_OK )
3111 return ulResult;
3112
3113 /* Disable all clks to prepare for bist clock switchover. */
3114 WriteParams.ulWriteAddress = 0x182;
3115 WriteParams.usWriteData = 0x0001;
3116
3117 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3118 if ( ulResult != cOCT6100_ERR_OK )
3119 return ulResult;
3120
3121 WriteParams.ulWriteAddress = 0x186;
3122 WriteParams.usWriteData = 0x0000;
3123
3124 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3125 if ( ulResult != cOCT6100_ERR_OK )
3126 return ulResult;
3127
3128 WriteParams.ulWriteAddress = 0x184;
3129 WriteParams.usWriteData = 0x0101;
3130
3131 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3132 if ( ulResult != cOCT6100_ERR_OK )
3133 return ulResult;
3134
3135 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
3136 if ( ulResult != cOCT6100_ERR_OK )
3137 return ulResult;
3138
3139 /* Deassert bist_active */
3140 WriteParams.ulWriteAddress = 0x160;
3141 WriteParams.usWriteData = 0x0008;
3142
3143 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3144 if ( ulResult != cOCT6100_ERR_OK )
3145 return ulResult;
3146
3147 /* Change CPU interface to normal mode (from boot mode). */
3148 WriteParams.ulWriteAddress = 0x154;
3149 WriteParams.usWriteData = 0x0000;
3150
3151 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3152 if ( ulResult != cOCT6100_ERR_OK )
3153 return ulResult;
3154
3155 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
3156 if ( ulResult != cOCT6100_ERR_OK )
3157 return ulResult;
3158
3159 /* Give a couple of BIST clock cycles to turn off the BIST permanently. */
3160 WriteParams.ulWriteAddress = 0x160;
3161 WriteParams.usWriteData = 0x0108;
3162
3163 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3164 if ( ulResult != cOCT6100_ERR_OK )
3165 return ulResult;
3166
3167 ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
3168 if ( ulResult != cOCT6100_ERR_OK )
3169 return ulResult;
3170
3171 /* Turn BIST clock off for the last time. */
3172 WriteParams.ulWriteAddress = 0x160;
3173 WriteParams.usWriteData = 0x0008;
3174
3175 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3176 if ( ulResult != cOCT6100_ERR_OK )
3177 return ulResult;
3178
3179 /* Reset procedure done! */
3180
3181 /* Enable mclk for cpu interface and external memory controller. */
3182 WriteParams.ulWriteAddress = 0x186;
3183 WriteParams.usWriteData = 0x0100;
3184
3185 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3186 if ( ulResult != cOCT6100_ERR_OK )
3187 return ulResult;
3188
3189 return cOCT6100_ERR_OK;
3190 }
3191 #endif
3192
3193
3194 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3195
3196 Function: Oct6100ApiLoadImage
3197
3198 Description: This function writes the firmware image in the external memory.
3199
3200 -------------------------------------------------------------------------------
3201 | Argument | Description
3202 -------------------------------------------------------------------------------
3203 f_pApiInstance Pointer to API instance. This memory is used to keep the
3204 present state of the chip and all its resources.
3205
3206 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3207 #if !SKIP_Oct6100ApiLoadImage
3208 UINT32 Oct6100ApiLoadImage(
3209 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
3210 {
3211 tPOCT6100_SHARED_INFO pSharedInfo;
3212 tOCT6100_WRITE_BURST_PARAMS BurstParams;
3213 tOCT6100_READ_PARAMS ReadParams;
3214 UINT32 ulResult;
3215 UINT32 ulTempPtr;
3216 UINT32 ulNumWrites;
3217 PUINT16 pusSuperArray;
3218 unsigned char const *pbyImageFile;
3219 UINT32 ulByteCount = 0;
3220 UINT16 usReadData;
3221 UINT32 ulAddressOfst;
3222 UINT32 i;
3223
3224 /* Get local pointer to shared portion of instance. */
3225 pSharedInfo = f_pApiInstance->pSharedInfo;
3226
3227 /* Set the process context and user chip ID parameters once and for all. */
3228 BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
3229
3230 BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3231
3232 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
3233
3234 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3235 ReadParams.pusReadData = &usReadData;
3236
3237 /* Breakdown image into subcomponents. */
3238 ulTempPtr = cOCT6100_IMAGE_FILE_BASE + cOCT6100_IMAGE_AF_CST_OFFSET;
3239
3240 for(i=0;i<cOCT6100_MAX_IMAGE_REGION;i++)
3241 {
3242 pSharedInfo->ImageRegion[ i ].ulPart1Size = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 0 ];
3243 pSharedInfo->ImageRegion[ i ].ulPart2Size = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 1 ];
3244 pSharedInfo->ImageRegion[ i ].ulClockInfo = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 2 ];
3245 pSharedInfo->ImageRegion[ i ].ulReserved = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 3 ];
3246
3247 if (i == 0) /* AF constant. */
3248 {
3249 pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
3250 pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0;
3251
3252 ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 612 );
3253 }
3254 else if (i == 1) /* NLP image */
3255 {
3256 pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
3257 pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0;
3258
3259 ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2056 );
3260 }
3261 else /* Others */
3262 {
3263 pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
3264 ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2064 );
3265
3266 pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = ulTempPtr & 0x07FFFFFF;
3267 ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart2Size * 2448 );
3268 }
3269 }
3270
3271 /* Write the image in external memory. */
3272 ulNumWrites = pSharedInfo->ChipConfig.ulImageSize / 2;
3273
3274 BurstParams.ulWriteAddress = cOCT6100_IMAGE_FILE_BASE;
3275 BurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
3276
3277 pusSuperArray = pSharedInfo->MiscVars.ausSuperArray;
3278 pbyImageFile = pSharedInfo->ChipConfig.pbyImageFile;
3279
3280 while ( ulNumWrites != 0 )
3281 {
3282 if ( ulNumWrites >= pSharedInfo->ChipConfig.usMaxRwAccesses )
3283 BurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
3284 else
3285 BurstParams.ulWriteLength = ulNumWrites;
3286
3287 for ( i = 0; i < BurstParams.ulWriteLength; i++ )
3288 {
3289 pusSuperArray[ i ] = ( UINT16 )(( pbyImageFile [ ulByteCount++ ]) << 8);
3290 pusSuperArray[ i ] |= ( UINT16 )pbyImageFile [ ulByteCount++ ];
3291 }
3292
3293 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )
3294 if ( ulResult != cOCT6100_ERR_OK )
3295 return ulResult;
3296
3297 BurstParams.ulWriteAddress += 2 * BurstParams.ulWriteLength;
3298 ulNumWrites -= BurstParams.ulWriteLength;
3299 }
3300
3301 /* Perform a serie of reads to make sure the image was correclty written into memory. */
3302 ulAddressOfst = ( pSharedInfo->ChipConfig.ulImageSize / 2 ) & 0xFFFFFFFE;
3303 while ( ulAddressOfst != 0 )
3304 {
3305 ReadParams.ulReadAddress = cOCT6100_IMAGE_FILE_BASE + ulAddressOfst;
3306
3307 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
3308 if ( ulResult != cOCT6100_ERR_OK )
3309 return ulResult;
3310
3311 if ( (usReadData >> 8) != pbyImageFile[ ulAddressOfst ] )
3312 return cOCT6100_ERR_OPEN_IMAGE_WRITE_FAILED;
3313
3314 ulAddressOfst = (ulAddressOfst / 2) & 0xFFFFFFFE;
3315 }
3316
3317 return cOCT6100_ERR_OK;
3318 }
3319 #endif
3320
3321 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3322
3323 Function: Oct6100ApiCpuRegisterBistReadCap
3324
3325 Description: Tests the operation of the CPU registers. Special Version for
3326 GetCapacityPins
3327
3328 -------------------------------------------------------------------------------
3329 | Argument | Description
3330 -------------------------------------------------------------------------------
3331 f_pApiInstance Pointer to API instance. This memory is used to keep the
3332 present state of the chip and all its resources.
3333
3334 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3335 UINT32 Oct6100ApiCpuRegisterBistReadCap(
3336 IN tPOCT6100_INSTANCE_API f_pApiInstance,
3337 IN tPOCT6100_API_GET_CAPACITY_PINS f_pGetCapacityPins
3338 )
3339 {
3340 tOCT6100_WRITE_PARAMS WriteParams;
3341 tOCT6100_READ_PARAMS ReadParams;
3342 UINT32 ulResult;
3343 UINT16 i;
3344 UINT16 usReadData;
3345
3346 /* Set the process context and user chip ID parameters once and for all. */
3347 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
3348
3349 WriteParams.ulUserChipId = f_pGetCapacityPins->ulUserChipId;
3350
3351 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
3352
3353 ReadParams.ulUserChipId = f_pGetCapacityPins->ulUserChipId;
3354
3355 /* Assign read data pointer that will be used throughout the function. */
3356 ReadParams.pusReadData = &usReadData;
3357
3358 /* Start with a walking bit test. */
3359 for ( i = 0; i < 16; i ++ )
3360 {
3361 /* Write at address 0x150.*/
3362 WriteParams.ulWriteAddress = 0x150;
3363 WriteParams.usWriteData = (UINT16)( 0x1 << i );
3364
3365 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3366 if ( ulResult != cOCT6100_ERR_OK )
3367 return ulResult;
3368
3369 /* Write at address 0x180.*/
3370 WriteParams.ulWriteAddress = 0x180;
3371 WriteParams.usWriteData = (UINT16)( 0x1 << ( 15 - i ) );
3372
3373 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3374 if ( ulResult != cOCT6100_ERR_OK )
3375 return ulResult;
3376
3377 /* Now read back the two registers to make sure the acceses were successfull. */
3378 ReadParams.ulReadAddress = 0x150;
3379
3380 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3381 if ( ulResult != cOCT6100_ERR_OK )
3382 return ulResult;
3383
3384 if ( usReadData != ( 0x1 << i ) )
3385 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3386
3387 ReadParams.ulReadAddress = 0x180;
3388
3389 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3390 if ( ulResult != cOCT6100_ERR_OK )
3391 return ulResult;
3392
3393 if ( usReadData != ( 0x1 << ( 15 - i ) ) )
3394 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3395 }
3396
3397 /* Write at address 0x150. */
3398 WriteParams.ulWriteAddress = 0x150;
3399 WriteParams.usWriteData = 0xCAFE;
3400
3401 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3402 if ( ulResult != cOCT6100_ERR_OK )
3403 return ulResult;
3404
3405 /* Write at address 0x180. */
3406 WriteParams.ulWriteAddress = 0x180;
3407 WriteParams.usWriteData = 0xDECA;
3408
3409 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3410 if ( ulResult != cOCT6100_ERR_OK )
3411 return ulResult;
3412
3413 /* Now read back the two registers to make sure the acceses were successfull. */
3414 ReadParams.ulReadAddress = 0x150;
3415
3416 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3417 if ( ulResult != cOCT6100_ERR_OK )
3418 return ulResult;
3419
3420 if ( usReadData != 0xCAFE )
3421 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3422
3423 ReadParams.ulReadAddress = 0x180;
3424
3425 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3426 if ( ulResult != cOCT6100_ERR_OK )
3427 return ulResult;
3428
3429 if ( usReadData != 0xDECA )
3430 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3431
3432 return cOCT6100_ERR_OK;
3433 }
3434 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3435
3436 Function: Oct6100ApiCpuRegisterBist
3437
3438 Description: Tests the operation of the CPU registers.
3439
3440 -------------------------------------------------------------------------------
3441 | Argument | Description
3442 -------------------------------------------------------------------------------
3443 f_pApiInstance Pointer to API instance. This memory is used to keep the
3444 present state of the chip and all its resources.
3445
3446 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3447 #if !SKIP_Oct6100ApiCpuRegisterBist
3448 UINT32 Oct6100ApiCpuRegisterBist(
3449 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
3450 {
3451 tPOCT6100_SHARED_INFO pSharedInfo;
3452 tOCT6100_WRITE_PARAMS WriteParams;
3453 tOCT6100_READ_PARAMS ReadParams;
3454 UINT32 ulResult;
3455 UINT16 i;
3456 UINT16 usReadData;
3457
3458 /* Get local pointer to shared portion of instance. */
3459 pSharedInfo = f_pApiInstance->pSharedInfo;
3460
3461 /* Set the process context and user chip ID parameters once and for all. */
3462 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
3463
3464 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3465
3466 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
3467
3468 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3469
3470 /* Assign read data pointer that will be used throughout the function. */
3471 ReadParams.pusReadData = &usReadData;
3472
3473 /* Start with a walking bit test. */
3474 for ( i = 0; i < 16; i ++ )
3475 {
3476 /* Write at address 0x150.*/
3477 WriteParams.ulWriteAddress = 0x150;
3478 WriteParams.usWriteData = (UINT16)( 0x1 << i );
3479
3480 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3481 if ( ulResult != cOCT6100_ERR_OK )
3482 return ulResult;
3483
3484 /* Write at address 0x180.*/
3485 WriteParams.ulWriteAddress = 0x180;
3486 WriteParams.usWriteData = (UINT16)( 0x1 << ( 15 - i ) );
3487
3488 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3489 if ( ulResult != cOCT6100_ERR_OK )
3490 return ulResult;
3491
3492 /* Now read back the two registers to make sure the acceses were successfull. */
3493 ReadParams.ulReadAddress = 0x150;
3494
3495 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3496 if ( ulResult != cOCT6100_ERR_OK )
3497 return ulResult;
3498
3499 if ( usReadData != ( 0x1 << i ) )
3500 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3501
3502 ReadParams.ulReadAddress = 0x180;
3503
3504 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3505 if ( ulResult != cOCT6100_ERR_OK )
3506 return ulResult;
3507
3508 if ( usReadData != ( 0x1 << ( 15 - i ) ) )
3509 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3510 }
3511
3512 /* Write at address 0x150. */
3513 WriteParams.ulWriteAddress = 0x150;
3514 WriteParams.usWriteData = 0xCAFE;
3515
3516 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3517 if ( ulResult != cOCT6100_ERR_OK )
3518 return ulResult;
3519
3520 /* Write at address 0x180. */
3521 WriteParams.ulWriteAddress = 0x180;
3522 WriteParams.usWriteData = 0xDECA;
3523
3524 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3525 if ( ulResult != cOCT6100_ERR_OK )
3526 return ulResult;
3527
3528 /* Now read back the two registers to make sure the acceses were successfull. */
3529 ReadParams.ulReadAddress = 0x150;
3530
3531 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3532 if ( ulResult != cOCT6100_ERR_OK )
3533 return ulResult;
3534
3535 if ( usReadData != 0xCAFE )
3536 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3537
3538 ReadParams.ulReadAddress = 0x180;
3539
3540 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
3541 if ( ulResult != cOCT6100_ERR_OK )
3542 return ulResult;
3543
3544 if ( usReadData != 0xDECA )
3545 return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
3546
3547 return cOCT6100_ERR_OK;
3548 }
3549 #endif
3550
3551
3552 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3553
3554 Function: Oct6100ApiBootSdram
3555
3556 Description: Configure and test the SDRAM.
3557
3558 -------------------------------------------------------------------------------
3559 | Argument | Description
3560 -------------------------------------------------------------------------------
3561 f_pApiInstance Pointer to API instance. This memory is used to keep the
3562 present state of the chip and all its resources.
3563
3564 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3565 #if !SKIP_Oct6100ApiBootSdram
3566 UINT32 Oct6100ApiBootSdram(
3567 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
3568 {
3569 tPOCT6100_SHARED_INFO pSharedInfo;
3570 tPOCT6100_API_CHIP_CONFIG pChipConfig;
3571 tOCT6100_WRITE_PARAMS WriteParams;
3572 UINT32 ulResult;
3573 UINT16 usWriteData23E;
3574 UINT16 usWriteData230;
3575 UINT32 i;
3576
3577 /* Get local pointer to shared portion of instance. */
3578 pSharedInfo = f_pApiInstance->pSharedInfo;
3579
3580 /* Get local pointer to the chip configuration structure.*/
3581 pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
3582
3583 /* Set the process context and user chip ID parameters once and for all. */
3584 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
3585
3586 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3587
3588 usWriteData23E = 0x0000;
3589 usWriteData230 = 0x0000;
3590
3591 if ( (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
3592 {
3593 /* SDRAM: */
3594 switch( pChipConfig->ulMemoryChipSize )
3595 {
3596 case cOCT6100_MEMORY_CHIP_SIZE_8MB:
3597 usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
3598 break;
3599 case cOCT6100_MEMORY_CHIP_SIZE_16MB:
3600 usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
3601 break;
3602 case cOCT6100_MEMORY_CHIP_SIZE_32MB:
3603 usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
3604 break;
3605 case cOCT6100_MEMORY_CHIP_SIZE_64MB:
3606 usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
3607 break;
3608 default:
3609 return cOCT6100_ERR_FATAL_16;
3610 }
3611
3612 usWriteData230 |= 0x0002;
3613
3614 WriteParams.ulWriteAddress = 0x230;
3615 WriteParams.usWriteData = usWriteData230;
3616
3617 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3618 if ( ulResult != cOCT6100_ERR_OK )
3619 return ulResult;
3620
3621 /* Precharge all banks. */
3622 usWriteData230 &= 0x000C;
3623 usWriteData230 |= 0x0010;
3624
3625 WriteParams.ulWriteAddress = 0x230;
3626 WriteParams.usWriteData = usWriteData230;
3627
3628 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3629 if ( ulResult != cOCT6100_ERR_OK )
3630 return ulResult;
3631
3632 usWriteData230 |= 0x0002;
3633
3634 WriteParams.usWriteData = usWriteData230;
3635
3636 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3637 if ( ulResult != cOCT6100_ERR_OK )
3638 return ulResult;
3639
3640 WriteParams.ulWriteAddress = 0x23E;
3641 WriteParams.usWriteData = usWriteData23E;
3642 for ( i = 0; i < 5; i++ )
3643 {
3644 /* Wait cycle. */
3645 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3646 if ( ulResult != cOCT6100_ERR_OK )
3647 return ulResult;
3648 }
3649
3650 /* Program the mode register. */
3651 usWriteData23E = 0x0030;
3652 WriteParams.usWriteData = usWriteData23E;
3653
3654 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3655 if ( ulResult != cOCT6100_ERR_OK )
3656 return ulResult;
3657
3658 usWriteData230 &= 0x000C;
3659 usWriteData230 |= 0x0000;
3660
3661 WriteParams.ulWriteAddress = 0x230;
3662 WriteParams.usWriteData = usWriteData230;
3663
3664 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3665 if ( ulResult != cOCT6100_ERR_OK )
3666 return ulResult;
3667
3668 usWriteData230 |= 0x0002;
3669
3670 WriteParams.usWriteData = usWriteData230;
3671
3672 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3673 if ( ulResult != cOCT6100_ERR_OK )
3674 return ulResult;
3675
3676 WriteParams.ulWriteAddress = 0x23E;
3677 WriteParams.usWriteData = usWriteData23E;
3678 for ( i = 0; i < 5; i++ )
3679 {
3680 /* Wait cycle. */
3681 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3682 if ( ulResult != cOCT6100_ERR_OK )
3683 return ulResult;
3684 }
3685
3686 /* Do CBR refresh (twice) */
3687 usWriteData230 &= 0x000C;
3688 usWriteData230 |= 0x0040;
3689
3690 WriteParams.ulWriteAddress = 0x230;
3691 WriteParams.usWriteData = usWriteData230;
3692
3693 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3694 if ( ulResult != cOCT6100_ERR_OK )
3695 return ulResult;
3696
3697 usWriteData230 |= 0x0002;
3698
3699 WriteParams.usWriteData = usWriteData230;
3700
3701 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3702 if ( ulResult != cOCT6100_ERR_OK )
3703 return ulResult;
3704
3705 WriteParams.ulWriteAddress = 0x23E;
3706 WriteParams.usWriteData = usWriteData23E;
3707 for ( i = 0; i < 5; i++ )
3708 {
3709 /* Wait cycle. */
3710 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3711 if ( ulResult != cOCT6100_ERR_OK )
3712 return ulResult;
3713 }
3714
3715 WriteParams.ulWriteAddress = 0x230;
3716 WriteParams.usWriteData = usWriteData230;
3717
3718 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3719 if ( ulResult != cOCT6100_ERR_OK )
3720 return ulResult;
3721
3722 WriteParams.ulWriteAddress = 0x23E;
3723 WriteParams.usWriteData = usWriteData23E;
3724 for ( i = 0; i < 5; i++ )
3725 {
3726 /* Wait cycle. */
3727 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3728 if ( ulResult != cOCT6100_ERR_OK )
3729 return ulResult;
3730 }
3731 }
3732 else
3733 {
3734 /* DDR: */
3735 switch( pChipConfig->ulMemoryChipSize )
3736 {
3737 case cOCT6100_MEMORY_CHIP_SIZE_16MB:
3738 usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
3739 break;
3740 case cOCT6100_MEMORY_CHIP_SIZE_32MB:
3741 usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
3742 break;
3743 case cOCT6100_MEMORY_CHIP_SIZE_64MB:
3744 usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
3745 break;
3746 case cOCT6100_MEMORY_CHIP_SIZE_128MB:
3747 usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
3748 break;
3749 default:
3750 return cOCT6100_ERR_FATAL_17;
3751 }
3752 WriteParams.ulWriteAddress = 0x230;
3753 WriteParams.usWriteData = usWriteData230;
3754
3755 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3756 if ( ulResult != cOCT6100_ERR_OK )
3757 return ulResult;
3758
3759 /* Precharge all banks. */
3760 usWriteData230 &= 0x000C;
3761 usWriteData230 |= 0x0010;
3762
3763 WriteParams.ulWriteAddress = 0x230;
3764 WriteParams.usWriteData = usWriteData230;
3765
3766 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3767 if ( ulResult != cOCT6100_ERR_OK )
3768 return ulResult;
3769
3770 usWriteData230 |= 0x0002;
3771
3772 WriteParams.usWriteData = usWriteData230;
3773
3774 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3775 if ( ulResult != cOCT6100_ERR_OK )
3776 return ulResult;
3777
3778 WriteParams.ulWriteAddress = 0x23E;
3779 WriteParams.usWriteData = usWriteData23E;
3780 for ( i = 0; i < 5; i++ )
3781 {
3782 /* Wait cycle. */
3783 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3784 if ( ulResult != cOCT6100_ERR_OK )
3785 return ulResult;
3786 }
3787
3788 /* Program DDR mode register. */
3789 usWriteData23E = 0x4000;
3790
3791 WriteParams.ulWriteAddress = 0x23E;
3792 WriteParams.usWriteData = usWriteData23E;
3793
3794 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3795 if ( ulResult != cOCT6100_ERR_OK )
3796 return ulResult;
3797
3798 usWriteData230 &= 0x000C;
3799 usWriteData230 |= 0x0000;
3800
3801 WriteParams.ulWriteAddress = 0x230;
3802 WriteParams.usWriteData = usWriteData230;
3803
3804 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3805 if ( ulResult != cOCT6100_ERR_OK )
3806 return ulResult;
3807
3808 usWriteData230 |= 0x0002;
3809
3810 WriteParams.usWriteData = usWriteData230;
3811
3812 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3813 if ( ulResult != cOCT6100_ERR_OK )
3814 return ulResult;
3815
3816 WriteParams.ulWriteAddress = 0x23E;
3817 WriteParams.usWriteData = usWriteData23E;
3818 for ( i = 0; i < 5; i++ )
3819 {
3820 /* Wait cycle. */
3821 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3822 if ( ulResult != cOCT6100_ERR_OK )
3823 return ulResult;
3824 }
3825
3826 /* Program SDR mode register. */
3827 usWriteData23E = 0x0161;
3828
3829 WriteParams.ulWriteAddress = 0x23E;
3830 WriteParams.usWriteData = usWriteData23E;
3831
3832 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3833 if ( ulResult != cOCT6100_ERR_OK )
3834 return ulResult;
3835
3836 usWriteData230 &= 0x000C;
3837 usWriteData230 |= 0x0000;
3838
3839 WriteParams.ulWriteAddress = 0x230;
3840 WriteParams.usWriteData = usWriteData230;
3841
3842 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3843 if ( ulResult != cOCT6100_ERR_OK )
3844 return ulResult;
3845
3846 usWriteData230 |= 0x0002;
3847
3848 WriteParams.usWriteData = usWriteData230;
3849
3850 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3851 if ( ulResult != cOCT6100_ERR_OK )
3852 return ulResult;
3853
3854 WriteParams.ulWriteAddress = 0x23E;
3855 WriteParams.usWriteData = usWriteData23E;
3856 for ( i = 0; i < 5; i++ )
3857 {
3858 /* Wait cycle. */
3859 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3860 if ( ulResult != cOCT6100_ERR_OK )
3861 return ulResult;
3862 }
3863
3864 /* Precharge all banks. */
3865 usWriteData23E = 0xFFFF;
3866
3867 WriteParams.ulWriteAddress = 0x23E;
3868 WriteParams.usWriteData = usWriteData23E;
3869
3870 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3871 if ( ulResult != cOCT6100_ERR_OK )
3872 return ulResult;
3873
3874 usWriteData230 &= 0x000C;
3875 usWriteData230 |= 0x0010;
3876
3877 WriteParams.ulWriteAddress = 0x230;
3878 WriteParams.usWriteData = usWriteData230;
3879
3880 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3881 if ( ulResult != cOCT6100_ERR_OK )
3882 return ulResult;
3883
3884 usWriteData230 |= 0x0002;
3885
3886 WriteParams.usWriteData = usWriteData230;
3887
3888 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3889 if ( ulResult != cOCT6100_ERR_OK )
3890 return ulResult;
3891
3892 WriteParams.ulWriteAddress = 0x23E;
3893 WriteParams.usWriteData = usWriteData23E;
3894 for ( i = 0; i < 5; i++ )
3895 {
3896 /* Wait cycle. */
3897 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3898 if ( ulResult != cOCT6100_ERR_OK )
3899 return ulResult;
3900 }
3901
3902 /* Do CBR refresh (twice) */
3903 usWriteData230 &= 0x000C;
3904 usWriteData230 |= 0x0040;
3905
3906 WriteParams.ulWriteAddress = 0x230;
3907 WriteParams.usWriteData = usWriteData230;
3908
3909 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3910 if ( ulResult != cOCT6100_ERR_OK )
3911 return ulResult;
3912
3913 usWriteData230 |= 0x0002;
3914
3915 WriteParams.usWriteData = usWriteData230;
3916
3917 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3918 if ( ulResult != cOCT6100_ERR_OK )
3919 return ulResult;
3920
3921 WriteParams.ulWriteAddress = 0x23E;
3922 WriteParams.usWriteData = usWriteData23E;
3923 for ( i = 0; i < 5; i++ )
3924 {
3925 /* Wait cycle. */
3926 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3927 if ( ulResult != cOCT6100_ERR_OK )
3928 return ulResult;
3929 }
3930
3931 WriteParams.ulWriteAddress = 0x230;
3932 WriteParams.usWriteData = usWriteData230;
3933
3934 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3935 if ( ulResult != cOCT6100_ERR_OK )
3936 return ulResult;
3937
3938 WriteParams.ulWriteAddress = 0x23E;
3939 WriteParams.usWriteData = usWriteData23E;
3940 for ( i = 0; i < 5; i++ )
3941 {
3942 /* Wait cycle.*/
3943 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3944 if ( ulResult != cOCT6100_ERR_OK )
3945 return ulResult;
3946 }
3947
3948 /* Program SDR mode register. */
3949 usWriteData23E = 0x0061;
3950
3951 WriteParams.ulWriteAddress = 0x23E;
3952 WriteParams.usWriteData = usWriteData23E;
3953
3954 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3955 if ( ulResult != cOCT6100_ERR_OK )
3956 return ulResult;
3957
3958 usWriteData230 &= 0x000C;
3959 usWriteData230 |= 0x0000;
3960
3961 WriteParams.ulWriteAddress = 0x230;
3962 WriteParams.usWriteData = usWriteData230;
3963
3964 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3965 if ( ulResult != cOCT6100_ERR_OK )
3966 return ulResult;
3967
3968 usWriteData230 |= 0x0002;
3969
3970 WriteParams.usWriteData = usWriteData230;
3971
3972 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3973 if ( ulResult != cOCT6100_ERR_OK )
3974 return ulResult;
3975
3976 WriteParams.ulWriteAddress = 0x23E;
3977 WriteParams.usWriteData = usWriteData23E;
3978 for ( i = 0; i < 5; i++ )
3979 {
3980 /* Wait cycle. */
3981 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3982 if ( ulResult != cOCT6100_ERR_OK )
3983 return ulResult;
3984 }
3985 }
3986
3987 /* Set the refresh frequency. */
3988 WriteParams.ulWriteAddress = 0x242;
3989 WriteParams.usWriteData = 0x0400;
3990
3991 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3992 if ( ulResult != cOCT6100_ERR_OK )
3993 return ulResult;
3994
3995 WriteParams.ulWriteAddress = 0x244;
3996 WriteParams.usWriteData = 0x0200;
3997
3998 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3999 if ( ulResult != cOCT6100_ERR_OK )
4000 return ulResult;
4001
4002 WriteParams.ulWriteAddress = 0x248;
4003 WriteParams.usWriteData = 0x800;
4004
4005 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4006 if ( ulResult != cOCT6100_ERR_OK )
4007 return ulResult;
4008
4009 WriteParams.ulWriteAddress = 0x246;
4010 WriteParams.usWriteData = 0x0012;
4011
4012 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4013 if ( ulResult != cOCT6100_ERR_OK )
4014 return ulResult;
4015
4016 /* Enable the SDRAM and refreshes. */
4017 usWriteData230 &= 0x000C;
4018 usWriteData230 |= 0x0001;
4019
4020 WriteParams.ulWriteAddress = 0x230;
4021 WriteParams.usWriteData = usWriteData230;
4022
4023 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4024 if ( ulResult != cOCT6100_ERR_OK )
4025 return ulResult;
4026
4027 WriteParams.ulWriteAddress = 0x246;
4028 WriteParams.usWriteData = 0x0013;
4029
4030 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4031 if ( ulResult != cOCT6100_ERR_OK )
4032 return ulResult;
4033
4034 return cOCT6100_ERR_OK;
4035 }
4036 #endif
4037
4038
4039 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4040
4041 Function: Oct6100ApiEnableClocks
4042
4043 Description: This function will disable clock masking for all the modules
4044 of the chip.
4045
4046 -------------------------------------------------------------------------------
4047 | Argument | Description
4048 -------------------------------------------------------------------------------
4049 f_pApiInstance Pointer to API instance. This memory is used to keep the
4050 present state of the chip and all its resources.
4051
4052 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4053 #if !SKIP_Oct6100ApiEnableClocks
4054 UINT32 Oct6100ApiEnableClocks(
4055 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4056 {
4057 tOCT6100_WRITE_PARAMS WriteParams;
4058 UINT32 ulResult;
4059
4060 /* Initialize the process context and user chip ID once and for all. */
4061 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4062
4063 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4064
4065 /* Enable tdmie / adpcm mclk clocks. */
4066 WriteParams.ulWriteAddress = 0x186;
4067 WriteParams.usWriteData = 0x015F;
4068
4069 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4070 if ( ulResult != cOCT6100_ERR_OK )
4071 return ulResult;
4072
4073 /* Configure the DQS register for the DDR memory */
4074 WriteParams.ulWriteAddress = 0x180;
4075 WriteParams.usWriteData = 0xFF00;
4076
4077 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4078 if ( ulResult != cOCT6100_ERR_OK )
4079 return ulResult;
4080
4081 /* Enable pgsp chariot clocks */
4082 WriteParams.ulWriteAddress = 0x182;
4083 WriteParams.usWriteData = 0x0000;
4084
4085 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4086 if ( ulResult != cOCT6100_ERR_OK )
4087 return ulResult;
4088
4089 /* Enable af/mt chariot clocks */
4090 WriteParams.ulWriteAddress = 0x184;
4091 WriteParams.usWriteData = 0x0000;
4092
4093 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4094 if ( ulResult != cOCT6100_ERR_OK )
4095 return ulResult;
4096
4097 return cOCT6100_ERR_OK;
4098 }
4099 #endif
4100
4101
4102 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4103
4104 Function: Oct6100ApiProgramNLP
4105
4106 Description: This function will write image values to configure the NLP.
4107
4108 -------------------------------------------------------------------------------
4109 | Argument | Description
4110 -------------------------------------------------------------------------------
4111 f_pApiInstance Pointer to API instance. This memory is used to keep the
4112 present state of the chip and all its resources.
4113
4114 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4115 #if !SKIP_Oct6100ApiProgramNLP
4116 UINT32 Oct6100ApiProgramNLP(
4117 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4118 {
4119 tOCT6100_WRITE_PARAMS WriteParams;
4120 tOCT6100_READ_PARAMS ReadParams;
4121 tPOCT6100_SHARED_INFO pSharedInfo;
4122 tPOCT6100_API_CHIP_CONFIG pChipConfig;
4123 UINT32 ulResult;
4124 UINT16 usReadData;
4125 UINT16 usReadHighData;
4126 BOOL fBitEqual;
4127 UINT32 ulEgoEntry[4];
4128 UINT32 ulTempAddress;
4129 UINT32 ulAfCpuUp = FALSE;
4130 UINT32 i;
4131 UINT32 ulLoopCounter = 0;
4132
4133 /* Get local pointer to shared portion of instance. */
4134 pSharedInfo = f_pApiInstance->pSharedInfo;
4135
4136 /* Get local pointer to the chip configuration structure.*/
4137 pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
4138
4139 /* Initialize the process context and user chip ID once and for all. */
4140 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4141
4142 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4143
4144 /* Initialize the process context and user chip ID once and for all. */
4145 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
4146
4147 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4148 ReadParams.pusReadData = &usReadData;
4149
4150 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4151 {
4152 UINT32 ulReadData;
4153 UINT32 ulBitPattern;
4154 UINT32 j, k;
4155
4156 /* Since the pouch section (256 bytes) will not be tested by the firmware, */
4157 /* the API has to make sure this section is working correctly. */
4158 for ( k = 0; k < 2; k ++ )
4159 {
4160 if ( k == 0 )
4161 ulBitPattern = 0x1;
4162 else
4163 ulBitPattern = 0xFFFFFFFE;
4164
4165 for ( j = 0; j < 32; j ++ )
4166 {
4167 /* Write the DWORDs. */
4168 for ( i = 0; i < 64; i ++ )
4169 {
4170 ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, ulBitPattern << j );
4171 if ( ulResult != cOCT6100_ERR_OK )
4172 return ulResult;
4173 }
4174
4175 /* Read the DWORDs. */
4176 for ( i = 0; i < 64; i ++ )
4177 {
4178 ulResult = Oct6100ApiReadDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, &ulReadData );
4179 if ( ulResult != cOCT6100_ERR_OK )
4180 return ulResult;
4181
4182 /* Check if the value matches. */
4183 if ( ( ulBitPattern << j ) != ulReadData )
4184 return cOCT6100_ERR_OPEN_PRODUCTION_BIST_POUCH_ERROR;
4185 }
4186 }
4187 }
4188 }
4189
4190 /* Write the image info in the chip. */
4191 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE;
4192 WriteParams.usWriteData = (UINT16)( ( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress >> 16 ) & 0xFFFF );
4193
4194 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4195 if ( ulResult != cOCT6100_ERR_OK )
4196 return ulResult;
4197
4198 WriteParams.ulWriteAddress += 2;
4199 WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress & 0xFFFF );
4200
4201 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4202 if ( ulResult != cOCT6100_ERR_OK )
4203 return ulResult;
4204
4205 for( i = 0; i < 8; i++ )
4206 {
4207 if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size != 0 )
4208 {
4209 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC );
4210 WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress >> 16 ) & 0xFFFF );
4211
4212 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4213 if ( ulResult != cOCT6100_ERR_OK )
4214 return ulResult;
4215
4216 WriteParams.ulWriteAddress += 2;
4217 WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress & 0xFFFF );
4218
4219 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4220 if ( ulResult != cOCT6100_ERR_OK )
4221 return ulResult;
4222 }
4223
4224 if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size != 0 )
4225 {
4226 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 4;
4227 WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress >> 16 ) & 0xFFFF );
4228
4229 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4230 if ( ulResult != cOCT6100_ERR_OK )
4231 return ulResult;
4232
4233 WriteParams.ulWriteAddress += 2;
4234 WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress & 0xFFFF );
4235
4236 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4237 if ( ulResult != cOCT6100_ERR_OK )
4238 return ulResult;
4239 }
4240
4241 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 8;
4242 WriteParams.usWriteData = 0x0000;
4243 WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size << 8 );
4244 WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size;
4245
4246 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4247 if ( ulResult != cOCT6100_ERR_OK )
4248 return ulResult;
4249
4250 WriteParams.ulWriteAddress += 2;
4251 WriteParams.usWriteData = 0x0000;
4252 WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulClockInfo << 8 );
4253 WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulReserved;
4254
4255 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4256 if ( ulResult != cOCT6100_ERR_OK )
4257 return ulResult;
4258 }
4259
4260 /* Put NLP in config mode. */
4261 WriteParams.ulWriteAddress = 0x2C2;
4262 WriteParams.usWriteData = 0x160E;
4263
4264 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4265 if ( ulResult != cOCT6100_ERR_OK )
4266 return ulResult;
4267
4268 WriteParams.ulWriteAddress = 0x692;
4269 WriteParams.usWriteData = 0x010A;
4270
4271 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4272 if ( ulResult != cOCT6100_ERR_OK )
4273 return ulResult;
4274
4275 /* Upload the up to 8 NLP pages + 1 AF page (for timing reasons). */
4276 for ( i = 0; i < pSharedInfo->ImageRegion[ 1 ].ulPart1Size; i++ )
4277 {
4278 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * ( i * 2 ), 0x1280, 1024, &(ulEgoEntry[0]));
4279 if ( ulResult != cOCT6100_ERR_OK )
4280 return ulResult;
4281
4282 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * (( i * 2 ) + 1 ), 0x1680, 1024, &(ulEgoEntry[2]));
4283 if ( ulResult != cOCT6100_ERR_OK )
4284 return ulResult;
4285
4286 ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
4287 if ( ulResult != cOCT6100_ERR_OK )
4288 return ulResult;
4289
4290 /* Shift mt chariot memories. This process will complete by the time */
4291 /* the next LSU transfer is done. */
4292 WriteParams.ulWriteAddress = 0x692;
4293 WriteParams.usWriteData = 0x010B;
4294
4295 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4296 if ( ulResult != cOCT6100_ERR_OK )
4297 return ulResult;
4298
4299 ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x692, 0, 0, 100000, &fBitEqual );
4300 if ( ulResult != cOCT6100_ERR_OK )
4301 return ulResult;
4302 if ( TRUE != fBitEqual )
4303 return cOCT6100_ERR_FATAL_1A;
4304 }
4305
4306 /* 1 AF page (for timing reasons). */
4307 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 0), 0x1280, 512, &(ulEgoEntry[0]));
4308 if ( ulResult != cOCT6100_ERR_OK )
4309 return ulResult;
4310
4311 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 1), 0x1480, 512, &(ulEgoEntry[2]));
4312 if ( ulResult != cOCT6100_ERR_OK )
4313 return ulResult;
4314
4315 ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
4316 if ( ulResult != cOCT6100_ERR_OK )
4317 return ulResult;
4318
4319 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 2), 0x1680, 512, &(ulEgoEntry[0]));
4320 if ( ulResult != cOCT6100_ERR_OK )
4321 return ulResult;
4322
4323 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 3), 0x1880, 512, &(ulEgoEntry[2]));
4324 if ( ulResult != cOCT6100_ERR_OK )
4325 return ulResult;
4326
4327 ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
4328 if ( ulResult != cOCT6100_ERR_OK )
4329 return ulResult;
4330
4331 /* Write constant memory init context position in channel "672" for pgsp. */
4332 WriteParams.ulWriteAddress = 0x71A;
4333 WriteParams.usWriteData = 0x8000;
4334
4335 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4336 if ( ulResult != cOCT6100_ERR_OK )
4337 return ulResult;
4338
4339 /* Set fixed PGSP event_in base address to 800 on a 2k boundary */
4340 WriteParams.ulWriteAddress = 0x716;
4341 WriteParams.usWriteData = 0x800 >> 11;
4342
4343 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4344 if ( ulResult != cOCT6100_ERR_OK )
4345 return ulResult;
4346
4347 /* Set fixed PGSP event_out to 0x2C0000h on a 16k boundary */
4348 WriteParams.ulWriteAddress = 0x71C;
4349 WriteParams.usWriteData = 0x2C0000 >> 14;
4350
4351 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4352 if ( ulResult != cOCT6100_ERR_OK )
4353 return ulResult;
4354
4355 /* Give chariot control of the chip. */
4356 WriteParams.ulWriteAddress = 0x712;
4357 WriteParams.usWriteData = 0x0000;
4358
4359 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4360 if ( ulResult != cOCT6100_ERR_OK )
4361 return ulResult;
4362
4363 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xC;
4364 ulTempAddress = 0x300000 + 0x0800;
4365 WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 16 ) & 0x07FF );
4366
4367 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4368 if ( ulResult != cOCT6100_ERR_OK )
4369 return ulResult;
4370
4371 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xE;
4372 WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 0 ) & 0xFF00 );
4373
4374 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4375 if ( ulResult != cOCT6100_ERR_OK )
4376 return ulResult;
4377
4378 /* Write the init PGSP event in place. */
4379 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x800;
4380 WriteParams.usWriteData = 0x0200;
4381
4382 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4383 if ( ulResult != cOCT6100_ERR_OK )
4384 return ulResult;
4385
4386 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x802;
4387 WriteParams.usWriteData = 0x02A0;
4388
4389 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4390 if ( ulResult != cOCT6100_ERR_OK )
4391 return ulResult;
4392
4393 /* Also write the register 710, which tells PGSP how many tones are supported. */
4394 WriteParams.ulWriteAddress = 0x710;
4395 WriteParams.usWriteData = 0x0000;
4396 WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FA ] << 8;
4397 WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FB ] << 0;
4398
4399 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4400 if ( ulResult != cOCT6100_ERR_OK )
4401 return ulResult;
4402
4403 /* Start both processors in the NLP. */
4404 WriteParams.ulWriteAddress = 0x373FE;
4405 WriteParams.usWriteData = 0x00FF;
4406
4407 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4408 if ( ulResult != cOCT6100_ERR_OK )
4409 return ulResult;
4410
4411 WriteParams.ulWriteAddress = 0x37BFE;
4412 WriteParams.usWriteData = 0x00FE; /* Tell processor 1 to just go to sleep. */
4413
4414 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4415 if ( ulResult != cOCT6100_ERR_OK )
4416 return ulResult;
4417
4418 WriteParams.ulWriteAddress = 0x37FC6;
4419 WriteParams.usWriteData = 0x8004; /* First PC.*/
4420
4421 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4422 if ( ulResult != cOCT6100_ERR_OK )
4423 return ulResult;
4424
4425 WriteParams.ulWriteAddress = 0x37FD0;
4426 WriteParams.usWriteData = 0x0002; /* Take out of reset. */
4427
4428 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4429 if ( ulResult != cOCT6100_ERR_OK )
4430 return ulResult;
4431
4432 WriteParams.ulWriteAddress = 0x37FD2;
4433 WriteParams.usWriteData = 0x0002; /* Take out of reset. */
4434
4435 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4436 if ( ulResult != cOCT6100_ERR_OK )
4437 return ulResult;
4438
4439 /* Start processor in the AF. */
4440 for ( i = 0; i < 16; i ++ )
4441 {
4442 WriteParams.ulWriteAddress = cOCT6100_POUCH_BASE + ( i * 2 );
4443 if ( i == 9 )
4444 {
4445 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4446 {
4447 if (pSharedInfo->ChipConfig.ulProductionBistMode == cOCT6100_PRODUCTION_BIST_SHORT)
4448 WriteParams.usWriteData = cOCT6100_PRODUCTION_SHORT_BOOT_TYPE;
4449 else
4450 WriteParams.usWriteData = cOCT6100_PRODUCTION_BOOT_TYPE;
4451 }
4452 else
4453 {
4454 WriteParams.usWriteData = cOCT6100_AF_BOOT_TYPE;
4455 }
4456 }
4457 else
4458 WriteParams.usWriteData = 0x0000;
4459
4460 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4461 if ( ulResult != cOCT6100_ERR_OK )
4462 return ulResult;
4463 }
4464
4465 /* Check if the production BIST mode was requested. */
4466 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4467 {
4468 UINT32 ulTotalElements = 3;
4469 UINT32 ulCrcKey;
4470 UINT32 aulMessage[ 4 ];
4471 UINT32 ulWriteAddress = 0x20 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
4472
4473 /* Magic key. */
4474 aulMessage[ 0 ] = 0xCAFECAFE;
4475 /* Memory size. */
4476 aulMessage[ 1 ] = pSharedInfo->MiscVars.ulTotalMemSize;
4477 /* Loop count. */
4478 aulMessage[ 2 ] = pSharedInfo->ChipConfig.ulNumProductionBistLoops;
4479 /* CRC initialized. */
4480 aulMessage[ 3 ] = 0;
4481
4482 ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCrcKey );
4483 if ( ulResult != cOCT6100_ERR_OK )
4484 return ulResult;
4485
4486 aulMessage[ 3 ] = ulCrcKey;
4487
4488 /* Write the message to the external memory. */
4489 for ( i = 0; i < ulTotalElements + 1; i ++ )
4490 {
4491 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulWriteAddress + i * 4, aulMessage[ i ] );
4492 if ( ulResult != cOCT6100_ERR_OK )
4493 return ulResult;
4494 }
4495 }
4496
4497 WriteParams.ulWriteAddress = 0xFFFC6;
4498 WriteParams.usWriteData = 0x1284; /* First PC.*/
4499
4500 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4501 if ( ulResult != cOCT6100_ERR_OK )
4502 return ulResult;
4503
4504 WriteParams.ulWriteAddress = 0xFFFD0;
4505 WriteParams.usWriteData = 0x0002; /* Take out of reset. */
4506
4507 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4508 if ( ulResult != cOCT6100_ERR_OK )
4509 return ulResult;
4510
4511 while ( ulAfCpuUp == FALSE )
4512 {
4513 if ( ulAfCpuUp == FALSE )
4514 {
4515 ReadParams.ulReadAddress = cOCT6100_POUCH_BASE;
4516 ReadParams.pusReadData = &usReadHighData;
4517
4518 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4519 if ( ulResult != cOCT6100_ERR_OK )
4520 return ulResult;
4521
4522 ReadParams.ulReadAddress += 2;
4523 ReadParams.pusReadData = &usReadData;
4524
4525 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4526 if ( ulResult != cOCT6100_ERR_OK )
4527 return ulResult;
4528
4529 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4530 {
4531 /* Should read 0x0007 when bisting. */
4532 if ( (( usReadHighData & 0xFFFF ) == cOCT6100_PRODUCTION_BOOT_TYPE) ||
4533 (( usReadHighData & 0xFFFF ) == cOCT6100_PRODUCTION_SHORT_BOOT_TYPE) )
4534 {
4535 /* Verify if the bist has started successfully. */
4536 if ( ( usReadData & 0xFFFF ) == 0x0002 )
4537 return cOCT6100_ERR_OPEN_PRODUCTION_BIST_CONF_FAILED;
4538 else if ( ( usReadData & 0xFFFF ) != 0xEEEE )
4539 return cOCT6100_ERR_OPEN_PRODUCTION_BOOT_FAILED;
4540
4541 ulAfCpuUp = TRUE;
4542 }
4543 }
4544 else /* if ( pSharedInfo->ChipConfig.fEnableProductionBist == FALSE ) */
4545 {
4546 if ( ( usReadHighData & 0xFFFF ) == cOCT6100_AF_BOOT_TYPE )
4547 {
4548 /* Verify if the bist succeeded. */
4549 if ( ( usReadData & 0xFFFF ) != 0x0000 )
4550 return cOCT6100_ERR_OPEN_FUNCTIONAL_BIST_FAILED;
4551
4552 ulAfCpuUp = TRUE;
4553 }
4554 }
4555 }
4556
4557 ulLoopCounter++;
4558
4559 if ( ulLoopCounter == cOCT6100_MAX_LOOP_CPU_TIMEOUT )
4560 return cOCT6100_ERR_OPEN_AF_CPU_TIMEOUT;
4561 }
4562
4563 /* Return NLP in operationnal mode. */
4564 WriteParams.ulWriteAddress = 0x2C2;
4565 WriteParams.usWriteData = 0x060E;
4566
4567 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4568 if ( ulResult != cOCT6100_ERR_OK )
4569 return ulResult;
4570
4571 WriteParams.ulWriteAddress = 0x692;
4572 WriteParams.usWriteData = 0x0000;
4573
4574 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4575 if ( ulResult != cOCT6100_ERR_OK )
4576 return ulResult;
4577
4578 return cOCT6100_ERR_OK;
4579 }
4580 #endif
4581
4582
4583 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4584
4585 Function: Oct6100ApiSetH100Register
4586
4587 Description: This function will configure the H.100 registers.
4588
4589 -------------------------------------------------------------------------------
4590 | Argument | Description
4591 -------------------------------------------------------------------------------
4592 f_pApiInstance Pointer to API instance. This memory is used to keep the
4593 present state of the chip and all its resources.
4594
4595 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4596 #if !SKIP_Oct6100ApiSetH100Register
4597 UINT32 Oct6100ApiSetH100Register(
4598 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4599 {
4600 tOCT6100_WRITE_PARAMS WriteParams;
4601 UINT32 ulResult;
4602 tPOCT6100_SHARED_INFO pSharedInfo;
4603 tPOCT6100_API_CHIP_CONFIG pChipConfig;
4604 UINT32 i;
4605 UINT32 ulOffset;
4606 BOOL fAllStreamAt2Mhz = TRUE;
4607 const UINT16 ausAdpcmResetContext[32] = { 0x1100, 0x0220, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000, 0x0100, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0040,
4608 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000};
4609
4610 /* Get local pointer to shared portion of instance. */
4611 pSharedInfo = f_pApiInstance->pSharedInfo;
4612
4613 /* Get local pointer to the chip configuration structure. */
4614 pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
4615
4616 /* Initialize the process context and user chip ID once and for all. */
4617 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4618
4619 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4620
4621 /* Set the Global OE bit. */
4622 WriteParams.ulWriteAddress = 0x300;
4623 WriteParams.usWriteData = 0x0004;
4624
4625 /* Set the number of streams. */
4626 switch( pChipConfig->byMaxTdmStreams )
4627 {
4628 case 32:
4629 WriteParams.usWriteData |= ( 0 << 3 );
4630 break;
4631 case 16:
4632 WriteParams.usWriteData |= ( 1 << 3 );
4633 break;
4634 case 8:
4635 WriteParams.usWriteData |= ( 2 << 3 );
4636 break;
4637 case 4:
4638 WriteParams.usWriteData |= ( 3 << 3 );
4639 break;
4640 default:
4641 break;
4642 }
4643
4644 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4645 if ( ulResult != cOCT6100_ERR_OK )
4646 return ulResult;
4647
4648 /* Configure the stream frequency. */
4649 WriteParams.ulWriteAddress = 0x330;
4650 WriteParams.usWriteData = 0x0000;
4651 for ( i = 0; i < (UINT32)(pChipConfig->byMaxTdmStreams / 4); i++)
4652 {
4653 ulOffset = i*2;
4654 switch( pChipConfig->aulTdmStreamFreqs[ i ] )
4655 {
4656 case cOCT6100_TDM_STREAM_FREQ_2MHZ:
4657 WriteParams.usWriteData |= ( 0x0 << ulOffset );
4658 break;
4659 case cOCT6100_TDM_STREAM_FREQ_4MHZ:
4660 WriteParams.usWriteData |= ( 0x1 << ulOffset );
4661 fAllStreamAt2Mhz = FALSE;
4662 break;
4663 case cOCT6100_TDM_STREAM_FREQ_8MHZ:
4664 WriteParams.usWriteData |= ( 0x2 << ulOffset );
4665 fAllStreamAt2Mhz = FALSE;
4666 break;
4667 default:
4668 break;
4669 }
4670 }
4671
4672 /* Set the stream to 16 MHz if the fast H.100 mode is selected. */
4673 if ( pChipConfig->fEnableFastH100Mode == TRUE )
4674 {
4675 fAllStreamAt2Mhz = FALSE;
4676 WriteParams.usWriteData = 0xFFFF;
4677 }
4678
4679 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4680 if ( ulResult != cOCT6100_ERR_OK )
4681 return ulResult;
4682
4683 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
4684 {
4685 /* Make the chip track both clock A and B to perform fast H.100 mode. */
4686 WriteParams.ulWriteAddress = 0x322;
4687 WriteParams.usWriteData = 0x0004;
4688 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4689 if ( ulResult != cOCT6100_ERR_OK )
4690 return ulResult;
4691
4692 /* Enable the fast H.100 mode. */
4693 WriteParams.ulWriteAddress = 0x332;
4694 WriteParams.usWriteData = 0x0003;
4695 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4696 if ( ulResult != cOCT6100_ERR_OK )
4697 return ulResult;
4698 }
4699
4700 WriteParams.ulWriteAddress = 0x376;
4701 WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usTdmClkBoundary );
4702 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4703 if ( ulResult != cOCT6100_ERR_OK )
4704 return ulResult;
4705
4706 /* Select delay for early clock (90 and 110). */
4707 WriteParams.ulWriteAddress = 0x378;
4708 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
4709 WriteParams.usWriteData = 0x000A;
4710 else
4711 {
4712 /* Set the TDM sampling. */
4713 if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_RISING_EDGE )
4714 {
4715 WriteParams.usWriteData = 0x0AF0;
4716 }
4717 else if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE )
4718 {
4719 WriteParams.usWriteData = 0x0A0F;
4720 }
4721 else /* pSharedInfo->ChipConfig.ulTdmSampling == cOCT6100_TDM_SAMPLE_AT_3_QUARTERS */
4722 {
4723 WriteParams.usWriteData = 0x0A08;
4724 }
4725 }
4726
4727 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4728 if ( ulResult != cOCT6100_ERR_OK )
4729 return ulResult;
4730
4731 /* Protect chip by preventing too rapid timeslot arrival (mclk == 133 MHz). */
4732 WriteParams.ulWriteAddress = 0x37A;
4733 WriteParams.usWriteData = (UINT16)pSharedInfo->MiscVars.usMaxH100Speed;
4734
4735 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4736 if ( ulResult != cOCT6100_ERR_OK )
4737 return ulResult;
4738
4739 /* Allow H.100 TS to progress. */
4740 WriteParams.ulWriteAddress = 0x382;
4741 WriteParams.usWriteData = 0x0000;
4742
4743 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4744 if ( ulResult != cOCT6100_ERR_OK )
4745 return ulResult;
4746
4747 /* Set by-pass mode. */
4748 WriteParams.ulWriteAddress = 0x50E;
4749 WriteParams.usWriteData = 0x0001;
4750
4751 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4752 if ( ulResult != cOCT6100_ERR_OK )
4753 return ulResult;
4754
4755 /* TDMIE bits. */
4756 WriteParams.ulWriteAddress = 0x500;
4757 WriteParams.usWriteData = 0x0003;
4758
4759 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4760 if ( ulResult != cOCT6100_ERR_OK )
4761 return ulResult;
4762
4763 /* Write normal ADPCM reset values in ADPCM context 1344. */
4764 for(i=0;i<32;i++)
4765 {
4766 WriteParams.ulWriteAddress = 0x140000 + ( 0x40 * 1344 ) + ( i * 2 );
4767 WriteParams.usWriteData = ausAdpcmResetContext[i];
4768
4769 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4770 if ( ulResult != cOCT6100_ERR_OK )
4771 return ulResult;
4772 }
4773
4774 /* Make sure delay flops are configured correctly if all streams are at 2 MHz. */
4775 if ( fAllStreamAt2Mhz == TRUE )
4776 {
4777 /* Setup H.100 sampling to lowest value. */
4778 WriteParams.ulWriteAddress = 0x144;
4779 WriteParams.usWriteData = 0x4041;
4780
4781 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4782 if ( ulResult != cOCT6100_ERR_OK )
4783 return ulResult;
4784
4785 WriteParams.ulWriteAddress = 0x378;
4786 WriteParams.usWriteData = 0x0A00;
4787
4788 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4789 if ( ulResult != cOCT6100_ERR_OK )
4790 return ulResult;
4791 }
4792
4793 return cOCT6100_ERR_OK;
4794 }
4795 #endif
4796
4797
4798 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4799
4800 Function: Oct6100ApiWriteMiscellaneousRegisters
4801
4802 Description: This function will write to various registers to activate the chip.
4803
4804 -------------------------------------------------------------------------------
4805 | Argument | Description
4806 -------------------------------------------------------------------------------
4807 f_pApiInstance Pointer to API instance. This memory is used to keep the
4808 present state of the chip and all its resources.
4809
4810 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4811 #if !SKIP_Oct6100ApiWriteMiscellaneousRegisters
4812 UINT32 Oct6100ApiWriteMiscellaneousRegisters(
4813 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4814 {
4815 tOCT6100_WRITE_PARAMS WriteParams;
4816 UINT32 ulResult;
4817
4818 /* Initialize the process context and user chip ID once and for all. */
4819 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4820
4821 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4822
4823 /* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */
4824 WriteParams.ulWriteAddress = 0x214;
4825 WriteParams.usWriteData = 0x0000;
4826 if ( f_pApiInstance->pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY )
4827 WriteParams.usWriteData |= 0x4000;
4828 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
4829 if ( ulResult != cOCT6100_ERR_OK )
4830 return ulResult;
4831
4832 /* Write MT chariot interval */
4833 WriteParams.ulWriteAddress = 0x2C2;
4834 if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 640 )
4835 WriteParams.usWriteData = 0x05EA;
4836 else if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 513 )
4837 WriteParams.usWriteData = 0x0672;
4838 else /* if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels <= 513 ) */
4839 WriteParams.usWriteData = 0x0750;
4840 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4841 if ( ulResult != cOCT6100_ERR_OK )
4842 return ulResult;
4843
4844 /* Write set second part5 time. */
4845 WriteParams.ulWriteAddress = 0x2C4;
4846 WriteParams.usWriteData = 0x04A0;
4847
4848 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4849 if ( ulResult != cOCT6100_ERR_OK )
4850 return ulResult;
4851
4852 /* Write CPU bucket timer to guarantee 200 cycles between each CPU access. */
4853 WriteParams.ulWriteAddress = 0x234;
4854 WriteParams.usWriteData = 0x0804;
4855
4856 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4857 if ( ulResult != cOCT6100_ERR_OK )
4858 return ulResult;
4859
4860 WriteParams.ulWriteAddress = 0x236;
4861 WriteParams.usWriteData = 0x0100;
4862
4863 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4864 if ( ulResult != cOCT6100_ERR_OK )
4865 return ulResult;
4866
4867 return cOCT6100_ERR_OK;
4868 }
4869 #endif
4870
4871
4872 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4873
4874 Function: Oct6100ApiCreateSerializeObjects
4875
4876 Description: Creates a handle to each serialization object used by the API.
4877
4878 Note that in a multi-process system the user's process context
4879 structure pointer is needed by this function. Thus, the
4880 pointer must be valid.
4881
4882 -------------------------------------------------------------------------------
4883 | Argument | Description
4884 -------------------------------------------------------------------------------
4885 f_pApiInstance Pointer to API instance. This memory is used to keep the
4886 present state of the chip and all its resources.
4887
4888 f_ulUserChipId User chip ID for this serialization object.
4889
4890 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4891 #if !SKIP_Oct6100ApiCreateSerializeObjects
4892 UINT32 Oct6100ApiCreateSerializeObjects(
4893 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
4894 IN UINT32 f_ulUserChipId )
4895 {
4896 tOCT6100_CREATE_SERIALIZE_OBJECT CreateSerObj;
4897 UINT32 ulResult;
4898 CHAR szSerObjName[ 64 ] = "Oct6100ApiXXXXXXXXApiSerObj";
4899
4900
4901 /* Set some parameters of the create structure once and for all. */
4902 CreateSerObj.pProcessContext = f_pApiInstance->pProcessContext;
4903 CreateSerObj.pszSerialObjName = szSerObjName;
4904
4905 /*----------------------------------------------------------------------*/
4906 /* Set the chip ID in the semaphore name. */
4907 szSerObjName[ 10 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 28 ) & 0xFF );
4908 szSerObjName[ 11 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 24 ) & 0xFF );
4909 szSerObjName[ 12 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 20 ) & 0xFF );
4910 szSerObjName[ 13 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 16 ) & 0xFF );
4911 szSerObjName[ 14 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 12 ) & 0xFF );
4912 szSerObjName[ 15 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 8 ) & 0xFF );
4913 szSerObjName[ 16 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 4 ) & 0xFF );
4914 szSerObjName[ 17 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 0 ) & 0xFF );
4915
4916 ulResult = Oct6100UserCreateSerializeObject( &CreateSerObj );
4917 if ( ulResult != cOCT6100_ERR_OK )
4918 return ulResult;
4919 f_pApiInstance->ulApiSerObj = CreateSerObj.ulSerialObjHndl;
4920 /*----------------------------------------------------------------------*/
4921
4922
4923
4924 return cOCT6100_ERR_OK;
4925 }
4926 #endif
4927
4928
4929 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4930
4931 Function: Oct6100ApiDestroySerializeObjects
4932
4933 Description: Destroy handles to each serialization object used by the API.
4934
4935 Note that in a multi-process system the user's process context
4936 structure pointer is needed by this function. Thus, the
4937 pointer must be valid.
4938
4939 -------------------------------------------------------------------------------
4940 | Argument | Description
4941 -------------------------------------------------------------------------------
4942 f_pApiInstance Pointer to API instance. This memory is used to keep the
4943 present state of the chip and all its resources.
4944
4945 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4946 #if !SKIP_Oct6100ApiDestroySerializeObjects
4947 UINT32 Oct6100ApiDestroySerializeObjects(
4948 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4949 {
4950 tOCT6100_DESTROY_SERIALIZE_OBJECT DestroySerObj;
4951 UINT32 ulResult;
4952
4953 /* Set some parameters of the create structure once and for all. */
4954 DestroySerObj.pProcessContext = f_pApiInstance->pProcessContext;
4955 DestroySerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
4956
4957 ulResult = Oct6100UserDestroySerializeObject( &DestroySerObj );
4958 if ( ulResult != cOCT6100_ERR_OK )
4959 return ulResult;
4960
4961 return cOCT6100_ERR_OK;
4962 }
4963 #endif
4964
4965
4966 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4967
4968 Function: Oct6100ApiRunEgo
4969
4970 Description: Private function used to communicate with the internal processors.
4971
4972 -------------------------------------------------------------------------------
4973 | Argument | Description
4974 -------------------------------------------------------------------------------
4975 f_pApiInstance Pointer to API instance. This memory is used to keep the
4976 present state of the chip and all its resources.
4977
4978 f_fStoreFlag Type of access performed. (Load or Store)
4979 f_ulNumEntry Number of access.
4980 f_aulEntry Array of access to perform.
4981
4982 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4983 #if !SKIP_Oct6100ApiRunEgo
4984 UINT32 Oct6100ApiRunEgo(
4985 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
4986 IN BOOL f_fStoreFlag,
4987 IN UINT32 f_ulNumEntry,
4988 OUT PUINT32 f_aulEntry )
4989 {
4990 tPOCT6100_SHARED_INFO pSharedInfo;
4991 tOCT6100_WRITE_PARAMS WriteParams;
4992 tOCT6100_READ_PARAMS ReadParams;
4993 UINT32 ulResult;
4994 UINT32 aulCpuLsuCmd[ 2 ];
4995 UINT16 usReadData;
4996 UINT32 i;
4997 BOOL fConditionFlag = TRUE;
4998 UINT32 ulLoopCounter = 0;
4999
5000 /* Get local pointer to shared portion of instance. */
5001 pSharedInfo = f_pApiInstance->pSharedInfo;
5002
5003 /* Set the process context and user chip ID parameters once and for all. */
5004 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
5005
5006 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5007
5008 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
5009
5010 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5011 ReadParams.pusReadData = &usReadData;
5012
5013 /* No more than 2 entries may be requested. */
5014 if ( f_ulNumEntry > 2 )
5015 return cOCT6100_ERR_FATAL_1B;
5016
5017 /* Write the requested entries at address reserved for CPU. */
5018 for( i = 0; i < f_ulNumEntry; i++ )
5019 {
5020 WriteParams.ulWriteAddress = cOCT6100_PART1_API_SCRATCH_PAD + ( 0x8 * i );
5021 WriteParams.usWriteData = (UINT16)(( f_aulEntry[ i * 2 ] >> 16 ) & 0xFFFF );
5022
5023 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5024 if ( ulResult != cOCT6100_ERR_OK )
5025 return ulResult;
5026
5027 WriteParams.ulWriteAddress += 2;
5028 WriteParams.usWriteData = (UINT16)( f_aulEntry[ i * 2 ] & 0xFFFF );
5029
5030 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5031 if ( ulResult != cOCT6100_ERR_OK )
5032 return ulResult;
5033
5034 WriteParams.ulWriteAddress += 2;
5035 WriteParams.usWriteData = (UINT16)(( f_aulEntry[ (i * 2) + 1] >> 16 ) & 0xFFFF );
5036
5037 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5038 if ( ulResult != cOCT6100_ERR_OK )
5039 return ulResult;
5040
5041 WriteParams.ulWriteAddress += 2;
5042 WriteParams.usWriteData = (UINT16)( f_aulEntry[ (i * 2) + 1] & 0xFFFF );
5043
5044 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5045 if ( ulResult != cOCT6100_ERR_OK )
5046 return ulResult;
5047 }
5048
5049 /* Preincrement code point. */
5050 pSharedInfo->MiscVars.usCodepoint++;
5051
5052 /* Create DWORD 0 of command. */
5053 aulCpuLsuCmd[0] = 0x00000000;
5054 if ( f_fStoreFlag == FALSE )
5055 aulCpuLsuCmd[0] |= 0xC0000000; /* EGO load. */
5056 else
5057 aulCpuLsuCmd[0] |= 0xE0000000; /* EGO store. */
5058
5059 aulCpuLsuCmd[0] |= (f_ulNumEntry - 1) << 19;
5060 aulCpuLsuCmd[0] |= cOCT6100_PART1_API_SCRATCH_PAD;
5061
5062 /* Create DWORD 1 of command. */
5063 aulCpuLsuCmd[1] = 0x00000000;
5064 aulCpuLsuCmd[1] |= ( ( cOCT6100_PART1_API_SCRATCH_PAD + 0x10 ) & 0xFFFF ) << 16;
5065 aulCpuLsuCmd[1] |= pSharedInfo->MiscVars.usCodepoint;
5066
5067 /* Write the EGO command in the LSU CB. */
5068 WriteParams.ulWriteAddress = cOCT6100_PART1_CPU_LSU_CB_BASE + ((pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7) * 0x8 );
5069 WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 0 ] >> 16 ) & 0xFFFF );
5070
5071 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5072 if ( ulResult != cOCT6100_ERR_OK )
5073 return ulResult;
5074
5075 WriteParams.ulWriteAddress += 2;
5076 WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 0 ] & 0xFFFF );
5077
5078 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5079 if ( ulResult != cOCT6100_ERR_OK )
5080 return ulResult;
5081
5082 WriteParams.ulWriteAddress += 2;
5083 WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 1 ] >> 16 ) & 0xFFFF );
5084
5085 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5086 if ( ulResult != cOCT6100_ERR_OK )
5087 return ulResult;
5088
5089 WriteParams.ulWriteAddress += 2;
5090 WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 1 ] & 0xFFFF );
5091
5092 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5093 if ( ulResult != cOCT6100_ERR_OK )
5094 return ulResult;
5095
5096 /* Post increment the write pointer. */
5097 pSharedInfo->MiscVars.usCpuLsuWritePtr++;
5098
5099 /* Indicate new write pointer position to HW. */
5100 WriteParams.ulWriteAddress = cOCT6100_PART1_EGO_REG + 0x5A;
5101 WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7 );
5102
5103 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5104 if ( ulResult != cOCT6100_ERR_OK )
5105 return ulResult;
5106
5107 /* Wait for codepoint to be updated before returning. */
5108 while( fConditionFlag )
5109 {
5110 ReadParams.ulReadAddress = cOCT6100_PART1_API_SCRATCH_PAD + 0x12;
5111 usReadData = (UINT16)( pSharedInfo->MiscVars.usCodepoint );
5112
5113 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5114 if ( ulResult != cOCT6100_ERR_OK )
5115 return ulResult;
5116
5117 if ( usReadData == pSharedInfo->MiscVars.usCodepoint )
5118 fConditionFlag = FALSE;
5119
5120 ulLoopCounter++;
5121
5122 if ( ulLoopCounter == cOCT6100_MAX_LOOP )
5123 return cOCT6100_ERR_OPEN_EGO_TIMEOUT;
5124 }
5125
5126 /* CRC error bit must be zero. */
5127 ReadParams.ulReadAddress = 0x202;
5128
5129 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5130 if ( ulResult != cOCT6100_ERR_OK )
5131 return ulResult;
5132
5133 if ( ( usReadData & 0x0400 ) != 0 )
5134 return cOCT6100_ERR_OPEN_CORRUPTED_IMAGE;
5135
5136 return cOCT6100_ERR_OK;
5137 }
5138 #endif
5139
5140
5141 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5142
5143 Function: Oct6100ApiCreateEgoEntry
5144
5145 Description: Private function used to create an access structure to be sent
5146 to the internal processors.
5147
5148 -------------------------------------------------------------------------------
5149 | Argument | Description
5150 -------------------------------------------------------------------------------
5151 f_ulExternalAddress External memory address for the access.
5152 f_ulInternalAddress Which process should receive the command.
5153 f_ulNumBytes Number of bytes associated to the access.
5154 f_aulEntry Array of access to perform.
5155
5156 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5157 #if !SKIP_Oct6100ApiCreateEgoEntry
5158 UINT32 Oct6100ApiCreateEgoEntry(
5159 IN UINT32 f_ulExternalAddress,
5160 IN UINT32 f_ulInternalAddress,
5161 IN UINT32 f_ulNumBytes,
5162 OUT UINT32 f_aulEntry[ 2 ] )
5163 {
5164 f_aulEntry[0] = 0x80000000;
5165 f_aulEntry[0] |= f_ulExternalAddress & 0x07FFFFFC;
5166
5167 f_aulEntry[1] = 0x0011C000;
5168 f_aulEntry[1] |= (f_ulNumBytes / 8) << 23;
5169 f_aulEntry[1] |= (f_ulInternalAddress >> 2) & 0x3FFF;
5170
5171 return cOCT6100_ERR_OK;
5172 }
5173 #endif
5174
5175
5176
5177
5178
5179
5180
5181
5182 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5183
5184 Function: Oct6100ApiInitChannels
5185
5186 Description: This function will initialize all the channels to power down.
5187
5188 -------------------------------------------------------------------------------
5189 | Argument | Description
5190 -------------------------------------------------------------------------------
5191 f_pApiInstance Pointer to API instance. This memory is used to keep the
5192 present state of the chip and all its resources.
5193
5194 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5195 #if !SKIP_Oct6100ApiInitChannels
5196 UINT32 Oct6100ApiInitChannels(
5197 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
5198 {
5199 tPOCT6100_SHARED_INFO pSharedInfo;
5200 UINT32 i;
5201 UINT32 ulResult;
5202 tOCT6100_WRITE_PARAMS WriteParams;
5203 tOCT6100_READ_PARAMS ReadParams;
5204 UINT16 usReadData;
5205 UINT32 ulTempData;
5206 UINT32 ulBaseAddress;
5207 UINT32 ulFeatureBytesOffset;
5208 UINT32 ulFeatureBitOffset;
5209 UINT32 ulFeatureFieldLength;
5210 UINT32 ulMask;
5211 UINT16 usLoopCount = 0;
5212 UINT16 usWriteData = 0;
5213 UINT16 usMclkRead;
5214 UINT16 usLastMclkRead;
5215 UINT16 usMclkDiff;
5216 UINT32 ulNumberOfCycleToWait;
5217 UINT32 ulTimeoutCounter;
5218
5219 pSharedInfo = f_pApiInstance->pSharedInfo;
5220
5221 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
5222
5223 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
5224
5225 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
5226
5227 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
5228 ReadParams.pusReadData = &usReadData;
5229
5230 /* Verify that the image has enough memory to work correctly. */
5231 if ( ( pSharedInfo->MiscVars.ulTotalMemSize + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) < pSharedInfo->MemoryMap.ulFreeMemBaseAddress )
5232 return cOCT6100_ERR_OPEN_INSUFFICIENT_EXTERNAL_MEMORY;
5233
5234 /* Verify that the tail length is supported by the device.*/
5235 if ( pSharedInfo->ChipConfig.usTailDisplacement > pSharedInfo->ImageInfo.usMaxTailDisplacement )
5236 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_TAIL_DISPLACEMENT_VALUE;
5237
5238 /* Verify that acoustic echo is supported by the device. */
5239 if ( pSharedInfo->ChipConfig.fEnableAcousticEcho == TRUE && pSharedInfo->ImageInfo.fAcousticEcho == FALSE )
5240 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_ACOUSTIC_ECHO;
5241
5242 /* Verify that the image supports all the requested channels. */
5243 if ( pSharedInfo->ChipConfig.usMaxChannels > pSharedInfo->ImageInfo.usMaxNumberOfChannels )
5244 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE;
5245
5246 /* Max number of channels the image supports + 1 for channel recording, if requested */
5247 if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
5248 && ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < cOCT6100_MAX_ECHO_CHANNELS )
5249 && ( pSharedInfo->ChipConfig.usMaxChannels == pSharedInfo->ImageInfo.usMaxNumberOfChannels ) )
5250 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE;
5251
5252 /* Initialize the memory for all required channels. */
5253 for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
5254 {
5255 /*==============================================================================*/
5256 /* Configure the Global Static Configuration memory of the channel. */
5257
5258 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( i * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
5259
5260 /* Set the PGSP context base address. */
5261 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
5262
5263 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
5264 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5265
5266 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5267 if ( ulResult != cOCT6100_ERR_OK )
5268 return ulResult;
5269
5270 WriteParams.ulWriteAddress += 2;
5271 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5272
5273 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5274 if ( ulResult != cOCT6100_ERR_OK )
5275 return ulResult;
5276
5277 /* Set the PGSP init context base address. */
5278 ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
5279
5280 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
5281 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5282
5283 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5284 if ( ulResult != cOCT6100_ERR_OK )
5285 return ulResult;
5286
5287 WriteParams.ulWriteAddress += 2;
5288 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5289
5290 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5291 if ( ulResult != cOCT6100_ERR_OK )
5292 return ulResult;
5293
5294 /* Set the RIN circular buffer base address. */
5295 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst;
5296
5297 /* Set the circular buffer size. */
5298 ulTempData &= 0xFFFFFF00;
5299 if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 )
5300 return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE;
5301 ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8;
5302
5303 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
5304 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5305
5306 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5307 if ( ulResult != cOCT6100_ERR_OK )
5308 return ulResult;
5309
5310 WriteParams.ulWriteAddress += 2;
5311 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5312
5313 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5314 if ( ulResult != cOCT6100_ERR_OK )
5315 return ulResult;
5316
5317 /* Set the SIN circular buffer base address. */
5318 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst;
5319
5320 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
5321 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5322
5323 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5324 if ( ulResult != cOCT6100_ERR_OK )
5325 return ulResult;
5326
5327 WriteParams.ulWriteAddress += 2;
5328 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5329
5330 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5331 if ( ulResult != cOCT6100_ERR_OK )
5332 return ulResult;
5333
5334 /* Set the SOUT circular buffer base address. */
5335 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst;;
5336
5337 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
5338 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5339
5340 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5341 if ( ulResult != cOCT6100_ERR_OK )
5342 return ulResult;
5343
5344 WriteParams.ulWriteAddress += 2;
5345 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5346
5347 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5348 if ( ulResult != cOCT6100_ERR_OK )
5349 return ulResult;
5350
5351 /*==============================================================================*/
5352 }
5353
5354 /* Put all channel in powerdown mode "3". */
5355 for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
5356 {
5357 WriteParams.ulWriteAddress = 0x014000 + (i*4) + 0;
5358 WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */
5359
5360 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5361 if ( ulResult != cOCT6100_ERR_OK )
5362 return ulResult;
5363
5364 WriteParams.ulWriteAddress = 0x014000 + (i*4) + 2;
5365 WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */
5366
5367 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5368 if ( ulResult != cOCT6100_ERR_OK )
5369 return ulResult;
5370 }
5371
5372 /* Set the maximum number of channels. */
5373 WriteParams.ulWriteAddress = 0x690;
5374 if ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < 384 )
5375 WriteParams.usWriteData = 384;
5376 else
5377 WriteParams.usWriteData = (UINT16)pSharedInfo->ImageInfo.usMaxNumberOfChannels;
5378
5379 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5380 if ( ulResult != cOCT6100_ERR_OK )
5381 return ulResult;
5382
5383 /* Set power-dowm TSI chariot memory to silence. */
5384 for( i = 0; i < 6; i++ )
5385 {
5386 WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1534 * 2 );
5387 WriteParams.usWriteData = 0x3EFF;
5388
5389 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5390 if ( ulResult != cOCT6100_ERR_OK )
5391 return ulResult;
5392
5393 WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1535 * 2 );
5394 WriteParams.usWriteData = 0x3EFF;
5395
5396 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5397 if ( ulResult != cOCT6100_ERR_OK )
5398 return ulResult;
5399 }
5400
5401 /* Remove chariot hold. */
5402 WriteParams.ulWriteAddress = 0x500;
5403 WriteParams.usWriteData = 0x0001;
5404
5405 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5406 if ( ulResult != cOCT6100_ERR_OK )
5407 return ulResult;
5408
5409 for( usLoopCount = 0; usLoopCount < 4096; usLoopCount++ )
5410 {
5411 if ( (usLoopCount % 16) < 8 )
5412 {
5413 usWriteData = (UINT16)((usLoopCount / 16) << 7);
5414 usWriteData |= (UINT16)((usLoopCount % 8));
5415 }
5416 else
5417 {
5418 usWriteData = (UINT16)((usLoopCount / 16) << 7);
5419 usWriteData |= (UINT16)((usLoopCount % 8));
5420 usWriteData |= 0x78;
5421 }
5422
5423 /* Set timeslot pointer. */
5424 WriteParams.ulWriteAddress = 0x50E;
5425 WriteParams.usWriteData = 0x0003;
5426 WriteParams.usWriteData |= usWriteData << 2;
5427
5428 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5429 if ( ulResult != cOCT6100_ERR_OK )
5430 return ulResult;
5431
5432 /* Now read the mclk counter. */
5433 ReadParams.ulReadAddress = 0x30A;
5434 ReadParams.pusReadData = &usLastMclkRead;
5435
5436 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5437 if ( ulResult != cOCT6100_ERR_OK )
5438 return ulResult;
5439
5440 /* Reset loop timeout counter. */
5441 ulTimeoutCounter = 0x0;
5442
5443 do {
5444 ReadParams.pusReadData = &usMclkRead;
5445
5446 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5447 if ( ulResult != cOCT6100_ERR_OK )
5448 return ulResult;
5449
5450 if ( ( usLoopCount % 16 ) != 15 )
5451 {
5452 ulNumberOfCycleToWait = 133;
5453 }
5454 else
5455 {
5456 ulNumberOfCycleToWait = 20000;
5457 }
5458
5459 /* Evaluate the difference. */
5460 usMclkDiff = (UINT16)(( usMclkRead - usLastMclkRead ) & 0xFFFF);
5461
5462 /* Check for loop timeout. Bad mclk? */
5463 ulTimeoutCounter++;
5464 if ( ulTimeoutCounter == cOCT6100_MAX_LOOP_CPU_TIMEOUT )
5465 return cOCT6100_ERR_FATAL_EA;
5466
5467 } while( usMclkDiff <= ulNumberOfCycleToWait );
5468 }
5469
5470 /* Back to normal mode. */
5471 WriteParams.ulWriteAddress = 0x50E;
5472 WriteParams.usWriteData = 0x0000;
5473
5474 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5475 if ( ulResult != cOCT6100_ERR_OK )
5476 return ulResult;
5477
5478 /* Check for CRC errors. */
5479 ReadParams.pusReadData = &usReadData;
5480 ReadParams.ulReadAddress = 0x202;
5481
5482 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5483 if ( ulResult != cOCT6100_ERR_OK )
5484 return ulResult;
5485
5486 if ( (usReadData & 0x400) != 0x0000 )
5487 return cOCT6100_ERR_OPEN_CRC_ERROR;
5488
5489 /* Clear the error rol raised by manually moving the clocks. */
5490 WriteParams.ulWriteAddress = 0x502;
5491 WriteParams.usWriteData = 0x0002;
5492
5493 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5494 if ( ulResult != cOCT6100_ERR_OK )
5495 return ulResult;
5496
5497 /*======================================================================*/
5498 /* Write the tail displacement value in external memory. */
5499
5500 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.usDwordOffset * 4;
5501 ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.byBitOffset;
5502 ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchTailDisplOfst.byFieldSize;
5503
5504 ulResult = Oct6100ApiReadDword( f_pApiInstance,
5505 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5506 &ulTempData );
5507
5508 /* Clear previous value set in the feature field.*/
5509 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
5510
5511 ulTempData &= (~ulMask);
5512
5513 /* Set the tail displacement. */
5514 ulTempData |= (pSharedInfo->ChipConfig.usTailDisplacement << ulFeatureBitOffset );
5515
5516 /* Write the DWORD where the field is located. */
5517 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
5518 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5519 ulTempData );
5520 if ( ulResult != cOCT6100_ERR_OK )
5521 return ulResult;
5522
5523 /*======================================================================*/
5524
5525
5526 /*======================================================================*/
5527 /* Clear the pouch counter, if present. */
5528
5529 if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
5530 {
5531 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
5532 ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
5533 ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
5534
5535 ulResult = Oct6100ApiReadDword( f_pApiInstance,
5536 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5537 &ulTempData );
5538
5539 /* Clear previous value set in the feature field.*/
5540 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
5541
5542 /* Clear counter! */
5543 ulTempData &= (~ulMask);
5544
5545 /* Write the DWORD where the field is located.*/
5546 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
5547 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5548 ulTempData );
5549 if ( ulResult != cOCT6100_ERR_OK )
5550 return ulResult;
5551 }
5552
5553 /* The ISR has not yet been called. Set the appropriate bit in external memory. */
5554 if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
5555 {
5556 ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
5557 ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
5558 ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
5559
5560 ulResult = Oct6100ApiReadDword( f_pApiInstance,
5561 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5562 &ulTempData );
5563
5564 /* Read previous value set in the feature field.*/
5565 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
5566
5567 /* Toggle the bit to '1'. */
5568 ulTempData |= 1 << ulFeatureBitOffset;
5569
5570 /* Write the DWORD where the field is located.*/
5571 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
5572 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5573 ulTempData );
5574 if ( ulResult != cOCT6100_ERR_OK )
5575 return ulResult;
5576 }
5577
5578 /*======================================================================*/
5579
5580 return cOCT6100_ERR_OK;
5581 }
5582 #endif
5583
5584
5585 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5586
5587 Function: Oct6100ApiInitToneInfo
5588
5589 Description: This function will parse the software image and retrieve
5590 the information about the tones that it supports.
5591
5592 -------------------------------------------------------------------------------
5593 | Argument | Description
5594 -------------------------------------------------------------------------------
5595 f_pApiInstance Pointer to API instance. This memory is used to keep the
5596 present state of the chip and all its resources.
5597
5598 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5599 #if !SKIP_Oct6100ApiInitToneInfo
5600 UINT32 Oct6100ApiInitToneInfo(
5601 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
5602 {
5603 UINT32 ulResult;
5604
5605 unsigned char const *pszToneInfoStart = NULL;
5606 unsigned char const *pszToneInfoEnd = NULL;
5607
5608 unsigned char const *pszCurrentInfo;
5609 unsigned char const *pszNextInfo;
5610
5611 UINT32 ulToneEventNumber;
5612 UINT32 ulTempValue;
5613 UINT32 ulNumCharForValue;
5614 UINT32 ulUniqueToneId;
5615 UINT32 ulToneNameSize;
5616 UINT32 ulOffset = 0;
5617
5618 UINT32 i;
5619
5620 /* Init the tone detector parameter. */
5621 f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors = 0;
5622
5623 /* Find the start and the end of the tone info section. */
5624 if ( f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize > 4096 )
5625 {
5626 /* For performance reasons, and since the tone detector information */
5627 /* is always located at the end of the image file, try to start from the end */
5628 /* of the buffer. */
5629
5630 ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 2048;
5631 pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset,
5632 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
5633 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5634
5635 /* Check if the information was found. */
5636 if ( pszToneInfoStart == NULL )
5637 {
5638 /* Try again, but giving a larger string to search. */
5639 ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 4096;
5640 pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset,
5641 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
5642 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5643
5644 }
5645 }
5646
5647 if ( pszToneInfoStart == NULL )
5648 {
5649 /* Travel through the whole file buffer. */
5650 pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile,
5651 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
5652 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5653 }
5654 /* We have to return immediatly if no tones are found. */
5655 if ( pszToneInfoStart == NULL )
5656 return cOCT6100_ERR_OK;
5657
5658 /* The end of the tone detector information is after the beginning of the tone information. */
5659 pszToneInfoEnd = Oct6100ApiStrStr( pszToneInfoStart,
5660 (PUINT8)cOCT6100_TONE_INFO_STOP_STRING,
5661 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5662 if ( pszToneInfoEnd == NULL )
5663 return cOCT6100_ERR_OPEN_TONE_INFO_STOP_TAG_NOT_FOUND;
5664
5665 /* Find and process all tone events within the region. */
5666 pszCurrentInfo = Oct6100ApiStrStr( pszToneInfoStart, (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
5667
5668 while ( pszCurrentInfo != NULL )
5669 {
5670 /* Skip the string. */
5671 pszCurrentInfo += ( Oct6100ApiStrLen( (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING ) );
5672
5673 /* Extract the number of char used to represent the tone event number ( 1 or 2 ). */
5674 pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo, (PUINT8)",", pszToneInfoEnd );
5675 ulNumCharForValue = (UINT32)( pszNextInfo - pszCurrentInfo );
5676
5677 /* Retreive the event number */
5678 ulToneEventNumber = 0;
5679 for ( i = ulNumCharForValue; i > 0; i-- )
5680 {
5681 ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
5682 if ( ulResult != cOCT6100_ERR_OK )
5683 return ulResult;
5684
5685 ulToneEventNumber |= ( ulTempValue << (( i - 1) * 4 ) );
5686 pszCurrentInfo++;
5687 }
5688
5689 if ( ulToneEventNumber >= cOCT6100_MAX_TONE_EVENT )
5690 return cOCT6100_ERR_OPEN_INVALID_TONE_EVENT;
5691
5692 /* Skip the comma and the 0x. */
5693 pszCurrentInfo += 3;
5694
5695 /*======================================================================*/
5696 /* Retreive the unique tone id. */
5697 ulUniqueToneId = 0;
5698 for ( i = 0; i < 8; i++ )
5699 {
5700 ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
5701 if ( ulResult != cOCT6100_ERR_OK )
5702 return ulResult;
5703
5704 ulOffset = 28 - ( i * 4 );
5705 ulUniqueToneId |= ( ulTempValue << ulOffset );
5706 pszCurrentInfo++;
5707 }
5708
5709 /*======================================================================*/
5710
5711 /* Skip the comma. */
5712 pszCurrentInfo++;
5713
5714 /* Find out where the next event info starts */
5715 pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
5716 if ( pszNextInfo == NULL )
5717 pszNextInfo = pszToneInfoEnd;
5718
5719 /* Extract the name size. */
5720 ulToneNameSize = (UINT32)( pszNextInfo - pszCurrentInfo - 2 ); /* - 2 for 0x0D and 0x0A.*/
5721
5722 if ( ulToneNameSize > cOCT6100_TLV_MAX_TONE_NAME_SIZE )
5723 return cOCT6100_ERR_OPEN_INVALID_TONE_NAME;
5724
5725 /* Copy the tone name into the image info structure. */
5726 ulResult = Oct6100UserMemCopy( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].aszToneName,
5727 pszCurrentInfo,
5728 ulToneNameSize );
5729
5730
5731
5732 /* Update the tone info into the image info structure. */
5733 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID = ulUniqueToneId;
5734 /* Find out the port on which this tone detector is associated. */
5735 switch( (ulUniqueToneId >> 28) & 0xF )
5736 {
5737 case 1:
5738 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT;
5739 break;
5740
5741 case 2:
5742 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SIN;
5743 break;
5744
5745 case 4:
5746 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SOUT;
5747 break;
5748
5749 case 5:
5750 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT_SOUT;
5751 break;
5752
5753 default:
5754 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_INVALID_PORT;
5755 break;
5756 }
5757
5758 /* Find out where the next event info starts */
5759 pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
5760 /* Update the current info pointer. */
5761 pszCurrentInfo = pszNextInfo;
5762
5763 f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors++;
5764 }
5765
5766 return cOCT6100_ERR_OK;
5767 }
5768 #endif
5769
5770
5771 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5772
5773 Function: Oct6100ApiExternalMemoryBist
5774
5775 Description: Tests the functionality of the external memories.
5776
5777 -------------------------------------------------------------------------------
5778 | Argument | Description
5779 -------------------------------------------------------------------------------
5780 f_pApiInstance Pointer to API instance. This memory is used to keep the
5781 present state of the chip and all its resources.
5782
5783 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5784 #if !SKIP_Oct6100ApiExternalMemoryBist
5785 UINT32 Oct6100ApiExternalMemoryBist(
5786 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
5787 {
5788 tPOCT6100_SHARED_INFO pSharedInfo;
5789 UINT32 ulMemSize = 0;
5790 UINT32 ulResult;
5791
5792 /* Get local pointer to shared portion of instance. */
5793 pSharedInfo = f_pApiInstance->pSharedInfo;
5794
5795 /* Test the external memory. */
5796 switch ( pSharedInfo->ChipConfig.ulMemoryChipSize )
5797 {
5798 case cOCT6100_MEMORY_CHIP_SIZE_8MB:
5799 ulMemSize = cOCT6100_SIZE_8M;
5800 break;
5801 case cOCT6100_MEMORY_CHIP_SIZE_16MB:
5802 ulMemSize = cOCT6100_SIZE_16M;
5803 break;
5804 case cOCT6100_MEMORY_CHIP_SIZE_32MB:
5805 ulMemSize = cOCT6100_SIZE_32M;
5806 break;
5807 case cOCT6100_MEMORY_CHIP_SIZE_64MB:
5808 ulMemSize = cOCT6100_SIZE_64M;
5809 break;
5810 case cOCT6100_MEMORY_CHIP_SIZE_128MB:
5811 ulMemSize = cOCT6100_SIZE_128M;
5812 break;
5813 default:
5814 return cOCT6100_ERR_FATAL_D9;
5815 }
5816
5817 ulMemSize *= pSharedInfo->ChipConfig.byNumMemoryChips;
5818
5819 ulResult = Oct6100ApiRandomMemoryWrite( f_pApiInstance, cOCT6100_EXTERNAL_MEM_BASE_ADDRESS, ulMemSize, 16, 1000, cOCT6100_ERR_OPEN_EXTERNAL_MEM_BIST_FAILED );
5820 if ( ulResult != cOCT6100_ERR_OK )
5821 return ulResult;
5822
5823 /* Make sure the user I/O functions are working as required. */
5824 ulResult = Oct6100ApiUserIoTest( f_pApiInstance );
5825 if ( ulResult != cOCT6100_ERR_OK )
5826 return ulResult;
5827
5828 return cOCT6100_ERR_OK;
5829 }
5830 #endif
5831
5832
5833 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5834
5835 Function: Oct6100ApiGenerateNumber
5836
5837 Description: Generate a number using an index. Passing the same
5838 index generates the same number.
5839
5840 -------------------------------------------------------------------------------
5841 | Argument | Description
5842 -------------------------------------------------------------------------------
5843 f_pApiInstance Pointer to API instance. This memory is used to keep the
5844 present state of the chip and all its resources.
5845 f_ulIndex Index used to generate the random number.
5846 f_ulDataMask Data mask to apply to generated number.
5847
5848 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5849 #if !SKIP_Oct6100ApiGenerateNumber
5850 UINT16 Oct6100ApiGenerateNumber(
5851 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
5852 IN UINT32 f_ulIndex,
5853 IN UINT32 f_ulDataMask )
5854 {
5855 UINT16 usGeneratedNumber;
5856
5857 usGeneratedNumber = (UINT16)( ( ( ~( f_ulIndex - 1 ) ) & 0xFF00 ) | ( ( f_ulIndex + 1 ) & 0xFF ) );
5858
5859 return (UINT16)( usGeneratedNumber & f_ulDataMask );
5860 }
5861 #endif
5862
5863
5864 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5865
5866 Function: Oct6100ApiRandomMemoryWrite
5867
5868 Description: Writes to f_ulNumAccesses random locations in the indicated
5869 memory and read back to test the operation of that memory.
5870
5871 -------------------------------------------------------------------------------
5872 | Argument | Description
5873 -------------------------------------------------------------------------------
5874 f_pApiInstance Pointer to API instance. This memory is used to keep the
5875 present state of the chip and all its resources.
5876 f_ulMemBase Base address of the memory access.
5877 f_ulMemSize Size of the memory to be tested.
5878 f_ulNumDataBits Number of data bits.
5879 f_ulNumAccesses Number of random access to be perform.
5880 f_ulErrorCode Error code to be returned if the bist fails.
5881
5882 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5883 #if !SKIP_Oct6100ApiRandomMemoryWrite
5884 UINT32 Oct6100ApiRandomMemoryWrite(
5885 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
5886 IN UINT32 f_ulMemBase,
5887 IN UINT32 f_ulMemSize,
5888 IN UINT32 f_ulNumDataBits,
5889 IN UINT32 f_ulNumAccesses,
5890 IN UINT32 f_ulErrorCode )
5891 {
5892 tPOCT6100_SHARED_INFO pSharedInfo;
5893 tOCT6100_WRITE_PARAMS WriteParams;
5894 tOCT6100_READ_PARAMS ReadParams;
5895 UINT32 ulDataMask;
5896 UINT32 ulResult, i, j;
5897 UINT32 ulBistAddress;
5898 UINT16 usReadData;
5899 UINT32 aulBistAddress[20]={0x00000000, 0x00000002, 0x00000004, 0x007FFFFE,
5900 0x00900000, 0x00900006, 0x00900008, 0x009FFFFE,
5901 0x01000000, 0x0100000A, 0x0200000C, 0x01FFFFFE,
5902 0x03000000, 0x03000002, 0x04000004, 0x03FFFFFE,
5903 0x04000000, 0x05000006, 0x06000008, 0x07FFFFFE};
5904
5905 /* Get local pointer to shared portion of instance. */
5906 pSharedInfo = f_pApiInstance->pSharedInfo;
5907
5908 /* Set the process context and user chip ID parameters once and for all. */
5909 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
5910
5911 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5912
5913 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
5914
5915 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5916
5917 /* Determine mask for number of data bits. */
5918 ulDataMask = (1 << f_ulNumDataBits) - 1;
5919
5920 /* Write specific data to specific address */
5921 WriteParams.ulWriteAddress = f_ulMemBase | 0x00001000;
5922 WriteParams.usWriteData = 0xCAFE;
5923
5924 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5925 if ( ulResult != cOCT6100_ERR_OK )
5926 return ulResult;
5927
5928 for(j=0; j<20; j++)
5929 {
5930 /* Change address to test lower and higher part of the 32 bit bus */
5931 ulBistAddress = aulBistAddress[j];
5932 ulBistAddress &= f_ulMemSize - 2;
5933 ulBistAddress |= f_ulMemBase;
5934
5935 /* Bist 16 data pins of this address */
5936 for ( i = 0; i < 16; i ++)
5937 {
5938 WriteParams.ulWriteAddress = ulBistAddress;
5939 WriteParams.usWriteData = (UINT16)(0x1 << i);
5940
5941 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5942 if ( ulResult != cOCT6100_ERR_OK )
5943 return ulResult;
5944
5945 /* Read back the specific data to flush the data bus.*/
5946 ReadParams.ulReadAddress = f_ulMemBase | 0x00001000;
5947 ReadParams.pusReadData = &usReadData;
5948 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
5949 if ( ulResult != cOCT6100_ERR_OK )
5950 return ulResult;
5951
5952 if ( usReadData != 0xCAFE )
5953 return f_ulErrorCode;
5954
5955 /* Read back the data written.*/
5956 ReadParams.ulReadAddress = WriteParams.ulWriteAddress;
5957 ReadParams.pusReadData = &usReadData;
5958 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
5959 if ( ulResult != cOCT6100_ERR_OK )
5960 return ulResult;
5961
5962 if ( usReadData != (UINT16)(0x1 << i) )
5963 return f_ulErrorCode;
5964 }
5965 }
5966
5967 /* Perform the first write at address 0 + mem base */
5968 j = 0;
5969 WriteParams.ulWriteAddress = f_ulMemBase;
5970 WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask );
5971 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5972 if ( ulResult != cOCT6100_ERR_OK )
5973 return ulResult;
5974
5975 /* Try each address line of the memory. */
5976 for ( i = 2, j = 1; i < f_ulMemSize; i <<= 1, j++ )
5977 {
5978 WriteParams.ulWriteAddress = ( f_ulMemBase + i );
5979 WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask );
5980 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5981 if ( ulResult != cOCT6100_ERR_OK )
5982 return ulResult;
5983 }
5984
5985 for ( i = 0; i < j; i++ )
5986 {
5987 if ( i > 0 )
5988 ReadParams.ulReadAddress = ( f_ulMemBase + ( 0x1 << i ) );
5989 else
5990 ReadParams.ulReadAddress = f_ulMemBase;
5991 ReadParams.pusReadData = &usReadData;
5992 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
5993 if ( ulResult != cOCT6100_ERR_OK )
5994 return ulResult;
5995
5996 if ( usReadData != Oct6100ApiGenerateNumber( f_pApiInstance, i, ulDataMask ) )
5997 return f_ulErrorCode;
5998 }
5999
6000 /* Write to random addresses of the memory. */
6001 for ( i = 0; i < f_ulNumAccesses; i++ )
6002 {
6003 ulBistAddress = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16;
6004 ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6005 ulBistAddress &= f_ulMemSize - 2;
6006 ulBistAddress |= f_ulMemBase;
6007
6008 WriteParams.ulWriteAddress = ulBistAddress;
6009 WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6010 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6011 if ( ulResult != cOCT6100_ERR_OK )
6012 return ulResult;
6013 }
6014
6015 for ( i = 0; i < f_ulNumAccesses; i++ )
6016 {
6017 ulBistAddress = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16;
6018 ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6019 ulBistAddress &= f_ulMemSize - 2;
6020 ulBistAddress |= f_ulMemBase;
6021
6022 ReadParams.ulReadAddress = ulBistAddress;
6023 ReadParams.pusReadData = &usReadData;
6024 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
6025 if ( ulResult != cOCT6100_ERR_OK )
6026 return ulResult;
6027
6028 if ( ( usReadData & ulDataMask ) != ( Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) & ulDataMask ) )
6029 return f_ulErrorCode;
6030 }
6031
6032
6033 return cOCT6100_ERR_OK;
6034 }
6035 #endif
6036
6037
6038 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6039
6040 Function: Oct6100ApiUserIoTest
6041
6042 Description: This function will verify the correct functionality of
6043 the following user functions:
6044
6045 - Oct6100UserDriverWriteBurstApi
6046 - Oct6100UserDriverWriteSmearApi
6047 - Oct6100UserDriverReadBurstApi
6048
6049 The Oct6100UserDriverWriteApi and Oct6100UserDriverReadApi
6050 functions do not need to be tested here as this has be done in
6051 the external memory bisting function above.
6052
6053 -------------------------------------------------------------------------------
6054 | Argument | Description
6055 -------------------------------------------------------------------------------
6056 f_pApiInstance Pointer to API instance. This memory is used to keep the
6057 present state of the chip and all its resources.
6058
6059 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6060 #if !SKIP_Oct6100ApiUserIoTest
6061 UINT32 Oct6100ApiUserIoTest(
6062 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6063 {
6064 tPOCT6100_SHARED_INFO pSharedInfo;
6065 tOCT6100_WRITE_BURST_PARAMS WriteBurstParams;
6066 tOCT6100_WRITE_SMEAR_PARAMS WriteSmearParams;
6067 tOCT6100_READ_PARAMS ReadParams;
6068 tOCT6100_READ_BURST_PARAMS ReadBurstParams;
6069 UINT32 ulResult, i;
6070 UINT16 usReadData;
6071
6072 /* Get local pointer to shared portion of instance. */
6073 pSharedInfo = f_pApiInstance->pSharedInfo;
6074
6075 /* Set the process context and user chip ID parameters once and for all. */
6076 WriteBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6077
6078 WriteBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6079 /* Test what the user has specified is the maximum that can be used for a burst. */
6080 WriteBurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6081 WriteBurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
6082
6083 WriteSmearParams.pProcessContext = f_pApiInstance->pProcessContext;
6084
6085 WriteSmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6086 /* Test what the user has specified is the maximum that can be used for a smear. */
6087 WriteSmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6088
6089 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
6090
6091 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6092 ReadParams.pusReadData = &usReadData;
6093
6094 ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6095
6096 ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6097 /* Test what the user has specified is the maximum that can be used for a burst. */
6098 ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6099 ReadBurstParams.pusReadData = pSharedInfo->MiscVars.ausSuperArray;
6100
6101
6102 /*======================================================================*/
6103 /* Write burst check. */
6104
6105 WriteBurstParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6106 /* Set the random data to be written. */
6107 for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ )
6108 {
6109 WriteBurstParams.pusWriteData[ i ] = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6110 }
6111 mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult )
6112 if ( ulResult != cOCT6100_ERR_OK )
6113 return ulResult;
6114
6115 /* Read back pattern using simple read function and make sure we are reading what's expected. */
6116 ReadParams.ulReadAddress = WriteBurstParams.ulWriteAddress;
6117 for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ )
6118 {
6119 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
6120 if ( ulResult != cOCT6100_ERR_OK )
6121 return ulResult;
6122
6123 /* Check if the data matches. */
6124 if ( usReadData != WriteBurstParams.pusWriteData[ i ] )
6125 {
6126 /* The values do not match. Something seems to be wrong with the WriteBurst user function. */
6127 return cOCT6100_ERR_OPEN_USER_WRITE_BURST_FAILED;
6128 }
6129
6130 /* Next address to check. */
6131 ReadParams.ulReadAddress += 2;
6132 }
6133
6134 /*======================================================================*/
6135
6136
6137 /*======================================================================*/
6138 /* Write smear check. */
6139
6140 WriteSmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + ( WriteBurstParams.ulWriteLength * 2 );
6141 /* Set the random data to be written. */
6142 WriteSmearParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, Oct6100ApiRand( 0xFFFF ), 0xFFFF );
6143 mOCT6100_DRIVER_WRITE_SMEAR_API( WriteSmearParams, ulResult )
6144 if ( ulResult != cOCT6100_ERR_OK )
6145 return ulResult;
6146
6147 /* Read back pattern using simple read function and make sure we are reading what's expected. */
6148 ReadParams.ulReadAddress = WriteSmearParams.ulWriteAddress;
6149 for ( i = 0; i < WriteSmearParams.ulWriteLength; i++ )
6150 {
6151 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
6152 if ( ulResult != cOCT6100_ERR_OK )
6153 return ulResult;
6154
6155 /* Check if the data matches. */
6156 if ( usReadData != WriteSmearParams.usWriteData )
6157 {
6158 /* The values do not match. Something seems to be wrong with the WriteSmear user function. */
6159 return cOCT6100_ERR_OPEN_USER_WRITE_SMEAR_FAILED;
6160 }
6161
6162 /* Next address to check. */
6163 ReadParams.ulReadAddress += 2;
6164 }
6165
6166 /*======================================================================*/
6167
6168
6169 /*======================================================================*/
6170 /* Read burst check. */
6171
6172 /* First check with what the WriteBurst function wrote. */
6173 ReadBurstParams.ulReadAddress = WriteBurstParams.ulWriteAddress;
6174 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
6175 if ( ulResult != cOCT6100_ERR_OK )
6176 return ulResult;
6177
6178 for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
6179 {
6180 /* Check if the data matches. */
6181 if ( ReadBurstParams.pusReadData[ i ] != Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) )
6182 {
6183 /* The values do not match. Something seems to be wrong with the ReadBurst user function. */
6184 return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED;
6185 }
6186 }
6187
6188 /* Then check with what the WriteSmear function wrote. */
6189 ReadBurstParams.ulReadAddress = WriteSmearParams.ulWriteAddress;
6190 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
6191 if ( ulResult != cOCT6100_ERR_OK )
6192 return ulResult;
6193
6194 for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
6195 {
6196 /* Check if the data matches. */
6197 if ( ReadBurstParams.pusReadData[ i ] != WriteSmearParams.usWriteData )
6198 {
6199 /* The values do not match. Something seems to be wrong with the ReadBurst user function. */
6200 return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED;
6201 }
6202 }
6203
6204 /*======================================================================*/
6205
6206 return cOCT6100_ERR_OK;
6207 }
6208 #endif
6209
6210
6211 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6212
6213 Function: Oct6100ApiExternalMemoryInit
6214
6215 Description: Initialize the external memory before uploading the image.
6216
6217 -------------------------------------------------------------------------------
6218 | Argument | Description
6219 -------------------------------------------------------------------------------
6220 f_pApiInstance Pointer to API instance. This memory is used to keep the
6221 present state of the chip and all its resources.
6222
6223 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6224 #if !SKIP_Oct6100ApiExternalMemoryInit
6225 UINT32 Oct6100ApiExternalMemoryInit(
6226 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6227 {
6228 tPOCT6100_SHARED_INFO pSharedInfo;
6229 tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
6230 UINT32 ulTotalWordToWrite;
6231 UINT32 ulResult;
6232
6233 /* Get local pointer to shared portion of instance. */
6234 pSharedInfo = f_pApiInstance->pSharedInfo;
6235
6236 SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
6237
6238 SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6239
6240 /* Clear the first part of the memory. */
6241 ulTotalWordToWrite = 0x400;
6242 SmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6243
6244 while ( ulTotalWordToWrite != 0 )
6245 {
6246 if ( ulTotalWordToWrite >= pSharedInfo->ChipConfig.usMaxRwAccesses )
6247 SmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6248 else
6249 SmearParams.ulWriteLength = ulTotalWordToWrite;
6250
6251 SmearParams.usWriteData = 0x0;
6252
6253 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
6254 if ( ulResult != cOCT6100_ERR_OK )
6255 return ulResult;
6256
6257 /* Update the number of words to write. */
6258 ulTotalWordToWrite -= SmearParams.ulWriteLength;
6259 /* Update the address. */
6260 SmearParams.ulWriteAddress += ( SmearParams.ulWriteLength * 2 );
6261 }
6262
6263 /* Clear the TLV flag.*/
6264 ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_TLV_BASE, 0x0 );
6265 if ( ulResult != cOCT6100_ERR_OK )
6266 return ulResult;
6267
6268 return cOCT6100_ERR_OK;
6269 }
6270 #endif
6271
6272
6273 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6274
6275 Function: Oct6100ApiInitMixer
6276
6277 Description: This function will initialize the mixer memory.
6278
6279 -------------------------------------------------------------------------------
6280 | Argument | Description
6281 -------------------------------------------------------------------------------
6282 f_pApiInstance Pointer to API instance. This memory is used to keep the
6283 present state of the chip and all its resources.
6284
6285 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6286 #if !SKIP_Oct6100ApiInitMixer
6287 UINT32 Oct6100ApiInitMixer(
6288 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6289 {
6290 tPOCT6100_SHARED_INFO pSharedInfo;
6291 tOCT6100_WRITE_BURST_PARAMS BurstParams;
6292 UINT16 ausWriteData[ 4 ];
6293 UINT32 ulResult;
6294
6295 pSharedInfo = f_pApiInstance->pSharedInfo;
6296
6297 BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6298
6299 BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6300 BurstParams.pusWriteData = ausWriteData;
6301 /*======================================================================*/
6302 /* Initialize the mixer memory if required. */
6303 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
6304 {
6305 /* Modify the mixer pointer by adding the record event into the link list. */
6306 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
6307 pSharedInfo->MixerInfo.usLastSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
6308 pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
6309 pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
6310
6311 /* Program the Sin copy event. */
6312 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordSinEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
6313 BurstParams.ulWriteLength = 4;
6314
6315 ausWriteData[ 0 ] = 0x0000;
6316 ausWriteData[ 1 ] = 0x0000;
6317 ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node.*/
6318 ausWriteData[ 3 ] = 0x0000;
6319
6320 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6321 if ( ulResult != cOCT6100_ERR_OK )
6322 return ulResult;
6323
6324 /* Program the Sout copy event. */
6325 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
6326 BurstParams.ulWriteLength = 4;
6327
6328 ausWriteData[ 0 ] = 0x0000;
6329 ausWriteData[ 1 ] = 0x0000;
6330 ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordSinEventIndex & 0x7FF);
6331 ausWriteData[ 3 ] = 0x0000;
6332
6333 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6334 if ( ulResult != cOCT6100_ERR_OK )
6335 return ulResult;
6336
6337 /* Configure the head node. */
6338 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE;
6339 BurstParams.ulWriteLength = 4;
6340
6341 ausWriteData[ 0 ] = 0x0000;
6342 ausWriteData[ 1 ] = 0x0000;
6343 ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordCopyEventIndex & 0x7FF);
6344 ausWriteData[ 3 ] = 0x0000;
6345
6346 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6347 if ( ulResult != cOCT6100_ERR_OK )
6348 return ulResult;
6349
6350 /* Init the mixer pointer */
6351 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
6352 }
6353 else
6354 {
6355 /* Configure the head node. */
6356 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE;
6357 BurstParams.ulWriteLength = 4;
6358
6359 ausWriteData[ 0 ] = 0x0000;
6360 ausWriteData[ 1 ] = 0x0000;
6361 ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node. */
6362 ausWriteData[ 3 ] = 0x0000;
6363
6364 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6365 if ( ulResult != cOCT6100_ERR_OK )
6366 return ulResult;
6367
6368 /* Configure the tail node. */
6369 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + 0x10;
6370 BurstParams.ulWriteLength = 4;
6371
6372 ausWriteData[ 0 ] = 0x0000;
6373 ausWriteData[ 1 ] = 0x0000;
6374 ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_HEAD_NODE & 0x7FF); /* Head node. */
6375 ausWriteData[ 3 ] = 0x0000;
6376
6377 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6378 if ( ulResult != cOCT6100_ERR_OK )
6379 return ulResult;
6380 }
6381
6382 return cOCT6100_ERR_OK;
6383 }
6384 #endif
6385
6386
6387 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6388
6389 Function: Oct6100ApiInitRecordResources
6390
6391 Description: This function will initialize the resources required to
6392 perform recording on a debug channel.
6393
6394 -------------------------------------------------------------------------------
6395 | Argument | Description
6396 -------------------------------------------------------------------------------
6397 f_pApiInstance Pointer to API instance. This memory is used to keep the
6398 present state of the chip and all its resources.
6399
6400 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6401 #if !SKIP_Oct6100ApiInitRecordResources
6402 UINT32 Oct6100ApiInitRecordResources(
6403 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6404 {
6405 tPOCT6100_SHARED_INFO pSharedInfo;
6406 UINT32 ulResult;
6407
6408 pSharedInfo = f_pApiInstance->pSharedInfo;
6409
6410 /* Check if recording is enabled. */
6411 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
6412 return cOCT6100_ERR_OK;
6413
6414 if ( pSharedInfo->DebugInfo.usRecordMemIndex == cOCT6100_INVALID_INDEX )
6415 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_DEBUG_RECORD;
6416
6417 /* Check the provided recording memory index within the SSPX. */
6418 if ( pSharedInfo->DebugInfo.usRecordMemIndex != ( pSharedInfo->ImageInfo.usMaxNumberOfChannels - 1 ) )
6419 return cOCT6100_ERR_OPEN_DEBUG_MEM_INDEX;
6420
6421 /* Reserve the TSI entries for the channel. */
6422 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex );
6423 if ( ulResult != cOCT6100_ERR_OK )
6424 return ulResult;
6425
6426 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
6427 if ( ulResult != cOCT6100_ERR_OK )
6428 return ulResult;
6429
6430 /* Open the debug channel. */
6431 ulResult = Oct6100ApiDebugChannelOpen( f_pApiInstance );
6432 if ( ulResult != cOCT6100_ERR_OK )
6433 return ulResult;
6434
6435 return cOCT6100_ERR_OK;
6436 }
6437 #endif
6438
6439
6440 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6441
6442 Function: Oct6100FreeResourcesSer
6443
6444 Description: This function closes all opened channels and frees all
6445 specified global resources used by the chip.
6446
6447 -------------------------------------------------------------------------------
6448 | Argument | Description
6449 -------------------------------------------------------------------------------
6450 f_pApiInstance Pointer to API instance. This memory is used to keep
6451 the present state of the chip and all its resources.
6452
6453 f_pFreeResources Pointer to user structure in which to choose what
6454 to free.
6455
6456 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6457 #if !SKIP_Oct6100FreeResourcesSer
6458 UINT32 Oct6100FreeResourcesSer(
6459 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
6460 IN tPOCT6100_FREE_RESOURCES f_pFreeResources )
6461 {
6462 tPOCT6100_SHARED_INFO pSharedInfo;
6463 tPOCT6100_API_CHANNEL pChanEntry;
6464
6465 UINT32 ulResult;
6466 UINT32 i;
6467
6468 /* Obtain local pointer to shared portion of instance. */
6469 pSharedInfo = f_pApiInstance->pSharedInfo;
6470
6471 /* Close all bidirectional channels. */
6472 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxBiDirChannels; i ++ )
6473 {
6474 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
6475
6476 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, i );
6477
6478 if ( pBiDirChanEntry->fReserved == TRUE )
6479 {
6480 tOCT6100_CHANNEL_DESTROY_BIDIR DestroyBidir;
6481
6482 Oct6100ChannelDestroyBiDirDef( &DestroyBidir );
6483
6484 DestroyBidir.ulBiDirChannelHndl = cOCT6100_HNDL_TAG_BIDIR_CHANNEL | (pBiDirChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6485
6486 ulResult = Oct6100ChannelDestroyBiDirSer( f_pApiInstance, &DestroyBidir );
6487 if ( ulResult != cOCT6100_ERR_OK )
6488 return ulResult;
6489 }
6490 }
6491
6492 /* Close all bridge participants. */
6493 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i ++ )
6494 {
6495 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, i );
6496 if ( pChanEntry->fReserved == TRUE && pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
6497 {
6498 /* This channel is on a bridge. */
6499 tOCT6100_CONF_BRIDGE_CHAN_REMOVE BridgeChanRemove;
6500 tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
6501
6502 Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
6503
6504 /* Obtain a pointer to the conference bridge's list entry. */
6505 mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, pChanEntry->usBridgeIndex );
6506
6507 BridgeChanRemove.fRemoveAll = TRUE;
6508 BridgeChanRemove.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pBridgeEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pChanEntry->usBridgeIndex;
6509
6510 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
6511 if ( ulResult != cOCT6100_ERR_OK )
6512 return ulResult;
6513 }
6514 }
6515
6516 /* Close all opened channels. This will bring the broadcast TSSTs with it. */
6517 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i ++ )
6518 {
6519 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, i );
6520
6521 if ( pChanEntry->fReserved == TRUE )
6522 {
6523 tOCT6100_CHANNEL_CLOSE ChannelClose;
6524
6525 /* Generate handle. */
6526 ChannelClose.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6527
6528 /* Call serialized close channel function. */
6529 ulResult = Oct6100ChannelCloseSer( f_pApiInstance, &ChannelClose );
6530 if ( ulResult != cOCT6100_ERR_OK )
6531 return ulResult;
6532 }
6533 }
6534 /* Close all TSI connections. */
6535 if ( f_pFreeResources->fFreeTsiConnections == TRUE )
6536 {
6537 tPOCT6100_API_TSI_CNCT pTsiCnct;
6538 tOCT6100_TSI_CNCT_CLOSE TsiCnctClose;
6539
6540 Oct6100TsiCnctCloseDef( &TsiCnctClose );
6541
6542 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxTsiCncts; i ++ )
6543 {
6544 /* Obtain a pointer to the TSI connection list entry. */
6545 mOCT6100_GET_TSI_CNCT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsiCnct, i );
6546
6547 if ( pTsiCnct->fReserved == TRUE )
6548 {
6549 TsiCnctClose.ulTsiCnctHndl = cOCT6100_HNDL_TAG_TSI_CNCT | (pTsiCnct->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6550
6551 ulResult = Oct6100TsiCnctCloseSer( f_pApiInstance, &TsiCnctClose );
6552 if ( ulResult != cOCT6100_ERR_OK )
6553 return ulResult;
6554 }
6555 }
6556 }
6557 /* Close all conference bridges. */
6558 if ( f_pFreeResources->fFreeConferenceBridges == TRUE )
6559 {
6560 tPOCT6100_API_CONF_BRIDGE pConfBridge;
6561 tOCT6100_CONF_BRIDGE_CLOSE ConfBridgeClose;
6562
6563 Oct6100ConfBridgeCloseDef( &ConfBridgeClose );
6564
6565 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxConfBridges; i ++ )
6566 {
6567 /* Obtain a pointer to the conference bridge's list entry. */
6568 mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pConfBridge, i );
6569
6570 if ( pConfBridge->fReserved == TRUE )
6571 {
6572 ConfBridgeClose.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pConfBridge->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6573
6574 ulResult = Oct6100ConfBridgeCloseSer( f_pApiInstance, &ConfBridgeClose );
6575 if ( ulResult != cOCT6100_ERR_OK )
6576 return ulResult;
6577 }
6578 }
6579 }
6580
6581 /* Free all playout buffers loaded in external memory. */
6582 if ( f_pFreeResources->fFreePlayoutBuffers == TRUE )
6583 {
6584 tPOCT6100_API_BUFFER pBuffer;
6585 tOCT6100_BUFFER_UNLOAD BufferUnload;
6586
6587 Oct6100BufferPlayoutUnloadDef( &BufferUnload );
6588
6589 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxPlayoutBuffers; i ++ )
6590 {
6591
6592
6593 /* Obtain a pointer to the buffer list entry. */
6594 mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBuffer, i );
6595
6596 if ( pBuffer->fReserved == TRUE )
6597 {
6598 BufferUnload.ulBufferIndex = i;
6599 ulResult = Oct6100BufferUnloadSer( f_pApiInstance, &BufferUnload, TRUE );
6600 if ( ulResult != cOCT6100_ERR_OK )
6601 return ulResult;
6602 }
6603 }
6604 }
6605
6606 /* Close all phasing TSSTs. */
6607 if ( f_pFreeResources->fFreePhasingTssts == TRUE )
6608 {
6609 tPOCT6100_API_PHASING_TSST pPhasingTsst;
6610 tOCT6100_PHASING_TSST_CLOSE PhasingTsstClose;
6611
6612 Oct6100PhasingTsstCloseDef( &PhasingTsstClose );
6613
6614 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxPhasingTssts; i ++ )
6615 {
6616 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, i );
6617
6618 if ( pPhasingTsst->fReserved == TRUE )
6619 {
6620 PhasingTsstClose.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsst->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6621
6622 ulResult = Oct6100PhasingTsstCloseSer( f_pApiInstance, &PhasingTsstClose );
6623 if ( ulResult != cOCT6100_ERR_OK )
6624 return ulResult;
6625 }
6626 }
6627 }
6628 /* Close all ADPCM channels. */
6629 if ( f_pFreeResources->fFreeAdpcmChannels == TRUE )
6630 {
6631 tPOCT6100_API_ADPCM_CHAN pAdpcmChannel;
6632 tOCT6100_ADPCM_CHAN_CLOSE AdpcmChanClose;
6633
6634 Oct6100AdpcmChanCloseDef( &AdpcmChanClose );
6635
6636 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxAdpcmChannels; i ++ )
6637 {
6638 mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( pSharedInfo, pAdpcmChannel, i );
6639 if ( pAdpcmChannel->fReserved == TRUE )
6640 {
6641 AdpcmChanClose.ulChanHndl = cOCT6100_HNDL_TAG_ADPCM_CHANNEL | (pAdpcmChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6642
6643 ulResult = Oct6100AdpcmChanCloseSer( f_pApiInstance, &AdpcmChanClose );
6644 if ( ulResult != cOCT6100_ERR_OK )
6645 return ulResult;
6646 }
6647 }
6648 }
6649
6650 return cOCT6100_ERR_OK;
6651 }
6652 #endif
6653
6654
6655 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6656
6657 Function: Oct6100ProductionBistSer
6658
6659 Description: This function returns the instantaneous production BIST status.
6660
6661 -------------------------------------------------------------------------------
6662 | Argument | Description
6663 -------------------------------------------------------------------------------
6664 f_pApiInstance Pointer to API instance. This memory is used to keep
6665 the present state of the chip and all its resources.
6666
6667 f_pProductionBist Pointer to user structure in which BIST status will
6668 be returned.
6669
6670 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6671 #if !SKIP_Oct6100ProductionBistSer
6672 UINT32 Oct6100ProductionBistSer(
6673 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
6674 IN OUT tPOCT6100_PRODUCTION_BIST f_pProductionBist )
6675 {
6676 UINT32 ulCalculatedCrc = cOCT6100_INVALID_VALUE;
6677 UINT32 ulResult;
6678 UINT32 ulLoopCnt = 0x0;
6679 UINT32 i = 1;
6680 UINT32 ulTotalElements = 4;
6681 UINT32 ulReadAddress = cOCT6100_POUCH_BASE;
6682 UINT32 aulMessage[ 5 ];
6683
6684 /* Check if the production bist has been activated. */
6685 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableProductionBist == FALSE )
6686 return cOCT6100_ERR_PRODUCTION_BIST_DISABLED;
6687
6688 f_pProductionBist->ulCurrentAddress = cOCT6100_INVALID_VALUE;
6689 f_pProductionBist->ulCurrentLoop = cOCT6100_INVALID_VALUE;
6690 f_pProductionBist->ulCurrentTest = cOCT6100_INVALID_VALUE;
6691 f_pProductionBist->ulFailedAddress = cOCT6100_INVALID_VALUE;
6692 f_pProductionBist->ulReadValue = cOCT6100_INVALID_VALUE;
6693 f_pProductionBist->ulExpectedValue = cOCT6100_INVALID_VALUE;
6694 f_pProductionBist->ulBistStatus = cOCT6100_BIST_IN_PROGRESS;
6695
6696 /* The API knows that the firmware might be writing a status event. */
6697 /* The firmware does write a status event every 200ms (approximately). */
6698 /* So the status is read a couple of times to make sure an event was not read while */
6699 /* it was written. */
6700 while ( ulLoopCnt != 2 )
6701 {
6702 /* Read the BIST status in the external memory. */
6703 for ( i = 0; i < ulTotalElements + 1; i ++ )
6704 {
6705 ulResult = Oct6100ApiReadDword( f_pApiInstance, ulReadAddress + i * 4, &aulMessage[ i ] );
6706 if ( ulResult != cOCT6100_ERR_OK )
6707 return ulResult;
6708 }
6709
6710 /* Calculate the CRC of this message. */
6711 ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCalculatedCrc );
6712 if ( ulResult != cOCT6100_ERR_OK )
6713 return ulResult;
6714
6715 /* If the CRCs do match, break off the while. We have a valid status event. */
6716 if ( aulMessage[ i - 1 ] == ulCalculatedCrc )
6717 break;
6718
6719 ulLoopCnt++;
6720 }
6721
6722 /* Check if the CRC matches */
6723 if ( aulMessage[ i - 1 ] != ulCalculatedCrc )
6724 {
6725 /* Well, the exchange memory at the base of the external memory is corrupted. */
6726 /* Something very basic is not working correctly with this chip! */
6727 f_pProductionBist->ulBistStatus = cOCT6100_BIST_STATUS_CRC_FAILED;
6728 }
6729 else
6730 {
6731 /* Check for problems. */
6732 switch ( aulMessage[ 0 ] & 0xFFFF )
6733 {
6734 case ( 0x2 ):
6735
6736 /* The initial configuration failed. */
6737 f_pProductionBist->ulBistStatus = cOCT6100_BIST_CONFIGURATION_FAILED;
6738 break;
6739
6740 case ( 0x1 ):
6741
6742 /* A memory location failed. Return useful information to the user. */
6743 f_pProductionBist->ulBistStatus = cOCT6100_BIST_MEMORY_FAILED;
6744
6745 f_pProductionBist->ulFailedAddress = ( aulMessage[ 1 ] & ( ~0x80000000 ) ) + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6746 f_pProductionBist->ulReadValue = aulMessage[ 2 ];
6747 f_pProductionBist->ulExpectedValue = aulMessage[ 3 ];
6748 break;
6749
6750 case ( 0xFFFF ):
6751
6752 /* Bist is completed! */
6753 f_pProductionBist->ulBistStatus = cOCT6100_BIST_SUCCESS;
6754 break;
6755
6756 default:
6757 /* Bist is in progress. All seems to be working fine up to now. */
6758
6759 /* Return progress status. */
6760 f_pProductionBist->ulCurrentAddress = ( aulMessage[ 1 ] & ( ~0x80000000 ) ) + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6761 f_pProductionBist->ulCurrentTest = aulMessage[ 2 ];
6762 f_pProductionBist->ulCurrentLoop = aulMessage[ 3 ];
6763 break;
6764 }
6765 }
6766
6767 return cOCT6100_ERR_OK;
6768 }
6769 #endif
6770
6771
6772 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6773
6774 Function: Oct6100ApiProductionCrc
6775
6776 Description: This function calculates the crc for a production BIST
6777 message.
6778
6779 -------------------------------------------------------------------------------
6780 | Argument | Description
6781 -------------------------------------------------------------------------------
6782 f_pApiInstance Pointer to API instance. This memory is used to keep
6783 the present state of the chip and all its resources.
6784
6785 f_pulMessage Message to be exchanged with the firmware. The CRC
6786 will be calculated on this.
6787 f_ulMessageLength Length of the message to be exchanged. This value
6788 does not include the CRC value at the end
6789 f_pulCrcResult Resulting calculated CRC value.
6790
6791 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6792 #if !SKIP_Oct6100ApiProductionCrc
6793 UINT32 Oct6100ApiProductionCrc(
6794 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
6795 IN PUINT32 f_pulMessage,
6796 IN UINT32 f_ulMessageLength,
6797 OUT PUINT32 f_pulCrcResult )
6798 {
6799 UINT32 ulWidth = 32;
6800 UINT32 ulKey, i, j;
6801 UINT32 ulRemainder = 0;
6802
6803 /* CRC the message. */
6804 ulRemainder = f_pulMessage[ f_ulMessageLength - 1 ];
6805 for ( j = f_ulMessageLength - 1; j != 0xFFFFFFFF ; j-- )
6806 {
6807 for ( i = 0; i < ulWidth; i++ )
6808 {
6809 if ( ( ( ulRemainder >> 0x1F ) & 0x1 ) == 0x1 )
6810 {
6811 /* Division is by something meaningful */
6812 ulKey = 0x8765DCBA;
6813 }
6814 else
6815 {
6816 /* Remainder is less than our divisor */
6817 ulKey = 0;
6818 }
6819 ulRemainder = ulRemainder ^ ulKey;
6820
6821 ulRemainder = ulRemainder << 1;
6822 if ( j != 0 )
6823 {
6824 ulRemainder = ulRemainder | ( ( f_pulMessage[ j - 1 ] ) >> ( 0x1F - i ) );
6825 }
6826 }
6827 }
6828
6829 *f_pulCrcResult = ulRemainder;
6830
6831 return cOCT6100_ERR_OK;
6832 }
6833 #endif
6834
6835 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6836
6837 Function: Oct6100ApiClearInterrupts
6838
6839 Description: Called only by the Oct6100OpenChip function, this function
6840 writes to all register ROLs to clear them. This is necessary
6841 because some ROLs are set during the startup.
6842
6843 -------------------------------------------------------------------------------
6844 | Argument | Description
6845 -------------------------------------------------------------------------------
6846 IN f_pApiInst Pointer to API instance. This memory is used to keep the
6847 present state of the chip and all its resources.
6848
6849 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6850 #if !SKIP_Oct6100ApiClearInterrupts
6851 UINT32 Oct6100ApiClearInterrupts(
6852 IN tPOCT6100_INSTANCE_API f_pApiInstance )
6853 {
6854 tPOCT6100_SHARED_INFO pSharedInfo;
6855 tOCT6100_WRITE_PARAMS WriteParams;
6856 UINT32 ulResult;
6857
6858 /* Get local pointer to shared portion of instance. */
6859 pSharedInfo = f_pApiInstance->pSharedInfo;
6860
6861 /* Set the process context and user chip ID parameters once and for all. */
6862 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6863
6864 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6865
6866 WriteParams.ulWriteAddress = 0x102;
6867 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_102H;
6868 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6869 if ( ulResult != cOCT6100_ERR_OK )
6870 return ulResult;
6871
6872 WriteParams.ulWriteAddress = 0x202;
6873 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_202H;
6874 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6875 if ( ulResult != cOCT6100_ERR_OK )
6876 return ulResult;
6877
6878 WriteParams.ulWriteAddress = 0x302;
6879 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_302H;
6880 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6881 if ( ulResult != cOCT6100_ERR_OK )
6882 return ulResult;
6883
6884 WriteParams.ulWriteAddress = 0x502;
6885 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_502H;
6886 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6887 if ( ulResult != cOCT6100_ERR_OK )
6888 return ulResult;
6889
6890 WriteParams.ulWriteAddress = 0x702;
6891 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_702H;
6892 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6893 if ( ulResult != cOCT6100_ERR_OK )
6894 return ulResult;
6895
6896 return cOCT6100_ERR_OK;
6897
6898 }
6899 #endif