Debian Codegraph @

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

raw symbols SCIP
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 tOCT6100_READ_PARAMS ReadParams;
3573 UINT32 ulResult;
3574 UINT16 usReadData;
3575 UINT16 usWriteData23E;
3576 UINT16 usWriteData230;
3577 UINT32 i;
3578
3579 /* Get local pointer to shared portion of instance. */
3580 pSharedInfo = f_pApiInstance->pSharedInfo;
3581
3582 /* Get local pointer to the chip configuration structure.*/
3583 pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
3584
3585 /* Set the process context and user chip ID parameters once and for all. */
3586 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
3587
3588 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3589
3590 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
3591
3592 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3593 ReadParams.pusReadData = &usReadData;
3594
3595 usWriteData23E = 0x0000;
3596 usWriteData230 = 0x0000;
3597
3598 if ( (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
3599 {
3600 /* SDRAM: */
3601 switch( pChipConfig->ulMemoryChipSize )
3602 {
3603 case cOCT6100_MEMORY_CHIP_SIZE_8MB:
3604 usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
3605 break;
3606 case cOCT6100_MEMORY_CHIP_SIZE_16MB:
3607 usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
3608 break;
3609 case cOCT6100_MEMORY_CHIP_SIZE_32MB:
3610 usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
3611 break;
3612 case cOCT6100_MEMORY_CHIP_SIZE_64MB:
3613 usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
3614 break;
3615 default:
3616 return cOCT6100_ERR_FATAL_16;
3617 }
3618
3619 usWriteData230 |= 0x0002;
3620
3621 WriteParams.ulWriteAddress = 0x230;
3622 WriteParams.usWriteData = usWriteData230;
3623
3624 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3625 if ( ulResult != cOCT6100_ERR_OK )
3626 return ulResult;
3627
3628 /* Precharge all banks. */
3629 usWriteData230 &= 0x000C;
3630 usWriteData230 |= 0x0010;
3631
3632 WriteParams.ulWriteAddress = 0x230;
3633 WriteParams.usWriteData = usWriteData230;
3634
3635 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3636 if ( ulResult != cOCT6100_ERR_OK )
3637 return ulResult;
3638
3639 usWriteData230 |= 0x0002;
3640
3641 WriteParams.usWriteData = usWriteData230;
3642
3643 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3644 if ( ulResult != cOCT6100_ERR_OK )
3645 return ulResult;
3646
3647 WriteParams.ulWriteAddress = 0x23E;
3648 WriteParams.usWriteData = usWriteData23E;
3649 for ( i = 0; i < 5; i++ )
3650 {
3651 /* Wait cycle. */
3652 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3653 if ( ulResult != cOCT6100_ERR_OK )
3654 return ulResult;
3655 }
3656
3657 /* Program the mode register. */
3658 usWriteData23E = 0x0030;
3659 WriteParams.usWriteData = usWriteData23E;
3660
3661 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3662 if ( ulResult != cOCT6100_ERR_OK )
3663 return ulResult;
3664
3665 usWriteData230 &= 0x000C;
3666 usWriteData230 |= 0x0000;
3667
3668 WriteParams.ulWriteAddress = 0x230;
3669 WriteParams.usWriteData = usWriteData230;
3670
3671 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3672 if ( ulResult != cOCT6100_ERR_OK )
3673 return ulResult;
3674
3675 usWriteData230 |= 0x0002;
3676
3677 WriteParams.usWriteData = usWriteData230;
3678
3679 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3680 if ( ulResult != cOCT6100_ERR_OK )
3681 return ulResult;
3682
3683 WriteParams.ulWriteAddress = 0x23E;
3684 WriteParams.usWriteData = usWriteData23E;
3685 for ( i = 0; i < 5; i++ )
3686 {
3687 /* Wait cycle. */
3688 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3689 if ( ulResult != cOCT6100_ERR_OK )
3690 return ulResult;
3691 }
3692
3693 /* Do CBR refresh (twice) */
3694 usWriteData230 &= 0x000C;
3695 usWriteData230 |= 0x0040;
3696
3697 WriteParams.ulWriteAddress = 0x230;
3698 WriteParams.usWriteData = usWriteData230;
3699
3700 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3701 if ( ulResult != cOCT6100_ERR_OK )
3702 return ulResult;
3703
3704 usWriteData230 |= 0x0002;
3705
3706 WriteParams.usWriteData = usWriteData230;
3707
3708 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3709 if ( ulResult != cOCT6100_ERR_OK )
3710 return ulResult;
3711
3712 WriteParams.ulWriteAddress = 0x23E;
3713 WriteParams.usWriteData = usWriteData23E;
3714 for ( i = 0; i < 5; i++ )
3715 {
3716 /* Wait cycle. */
3717 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3718 if ( ulResult != cOCT6100_ERR_OK )
3719 return ulResult;
3720 }
3721
3722 WriteParams.ulWriteAddress = 0x230;
3723 WriteParams.usWriteData = usWriteData230;
3724
3725 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3726 if ( ulResult != cOCT6100_ERR_OK )
3727 return ulResult;
3728
3729 WriteParams.ulWriteAddress = 0x23E;
3730 WriteParams.usWriteData = usWriteData23E;
3731 for ( i = 0; i < 5; i++ )
3732 {
3733 /* Wait cycle. */
3734 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3735 if ( ulResult != cOCT6100_ERR_OK )
3736 return ulResult;
3737 }
3738 }
3739 else
3740 {
3741 /* DDR: */
3742 switch( pChipConfig->ulMemoryChipSize )
3743 {
3744 case cOCT6100_MEMORY_CHIP_SIZE_16MB:
3745 usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
3746 break;
3747 case cOCT6100_MEMORY_CHIP_SIZE_32MB:
3748 usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
3749 break;
3750 case cOCT6100_MEMORY_CHIP_SIZE_64MB:
3751 usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
3752 break;
3753 case cOCT6100_MEMORY_CHIP_SIZE_128MB:
3754 usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
3755 break;
3756 default:
3757 return cOCT6100_ERR_FATAL_17;
3758 }
3759 WriteParams.ulWriteAddress = 0x230;
3760 WriteParams.usWriteData = usWriteData230;
3761
3762 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3763 if ( ulResult != cOCT6100_ERR_OK )
3764 return ulResult;
3765
3766 /* Precharge all banks. */
3767 usWriteData230 &= 0x000C;
3768 usWriteData230 |= 0x0010;
3769
3770 WriteParams.ulWriteAddress = 0x230;
3771 WriteParams.usWriteData = usWriteData230;
3772
3773 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3774 if ( ulResult != cOCT6100_ERR_OK )
3775 return ulResult;
3776
3777 usWriteData230 |= 0x0002;
3778
3779 WriteParams.usWriteData = usWriteData230;
3780
3781 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3782 if ( ulResult != cOCT6100_ERR_OK )
3783 return ulResult;
3784
3785 WriteParams.ulWriteAddress = 0x23E;
3786 WriteParams.usWriteData = usWriteData23E;
3787 for ( i = 0; i < 5; i++ )
3788 {
3789 /* Wait cycle. */
3790 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3791 if ( ulResult != cOCT6100_ERR_OK )
3792 return ulResult;
3793 }
3794
3795 /* Program DDR mode register. */
3796 usWriteData23E = 0x4000;
3797
3798 WriteParams.ulWriteAddress = 0x23E;
3799 WriteParams.usWriteData = usWriteData23E;
3800
3801 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3802 if ( ulResult != cOCT6100_ERR_OK )
3803 return ulResult;
3804
3805 usWriteData230 &= 0x000C;
3806 usWriteData230 |= 0x0000;
3807
3808 WriteParams.ulWriteAddress = 0x230;
3809 WriteParams.usWriteData = usWriteData230;
3810
3811 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3812 if ( ulResult != cOCT6100_ERR_OK )
3813 return ulResult;
3814
3815 usWriteData230 |= 0x0002;
3816
3817 WriteParams.usWriteData = usWriteData230;
3818
3819 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3820 if ( ulResult != cOCT6100_ERR_OK )
3821 return ulResult;
3822
3823 WriteParams.ulWriteAddress = 0x23E;
3824 WriteParams.usWriteData = usWriteData23E;
3825 for ( i = 0; i < 5; i++ )
3826 {
3827 /* Wait cycle. */
3828 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3829 if ( ulResult != cOCT6100_ERR_OK )
3830 return ulResult;
3831 }
3832
3833 /* Program SDR mode register. */
3834 usWriteData23E = 0x0161;
3835
3836 WriteParams.ulWriteAddress = 0x23E;
3837 WriteParams.usWriteData = usWriteData23E;
3838
3839 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3840 if ( ulResult != cOCT6100_ERR_OK )
3841 return ulResult;
3842
3843 usWriteData230 &= 0x000C;
3844 usWriteData230 |= 0x0000;
3845
3846 WriteParams.ulWriteAddress = 0x230;
3847 WriteParams.usWriteData = usWriteData230;
3848
3849 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3850 if ( ulResult != cOCT6100_ERR_OK )
3851 return ulResult;
3852
3853 usWriteData230 |= 0x0002;
3854
3855 WriteParams.usWriteData = usWriteData230;
3856
3857 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3858 if ( ulResult != cOCT6100_ERR_OK )
3859 return ulResult;
3860
3861 WriteParams.ulWriteAddress = 0x23E;
3862 WriteParams.usWriteData = usWriteData23E;
3863 for ( i = 0; i < 5; i++ )
3864 {
3865 /* Wait cycle. */
3866 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3867 if ( ulResult != cOCT6100_ERR_OK )
3868 return ulResult;
3869 }
3870
3871 /* Precharge all banks. */
3872 usWriteData23E = 0xFFFF;
3873
3874 WriteParams.ulWriteAddress = 0x23E;
3875 WriteParams.usWriteData = usWriteData23E;
3876
3877 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3878 if ( ulResult != cOCT6100_ERR_OK )
3879 return ulResult;
3880
3881 usWriteData230 &= 0x000C;
3882 usWriteData230 |= 0x0010;
3883
3884 WriteParams.ulWriteAddress = 0x230;
3885 WriteParams.usWriteData = usWriteData230;
3886
3887 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3888 if ( ulResult != cOCT6100_ERR_OK )
3889 return ulResult;
3890
3891 usWriteData230 |= 0x0002;
3892
3893 WriteParams.usWriteData = usWriteData230;
3894
3895 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3896 if ( ulResult != cOCT6100_ERR_OK )
3897 return ulResult;
3898
3899 WriteParams.ulWriteAddress = 0x23E;
3900 WriteParams.usWriteData = usWriteData23E;
3901 for ( i = 0; i < 5; i++ )
3902 {
3903 /* Wait cycle. */
3904 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3905 if ( ulResult != cOCT6100_ERR_OK )
3906 return ulResult;
3907 }
3908
3909 /* Do CBR refresh (twice) */
3910 usWriteData230 &= 0x000C;
3911 usWriteData230 |= 0x0040;
3912
3913 WriteParams.ulWriteAddress = 0x230;
3914 WriteParams.usWriteData = usWriteData230;
3915
3916 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3917 if ( ulResult != cOCT6100_ERR_OK )
3918 return ulResult;
3919
3920 usWriteData230 |= 0x0002;
3921
3922 WriteParams.usWriteData = usWriteData230;
3923
3924 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3925 if ( ulResult != cOCT6100_ERR_OK )
3926 return ulResult;
3927
3928 WriteParams.ulWriteAddress = 0x23E;
3929 WriteParams.usWriteData = usWriteData23E;
3930 for ( i = 0; i < 5; i++ )
3931 {
3932 /* Wait cycle. */
3933 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3934 if ( ulResult != cOCT6100_ERR_OK )
3935 return ulResult;
3936 }
3937
3938 WriteParams.ulWriteAddress = 0x230;
3939 WriteParams.usWriteData = usWriteData230;
3940
3941 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3942 if ( ulResult != cOCT6100_ERR_OK )
3943 return ulResult;
3944
3945 WriteParams.ulWriteAddress = 0x23E;
3946 WriteParams.usWriteData = usWriteData23E;
3947 for ( i = 0; i < 5; i++ )
3948 {
3949 /* Wait cycle.*/
3950 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3951 if ( ulResult != cOCT6100_ERR_OK )
3952 return ulResult;
3953 }
3954
3955 /* Program SDR mode register. */
3956 usWriteData23E = 0x0061;
3957
3958 WriteParams.ulWriteAddress = 0x23E;
3959 WriteParams.usWriteData = usWriteData23E;
3960
3961 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3962 if ( ulResult != cOCT6100_ERR_OK )
3963 return ulResult;
3964
3965 usWriteData230 &= 0x000C;
3966 usWriteData230 |= 0x0000;
3967
3968 WriteParams.ulWriteAddress = 0x230;
3969 WriteParams.usWriteData = usWriteData230;
3970
3971 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3972 if ( ulResult != cOCT6100_ERR_OK )
3973 return ulResult;
3974
3975 usWriteData230 |= 0x0002;
3976
3977 WriteParams.usWriteData = usWriteData230;
3978
3979 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3980 if ( ulResult != cOCT6100_ERR_OK )
3981 return ulResult;
3982
3983 WriteParams.ulWriteAddress = 0x23E;
3984 WriteParams.usWriteData = usWriteData23E;
3985 for ( i = 0; i < 5; i++ )
3986 {
3987 /* Wait cycle. */
3988 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3989 if ( ulResult != cOCT6100_ERR_OK )
3990 return ulResult;
3991 }
3992 }
3993
3994 /* Set the refresh frequency. */
3995 WriteParams.ulWriteAddress = 0x242;
3996 WriteParams.usWriteData = 0x0400;
3997
3998 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3999 if ( ulResult != cOCT6100_ERR_OK )
4000 return ulResult;
4001
4002 WriteParams.ulWriteAddress = 0x244;
4003 WriteParams.usWriteData = 0x0200;
4004
4005 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4006 if ( ulResult != cOCT6100_ERR_OK )
4007 return ulResult;
4008
4009 WriteParams.ulWriteAddress = 0x248;
4010 WriteParams.usWriteData = 0x800;
4011
4012 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4013 if ( ulResult != cOCT6100_ERR_OK )
4014 return ulResult;
4015
4016 WriteParams.ulWriteAddress = 0x246;
4017 WriteParams.usWriteData = 0x0012;
4018
4019 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4020 if ( ulResult != cOCT6100_ERR_OK )
4021 return ulResult;
4022
4023 /* Enable the SDRAM and refreshes. */
4024 usWriteData230 &= 0x000C;
4025 usWriteData230 |= 0x0001;
4026
4027 WriteParams.ulWriteAddress = 0x230;
4028 WriteParams.usWriteData = usWriteData230;
4029
4030 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4031 if ( ulResult != cOCT6100_ERR_OK )
4032 return ulResult;
4033
4034 WriteParams.ulWriteAddress = 0x246;
4035 WriteParams.usWriteData = 0x0013;
4036
4037 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4038 if ( ulResult != cOCT6100_ERR_OK )
4039 return ulResult;
4040
4041 return cOCT6100_ERR_OK;
4042 }
4043 #endif
4044
4045
4046 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4047
4048 Function: Oct6100ApiEnableClocks
4049
4050 Description: This function will disable clock masking for all the modules
4051 of the chip.
4052
4053 -------------------------------------------------------------------------------
4054 | Argument | Description
4055 -------------------------------------------------------------------------------
4056 f_pApiInstance Pointer to API instance. This memory is used to keep the
4057 present state of the chip and all its resources.
4058
4059 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4060 #if !SKIP_Oct6100ApiEnableClocks
4061 UINT32 Oct6100ApiEnableClocks(
4062 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4063 {
4064 tOCT6100_WRITE_PARAMS WriteParams;
4065 UINT32 ulResult;
4066
4067 /* Initialize the process context and user chip ID once and for all. */
4068 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4069
4070 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4071
4072 /* Enable tdmie / adpcm mclk clocks. */
4073 WriteParams.ulWriteAddress = 0x186;
4074 WriteParams.usWriteData = 0x015F;
4075
4076 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4077 if ( ulResult != cOCT6100_ERR_OK )
4078 return ulResult;
4079
4080 /* Configure the DQS register for the DDR memory */
4081 WriteParams.ulWriteAddress = 0x180;
4082 WriteParams.usWriteData = 0xFF00;
4083
4084 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4085 if ( ulResult != cOCT6100_ERR_OK )
4086 return ulResult;
4087
4088 /* Enable pgsp chariot clocks */
4089 WriteParams.ulWriteAddress = 0x182;
4090 WriteParams.usWriteData = 0x0000;
4091
4092 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4093 if ( ulResult != cOCT6100_ERR_OK )
4094 return ulResult;
4095
4096 /* Enable af/mt chariot clocks */
4097 WriteParams.ulWriteAddress = 0x184;
4098 WriteParams.usWriteData = 0x0000;
4099
4100 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4101 if ( ulResult != cOCT6100_ERR_OK )
4102 return ulResult;
4103
4104 return cOCT6100_ERR_OK;
4105 }
4106 #endif
4107
4108
4109 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4110
4111 Function: Oct6100ApiProgramNLP
4112
4113 Description: This function will write image values to configure the NLP.
4114
4115 -------------------------------------------------------------------------------
4116 | Argument | Description
4117 -------------------------------------------------------------------------------
4118 f_pApiInstance Pointer to API instance. This memory is used to keep the
4119 present state of the chip and all its resources.
4120
4121 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4122 #if !SKIP_Oct6100ApiProgramNLP
4123 UINT32 Oct6100ApiProgramNLP(
4124 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4125 {
4126 tOCT6100_WRITE_PARAMS WriteParams;
4127 tOCT6100_READ_PARAMS ReadParams;
4128 tPOCT6100_SHARED_INFO pSharedInfo;
4129 tPOCT6100_API_CHIP_CONFIG pChipConfig;
4130 UINT32 ulResult;
4131 UINT16 usReadData;
4132 UINT16 usReadHighData;
4133 BOOL fBitEqual;
4134 UINT32 ulEgoEntry[4];
4135 UINT32 ulTempAddress;
4136 UINT32 ulAfCpuUp = FALSE;
4137 UINT32 i;
4138 UINT32 ulLoopCounter = 0;
4139
4140 /* Get local pointer to shared portion of instance. */
4141 pSharedInfo = f_pApiInstance->pSharedInfo;
4142
4143 /* Get local pointer to the chip configuration structure.*/
4144 pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
4145
4146 /* Initialize the process context and user chip ID once and for all. */
4147 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4148
4149 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4150
4151 /* Initialize the process context and user chip ID once and for all. */
4152 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
4153
4154 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4155 ReadParams.pusReadData = &usReadData;
4156
4157 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4158 {
4159 UINT32 ulReadData;
4160 UINT32 ulBitPattern;
4161 UINT32 j, k;
4162
4163 /* Since the pouch section (256 bytes) will not be tested by the firmware, */
4164 /* the API has to make sure this section is working correctly. */
4165 for ( k = 0; k < 2; k ++ )
4166 {
4167 if ( k == 0 )
4168 ulBitPattern = 0x1;
4169 else
4170 ulBitPattern = 0xFFFFFFFE;
4171
4172 for ( j = 0; j < 32; j ++ )
4173 {
4174 /* Write the DWORDs. */
4175 for ( i = 0; i < 64; i ++ )
4176 {
4177 ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, ulBitPattern << j );
4178 if ( ulResult != cOCT6100_ERR_OK )
4179 return ulResult;
4180 }
4181
4182 /* Read the DWORDs. */
4183 for ( i = 0; i < 64; i ++ )
4184 {
4185 ulResult = Oct6100ApiReadDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, &ulReadData );
4186 if ( ulResult != cOCT6100_ERR_OK )
4187 return ulResult;
4188
4189 /* Check if the value matches. */
4190 if ( ( ulBitPattern << j ) != ulReadData )
4191 return cOCT6100_ERR_OPEN_PRODUCTION_BIST_POUCH_ERROR;
4192 }
4193 }
4194 }
4195 }
4196
4197 /* Write the image info in the chip. */
4198 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE;
4199 WriteParams.usWriteData = (UINT16)( ( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress >> 16 ) & 0xFFFF );
4200
4201 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4202 if ( ulResult != cOCT6100_ERR_OK )
4203 return ulResult;
4204
4205 WriteParams.ulWriteAddress += 2;
4206 WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress & 0xFFFF );
4207
4208 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4209 if ( ulResult != cOCT6100_ERR_OK )
4210 return ulResult;
4211
4212 for( i = 0; i < 8; i++ )
4213 {
4214 if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size != 0 )
4215 {
4216 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC );
4217 WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress >> 16 ) & 0xFFFF );
4218
4219 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4220 if ( ulResult != cOCT6100_ERR_OK )
4221 return ulResult;
4222
4223 WriteParams.ulWriteAddress += 2;
4224 WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress & 0xFFFF );
4225
4226 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4227 if ( ulResult != cOCT6100_ERR_OK )
4228 return ulResult;
4229 }
4230
4231 if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size != 0 )
4232 {
4233 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 4;
4234 WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress >> 16 ) & 0xFFFF );
4235
4236 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4237 if ( ulResult != cOCT6100_ERR_OK )
4238 return ulResult;
4239
4240 WriteParams.ulWriteAddress += 2;
4241 WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress & 0xFFFF );
4242
4243 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4244 if ( ulResult != cOCT6100_ERR_OK )
4245 return ulResult;
4246 }
4247
4248 WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 8;
4249 WriteParams.usWriteData = 0x0000;
4250 WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size << 8 );
4251 WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size;
4252
4253 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4254 if ( ulResult != cOCT6100_ERR_OK )
4255 return ulResult;
4256
4257 WriteParams.ulWriteAddress += 2;
4258 WriteParams.usWriteData = 0x0000;
4259 WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulClockInfo << 8 );
4260 WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulReserved;
4261
4262 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4263 if ( ulResult != cOCT6100_ERR_OK )
4264 return ulResult;
4265 }
4266
4267 /* Put NLP in config mode. */
4268 WriteParams.ulWriteAddress = 0x2C2;
4269 WriteParams.usWriteData = 0x160E;
4270
4271 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4272 if ( ulResult != cOCT6100_ERR_OK )
4273 return ulResult;
4274
4275 WriteParams.ulWriteAddress = 0x692;
4276 WriteParams.usWriteData = 0x010A;
4277
4278 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4279 if ( ulResult != cOCT6100_ERR_OK )
4280 return ulResult;
4281
4282 /* Upload the up to 8 NLP pages + 1 AF page (for timing reasons). */
4283 for ( i = 0; i < pSharedInfo->ImageRegion[ 1 ].ulPart1Size; i++ )
4284 {
4285 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * ( i * 2 ), 0x1280, 1024, &(ulEgoEntry[0]));
4286 if ( ulResult != cOCT6100_ERR_OK )
4287 return ulResult;
4288
4289 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * (( i * 2 ) + 1 ), 0x1680, 1024, &(ulEgoEntry[2]));
4290 if ( ulResult != cOCT6100_ERR_OK )
4291 return ulResult;
4292
4293 ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
4294 if ( ulResult != cOCT6100_ERR_OK )
4295 return ulResult;
4296
4297 /* Shift mt chariot memories. This process will complete by the time */
4298 /* the next LSU transfer is done. */
4299 WriteParams.ulWriteAddress = 0x692;
4300 WriteParams.usWriteData = 0x010B;
4301
4302 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4303 if ( ulResult != cOCT6100_ERR_OK )
4304 return ulResult;
4305
4306 ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x692, 0, 0, 100000, &fBitEqual );
4307 if ( ulResult != cOCT6100_ERR_OK )
4308 return ulResult;
4309 if ( TRUE != fBitEqual )
4310 return cOCT6100_ERR_FATAL_1A;
4311 }
4312
4313 /* 1 AF page (for timing reasons). */
4314 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 0), 0x1280, 512, &(ulEgoEntry[0]));
4315 if ( ulResult != cOCT6100_ERR_OK )
4316 return ulResult;
4317
4318 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 1), 0x1480, 512, &(ulEgoEntry[2]));
4319 if ( ulResult != cOCT6100_ERR_OK )
4320 return ulResult;
4321
4322 ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
4323 if ( ulResult != cOCT6100_ERR_OK )
4324 return ulResult;
4325
4326 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 2), 0x1680, 512, &(ulEgoEntry[0]));
4327 if ( ulResult != cOCT6100_ERR_OK )
4328 return ulResult;
4329
4330 ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 3), 0x1880, 512, &(ulEgoEntry[2]));
4331 if ( ulResult != cOCT6100_ERR_OK )
4332 return ulResult;
4333
4334 ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
4335 if ( ulResult != cOCT6100_ERR_OK )
4336 return ulResult;
4337
4338 /* Write constant memory init context position in channel "672" for pgsp. */
4339 WriteParams.ulWriteAddress = 0x71A;
4340 WriteParams.usWriteData = 0x8000;
4341
4342 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4343 if ( ulResult != cOCT6100_ERR_OK )
4344 return ulResult;
4345
4346 /* Set fixed PGSP event_in base address to 800 on a 2k boundary */
4347 WriteParams.ulWriteAddress = 0x716;
4348 WriteParams.usWriteData = 0x800 >> 11;
4349
4350 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4351 if ( ulResult != cOCT6100_ERR_OK )
4352 return ulResult;
4353
4354 /* Set fixed PGSP event_out to 0x2C0000h on a 16k boundary */
4355 WriteParams.ulWriteAddress = 0x71C;
4356 WriteParams.usWriteData = 0x2C0000 >> 14;
4357
4358 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4359 if ( ulResult != cOCT6100_ERR_OK )
4360 return ulResult;
4361
4362 /* Give chariot control of the chip. */
4363 WriteParams.ulWriteAddress = 0x712;
4364 WriteParams.usWriteData = 0x0000;
4365
4366 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4367 if ( ulResult != cOCT6100_ERR_OK )
4368 return ulResult;
4369
4370 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xC;
4371 ulTempAddress = 0x300000 + 0x0800;
4372 WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 16 ) & 0x07FF );
4373
4374 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4375 if ( ulResult != cOCT6100_ERR_OK )
4376 return ulResult;
4377
4378 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xE;
4379 WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 0 ) & 0xFF00 );
4380
4381 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4382 if ( ulResult != cOCT6100_ERR_OK )
4383 return ulResult;
4384
4385 /* Write the init PGSP event in place. */
4386 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x800;
4387 WriteParams.usWriteData = 0x0200;
4388
4389 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4390 if ( ulResult != cOCT6100_ERR_OK )
4391 return ulResult;
4392
4393 WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x802;
4394 WriteParams.usWriteData = 0x02A0;
4395
4396 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4397 if ( ulResult != cOCT6100_ERR_OK )
4398 return ulResult;
4399
4400 /* Also write the register 710, which tells PGSP how many tones are supported. */
4401 WriteParams.ulWriteAddress = 0x710;
4402 WriteParams.usWriteData = 0x0000;
4403 WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FA ] << 8;
4404 WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FB ] << 0;
4405
4406 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4407 if ( ulResult != cOCT6100_ERR_OK )
4408 return ulResult;
4409
4410 /* Start both processors in the NLP. */
4411 WriteParams.ulWriteAddress = 0x373FE;
4412 WriteParams.usWriteData = 0x00FF;
4413
4414 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4415 if ( ulResult != cOCT6100_ERR_OK )
4416 return ulResult;
4417
4418 WriteParams.ulWriteAddress = 0x37BFE;
4419 WriteParams.usWriteData = 0x00FE; /* Tell processor 1 to just go to sleep. */
4420
4421 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4422 if ( ulResult != cOCT6100_ERR_OK )
4423 return ulResult;
4424
4425 WriteParams.ulWriteAddress = 0x37FC6;
4426 WriteParams.usWriteData = 0x8004; /* First PC.*/
4427
4428 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4429 if ( ulResult != cOCT6100_ERR_OK )
4430 return ulResult;
4431
4432 WriteParams.ulWriteAddress = 0x37FD0;
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 WriteParams.ulWriteAddress = 0x37FD2;
4440 WriteParams.usWriteData = 0x0002; /* Take out of reset. */
4441
4442 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4443 if ( ulResult != cOCT6100_ERR_OK )
4444 return ulResult;
4445
4446 /* Start processor in the AF. */
4447 for ( i = 0; i < 16; i ++ )
4448 {
4449 WriteParams.ulWriteAddress = cOCT6100_POUCH_BASE + ( i * 2 );
4450 if ( i == 9 )
4451 {
4452 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4453 {
4454 if (pSharedInfo->ChipConfig.ulProductionBistMode == cOCT6100_PRODUCTION_BIST_SHORT)
4455 WriteParams.usWriteData = cOCT6100_PRODUCTION_SHORT_BOOT_TYPE;
4456 else
4457 WriteParams.usWriteData = cOCT6100_PRODUCTION_BOOT_TYPE;
4458 }
4459 else
4460 {
4461 WriteParams.usWriteData = cOCT6100_AF_BOOT_TYPE;
4462 }
4463 }
4464 else
4465 WriteParams.usWriteData = 0x0000;
4466
4467 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4468 if ( ulResult != cOCT6100_ERR_OK )
4469 return ulResult;
4470 }
4471
4472 /* Check if the production BIST mode was requested. */
4473 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4474 {
4475 UINT32 ulTotalElements = 3;
4476 UINT32 ulCrcKey;
4477 UINT32 aulMessage[ 4 ];
4478 UINT32 ulWriteAddress = 0x20 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
4479
4480 /* Magic key. */
4481 aulMessage[ 0 ] = 0xCAFECAFE;
4482 /* Memory size. */
4483 aulMessage[ 1 ] = pSharedInfo->MiscVars.ulTotalMemSize;
4484 /* Loop count. */
4485 aulMessage[ 2 ] = pSharedInfo->ChipConfig.ulNumProductionBistLoops;
4486 /* CRC initialized. */
4487 aulMessage[ 3 ] = 0;
4488
4489 ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCrcKey );
4490 if ( ulResult != cOCT6100_ERR_OK )
4491 return ulResult;
4492
4493 aulMessage[ 3 ] = ulCrcKey;
4494
4495 /* Write the message to the external memory. */
4496 for ( i = 0; i < ulTotalElements + 1; i ++ )
4497 {
4498 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulWriteAddress + i * 4, aulMessage[ i ] );
4499 if ( ulResult != cOCT6100_ERR_OK )
4500 return ulResult;
4501 }
4502 }
4503
4504 WriteParams.ulWriteAddress = 0xFFFC6;
4505 WriteParams.usWriteData = 0x1284; /* First PC.*/
4506
4507 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4508 if ( ulResult != cOCT6100_ERR_OK )
4509 return ulResult;
4510
4511 WriteParams.ulWriteAddress = 0xFFFD0;
4512 WriteParams.usWriteData = 0x0002; /* Take out of reset. */
4513
4514 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4515 if ( ulResult != cOCT6100_ERR_OK )
4516 return ulResult;
4517
4518 while ( ulAfCpuUp == FALSE )
4519 {
4520 if ( ulAfCpuUp == FALSE )
4521 {
4522 ReadParams.ulReadAddress = cOCT6100_POUCH_BASE;
4523 ReadParams.pusReadData = &usReadHighData;
4524
4525 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4526 if ( ulResult != cOCT6100_ERR_OK )
4527 return ulResult;
4528
4529 ReadParams.ulReadAddress += 2;
4530 ReadParams.pusReadData = &usReadData;
4531
4532 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4533 if ( ulResult != cOCT6100_ERR_OK )
4534 return ulResult;
4535
4536 if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
4537 {
4538 /* Should read 0x0007 when bisting. */
4539 if ( (( usReadHighData & 0xFFFF ) == cOCT6100_PRODUCTION_BOOT_TYPE) ||
4540 (( usReadHighData & 0xFFFF ) == cOCT6100_PRODUCTION_SHORT_BOOT_TYPE) )
4541 {
4542 /* Verify if the bist has started successfully. */
4543 if ( ( usReadData & 0xFFFF ) == 0x0002 )
4544 return cOCT6100_ERR_OPEN_PRODUCTION_BIST_CONF_FAILED;
4545 else if ( ( usReadData & 0xFFFF ) != 0xEEEE )
4546 return cOCT6100_ERR_OPEN_PRODUCTION_BOOT_FAILED;
4547
4548 ulAfCpuUp = TRUE;
4549 }
4550 }
4551 else /* if ( pSharedInfo->ChipConfig.fEnableProductionBist == FALSE ) */
4552 {
4553 if ( ( usReadHighData & 0xFFFF ) == cOCT6100_AF_BOOT_TYPE )
4554 {
4555 /* Verify if the bist succeeded. */
4556 if ( ( usReadData & 0xFFFF ) != 0x0000 )
4557 return cOCT6100_ERR_OPEN_FUNCTIONAL_BIST_FAILED;
4558
4559 ulAfCpuUp = TRUE;
4560 }
4561 }
4562 }
4563
4564 ulLoopCounter++;
4565
4566 if ( ulLoopCounter == cOCT6100_MAX_LOOP_CPU_TIMEOUT )
4567 return cOCT6100_ERR_OPEN_AF_CPU_TIMEOUT;
4568 }
4569
4570 /* Return NLP in operationnal mode. */
4571 WriteParams.ulWriteAddress = 0x2C2;
4572 WriteParams.usWriteData = 0x060E;
4573
4574 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4575 if ( ulResult != cOCT6100_ERR_OK )
4576 return ulResult;
4577
4578 WriteParams.ulWriteAddress = 0x692;
4579 WriteParams.usWriteData = 0x0000;
4580
4581 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4582 if ( ulResult != cOCT6100_ERR_OK )
4583 return ulResult;
4584
4585 return cOCT6100_ERR_OK;
4586 }
4587 #endif
4588
4589
4590 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4591
4592 Function: Oct6100ApiSetH100Register
4593
4594 Description: This function will configure the H.100 registers.
4595
4596 -------------------------------------------------------------------------------
4597 | Argument | Description
4598 -------------------------------------------------------------------------------
4599 f_pApiInstance Pointer to API instance. This memory is used to keep the
4600 present state of the chip and all its resources.
4601
4602 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4603 #if !SKIP_Oct6100ApiSetH100Register
4604 UINT32 Oct6100ApiSetH100Register(
4605 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4606 {
4607 tOCT6100_WRITE_PARAMS WriteParams;
4608 UINT32 ulResult;
4609 tPOCT6100_SHARED_INFO pSharedInfo;
4610 tPOCT6100_API_CHIP_CONFIG pChipConfig;
4611 UINT32 i;
4612 UINT32 ulOffset;
4613 BOOL fAllStreamAt2Mhz = TRUE;
4614 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,
4615 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000};
4616
4617 /* Get local pointer to shared portion of instance. */
4618 pSharedInfo = f_pApiInstance->pSharedInfo;
4619
4620 /* Get local pointer to the chip configuration structure. */
4621 pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
4622
4623 /* Initialize the process context and user chip ID once and for all. */
4624 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4625
4626 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4627
4628 /* Set the Global OE bit. */
4629 WriteParams.ulWriteAddress = 0x300;
4630 WriteParams.usWriteData = 0x0004;
4631
4632 /* Set the number of streams. */
4633 switch( pChipConfig->byMaxTdmStreams )
4634 {
4635 case 32:
4636 WriteParams.usWriteData |= ( 0 << 3 );
4637 break;
4638 case 16:
4639 WriteParams.usWriteData |= ( 1 << 3 );
4640 break;
4641 case 8:
4642 WriteParams.usWriteData |= ( 2 << 3 );
4643 break;
4644 case 4:
4645 WriteParams.usWriteData |= ( 3 << 3 );
4646 break;
4647 default:
4648 break;
4649 }
4650
4651 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4652 if ( ulResult != cOCT6100_ERR_OK )
4653 return ulResult;
4654
4655 /* Configure the stream frequency. */
4656 WriteParams.ulWriteAddress = 0x330;
4657 WriteParams.usWriteData = 0x0000;
4658 for ( i = 0; i < (UINT32)(pChipConfig->byMaxTdmStreams / 4); i++)
4659 {
4660 ulOffset = i*2;
4661 switch( pChipConfig->aulTdmStreamFreqs[ i ] )
4662 {
4663 case cOCT6100_TDM_STREAM_FREQ_2MHZ:
4664 WriteParams.usWriteData |= ( 0x0 << ulOffset );
4665 break;
4666 case cOCT6100_TDM_STREAM_FREQ_4MHZ:
4667 WriteParams.usWriteData |= ( 0x1 << ulOffset );
4668 fAllStreamAt2Mhz = FALSE;
4669 break;
4670 case cOCT6100_TDM_STREAM_FREQ_8MHZ:
4671 WriteParams.usWriteData |= ( 0x2 << ulOffset );
4672 fAllStreamAt2Mhz = FALSE;
4673 break;
4674 default:
4675 break;
4676 }
4677 }
4678
4679 /* Set the stream to 16 MHz if the fast H.100 mode is selected. */
4680 if ( pChipConfig->fEnableFastH100Mode == TRUE )
4681 {
4682 fAllStreamAt2Mhz = FALSE;
4683 WriteParams.usWriteData = 0xFFFF;
4684 }
4685
4686 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4687 if ( ulResult != cOCT6100_ERR_OK )
4688 return ulResult;
4689
4690 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
4691 {
4692 /* Make the chip track both clock A and B to perform fast H.100 mode. */
4693 WriteParams.ulWriteAddress = 0x322;
4694 WriteParams.usWriteData = 0x0004;
4695 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4696 if ( ulResult != cOCT6100_ERR_OK )
4697 return ulResult;
4698
4699 /* Enable the fast H.100 mode. */
4700 WriteParams.ulWriteAddress = 0x332;
4701 WriteParams.usWriteData = 0x0003;
4702 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4703 if ( ulResult != cOCT6100_ERR_OK )
4704 return ulResult;
4705 }
4706
4707 WriteParams.ulWriteAddress = 0x376;
4708 WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usTdmClkBoundary );
4709 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4710 if ( ulResult != cOCT6100_ERR_OK )
4711 return ulResult;
4712
4713 /* Select delay for early clock (90 and 110). */
4714 WriteParams.ulWriteAddress = 0x378;
4715 if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
4716 WriteParams.usWriteData = 0x000A;
4717 else
4718 {
4719 /* Set the TDM sampling. */
4720 if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_RISING_EDGE )
4721 {
4722 WriteParams.usWriteData = 0x0AF0;
4723 }
4724 else if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE )
4725 {
4726 WriteParams.usWriteData = 0x0A0F;
4727 }
4728 else /* pSharedInfo->ChipConfig.ulTdmSampling == cOCT6100_TDM_SAMPLE_AT_3_QUARTERS */
4729 {
4730 WriteParams.usWriteData = 0x0A08;
4731 }
4732 }
4733
4734 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4735 if ( ulResult != cOCT6100_ERR_OK )
4736 return ulResult;
4737
4738 /* Protect chip by preventing too rapid timeslot arrival (mclk == 133 MHz). */
4739 WriteParams.ulWriteAddress = 0x37A;
4740 WriteParams.usWriteData = (UINT16)pSharedInfo->MiscVars.usMaxH100Speed;
4741
4742 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4743 if ( ulResult != cOCT6100_ERR_OK )
4744 return ulResult;
4745
4746 /* Allow H.100 TS to progress. */
4747 WriteParams.ulWriteAddress = 0x382;
4748 WriteParams.usWriteData = 0x0000;
4749
4750 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4751 if ( ulResult != cOCT6100_ERR_OK )
4752 return ulResult;
4753
4754 /* Set by-pass mode. */
4755 WriteParams.ulWriteAddress = 0x50E;
4756 WriteParams.usWriteData = 0x0001;
4757
4758 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4759 if ( ulResult != cOCT6100_ERR_OK )
4760 return ulResult;
4761
4762 /* TDMIE bits. */
4763 WriteParams.ulWriteAddress = 0x500;
4764 WriteParams.usWriteData = 0x0003;
4765
4766 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4767 if ( ulResult != cOCT6100_ERR_OK )
4768 return ulResult;
4769
4770 /* Write normal ADPCM reset values in ADPCM context 1344. */
4771 for(i=0;i<32;i++)
4772 {
4773 WriteParams.ulWriteAddress = 0x140000 + ( 0x40 * 1344 ) + ( i * 2 );
4774 WriteParams.usWriteData = ausAdpcmResetContext[i];
4775
4776 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4777 if ( ulResult != cOCT6100_ERR_OK )
4778 return ulResult;
4779 }
4780
4781 /* Make sure delay flops are configured correctly if all streams are at 2 MHz. */
4782 if ( fAllStreamAt2Mhz == TRUE )
4783 {
4784 /* Setup H.100 sampling to lowest value. */
4785 WriteParams.ulWriteAddress = 0x144;
4786 WriteParams.usWriteData = 0x4041;
4787
4788 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4789 if ( ulResult != cOCT6100_ERR_OK )
4790 return ulResult;
4791
4792 WriteParams.ulWriteAddress = 0x378;
4793 WriteParams.usWriteData = 0x0A00;
4794
4795 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4796 if ( ulResult != cOCT6100_ERR_OK )
4797 return ulResult;
4798 }
4799
4800 return cOCT6100_ERR_OK;
4801 }
4802 #endif
4803
4804
4805 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4806
4807 Function: Oct6100ApiWriteMiscellaneousRegisters
4808
4809 Description: This function will write to various registers to activate the chip.
4810
4811 -------------------------------------------------------------------------------
4812 | Argument | Description
4813 -------------------------------------------------------------------------------
4814 f_pApiInstance Pointer to API instance. This memory is used to keep the
4815 present state of the chip and all its resources.
4816
4817 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4818 #if !SKIP_Oct6100ApiWriteMiscellaneousRegisters
4819 UINT32 Oct6100ApiWriteMiscellaneousRegisters(
4820 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4821 {
4822 tOCT6100_WRITE_PARAMS WriteParams;
4823 UINT32 ulResult;
4824
4825 /* Initialize the process context and user chip ID once and for all. */
4826 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4827
4828 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4829
4830 /* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */
4831 WriteParams.ulWriteAddress = 0x214;
4832 WriteParams.usWriteData = 0x0000;
4833 if ( f_pApiInstance->pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY )
4834 WriteParams.usWriteData |= 0x4000;
4835 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
4836 if ( ulResult != cOCT6100_ERR_OK )
4837 return ulResult;
4838
4839 /* Write MT chariot interval */
4840 WriteParams.ulWriteAddress = 0x2C2;
4841 if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 640 )
4842 WriteParams.usWriteData = 0x05EA;
4843 else if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 513 )
4844 WriteParams.usWriteData = 0x0672;
4845 else /* if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels <= 513 ) */
4846 WriteParams.usWriteData = 0x0750;
4847 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4848 if ( ulResult != cOCT6100_ERR_OK )
4849 return ulResult;
4850
4851 /* Write set second part5 time. */
4852 WriteParams.ulWriteAddress = 0x2C4;
4853 WriteParams.usWriteData = 0x04A0;
4854
4855 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4856 if ( ulResult != cOCT6100_ERR_OK )
4857 return ulResult;
4858
4859 /* Write CPU bucket timer to guarantee 200 cycles between each CPU access. */
4860 WriteParams.ulWriteAddress = 0x234;
4861 WriteParams.usWriteData = 0x0804;
4862
4863 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4864 if ( ulResult != cOCT6100_ERR_OK )
4865 return ulResult;
4866
4867 WriteParams.ulWriteAddress = 0x236;
4868 WriteParams.usWriteData = 0x0100;
4869
4870 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4871 if ( ulResult != cOCT6100_ERR_OK )
4872 return ulResult;
4873
4874 return cOCT6100_ERR_OK;
4875 }
4876 #endif
4877
4878
4879 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4880
4881 Function: Oct6100ApiCreateSerializeObjects
4882
4883 Description: Creates a handle to each serialization object used by the API.
4884
4885 Note that in a multi-process system the user's process context
4886 structure pointer is needed by this function. Thus, the
4887 pointer must be valid.
4888
4889 -------------------------------------------------------------------------------
4890 | Argument | Description
4891 -------------------------------------------------------------------------------
4892 f_pApiInstance Pointer to API instance. This memory is used to keep the
4893 present state of the chip and all its resources.
4894
4895 f_ulUserChipId User chip ID for this serialization object.
4896
4897 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4898 #if !SKIP_Oct6100ApiCreateSerializeObjects
4899 UINT32 Oct6100ApiCreateSerializeObjects(
4900 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
4901 IN UINT32 f_ulUserChipId )
4902 {
4903 tOCT6100_CREATE_SERIALIZE_OBJECT CreateSerObj;
4904 UINT32 ulResult;
4905 CHAR szSerObjName[ 64 ] = "Oct6100ApiXXXXXXXXApiSerObj";
4906
4907
4908 /* Set some parameters of the create structure once and for all. */
4909 CreateSerObj.pProcessContext = f_pApiInstance->pProcessContext;
4910 CreateSerObj.pszSerialObjName = szSerObjName;
4911
4912 /*----------------------------------------------------------------------*/
4913 /* Set the chip ID in the semaphore name. */
4914 szSerObjName[ 10 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 28 ) & 0xFF );
4915 szSerObjName[ 11 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 24 ) & 0xFF );
4916 szSerObjName[ 12 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 20 ) & 0xFF );
4917 szSerObjName[ 13 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 16 ) & 0xFF );
4918 szSerObjName[ 14 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 12 ) & 0xFF );
4919 szSerObjName[ 15 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 8 ) & 0xFF );
4920 szSerObjName[ 16 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 4 ) & 0xFF );
4921 szSerObjName[ 17 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 0 ) & 0xFF );
4922
4923 ulResult = Oct6100UserCreateSerializeObject( &CreateSerObj );
4924 if ( ulResult != cOCT6100_ERR_OK )
4925 return ulResult;
4926 f_pApiInstance->ulApiSerObj = CreateSerObj.ulSerialObjHndl;
4927 /*----------------------------------------------------------------------*/
4928
4929
4930
4931 return cOCT6100_ERR_OK;
4932 }
4933 #endif
4934
4935
4936 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4937
4938 Function: Oct6100ApiDestroySerializeObjects
4939
4940 Description: Destroy handles to each serialization object used by the API.
4941
4942 Note that in a multi-process system the user's process context
4943 structure pointer is needed by this function. Thus, the
4944 pointer must be valid.
4945
4946 -------------------------------------------------------------------------------
4947 | Argument | Description
4948 -------------------------------------------------------------------------------
4949 f_pApiInstance Pointer to API instance. This memory is used to keep the
4950 present state of the chip and all its resources.
4951
4952 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4953 #if !SKIP_Oct6100ApiDestroySerializeObjects
4954 UINT32 Oct6100ApiDestroySerializeObjects(
4955 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
4956 {
4957 tOCT6100_DESTROY_SERIALIZE_OBJECT DestroySerObj;
4958 UINT32 ulResult;
4959
4960 /* Set some parameters of the create structure once and for all. */
4961 DestroySerObj.pProcessContext = f_pApiInstance->pProcessContext;
4962 DestroySerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
4963
4964 ulResult = Oct6100UserDestroySerializeObject( &DestroySerObj );
4965 if ( ulResult != cOCT6100_ERR_OK )
4966 return ulResult;
4967
4968 return cOCT6100_ERR_OK;
4969 }
4970 #endif
4971
4972
4973 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4974
4975 Function: Oct6100ApiRunEgo
4976
4977 Description: Private function used to communicate with the internal processors.
4978
4979 -------------------------------------------------------------------------------
4980 | Argument | Description
4981 -------------------------------------------------------------------------------
4982 f_pApiInstance Pointer to API instance. This memory is used to keep the
4983 present state of the chip and all its resources.
4984
4985 f_fStoreFlag Type of access performed. (Load or Store)
4986 f_ulNumEntry Number of access.
4987 f_aulEntry Array of access to perform.
4988
4989 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4990 #if !SKIP_Oct6100ApiRunEgo
4991 UINT32 Oct6100ApiRunEgo(
4992 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
4993 IN BOOL f_fStoreFlag,
4994 IN UINT32 f_ulNumEntry,
4995 OUT PUINT32 f_aulEntry )
4996 {
4997 tPOCT6100_SHARED_INFO pSharedInfo;
4998 tPOCT6100_API_CHIP_CONFIG pChipConfig;
4999 tOCT6100_WRITE_PARAMS WriteParams;
5000 tOCT6100_READ_PARAMS ReadParams;
5001 UINT32 ulResult;
5002 UINT32 aulCpuLsuCmd[ 2 ];
5003 UINT16 usReadData;
5004 UINT32 i;
5005 BOOL fConditionFlag = TRUE;
5006 UINT32 ulLoopCounter = 0;
5007
5008 /* Get local pointer to shared portion of instance. */
5009 pSharedInfo = f_pApiInstance->pSharedInfo;
5010
5011 /* Get local pointer to the chip configuration structure. */
5012 pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
5013
5014 /* Set the process context and user chip ID parameters once and for all. */
5015 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
5016
5017 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5018
5019 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
5020
5021 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5022 ReadParams.pusReadData = &usReadData;
5023
5024 /* No more than 2 entries may be requested. */
5025 if ( f_ulNumEntry > 2 )
5026 return cOCT6100_ERR_FATAL_1B;
5027
5028 /* Write the requested entries at address reserved for CPU. */
5029 for( i = 0; i < f_ulNumEntry; i++ )
5030 {
5031 WriteParams.ulWriteAddress = cOCT6100_PART1_API_SCRATCH_PAD + ( 0x8 * i );
5032 WriteParams.usWriteData = (UINT16)(( f_aulEntry[ i * 2 ] >> 16 ) & 0xFFFF );
5033
5034 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5035 if ( ulResult != cOCT6100_ERR_OK )
5036 return ulResult;
5037
5038 WriteParams.ulWriteAddress += 2;
5039 WriteParams.usWriteData = (UINT16)( f_aulEntry[ i * 2 ] & 0xFFFF );
5040
5041 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5042 if ( ulResult != cOCT6100_ERR_OK )
5043 return ulResult;
5044
5045 WriteParams.ulWriteAddress += 2;
5046 WriteParams.usWriteData = (UINT16)(( f_aulEntry[ (i * 2) + 1] >> 16 ) & 0xFFFF );
5047
5048 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5049 if ( ulResult != cOCT6100_ERR_OK )
5050 return ulResult;
5051
5052 WriteParams.ulWriteAddress += 2;
5053 WriteParams.usWriteData = (UINT16)( f_aulEntry[ (i * 2) + 1] & 0xFFFF );
5054
5055 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5056 if ( ulResult != cOCT6100_ERR_OK )
5057 return ulResult;
5058 }
5059
5060 /* Preincrement code point. */
5061 pSharedInfo->MiscVars.usCodepoint++;
5062
5063 /* Create DWORD 0 of command. */
5064 aulCpuLsuCmd[0] = 0x00000000;
5065 if ( f_fStoreFlag == FALSE )
5066 aulCpuLsuCmd[0] |= 0xC0000000; /* EGO load. */
5067 else
5068 aulCpuLsuCmd[0] |= 0xE0000000; /* EGO store. */
5069
5070 aulCpuLsuCmd[0] |= (f_ulNumEntry - 1) << 19;
5071 aulCpuLsuCmd[0] |= cOCT6100_PART1_API_SCRATCH_PAD;
5072
5073 /* Create DWORD 1 of command. */
5074 aulCpuLsuCmd[1] = 0x00000000;
5075 aulCpuLsuCmd[1] |= ( ( cOCT6100_PART1_API_SCRATCH_PAD + 0x10 ) & 0xFFFF ) << 16;
5076 aulCpuLsuCmd[1] |= pSharedInfo->MiscVars.usCodepoint;
5077
5078 /* Write the EGO command in the LSU CB. */
5079 WriteParams.ulWriteAddress = cOCT6100_PART1_CPU_LSU_CB_BASE + ((pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7) * 0x8 );
5080 WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 0 ] >> 16 ) & 0xFFFF );
5081
5082 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5083 if ( ulResult != cOCT6100_ERR_OK )
5084 return ulResult;
5085
5086 WriteParams.ulWriteAddress += 2;
5087 WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 0 ] & 0xFFFF );
5088
5089 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5090 if ( ulResult != cOCT6100_ERR_OK )
5091 return ulResult;
5092
5093 WriteParams.ulWriteAddress += 2;
5094 WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 1 ] >> 16 ) & 0xFFFF );
5095
5096 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5097 if ( ulResult != cOCT6100_ERR_OK )
5098 return ulResult;
5099
5100 WriteParams.ulWriteAddress += 2;
5101 WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 1 ] & 0xFFFF );
5102
5103 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5104 if ( ulResult != cOCT6100_ERR_OK )
5105 return ulResult;
5106
5107 /* Post increment the write pointer. */
5108 pSharedInfo->MiscVars.usCpuLsuWritePtr++;
5109
5110 /* Indicate new write pointer position to HW. */
5111 WriteParams.ulWriteAddress = cOCT6100_PART1_EGO_REG + 0x5A;
5112 WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7 );
5113
5114 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5115 if ( ulResult != cOCT6100_ERR_OK )
5116 return ulResult;
5117
5118 /* Wait for codepoint to be updated before returning. */
5119 while( fConditionFlag )
5120 {
5121 ReadParams.ulReadAddress = cOCT6100_PART1_API_SCRATCH_PAD + 0x12;
5122 usReadData = (UINT16)( pSharedInfo->MiscVars.usCodepoint );
5123
5124 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5125 if ( ulResult != cOCT6100_ERR_OK )
5126 return ulResult;
5127
5128 if ( usReadData == pSharedInfo->MiscVars.usCodepoint )
5129 fConditionFlag = FALSE;
5130
5131 ulLoopCounter++;
5132
5133 if ( ulLoopCounter == cOCT6100_MAX_LOOP )
5134 return cOCT6100_ERR_OPEN_EGO_TIMEOUT;
5135 }
5136
5137 /* CRC error bit must be zero. */
5138 ReadParams.ulReadAddress = 0x202;
5139
5140 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5141 if ( ulResult != cOCT6100_ERR_OK )
5142 return ulResult;
5143
5144 if ( ( usReadData & 0x0400 ) != 0 )
5145 return cOCT6100_ERR_OPEN_CORRUPTED_IMAGE;
5146
5147 return cOCT6100_ERR_OK;
5148 }
5149 #endif
5150
5151
5152 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5153
5154 Function: Oct6100ApiCreateEgoEntry
5155
5156 Description: Private function used to create an access structure to be sent
5157 to the internal processors.
5158
5159 -------------------------------------------------------------------------------
5160 | Argument | Description
5161 -------------------------------------------------------------------------------
5162 f_ulExternalAddress External memory address for the access.
5163 f_ulInternalAddress Which process should receive the command.
5164 f_ulNumBytes Number of bytes associated to the access.
5165 f_aulEntry Array of access to perform.
5166
5167 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5168 #if !SKIP_Oct6100ApiCreateEgoEntry
5169 UINT32 Oct6100ApiCreateEgoEntry(
5170 IN UINT32 f_ulExternalAddress,
5171 IN UINT32 f_ulInternalAddress,
5172 IN UINT32 f_ulNumBytes,
5173 OUT UINT32 f_aulEntry[ 2 ] )
5174 {
5175 f_aulEntry[0] = 0x80000000;
5176 f_aulEntry[0] |= f_ulExternalAddress & 0x07FFFFFC;
5177
5178 f_aulEntry[1] = 0x0011C000;
5179 f_aulEntry[1] |= (f_ulNumBytes / 8) << 23;
5180 f_aulEntry[1] |= (f_ulInternalAddress >> 2) & 0x3FFF;
5181
5182 return cOCT6100_ERR_OK;
5183 }
5184 #endif
5185
5186
5187
5188
5189
5190
5191
5192
5193 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5194
5195 Function: Oct6100ApiInitChannels
5196
5197 Description: This function will initialize all the channels to power down.
5198
5199 -------------------------------------------------------------------------------
5200 | Argument | Description
5201 -------------------------------------------------------------------------------
5202 f_pApiInstance Pointer to API instance. This memory is used to keep the
5203 present state of the chip and all its resources.
5204
5205 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5206 #if !SKIP_Oct6100ApiInitChannels
5207 UINT32 Oct6100ApiInitChannels(
5208 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
5209 {
5210 tPOCT6100_SHARED_INFO pSharedInfo;
5211 UINT32 i;
5212 UINT32 ulResult;
5213 tOCT6100_WRITE_BURST_PARAMS BurstParams;
5214 tOCT6100_WRITE_PARAMS WriteParams;
5215 tOCT6100_READ_PARAMS ReadParams;
5216 UINT16 usReadData;
5217 UINT32 ulTempData;
5218 UINT32 ulBaseAddress;
5219 UINT32 ulFeatureBytesOffset;
5220 UINT32 ulFeatureBitOffset;
5221 UINT32 ulFeatureFieldLength;
5222 UINT32 ulMask;
5223 UINT16 ausWriteData[ 4 ];
5224 UINT16 usLoopCount = 0;
5225 UINT16 usWriteData = 0;
5226 UINT16 usMclkRead;
5227 UINT16 usLastMclkRead;
5228 UINT16 usMclkDiff;
5229 UINT32 ulNumberOfCycleToWait;
5230 UINT32 ulTimeoutCounter;
5231
5232 pSharedInfo = f_pApiInstance->pSharedInfo;
5233
5234 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
5235
5236 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
5237
5238 BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
5239
5240 BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
5241 BurstParams.pusWriteData = ausWriteData;
5242
5243 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
5244
5245 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
5246 ReadParams.pusReadData = &usReadData;
5247
5248 /* Verify that the image has enough memory to work correctly. */
5249 if ( ( pSharedInfo->MiscVars.ulTotalMemSize + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) < pSharedInfo->MemoryMap.ulFreeMemBaseAddress )
5250 return cOCT6100_ERR_OPEN_INSUFFICIENT_EXTERNAL_MEMORY;
5251
5252 /* Verify that the tail length is supported by the device.*/
5253 if ( pSharedInfo->ChipConfig.usTailDisplacement > pSharedInfo->ImageInfo.usMaxTailDisplacement )
5254 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_TAIL_DISPLACEMENT_VALUE;
5255
5256 /* Verify that acoustic echo is supported by the device. */
5257 if ( pSharedInfo->ChipConfig.fEnableAcousticEcho == TRUE && pSharedInfo->ImageInfo.fAcousticEcho == FALSE )
5258 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_ACOUSTIC_ECHO;
5259
5260 /* Verify that the image supports all the requested channels. */
5261 if ( pSharedInfo->ChipConfig.usMaxChannels > pSharedInfo->ImageInfo.usMaxNumberOfChannels )
5262 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE;
5263
5264 /* Max number of channels the image supports + 1 for channel recording, if requested */
5265 if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
5266 && ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < cOCT6100_MAX_ECHO_CHANNELS )
5267 && ( pSharedInfo->ChipConfig.usMaxChannels == pSharedInfo->ImageInfo.usMaxNumberOfChannels ) )
5268 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE;
5269
5270 /* Initialize the memory for all required channels. */
5271 for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
5272 {
5273 /*==============================================================================*/
5274 /* Configure the Global Static Configuration memory of the channel. */
5275
5276 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( i * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
5277
5278 /* Set the PGSP context base address. */
5279 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
5280
5281 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
5282 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5283
5284 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5285 if ( ulResult != cOCT6100_ERR_OK )
5286 return ulResult;
5287
5288 WriteParams.ulWriteAddress += 2;
5289 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5290
5291 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5292 if ( ulResult != cOCT6100_ERR_OK )
5293 return ulResult;
5294
5295 /* Set the PGSP init context base address. */
5296 ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
5297
5298 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
5299 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5300
5301 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5302 if ( ulResult != cOCT6100_ERR_OK )
5303 return ulResult;
5304
5305 WriteParams.ulWriteAddress += 2;
5306 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5307
5308 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5309 if ( ulResult != cOCT6100_ERR_OK )
5310 return ulResult;
5311
5312 /* Set the RIN circular buffer base address. */
5313 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst;
5314
5315 /* Set the circular buffer size. */
5316 ulTempData &= 0xFFFFFF00;
5317 if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 )
5318 return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE;
5319 ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8;
5320
5321 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
5322 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5323
5324 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5325 if ( ulResult != cOCT6100_ERR_OK )
5326 return ulResult;
5327
5328 WriteParams.ulWriteAddress += 2;
5329 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5330
5331 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5332 if ( ulResult != cOCT6100_ERR_OK )
5333 return ulResult;
5334
5335 /* Set the SIN circular buffer base address. */
5336 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst;
5337
5338 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
5339 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5340
5341 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5342 if ( ulResult != cOCT6100_ERR_OK )
5343 return ulResult;
5344
5345 WriteParams.ulWriteAddress += 2;
5346 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5347
5348 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5349 if ( ulResult != cOCT6100_ERR_OK )
5350 return ulResult;
5351
5352 /* Set the SOUT circular buffer base address. */
5353 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst;;
5354
5355 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
5356 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
5357
5358 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5359 if ( ulResult != cOCT6100_ERR_OK )
5360 return ulResult;
5361
5362 WriteParams.ulWriteAddress += 2;
5363 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
5364
5365 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5366 if ( ulResult != cOCT6100_ERR_OK )
5367 return ulResult;
5368
5369 /*==============================================================================*/
5370 }
5371
5372 /* Put all channel in powerdown mode "3". */
5373 for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
5374 {
5375 WriteParams.ulWriteAddress = 0x014000 + (i*4) + 0;
5376 WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */
5377
5378 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5379 if ( ulResult != cOCT6100_ERR_OK )
5380 return ulResult;
5381
5382 WriteParams.ulWriteAddress = 0x014000 + (i*4) + 2;
5383 WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */
5384
5385 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5386 if ( ulResult != cOCT6100_ERR_OK )
5387 return ulResult;
5388 }
5389
5390 /* Set the maximum number of channels. */
5391 WriteParams.ulWriteAddress = 0x690;
5392 if ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < 384 )
5393 WriteParams.usWriteData = 384;
5394 else
5395 WriteParams.usWriteData = (UINT16)pSharedInfo->ImageInfo.usMaxNumberOfChannels;
5396
5397 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5398 if ( ulResult != cOCT6100_ERR_OK )
5399 return ulResult;
5400
5401 /* Set power-dowm TSI chariot memory to silence. */
5402 for( i = 0; i < 6; i++ )
5403 {
5404 WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1534 * 2 );
5405 WriteParams.usWriteData = 0x3EFF;
5406
5407 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5408 if ( ulResult != cOCT6100_ERR_OK )
5409 return ulResult;
5410
5411 WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1535 * 2 );
5412 WriteParams.usWriteData = 0x3EFF;
5413
5414 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5415 if ( ulResult != cOCT6100_ERR_OK )
5416 return ulResult;
5417 }
5418
5419 /* Remove chariot hold. */
5420 WriteParams.ulWriteAddress = 0x500;
5421 WriteParams.usWriteData = 0x0001;
5422
5423 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5424 if ( ulResult != cOCT6100_ERR_OK )
5425 return ulResult;
5426
5427 for( usLoopCount = 0; usLoopCount < 4096; usLoopCount++ )
5428 {
5429 if ( (usLoopCount % 16) < 8 )
5430 {
5431 usWriteData = (UINT16)((usLoopCount / 16) << 7);
5432 usWriteData |= (UINT16)((usLoopCount % 8));
5433 }
5434 else
5435 {
5436 usWriteData = (UINT16)((usLoopCount / 16) << 7);
5437 usWriteData |= (UINT16)((usLoopCount % 8));
5438 usWriteData |= 0x78;
5439 }
5440
5441 /* Set timeslot pointer. */
5442 WriteParams.ulWriteAddress = 0x50E;
5443 WriteParams.usWriteData = 0x0003;
5444 WriteParams.usWriteData |= usWriteData << 2;
5445
5446 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5447 if ( ulResult != cOCT6100_ERR_OK )
5448 return ulResult;
5449
5450 /* Now read the mclk counter. */
5451 ReadParams.ulReadAddress = 0x30A;
5452 ReadParams.pusReadData = &usLastMclkRead;
5453
5454 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5455 if ( ulResult != cOCT6100_ERR_OK )
5456 return ulResult;
5457
5458 /* Reset loop timeout counter. */
5459 ulTimeoutCounter = 0x0;
5460
5461 do {
5462 ReadParams.pusReadData = &usMclkRead;
5463
5464 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5465 if ( ulResult != cOCT6100_ERR_OK )
5466 return ulResult;
5467
5468 if ( ( usLoopCount % 16 ) != 15 )
5469 {
5470 ulNumberOfCycleToWait = 133;
5471 }
5472 else
5473 {
5474 ulNumberOfCycleToWait = 20000;
5475 }
5476
5477 /* Evaluate the difference. */
5478 usMclkDiff = (UINT16)(( usMclkRead - usLastMclkRead ) & 0xFFFF);
5479
5480 /* Check for loop timeout. Bad mclk? */
5481 ulTimeoutCounter++;
5482 if ( ulTimeoutCounter == cOCT6100_MAX_LOOP_CPU_TIMEOUT )
5483 return cOCT6100_ERR_FATAL_EA;
5484
5485 } while( usMclkDiff <= ulNumberOfCycleToWait );
5486 }
5487
5488 /* Back to normal mode. */
5489 WriteParams.ulWriteAddress = 0x50E;
5490 WriteParams.usWriteData = 0x0000;
5491
5492 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5493 if ( ulResult != cOCT6100_ERR_OK )
5494 return ulResult;
5495
5496 /* Check for CRC errors. */
5497 ReadParams.pusReadData = &usReadData;
5498 ReadParams.ulReadAddress = 0x202;
5499
5500 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5501 if ( ulResult != cOCT6100_ERR_OK )
5502 return ulResult;
5503
5504 if ( (usReadData & 0x400) != 0x0000 )
5505 return cOCT6100_ERR_OPEN_CRC_ERROR;
5506
5507 /* Clear the error rol raised by manually moving the clocks. */
5508 WriteParams.ulWriteAddress = 0x502;
5509 WriteParams.usWriteData = 0x0002;
5510
5511 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5512 if ( ulResult != cOCT6100_ERR_OK )
5513 return ulResult;
5514
5515 /*======================================================================*/
5516 /* Write the tail displacement value in external memory. */
5517
5518 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.usDwordOffset * 4;
5519 ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.byBitOffset;
5520 ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchTailDisplOfst.byFieldSize;
5521
5522 ulResult = Oct6100ApiReadDword( f_pApiInstance,
5523 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5524 &ulTempData );
5525
5526 /* Clear previous value set in the feature field.*/
5527 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
5528
5529 ulTempData &= (~ulMask);
5530
5531 /* Set the tail displacement. */
5532 ulTempData |= (pSharedInfo->ChipConfig.usTailDisplacement << ulFeatureBitOffset );
5533
5534 /* Write the DWORD where the field is located. */
5535 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
5536 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5537 ulTempData );
5538 if ( ulResult != cOCT6100_ERR_OK )
5539 return ulResult;
5540
5541 /*======================================================================*/
5542
5543
5544 /*======================================================================*/
5545 /* Clear the pouch counter, if present. */
5546
5547 if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
5548 {
5549 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
5550 ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
5551 ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
5552
5553 ulResult = Oct6100ApiReadDword( f_pApiInstance,
5554 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5555 &ulTempData );
5556
5557 /* Clear previous value set in the feature field.*/
5558 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
5559
5560 /* Clear counter! */
5561 ulTempData &= (~ulMask);
5562
5563 /* Write the DWORD where the field is located.*/
5564 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
5565 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5566 ulTempData );
5567 if ( ulResult != cOCT6100_ERR_OK )
5568 return ulResult;
5569 }
5570
5571 /* The ISR has not yet been called. Set the appropriate bit in external memory. */
5572 if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
5573 {
5574 ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
5575 ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
5576 ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
5577
5578 ulResult = Oct6100ApiReadDword( f_pApiInstance,
5579 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5580 &ulTempData );
5581
5582 /* Read previous value set in the feature field.*/
5583 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
5584
5585 /* Toggle the bit to '1'. */
5586 ulTempData |= 1 << ulFeatureBitOffset;
5587
5588 /* Write the DWORD where the field is located.*/
5589 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
5590 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
5591 ulTempData );
5592 if ( ulResult != cOCT6100_ERR_OK )
5593 return ulResult;
5594 }
5595
5596 /*======================================================================*/
5597
5598 return cOCT6100_ERR_OK;
5599 }
5600 #endif
5601
5602
5603 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5604
5605 Function: Oct6100ApiInitToneInfo
5606
5607 Description: This function will parse the software image and retrieve
5608 the information about the tones that it supports.
5609
5610 -------------------------------------------------------------------------------
5611 | Argument | Description
5612 -------------------------------------------------------------------------------
5613 f_pApiInstance Pointer to API instance. This memory is used to keep the
5614 present state of the chip and all its resources.
5615
5616 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5617 #if !SKIP_Oct6100ApiInitToneInfo
5618 UINT32 Oct6100ApiInitToneInfo(
5619 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
5620 {
5621 UINT32 ulResult;
5622
5623 unsigned char const *pszToneInfoStart = NULL;
5624 unsigned char const *pszToneInfoEnd = NULL;
5625
5626 unsigned char const *pszCurrentInfo;
5627 unsigned char const *pszNextInfo;
5628
5629 UINT32 ulToneEventNumber;
5630 UINT32 ulTempValue;
5631 UINT32 ulNumCharForValue;
5632 UINT32 ulUniqueToneId;
5633 UINT32 ulToneNameSize;
5634 UINT32 ulOffset = 0;
5635
5636 UINT32 i;
5637
5638 /* Init the tone detector parameter. */
5639 f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors = 0;
5640
5641 /* Find the start and the end of the tone info section. */
5642 if ( f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize > 4096 )
5643 {
5644 /* For performance reasons, and since the tone detector information */
5645 /* is always located at the end of the image file, try to start from the end */
5646 /* of the buffer. */
5647
5648 ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 2048;
5649 pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset,
5650 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
5651 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5652
5653 /* Check if the information was found. */
5654 if ( pszToneInfoStart == NULL )
5655 {
5656 /* Try again, but giving a larger string to search. */
5657 ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 4096;
5658 pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset,
5659 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
5660 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5661
5662 }
5663 }
5664
5665 if ( pszToneInfoStart == NULL )
5666 {
5667 /* Travel through the whole file buffer. */
5668 pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile,
5669 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
5670 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5671 }
5672 /* We have to return immediatly if no tones are found. */
5673 if ( pszToneInfoStart == NULL )
5674 return cOCT6100_ERR_OK;
5675
5676 /* The end of the tone detector information is after the beginning of the tone information. */
5677 pszToneInfoEnd = Oct6100ApiStrStr( pszToneInfoStart,
5678 (PUINT8)cOCT6100_TONE_INFO_STOP_STRING,
5679 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
5680 if ( pszToneInfoEnd == NULL )
5681 return cOCT6100_ERR_OPEN_TONE_INFO_STOP_TAG_NOT_FOUND;
5682
5683 /* Find and process all tone events within the region. */
5684 pszCurrentInfo = Oct6100ApiStrStr( pszToneInfoStart, (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
5685
5686 while ( pszCurrentInfo != NULL )
5687 {
5688 /* Skip the string. */
5689 pszCurrentInfo += ( Oct6100ApiStrLen( (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING ) );
5690
5691 /* Extract the number of char used to represent the tone event number ( 1 or 2 ). */
5692 pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo, (PUINT8)",", pszToneInfoEnd );
5693 ulNumCharForValue = (UINT32)( pszNextInfo - pszCurrentInfo );
5694
5695 /* Retreive the event number */
5696 ulToneEventNumber = 0;
5697 for ( i = ulNumCharForValue; i > 0; i-- )
5698 {
5699 ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
5700 if ( ulResult != cOCT6100_ERR_OK )
5701 return ulResult;
5702
5703 ulToneEventNumber |= ( ulTempValue << (( i - 1) * 4 ) );
5704 pszCurrentInfo++;
5705 }
5706
5707 if ( ulToneEventNumber >= cOCT6100_MAX_TONE_EVENT )
5708 return cOCT6100_ERR_OPEN_INVALID_TONE_EVENT;
5709
5710 /* Skip the comma and the 0x. */
5711 pszCurrentInfo += 3;
5712
5713 /*======================================================================*/
5714 /* Retreive the unique tone id. */
5715 ulUniqueToneId = 0;
5716 for ( i = 0; i < 8; i++ )
5717 {
5718 ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
5719 if ( ulResult != cOCT6100_ERR_OK )
5720 return ulResult;
5721
5722 ulOffset = 28 - ( i * 4 );
5723 ulUniqueToneId |= ( ulTempValue << ulOffset );
5724 pszCurrentInfo++;
5725 }
5726
5727 /*======================================================================*/
5728
5729 /* Skip the comma. */
5730 pszCurrentInfo++;
5731
5732 /* Find out where the next event info starts */
5733 pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
5734 if ( pszNextInfo == NULL )
5735 pszNextInfo = pszToneInfoEnd;
5736
5737 /* Extract the name size. */
5738 ulToneNameSize = (UINT32)( pszNextInfo - pszCurrentInfo - 2 ); /* - 2 for 0x0D and 0x0A.*/
5739
5740 if ( ulToneNameSize > cOCT6100_TLV_MAX_TONE_NAME_SIZE )
5741 return cOCT6100_ERR_OPEN_INVALID_TONE_NAME;
5742
5743 /* Copy the tone name into the image info structure. */
5744 ulResult = Oct6100UserMemCopy( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].aszToneName,
5745 pszCurrentInfo,
5746 ulToneNameSize );
5747
5748
5749
5750 /* Update the tone info into the image info structure. */
5751 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID = ulUniqueToneId;
5752 /* Find out the port on which this tone detector is associated. */
5753 switch( (ulUniqueToneId >> 28) & 0xF )
5754 {
5755 case 1:
5756 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT;
5757 break;
5758
5759 case 2:
5760 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SIN;
5761 break;
5762
5763 case 4:
5764 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SOUT;
5765 break;
5766
5767 case 5:
5768 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT_SOUT;
5769 break;
5770
5771 default:
5772 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_INVALID_PORT;
5773 break;
5774 }
5775
5776 /* Find out where the next event info starts */
5777 pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
5778 /* Update the current info pointer. */
5779 pszCurrentInfo = pszNextInfo;
5780
5781 f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors++;
5782 }
5783
5784 return cOCT6100_ERR_OK;
5785 }
5786 #endif
5787
5788
5789 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5790
5791 Function: Oct6100ApiExternalMemoryBist
5792
5793 Description: Tests the functionality of the external memories.
5794
5795 -------------------------------------------------------------------------------
5796 | Argument | Description
5797 -------------------------------------------------------------------------------
5798 f_pApiInstance Pointer to API instance. This memory is used to keep the
5799 present state of the chip and all its resources.
5800
5801 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5802 #if !SKIP_Oct6100ApiExternalMemoryBist
5803 UINT32 Oct6100ApiExternalMemoryBist(
5804 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
5805 {
5806 tPOCT6100_SHARED_INFO pSharedInfo;
5807 UINT32 ulMemSize = 0;
5808 UINT32 ulResult;
5809
5810 /* Get local pointer to shared portion of instance. */
5811 pSharedInfo = f_pApiInstance->pSharedInfo;
5812
5813 /* Test the external memory. */
5814 switch ( pSharedInfo->ChipConfig.ulMemoryChipSize )
5815 {
5816 case cOCT6100_MEMORY_CHIP_SIZE_8MB:
5817 ulMemSize = cOCT6100_SIZE_8M;
5818 break;
5819 case cOCT6100_MEMORY_CHIP_SIZE_16MB:
5820 ulMemSize = cOCT6100_SIZE_16M;
5821 break;
5822 case cOCT6100_MEMORY_CHIP_SIZE_32MB:
5823 ulMemSize = cOCT6100_SIZE_32M;
5824 break;
5825 case cOCT6100_MEMORY_CHIP_SIZE_64MB:
5826 ulMemSize = cOCT6100_SIZE_64M;
5827 break;
5828 case cOCT6100_MEMORY_CHIP_SIZE_128MB:
5829 ulMemSize = cOCT6100_SIZE_128M;
5830 break;
5831 default:
5832 return cOCT6100_ERR_FATAL_D9;
5833 }
5834
5835 ulMemSize *= pSharedInfo->ChipConfig.byNumMemoryChips;
5836
5837 ulResult = Oct6100ApiRandomMemoryWrite( f_pApiInstance, cOCT6100_EXTERNAL_MEM_BASE_ADDRESS, ulMemSize, 16, 1000, cOCT6100_ERR_OPEN_EXTERNAL_MEM_BIST_FAILED );
5838 if ( ulResult != cOCT6100_ERR_OK )
5839 return ulResult;
5840
5841 /* Make sure the user I/O functions are working as required. */
5842 ulResult = Oct6100ApiUserIoTest( f_pApiInstance );
5843 if ( ulResult != cOCT6100_ERR_OK )
5844 return ulResult;
5845
5846 return cOCT6100_ERR_OK;
5847 }
5848 #endif
5849
5850
5851 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5852
5853 Function: Oct6100ApiGenerateNumber
5854
5855 Description: Generate a number using an index. Passing the same
5856 index generates the same number.
5857
5858 -------------------------------------------------------------------------------
5859 | Argument | Description
5860 -------------------------------------------------------------------------------
5861 f_pApiInstance Pointer to API instance. This memory is used to keep the
5862 present state of the chip and all its resources.
5863 f_ulIndex Index used to generate the random number.
5864 f_ulDataMask Data mask to apply to generated number.
5865
5866 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5867 #if !SKIP_Oct6100ApiGenerateNumber
5868 UINT16 Oct6100ApiGenerateNumber(
5869 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
5870 IN UINT32 f_ulIndex,
5871 IN UINT32 f_ulDataMask )
5872 {
5873 UINT16 usGeneratedNumber;
5874
5875 usGeneratedNumber = (UINT16)( ( ( ~( f_ulIndex - 1 ) ) & 0xFF00 ) | ( ( f_ulIndex + 1 ) & 0xFF ) );
5876
5877 return (UINT16)( usGeneratedNumber & f_ulDataMask );
5878 }
5879 #endif
5880
5881
5882 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5883
5884 Function: Oct6100ApiRandomMemoryWrite
5885
5886 Description: Writes to f_ulNumAccesses random locations in the indicated
5887 memory and read back to test the operation of that memory.
5888
5889 -------------------------------------------------------------------------------
5890 | Argument | Description
5891 -------------------------------------------------------------------------------
5892 f_pApiInstance Pointer to API instance. This memory is used to keep the
5893 present state of the chip and all its resources.
5894 f_ulMemBase Base address of the memory access.
5895 f_ulMemSize Size of the memory to be tested.
5896 f_ulNumDataBits Number of data bits.
5897 f_ulNumAccesses Number of random access to be perform.
5898 f_ulErrorCode Error code to be returned if the bist fails.
5899
5900 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5901 #if !SKIP_Oct6100ApiRandomMemoryWrite
5902 UINT32 Oct6100ApiRandomMemoryWrite(
5903 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
5904 IN UINT32 f_ulMemBase,
5905 IN UINT32 f_ulMemSize,
5906 IN UINT32 f_ulNumDataBits,
5907 IN UINT32 f_ulNumAccesses,
5908 IN UINT32 f_ulErrorCode )
5909 {
5910 tPOCT6100_SHARED_INFO pSharedInfo;
5911 tOCT6100_WRITE_PARAMS WriteParams;
5912 tOCT6100_READ_PARAMS ReadParams;
5913 UINT32 ulDataMask;
5914 UINT32 ulResult, i, j;
5915 UINT32 ulBistAddress;
5916 UINT16 usReadData;
5917 UINT32 aulBistAddress[20]={0x00000000, 0x00000002, 0x00000004, 0x007FFFFE,
5918 0x00900000, 0x00900006, 0x00900008, 0x009FFFFE,
5919 0x01000000, 0x0100000A, 0x0200000C, 0x01FFFFFE,
5920 0x03000000, 0x03000002, 0x04000004, 0x03FFFFFE,
5921 0x04000000, 0x05000006, 0x06000008, 0x07FFFFFE};
5922
5923 /* Get local pointer to shared portion of instance. */
5924 pSharedInfo = f_pApiInstance->pSharedInfo;
5925
5926 /* Set the process context and user chip ID parameters once and for all. */
5927 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
5928
5929 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5930
5931 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
5932
5933 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
5934
5935 /* Determine mask for number of data bits. */
5936 ulDataMask = (1 << f_ulNumDataBits) - 1;
5937
5938 /* Write specific data to specific address */
5939 WriteParams.ulWriteAddress = f_ulMemBase | 0x00001000;
5940 WriteParams.usWriteData = 0xCAFE;
5941
5942 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5943 if ( ulResult != cOCT6100_ERR_OK )
5944 return ulResult;
5945
5946 for(j=0; j<20; j++)
5947 {
5948 /* Change address to test lower and higher part of the 32 bit bus */
5949 ulBistAddress = aulBistAddress[j];
5950 ulBistAddress &= f_ulMemSize - 2;
5951 ulBistAddress |= f_ulMemBase;
5952
5953 /* Bist 16 data pins of this address */
5954 for ( i = 0; i < 16; i ++)
5955 {
5956 WriteParams.ulWriteAddress = ulBistAddress;
5957 WriteParams.usWriteData = (UINT16)(0x1 << i);
5958
5959 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5960 if ( ulResult != cOCT6100_ERR_OK )
5961 return ulResult;
5962
5963 /* Read back the specific data to flush the data bus.*/
5964 ReadParams.ulReadAddress = f_ulMemBase | 0x00001000;
5965 ReadParams.pusReadData = &usReadData;
5966 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
5967 if ( ulResult != cOCT6100_ERR_OK )
5968 return ulResult;
5969
5970 if ( usReadData != 0xCAFE )
5971 return f_ulErrorCode;
5972
5973 /* Read back the data written.*/
5974 ReadParams.ulReadAddress = WriteParams.ulWriteAddress;
5975 ReadParams.pusReadData = &usReadData;
5976 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
5977 if ( ulResult != cOCT6100_ERR_OK )
5978 return ulResult;
5979
5980 if ( usReadData != (UINT16)(0x1 << i) )
5981 return f_ulErrorCode;
5982 }
5983 }
5984
5985 /* Perform the first write at address 0 + mem base */
5986 j = 0;
5987 WriteParams.ulWriteAddress = f_ulMemBase;
5988 WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask );
5989 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5990 if ( ulResult != cOCT6100_ERR_OK )
5991 return ulResult;
5992
5993 /* Try each address line of the memory. */
5994 for ( i = 2, j = 1; i < f_ulMemSize; i <<= 1, j++ )
5995 {
5996 WriteParams.ulWriteAddress = ( f_ulMemBase + i );
5997 WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask );
5998 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
5999 if ( ulResult != cOCT6100_ERR_OK )
6000 return ulResult;
6001 }
6002
6003 for ( i = 0; i < j; i++ )
6004 {
6005 if ( i > 0 )
6006 ReadParams.ulReadAddress = ( f_ulMemBase + ( 0x1 << i ) );
6007 else
6008 ReadParams.ulReadAddress = f_ulMemBase;
6009 ReadParams.pusReadData = &usReadData;
6010 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
6011 if ( ulResult != cOCT6100_ERR_OK )
6012 return ulResult;
6013
6014 if ( usReadData != Oct6100ApiGenerateNumber( f_pApiInstance, i, ulDataMask ) )
6015 return f_ulErrorCode;
6016 }
6017
6018 /* Write to random addresses of the memory. */
6019 for ( i = 0; i < f_ulNumAccesses; i++ )
6020 {
6021 ulBistAddress = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16;
6022 ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6023 ulBistAddress &= f_ulMemSize - 2;
6024 ulBistAddress |= f_ulMemBase;
6025
6026 WriteParams.ulWriteAddress = ulBistAddress;
6027 WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6028 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6029 if ( ulResult != cOCT6100_ERR_OK )
6030 return ulResult;
6031 }
6032
6033 for ( i = 0; i < f_ulNumAccesses; i++ )
6034 {
6035 ulBistAddress = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16;
6036 ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6037 ulBistAddress &= f_ulMemSize - 2;
6038 ulBistAddress |= f_ulMemBase;
6039
6040 ReadParams.ulReadAddress = ulBistAddress;
6041 ReadParams.pusReadData = &usReadData;
6042 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
6043 if ( ulResult != cOCT6100_ERR_OK )
6044 return ulResult;
6045
6046 if ( ( usReadData & ulDataMask ) != ( Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) & ulDataMask ) )
6047 return f_ulErrorCode;
6048 }
6049
6050
6051 return cOCT6100_ERR_OK;
6052 }
6053 #endif
6054
6055
6056 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6057
6058 Function: Oct6100ApiUserIoTest
6059
6060 Description: This function will verify the correct functionality of
6061 the following user functions:
6062
6063 - Oct6100UserDriverWriteBurstApi
6064 - Oct6100UserDriverWriteSmearApi
6065 - Oct6100UserDriverReadBurstApi
6066
6067 The Oct6100UserDriverWriteApi and Oct6100UserDriverReadApi
6068 functions do not need to be tested here as this has be done in
6069 the external memory bisting function above.
6070
6071 -------------------------------------------------------------------------------
6072 | Argument | Description
6073 -------------------------------------------------------------------------------
6074 f_pApiInstance Pointer to API instance. This memory is used to keep the
6075 present state of the chip and all its resources.
6076
6077 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6078 #if !SKIP_Oct6100ApiUserIoTest
6079 UINT32 Oct6100ApiUserIoTest(
6080 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6081 {
6082 tPOCT6100_SHARED_INFO pSharedInfo;
6083 tOCT6100_WRITE_BURST_PARAMS WriteBurstParams;
6084 tOCT6100_WRITE_SMEAR_PARAMS WriteSmearParams;
6085 tOCT6100_READ_PARAMS ReadParams;
6086 tOCT6100_READ_BURST_PARAMS ReadBurstParams;
6087 UINT32 ulResult, i;
6088 UINT16 usReadData;
6089
6090 /* Get local pointer to shared portion of instance. */
6091 pSharedInfo = f_pApiInstance->pSharedInfo;
6092
6093 /* Set the process context and user chip ID parameters once and for all. */
6094 WriteBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6095
6096 WriteBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6097 /* Test what the user has specified is the maximum that can be used for a burst. */
6098 WriteBurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6099 WriteBurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
6100
6101 WriteSmearParams.pProcessContext = f_pApiInstance->pProcessContext;
6102
6103 WriteSmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6104 /* Test what the user has specified is the maximum that can be used for a smear. */
6105 WriteSmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6106
6107 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
6108
6109 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6110 ReadParams.pusReadData = &usReadData;
6111
6112 ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6113
6114 ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6115 /* Test what the user has specified is the maximum that can be used for a burst. */
6116 ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6117 ReadBurstParams.pusReadData = pSharedInfo->MiscVars.ausSuperArray;
6118
6119
6120 /*======================================================================*/
6121 /* Write burst check. */
6122
6123 WriteBurstParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6124 /* Set the random data to be written. */
6125 for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ )
6126 {
6127 WriteBurstParams.pusWriteData[ i ] = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
6128 }
6129 mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult )
6130 if ( ulResult != cOCT6100_ERR_OK )
6131 return ulResult;
6132
6133 /* Read back pattern using simple read function and make sure we are reading what's expected. */
6134 ReadParams.ulReadAddress = WriteBurstParams.ulWriteAddress;
6135 for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ )
6136 {
6137 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
6138 if ( ulResult != cOCT6100_ERR_OK )
6139 return ulResult;
6140
6141 /* Check if the data matches. */
6142 if ( usReadData != WriteBurstParams.pusWriteData[ i ] )
6143 {
6144 /* The values do not match. Something seems to be wrong with the WriteBurst user function. */
6145 return cOCT6100_ERR_OPEN_USER_WRITE_BURST_FAILED;
6146 }
6147
6148 /* Next address to check. */
6149 ReadParams.ulReadAddress += 2;
6150 }
6151
6152 /*======================================================================*/
6153
6154
6155 /*======================================================================*/
6156 /* Write smear check. */
6157
6158 WriteSmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + ( WriteBurstParams.ulWriteLength * 2 );
6159 /* Set the random data to be written. */
6160 WriteSmearParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, Oct6100ApiRand( 0xFFFF ), 0xFFFF );
6161 mOCT6100_DRIVER_WRITE_SMEAR_API( WriteSmearParams, ulResult )
6162 if ( ulResult != cOCT6100_ERR_OK )
6163 return ulResult;
6164
6165 /* Read back pattern using simple read function and make sure we are reading what's expected. */
6166 ReadParams.ulReadAddress = WriteSmearParams.ulWriteAddress;
6167 for ( i = 0; i < WriteSmearParams.ulWriteLength; i++ )
6168 {
6169 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
6170 if ( ulResult != cOCT6100_ERR_OK )
6171 return ulResult;
6172
6173 /* Check if the data matches. */
6174 if ( usReadData != WriteSmearParams.usWriteData )
6175 {
6176 /* The values do not match. Something seems to be wrong with the WriteSmear user function. */
6177 return cOCT6100_ERR_OPEN_USER_WRITE_SMEAR_FAILED;
6178 }
6179
6180 /* Next address to check. */
6181 ReadParams.ulReadAddress += 2;
6182 }
6183
6184 /*======================================================================*/
6185
6186
6187 /*======================================================================*/
6188 /* Read burst check. */
6189
6190 /* First check with what the WriteBurst function wrote. */
6191 ReadBurstParams.ulReadAddress = WriteBurstParams.ulWriteAddress;
6192 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
6193 if ( ulResult != cOCT6100_ERR_OK )
6194 return ulResult;
6195
6196 for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
6197 {
6198 /* Check if the data matches. */
6199 if ( ReadBurstParams.pusReadData[ i ] != Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) )
6200 {
6201 /* The values do not match. Something seems to be wrong with the ReadBurst user function. */
6202 return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED;
6203 }
6204 }
6205
6206 /* Then check with what the WriteSmear function wrote. */
6207 ReadBurstParams.ulReadAddress = WriteSmearParams.ulWriteAddress;
6208 mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
6209 if ( ulResult != cOCT6100_ERR_OK )
6210 return ulResult;
6211
6212 for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
6213 {
6214 /* Check if the data matches. */
6215 if ( ReadBurstParams.pusReadData[ i ] != WriteSmearParams.usWriteData )
6216 {
6217 /* The values do not match. Something seems to be wrong with the ReadBurst user function. */
6218 return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED;
6219 }
6220 }
6221
6222 /*======================================================================*/
6223
6224 return cOCT6100_ERR_OK;
6225 }
6226 #endif
6227
6228
6229 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6230
6231 Function: Oct6100ApiExternalMemoryInit
6232
6233 Description: Initialize the external memory before uploading the image.
6234
6235 -------------------------------------------------------------------------------
6236 | Argument | Description
6237 -------------------------------------------------------------------------------
6238 f_pApiInstance Pointer to API instance. This memory is used to keep the
6239 present state of the chip and all its resources.
6240
6241 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6242 #if !SKIP_Oct6100ApiExternalMemoryInit
6243 UINT32 Oct6100ApiExternalMemoryInit(
6244 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6245 {
6246 tPOCT6100_SHARED_INFO pSharedInfo;
6247 tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
6248 UINT32 ulTotalWordToWrite;
6249 UINT32 ulResult;
6250
6251 /* Get local pointer to shared portion of instance. */
6252 pSharedInfo = f_pApiInstance->pSharedInfo;
6253
6254 SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
6255
6256 SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6257
6258 /* Clear the first part of the memory. */
6259 ulTotalWordToWrite = 0x400;
6260 SmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6261
6262 while ( ulTotalWordToWrite != 0 )
6263 {
6264 if ( ulTotalWordToWrite >= pSharedInfo->ChipConfig.usMaxRwAccesses )
6265 SmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
6266 else
6267 SmearParams.ulWriteLength = ulTotalWordToWrite;
6268
6269 SmearParams.usWriteData = 0x0;
6270
6271 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
6272 if ( ulResult != cOCT6100_ERR_OK )
6273 return ulResult;
6274
6275 /* Update the number of words to write. */
6276 ulTotalWordToWrite -= SmearParams.ulWriteLength;
6277 /* Update the address. */
6278 SmearParams.ulWriteAddress += ( SmearParams.ulWriteLength * 2 );
6279 }
6280
6281 /* Clear the TLV flag.*/
6282 ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_TLV_BASE, 0x0 );
6283 if ( ulResult != cOCT6100_ERR_OK )
6284 return ulResult;
6285
6286 return cOCT6100_ERR_OK;
6287 }
6288 #endif
6289
6290
6291 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6292
6293 Function: Oct6100ApiInitMixer
6294
6295 Description: This function will initialize the mixer memory.
6296
6297 -------------------------------------------------------------------------------
6298 | Argument | Description
6299 -------------------------------------------------------------------------------
6300 f_pApiInstance Pointer to API instance. This memory is used to keep the
6301 present state of the chip and all its resources.
6302
6303 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6304 #if !SKIP_Oct6100ApiInitMixer
6305 UINT32 Oct6100ApiInitMixer(
6306 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6307 {
6308 tPOCT6100_SHARED_INFO pSharedInfo;
6309 tOCT6100_WRITE_BURST_PARAMS BurstParams;
6310 UINT16 ausWriteData[ 4 ];
6311 UINT32 ulResult;
6312
6313 pSharedInfo = f_pApiInstance->pSharedInfo;
6314
6315 BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6316
6317 BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6318 BurstParams.pusWriteData = ausWriteData;
6319 /*======================================================================*/
6320 /* Initialize the mixer memory if required. */
6321 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
6322 {
6323 /* Modify the mixer pointer by adding the record event into the link list. */
6324 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
6325 pSharedInfo->MixerInfo.usLastSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
6326 pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
6327 pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
6328
6329 /* Program the Sin copy event. */
6330 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordSinEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
6331 BurstParams.ulWriteLength = 4;
6332
6333 ausWriteData[ 0 ] = 0x0000;
6334 ausWriteData[ 1 ] = 0x0000;
6335 ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node.*/
6336 ausWriteData[ 3 ] = 0x0000;
6337
6338 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6339 if ( ulResult != cOCT6100_ERR_OK )
6340 return ulResult;
6341
6342 /* Program the Sout copy event. */
6343 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
6344 BurstParams.ulWriteLength = 4;
6345
6346 ausWriteData[ 0 ] = 0x0000;
6347 ausWriteData[ 1 ] = 0x0000;
6348 ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordSinEventIndex & 0x7FF);
6349 ausWriteData[ 3 ] = 0x0000;
6350
6351 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6352 if ( ulResult != cOCT6100_ERR_OK )
6353 return ulResult;
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)(pSharedInfo->MixerInfo.usRecordCopyEventIndex & 0x7FF);
6362 ausWriteData[ 3 ] = 0x0000;
6363
6364 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6365 if ( ulResult != cOCT6100_ERR_OK )
6366 return ulResult;
6367
6368 /* Init the mixer pointer */
6369 pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
6370 }
6371 else
6372 {
6373 /* Configure the head node. */
6374 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE;
6375 BurstParams.ulWriteLength = 4;
6376
6377 ausWriteData[ 0 ] = 0x0000;
6378 ausWriteData[ 1 ] = 0x0000;
6379 ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node. */
6380 ausWriteData[ 3 ] = 0x0000;
6381
6382 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6383 if ( ulResult != cOCT6100_ERR_OK )
6384 return ulResult;
6385
6386 /* Configure the tail node. */
6387 BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + 0x10;
6388 BurstParams.ulWriteLength = 4;
6389
6390 ausWriteData[ 0 ] = 0x0000;
6391 ausWriteData[ 1 ] = 0x0000;
6392 ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_HEAD_NODE & 0x7FF); /* Head node. */
6393 ausWriteData[ 3 ] = 0x0000;
6394
6395 mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
6396 if ( ulResult != cOCT6100_ERR_OK )
6397 return ulResult;
6398 }
6399
6400 return cOCT6100_ERR_OK;
6401 }
6402 #endif
6403
6404
6405 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6406
6407 Function: Oct6100ApiInitRecordResources
6408
6409 Description: This function will initialize the resources required to
6410 perform recording on a debug channel.
6411
6412 -------------------------------------------------------------------------------
6413 | Argument | Description
6414 -------------------------------------------------------------------------------
6415 f_pApiInstance Pointer to API instance. This memory is used to keep the
6416 present state of the chip and all its resources.
6417
6418 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6419 #if !SKIP_Oct6100ApiInitRecordResources
6420 UINT32 Oct6100ApiInitRecordResources(
6421 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
6422 {
6423 tPOCT6100_SHARED_INFO pSharedInfo;
6424 UINT32 ulResult;
6425
6426 pSharedInfo = f_pApiInstance->pSharedInfo;
6427
6428 /* Check if recording is enabled. */
6429 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
6430 return cOCT6100_ERR_OK;
6431
6432 if ( pSharedInfo->DebugInfo.usRecordMemIndex == cOCT6100_INVALID_INDEX )
6433 return cOCT6100_ERR_NOT_SUPPORTED_OPEN_DEBUG_RECORD;
6434
6435 /* Check the provided recording memory index within the SSPX. */
6436 if ( pSharedInfo->DebugInfo.usRecordMemIndex != ( pSharedInfo->ImageInfo.usMaxNumberOfChannels - 1 ) )
6437 return cOCT6100_ERR_OPEN_DEBUG_MEM_INDEX;
6438
6439 /* Reserve the TSI entries for the channel. */
6440 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex );
6441 if ( ulResult != cOCT6100_ERR_OK )
6442 return ulResult;
6443
6444 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
6445 if ( ulResult != cOCT6100_ERR_OK )
6446 return ulResult;
6447
6448 /* Open the debug channel. */
6449 ulResult = Oct6100ApiDebugChannelOpen( f_pApiInstance );
6450 if ( ulResult != cOCT6100_ERR_OK )
6451 return ulResult;
6452
6453 return cOCT6100_ERR_OK;
6454 }
6455 #endif
6456
6457
6458 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6459
6460 Function: Oct6100FreeResourcesSer
6461
6462 Description: This function closes all opened channels and frees all
6463 specified global resources used by the chip.
6464
6465 -------------------------------------------------------------------------------
6466 | Argument | Description
6467 -------------------------------------------------------------------------------
6468 f_pApiInstance Pointer to API instance. This memory is used to keep
6469 the present state of the chip and all its resources.
6470
6471 f_pFreeResources Pointer to user structure in which to choose what
6472 to free.
6473
6474 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6475 #if !SKIP_Oct6100FreeResourcesSer
6476 UINT32 Oct6100FreeResourcesSer(
6477 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
6478 IN tPOCT6100_FREE_RESOURCES f_pFreeResources )
6479 {
6480 tPOCT6100_SHARED_INFO pSharedInfo;
6481 tPOCT6100_API_CHANNEL pChanEntry;
6482
6483 UINT32 ulResult;
6484 UINT32 i;
6485
6486 /* Obtain local pointer to shared portion of instance. */
6487 pSharedInfo = f_pApiInstance->pSharedInfo;
6488
6489 /* Close all bidirectional channels. */
6490 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxBiDirChannels; i ++ )
6491 {
6492 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
6493
6494 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, i );
6495
6496 if ( pBiDirChanEntry->fReserved == TRUE )
6497 {
6498 tOCT6100_CHANNEL_DESTROY_BIDIR DestroyBidir;
6499
6500 Oct6100ChannelDestroyBiDirDef( &DestroyBidir );
6501
6502 DestroyBidir.ulBiDirChannelHndl = cOCT6100_HNDL_TAG_BIDIR_CHANNEL | (pBiDirChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6503
6504 ulResult = Oct6100ChannelDestroyBiDirSer( f_pApiInstance, &DestroyBidir );
6505 if ( ulResult != cOCT6100_ERR_OK )
6506 return ulResult;
6507 }
6508 }
6509
6510 /* Close all bridge participants. */
6511 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i ++ )
6512 {
6513 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, i );
6514 if ( pChanEntry->fReserved == TRUE && pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
6515 {
6516 /* This channel is on a bridge. */
6517 tOCT6100_CONF_BRIDGE_CHAN_REMOVE BridgeChanRemove;
6518 tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
6519
6520 Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
6521
6522 /* Obtain a pointer to the conference bridge's list entry. */
6523 mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, pChanEntry->usBridgeIndex );
6524
6525 BridgeChanRemove.fRemoveAll = TRUE;
6526 BridgeChanRemove.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pBridgeEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pChanEntry->usBridgeIndex;
6527
6528 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
6529 if ( ulResult != cOCT6100_ERR_OK )
6530 return ulResult;
6531 }
6532 }
6533
6534 /* Close all opened channels. This will bring the broadcast TSSTs with it. */
6535 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i ++ )
6536 {
6537 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, i );
6538
6539 if ( pChanEntry->fReserved == TRUE )
6540 {
6541 tOCT6100_CHANNEL_CLOSE ChannelClose;
6542
6543 /* Generate handle. */
6544 ChannelClose.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6545
6546 /* Call serialized close channel function. */
6547 ulResult = Oct6100ChannelCloseSer( f_pApiInstance, &ChannelClose );
6548 if ( ulResult != cOCT6100_ERR_OK )
6549 return ulResult;
6550 }
6551 }
6552 /* Close all TSI connections. */
6553 if ( f_pFreeResources->fFreeTsiConnections == TRUE )
6554 {
6555 tPOCT6100_API_TSI_CNCT pTsiCnct;
6556 tOCT6100_TSI_CNCT_CLOSE TsiCnctClose;
6557
6558 Oct6100TsiCnctCloseDef( &TsiCnctClose );
6559
6560 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxTsiCncts; i ++ )
6561 {
6562 /* Obtain a pointer to the TSI connection list entry. */
6563 mOCT6100_GET_TSI_CNCT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsiCnct, i );
6564
6565 if ( pTsiCnct->fReserved == TRUE )
6566 {
6567 TsiCnctClose.ulTsiCnctHndl = cOCT6100_HNDL_TAG_TSI_CNCT | (pTsiCnct->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6568
6569 ulResult = Oct6100TsiCnctCloseSer( f_pApiInstance, &TsiCnctClose );
6570 if ( ulResult != cOCT6100_ERR_OK )
6571 return ulResult;
6572 }
6573 }
6574 }
6575 /* Close all conference bridges. */
6576 if ( f_pFreeResources->fFreeConferenceBridges == TRUE )
6577 {
6578 tPOCT6100_API_CONF_BRIDGE pConfBridge;
6579 tOCT6100_CONF_BRIDGE_CLOSE ConfBridgeClose;
6580
6581 Oct6100ConfBridgeCloseDef( &ConfBridgeClose );
6582
6583 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxConfBridges; i ++ )
6584 {
6585 /* Obtain a pointer to the conference bridge's list entry. */
6586 mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pConfBridge, i );
6587
6588 if ( pConfBridge->fReserved == TRUE )
6589 {
6590 ConfBridgeClose.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pConfBridge->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6591
6592 ulResult = Oct6100ConfBridgeCloseSer( f_pApiInstance, &ConfBridgeClose );
6593 if ( ulResult != cOCT6100_ERR_OK )
6594 return ulResult;
6595 }
6596 }
6597 }
6598
6599 /* Free all playout buffers loaded in external memory. */
6600 if ( f_pFreeResources->fFreePlayoutBuffers == TRUE )
6601 {
6602 tPOCT6100_API_BUFFER pBuffer;
6603 tOCT6100_BUFFER_UNLOAD BufferUnload;
6604
6605 Oct6100BufferPlayoutUnloadDef( &BufferUnload );
6606
6607 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxPlayoutBuffers; i ++ )
6608 {
6609
6610
6611 /* Obtain a pointer to the buffer list entry. */
6612 mOCT6100_GET_BUFFER_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBuffer, i );
6613
6614 if ( pBuffer->fReserved == TRUE )
6615 {
6616 BufferUnload.ulBufferIndex = i;
6617 ulResult = Oct6100BufferUnloadSer( f_pApiInstance, &BufferUnload, TRUE );
6618 if ( ulResult != cOCT6100_ERR_OK )
6619 return ulResult;
6620 }
6621 }
6622 }
6623
6624 /* Close all phasing TSSTs. */
6625 if ( f_pFreeResources->fFreePhasingTssts == TRUE )
6626 {
6627 tPOCT6100_API_PHASING_TSST pPhasingTsst;
6628 tOCT6100_PHASING_TSST_CLOSE PhasingTsstClose;
6629
6630 Oct6100PhasingTsstCloseDef( &PhasingTsstClose );
6631
6632 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxPhasingTssts; i ++ )
6633 {
6634 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, i );
6635
6636 if ( pPhasingTsst->fReserved == TRUE )
6637 {
6638 PhasingTsstClose.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsst->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6639
6640 ulResult = Oct6100PhasingTsstCloseSer( f_pApiInstance, &PhasingTsstClose );
6641 if ( ulResult != cOCT6100_ERR_OK )
6642 return ulResult;
6643 }
6644 }
6645 }
6646 /* Close all ADPCM channels. */
6647 if ( f_pFreeResources->fFreeAdpcmChannels == TRUE )
6648 {
6649 tPOCT6100_API_ADPCM_CHAN pAdpcmChannel;
6650 tOCT6100_ADPCM_CHAN_CLOSE AdpcmChanClose;
6651
6652 Oct6100AdpcmChanCloseDef( &AdpcmChanClose );
6653
6654 for ( i = 0; i < pSharedInfo->ChipConfig.usMaxAdpcmChannels; i ++ )
6655 {
6656 mOCT6100_GET_ADPCM_CHAN_ENTRY_PNT( pSharedInfo, pAdpcmChannel, i );
6657 if ( pAdpcmChannel->fReserved == TRUE )
6658 {
6659 AdpcmChanClose.ulChanHndl = cOCT6100_HNDL_TAG_ADPCM_CHANNEL | (pAdpcmChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | i;
6660
6661 ulResult = Oct6100AdpcmChanCloseSer( f_pApiInstance, &AdpcmChanClose );
6662 if ( ulResult != cOCT6100_ERR_OK )
6663 return ulResult;
6664 }
6665 }
6666 }
6667
6668 return cOCT6100_ERR_OK;
6669 }
6670 #endif
6671
6672
6673 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6674
6675 Function: Oct6100ProductionBistSer
6676
6677 Description: This function returns the instantaneous production BIST status.
6678
6679 -------------------------------------------------------------------------------
6680 | Argument | Description
6681 -------------------------------------------------------------------------------
6682 f_pApiInstance Pointer to API instance. This memory is used to keep
6683 the present state of the chip and all its resources.
6684
6685 f_pProductionBist Pointer to user structure in which BIST status will
6686 be returned.
6687
6688 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6689 #if !SKIP_Oct6100ProductionBistSer
6690 UINT32 Oct6100ProductionBistSer(
6691 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
6692 IN OUT tPOCT6100_PRODUCTION_BIST f_pProductionBist )
6693 {
6694 UINT32 ulCalculatedCrc = cOCT6100_INVALID_VALUE;
6695 UINT32 ulResult;
6696 UINT32 ulLoopCnt = 0x0;
6697 UINT32 i = 1;
6698 UINT32 ulTotalElements = 4;
6699 UINT32 ulReadAddress = cOCT6100_POUCH_BASE;
6700 UINT32 aulMessage[ 5 ];
6701
6702 /* Check if the production bist has been activated. */
6703 if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableProductionBist == FALSE )
6704 return cOCT6100_ERR_PRODUCTION_BIST_DISABLED;
6705
6706 f_pProductionBist->ulCurrentAddress = cOCT6100_INVALID_VALUE;
6707 f_pProductionBist->ulCurrentLoop = cOCT6100_INVALID_VALUE;
6708 f_pProductionBist->ulCurrentTest = cOCT6100_INVALID_VALUE;
6709 f_pProductionBist->ulFailedAddress = cOCT6100_INVALID_VALUE;
6710 f_pProductionBist->ulReadValue = cOCT6100_INVALID_VALUE;
6711 f_pProductionBist->ulExpectedValue = cOCT6100_INVALID_VALUE;
6712 f_pProductionBist->ulBistStatus = cOCT6100_BIST_IN_PROGRESS;
6713
6714 /* The API knows that the firmware might be writing a status event. */
6715 /* The firmware does write a status event every 200ms (approximately). */
6716 /* So the status is read a couple of times to make sure an event was not read while */
6717 /* it was written. */
6718 while ( ulLoopCnt != 2 )
6719 {
6720 /* Read the BIST status in the external memory. */
6721 for ( i = 0; i < ulTotalElements + 1; i ++ )
6722 {
6723 ulResult = Oct6100ApiReadDword( f_pApiInstance, ulReadAddress + i * 4, &aulMessage[ i ] );
6724 if ( ulResult != cOCT6100_ERR_OK )
6725 return ulResult;
6726 }
6727
6728 /* Calculate the CRC of this message. */
6729 ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCalculatedCrc );
6730 if ( ulResult != cOCT6100_ERR_OK )
6731 return ulResult;
6732
6733 /* If the CRCs do match, break off the while. We have a valid status event. */
6734 if ( aulMessage[ i - 1 ] == ulCalculatedCrc )
6735 break;
6736
6737 ulLoopCnt++;
6738 }
6739
6740 /* Check if the CRC matches */
6741 if ( aulMessage[ i - 1 ] != ulCalculatedCrc )
6742 {
6743 /* Well, the exchange memory at the base of the external memory is corrupted. */
6744 /* Something very basic is not working correctly with this chip! */
6745 f_pProductionBist->ulBistStatus = cOCT6100_BIST_STATUS_CRC_FAILED;
6746 }
6747 else
6748 {
6749 /* Check for problems. */
6750 switch ( aulMessage[ 0 ] & 0xFFFF )
6751 {
6752 case ( 0x2 ):
6753
6754 /* The initial configuration failed. */
6755 f_pProductionBist->ulBistStatus = cOCT6100_BIST_CONFIGURATION_FAILED;
6756 break;
6757
6758 case ( 0x1 ):
6759
6760 /* A memory location failed. Return useful information to the user. */
6761 f_pProductionBist->ulBistStatus = cOCT6100_BIST_MEMORY_FAILED;
6762
6763 f_pProductionBist->ulFailedAddress = ( aulMessage[ 1 ] & ( ~0x80000000 ) ) + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6764 f_pProductionBist->ulReadValue = aulMessage[ 2 ];
6765 f_pProductionBist->ulExpectedValue = aulMessage[ 3 ];
6766 break;
6767
6768 case ( 0xFFFF ):
6769
6770 /* Bist is completed! */
6771 f_pProductionBist->ulBistStatus = cOCT6100_BIST_SUCCESS;
6772 break;
6773
6774 default:
6775 /* Bist is in progress. All seems to be working fine up to now. */
6776
6777 /* Return progress status. */
6778 f_pProductionBist->ulCurrentAddress = ( aulMessage[ 1 ] & ( ~0x80000000 ) ) + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
6779 f_pProductionBist->ulCurrentTest = aulMessage[ 2 ];
6780 f_pProductionBist->ulCurrentLoop = aulMessage[ 3 ];
6781 break;
6782 }
6783 }
6784
6785 return cOCT6100_ERR_OK;
6786 }
6787 #endif
6788
6789
6790 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6791
6792 Function: Oct6100ApiProductionCrc
6793
6794 Description: This function calculates the crc for a production BIST
6795 message.
6796
6797 -------------------------------------------------------------------------------
6798 | Argument | Description
6799 -------------------------------------------------------------------------------
6800 f_pApiInstance Pointer to API instance. This memory is used to keep
6801 the present state of the chip and all its resources.
6802
6803 f_pulMessage Message to be exchanged with the firmware. The CRC
6804 will be calculated on this.
6805 f_ulMessageLength Length of the message to be exchanged. This value
6806 does not include the CRC value at the end
6807 f_pulCrcResult Resulting calculated CRC value.
6808
6809 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6810 #if !SKIP_Oct6100ApiProductionCrc
6811 UINT32 Oct6100ApiProductionCrc(
6812 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
6813 IN PUINT32 f_pulMessage,
6814 IN UINT32 f_ulMessageLength,
6815 OUT PUINT32 f_pulCrcResult )
6816 {
6817 UINT32 ulWidth = 32;
6818 UINT32 ulKey, i, j;
6819 UINT32 ulRemainder = 0;
6820
6821 /* CRC the message. */
6822 ulRemainder = f_pulMessage[ f_ulMessageLength - 1 ];
6823 for ( j = f_ulMessageLength - 1; j != 0xFFFFFFFF ; j-- )
6824 {
6825 for ( i = 0; i < ulWidth; i++ )
6826 {
6827 if ( ( ( ulRemainder >> 0x1F ) & 0x1 ) == 0x1 )
6828 {
6829 /* Division is by something meaningful */
6830 ulKey = 0x8765DCBA;
6831 }
6832 else
6833 {
6834 /* Remainder is less than our divisor */
6835 ulKey = 0;
6836 }
6837 ulRemainder = ulRemainder ^ ulKey;
6838
6839 ulRemainder = ulRemainder << 1;
6840 if ( j != 0 )
6841 {
6842 ulRemainder = ulRemainder | ( ( f_pulMessage[ j - 1 ] ) >> ( 0x1F - i ) );
6843 }
6844 }
6845 }
6846
6847 *f_pulCrcResult = ulRemainder;
6848
6849 return cOCT6100_ERR_OK;
6850 }
6851 #endif
6852
6853 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6854
6855 Function: Oct6100ApiClearInterrupts
6856
6857 Description: Called only by the Oct6100OpenChip function, this function
6858 writes to all register ROLs to clear them. This is necessary
6859 because some ROLs are set during the startup.
6860
6861 -------------------------------------------------------------------------------
6862 | Argument | Description
6863 -------------------------------------------------------------------------------
6864 IN f_pApiInst Pointer to API instance. This memory is used to keep the
6865 present state of the chip and all its resources.
6866
6867 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6868 #if !SKIP_Oct6100ApiClearInterrupts
6869 UINT32 Oct6100ApiClearInterrupts(
6870 IN tPOCT6100_INSTANCE_API f_pApiInstance )
6871 {
6872 tPOCT6100_SHARED_INFO pSharedInfo;
6873 tOCT6100_WRITE_PARAMS WriteParams;
6874 UINT32 ulResult;
6875
6876 /* Get local pointer to shared portion of instance. */
6877 pSharedInfo = f_pApiInstance->pSharedInfo;
6878
6879 /* Set the process context and user chip ID parameters once and for all. */
6880 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6881
6882 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6883
6884 WriteParams.ulWriteAddress = 0x102;
6885 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_102H;
6886 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6887 if ( ulResult != cOCT6100_ERR_OK )
6888 return ulResult;
6889
6890 WriteParams.ulWriteAddress = 0x202;
6891 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_202H;
6892 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6893 if ( ulResult != cOCT6100_ERR_OK )
6894 return ulResult;
6895
6896 WriteParams.ulWriteAddress = 0x302;
6897 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_302H;
6898 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6899 if ( ulResult != cOCT6100_ERR_OK )
6900 return ulResult;
6901
6902 WriteParams.ulWriteAddress = 0x502;
6903 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_502H;
6904 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6905 if ( ulResult != cOCT6100_ERR_OK )
6906 return ulResult;
6907
6908 WriteParams.ulWriteAddress = 0x702;
6909 WriteParams.usWriteData = cOCT6100_INTRPT_MASK_REG_702H;
6910 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
6911 if ( ulResult != cOCT6100_ERR_OK )
6912 return ulResult;
6913
6914 return cOCT6100_ERR_OK;
6915
6916 }
6917 #endif