1 /*******************************************************************************
2 *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
4 *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5 *that the following conditions are met:
6 *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8 *2. Redistributions in binary form must reproduce the above copyright notice,
9 *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10 *with the distribution.
12 *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16 *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
21 ********************************************************************************/
22 /*******************************************************************************/
24 * \brief The file implements the functions to initialize the LL layer
27 /******************************************************************************/
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
30 #include <dev/pms/config.h>
32 #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
33 #ifdef SA_ENABLE_TRACE_FUNCTIONS
37 #define siTraceFileID 'F'
40 bit32 gLLDebugLevel = 3;
42 #if defined(SALLSDK_DEBUG)
43 bit32 gLLDebugLevelSet = 0; // block reinitialize from updating
44 bit32 gLLLogFuncDebugLevel = 0;
45 bit32 gLLSoftResetCounter = 0;
48 bit32 gPollForMissingInt;
51 void *eventLogAddress = 0;
56 bit32 gFPGA_TEST = 0; // If set unblock fpga functions
58 /******************************************************************************/
59 /*! \brief Get the memory and lock requirement from LL layer
61 * Get the memory and lock requirement from LL layer
63 * \param agRoot Handles for this instance of SAS/SATA hardware
64 * \param swConfig Pointer to the software configuration
65 * \param memoryRequirement Point to the data structure that holds the different
66 * chunks of memory that are required
67 * \param usecsPerTick micro-seconds per tick for the LL layer
68 * \param maxNumLocks maximum number of locks for the LL layer
73 /*******************************************************************************/
74 GLOBAL void saGetRequirements(
76 agsaSwConfig_t *swConfig,
77 agsaMemoryRequirement_t *memoryRequirement,
82 bit32 memoryReqCount = 0;
84 static mpiConfig_t mpiConfig;
85 static mpiMemReq_t mpiMemoryRequirement;
89 SA_ASSERT((agNULL != swConfig), "");
90 SA_ASSERT((agNULL != memoryRequirement), "");
91 SA_ASSERT((agNULL != usecsPerTick), "");
92 SA_ASSERT((agNULL != maxNumLocks), "");
94 si_memset(&mpiMemoryRequirement, 0, sizeof(mpiMemReq_t));
95 si_memset(&mpiConfig, 0, sizeof(mpiConfig_t));
97 SA_DBG1(("saGetRequirements:agRoot %p swConfig %p memoryRequirement %p usecsPerTick %p maxNumLocks %p\n",agRoot, swConfig,memoryRequirement,usecsPerTick,maxNumLocks));
98 SA_DBG1(("saGetRequirements: usecsPerTick 0x%x (%d)\n",*usecsPerTick,*usecsPerTick));
100 /* Get Resource Requirements for SPC MPI */
101 /* Set the default/specified requirements swConfig from TD layer */
102 siConfiguration(agRoot, &mpiConfig, agNULL, swConfig);
103 mpiRequirementsGet(&mpiConfig, &mpiMemoryRequirement);
105 /* memory requirement for saRoot, CACHE memory */
106 memoryRequirement->agMemory[LLROOT_MEM_INDEX].singleElementLength = sizeof(agsaLLRoot_t);
107 memoryRequirement->agMemory[LLROOT_MEM_INDEX].numElements = 1;
108 memoryRequirement->agMemory[LLROOT_MEM_INDEX].totalLength = sizeof(agsaLLRoot_t);
109 memoryRequirement->agMemory[LLROOT_MEM_INDEX].alignment = sizeof(void *);
110 memoryRequirement->agMemory[LLROOT_MEM_INDEX].type = AGSA_CACHED_MEM;
113 SA_DBG1(("saGetRequirements: agMemory[LLROOT_MEM_INDEX] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
114 memoryRequirement->agMemory[LLROOT_MEM_INDEX].singleElementLength,
115 memoryRequirement->agMemory[LLROOT_MEM_INDEX].totalLength,
116 memoryRequirement->agMemory[LLROOT_MEM_INDEX].alignment,
117 memoryRequirement->agMemory[LLROOT_MEM_INDEX].type ));
119 /* memory requirement for Device Links, CACHE memory */
120 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].singleElementLength = sizeof(agsaDeviceDesc_t);
121 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].numElements = swConfig->numDevHandles;
122 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].totalLength = sizeof(agsaDeviceDesc_t)
123 * swConfig->numDevHandles;
124 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].alignment = sizeof(void *);
125 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].type = AGSA_CACHED_MEM;
127 SA_DBG1(("saGetRequirements: agMemory[DEVICELINK_MEM_INDEX] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
128 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].singleElementLength,
129 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].totalLength,
130 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].alignment,
131 memoryRequirement->agMemory[DEVICELINK_MEM_INDEX].type ));
133 /* memory requirement for IORequest Links, CACHE memory */
134 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].singleElementLength = sizeof(agsaIORequestDesc_t);
136 Add SA_RESERVED_REQUEST_COUNT to guarantee quality of service
138 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].numElements = swConfig->maxActiveIOs + SA_RESERVED_REQUEST_COUNT;
139 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].totalLength = sizeof(agsaIORequestDesc_t) *
140 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].numElements;
141 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].alignment = sizeof(void *);
142 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].type = AGSA_CACHED_MEM;
145 SA_DBG1(("saGetRequirements: agMemory[IOREQLINK_MEM_INDEX] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
146 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].singleElementLength,
147 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].totalLength,
148 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].alignment,
149 memoryRequirement->agMemory[IOREQLINK_MEM_INDEX].type ));
151 /* memory requirement for Timer Links, CACHE memory */
152 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].singleElementLength = sizeof(agsaTimerDesc_t);
153 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].numElements = NUM_TIMERS;
154 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].totalLength = sizeof(agsaTimerDesc_t) * NUM_TIMERS;
155 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].alignment = sizeof(void *);
156 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].type = AGSA_CACHED_MEM;
158 SA_DBG1(("saGetRequirements: agMemory[TIMERLINK_MEM_INDEX] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
159 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].singleElementLength,
160 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].totalLength,
161 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].alignment,
162 memoryRequirement->agMemory[TIMERLINK_MEM_INDEX].type ));
164 #ifdef SA_ENABLE_TRACE_FUNCTIONS
166 /* memory requirement for LL trace memory */
167 memoryRequirement->agMemory[LL_FUNCTION_TRACE].singleElementLength = 1;
168 memoryRequirement->agMemory[LL_FUNCTION_TRACE].numElements = swConfig->TraceBufferSize;
169 memoryRequirement->agMemory[LL_FUNCTION_TRACE].totalLength = swConfig->TraceBufferSize;
170 memoryRequirement->agMemory[LL_FUNCTION_TRACE].alignment = sizeof(void *);
171 memoryRequirement->agMemory[LL_FUNCTION_TRACE].type = AGSA_CACHED_MEM;
174 SA_DBG1(("saGetRequirements: agMemory[LL_FUNCTION_TRACE] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
175 memoryRequirement->agMemory[LL_FUNCTION_TRACE].singleElementLength,
176 memoryRequirement->agMemory[LL_FUNCTION_TRACE].totalLength,
177 memoryRequirement->agMemory[LL_FUNCTION_TRACE].alignment,
178 memoryRequirement->agMemory[LL_FUNCTION_TRACE].type ));
180 #endif /* END SA_ENABLE_TRACE_FUNCTIONS */
184 agsaMem_t *agMemory = memoryRequirement->agMemory;
186 /* memory requirement for Super IO CACHE memory */
187 agMemory[LL_FAST_IO].singleElementLength = sizeof(saFastRequest_t);
188 agMemory[LL_FAST_IO].numElements = LL_FAST_IO_SIZE;
189 agMemory[LL_FAST_IO].totalLength = LL_FAST_IO_SIZE *
190 agMemory[LL_FAST_IO].singleElementLength;
191 agMemory[LL_FAST_IO].alignment = sizeof(void*);
192 agMemory[LL_FAST_IO].type = AGSA_CACHED_MEM;
195 SA_DBG1(("saGetRequirements: agMemory[LL_FAST_IO] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
196 memoryRequirement->agMemory[LL_FAST_IO].singleElementLength,
197 memoryRequirement->agMemory[LL_FAST_IO].totalLength,
198 memoryRequirement->agMemory[LL_FAST_IO].alignment,
199 memoryRequirement->agMemory[LL_FAST_IO].type ));
204 #ifdef SA_ENABLE_HDA_FUNCTIONS
206 agsaMem_t *agMemory = memoryRequirement->agMemory;
208 /* memory requirement for HDA FW image */
209 agMemory[HDA_DMA_BUFFER].singleElementLength = (1024 * 1024); /* must be greater than size of aap1 fw image */
210 agMemory[HDA_DMA_BUFFER].numElements = 1;
211 agMemory[HDA_DMA_BUFFER].totalLength = agMemory[HDA_DMA_BUFFER].numElements *
212 agMemory[HDA_DMA_BUFFER].singleElementLength;
213 agMemory[HDA_DMA_BUFFER].alignment = 32;
214 agMemory[HDA_DMA_BUFFER].type = AGSA_DMA_MEM;
216 SA_DBG1(("saGetRequirements: agMemory[HDA_DMA_BUFFER] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
217 memoryRequirement->agMemory[HDA_DMA_BUFFER].singleElementLength,
218 memoryRequirement->agMemory[HDA_DMA_BUFFER].totalLength,
219 memoryRequirement->agMemory[HDA_DMA_BUFFER].alignment,
220 memoryRequirement->agMemory[HDA_DMA_BUFFER].type ));
222 #endif /* SA_ENABLE_HDA_FUNCTIONS */
224 /* memory requirement for MPI MSGU layer, DMA memory */
225 for ( i = 0; i < mpiMemoryRequirement.count; i ++ )
227 memoryRequirement->agMemory[memoryReqCount].singleElementLength = mpiMemoryRequirement.region[i].elementSize;
228 memoryRequirement->agMemory[memoryReqCount].numElements = mpiMemoryRequirement.region[i].numElements;
229 memoryRequirement->agMemory[memoryReqCount].totalLength = mpiMemoryRequirement.region[i].totalLength;
230 memoryRequirement->agMemory[memoryReqCount].alignment = mpiMemoryRequirement.region[i].alignment;
231 memoryRequirement->agMemory[memoryReqCount].type = mpiMemoryRequirement.region[i].type;
232 SA_DBG1(("saGetRequirements:MPI agMemory[%d] singleElementLength = 0x%x totalLength = 0x%x align = 0x%x type %x\n",
234 memoryRequirement->agMemory[memoryReqCount].singleElementLength,
235 memoryRequirement->agMemory[memoryReqCount].totalLength,
236 memoryRequirement->agMemory[memoryReqCount].alignment,
237 memoryRequirement->agMemory[memoryReqCount].type ));
242 /* requirement for locks */
243 if (swConfig->param3 == agNULL)
245 *maxNumLocks = (LL_IOREQ_IBQ_LOCK + AGSA_MAX_INBOUND_Q );
246 SA_DBG1(("saGetRequirements: param3 == agNULL maxNumLocks %d\n", *maxNumLocks ));
250 agsaQueueConfig_t *queueConfig;
251 queueConfig = (agsaQueueConfig_t *)swConfig->param3;
252 *maxNumLocks = (LL_IOREQ_IBQ_LOCK_PARM + queueConfig->numInboundQueues );
253 SA_DBG1(("saGetRequirements: maxNumLocks %d\n", *maxNumLocks ));
257 /* setup the time tick */
258 *usecsPerTick = SA_USECS_PER_TICK;
260 SA_ASSERT(memoryReqCount < AGSA_NUM_MEM_CHUNKS, "saGetRequirements: Exceed max number of memory place holder");
262 /* set up memory requirement count */
263 memoryRequirement->count = memoryReqCount;
265 swConfig->legacyInt_X = 1;
266 swConfig->max_MSI_InterruptVectors = 32;
267 swConfig->max_MSIX_InterruptVectors = 64;//16;
269 SA_DBG1(("saGetRequirements: swConfig->stallUsec %d\n",swConfig->stallUsec ));
271 #ifdef SA_CONFIG_MDFD_REGISTRY
272 SA_DBG1(("saGetRequirements: swConfig->disableMDF %d\n",swConfig->disableMDF));
273 #endif /*SA_CONFIG_MDFD_REGISTRY*/
274 /*SA_DBG1(("saGetRequirements: swConfig->enableDIF %d\n",swConfig->enableDIF ));*/
275 /*SA_DBG1(("saGetRequirements: swConfig->enableEncryption %d\n",swConfig->enableEncryption ));*/
276 #ifdef SA_ENABLE_HDA_FUNCTIONS
277 swConfig->hostDirectAccessSupport = 1;
278 swConfig->hostDirectAccessMode = 0;
280 swConfig->hostDirectAccessSupport = 0;
281 swConfig->hostDirectAccessMode = 0;
286 /******************************************************************************/
287 /*! \brief Initialize the Hardware
289 * Initialize the Hardware
291 * \param agRoot Handles for this instance of SAS/SATA hardware
292 * \param memoryAllocated Point to the data structure that holds the different
293 chunks of memory that are required
294 * \param hwConfig Pointer to the hardware configuration
295 * \param swConfig Pointer to the software configuration
296 * \param usecsPerTick micro-seconds per tick for the LL layer
298 * \return If initialization is successful
299 * - \e AGSA_RC_SUCCESS initialization is successful
300 * - \e AGSA_RC_FAILURE initialization is not successful
302 /*******************************************************************************/
303 GLOBAL bit32 saInitialize(
305 agsaMemoryRequirement_t *memoryAllocated,
306 agsaHwConfig_t *hwConfig,
307 agsaSwConfig_t *swConfig,
311 agsaLLRoot_t *saRoot;
312 agsaDeviceDesc_t *pDeviceDesc;
313 agsaIORequestDesc_t *pRequestDesc;
314 agsaTimerDesc_t *pTimerDesc;
316 agsaPortMap_t *pPortMap;
317 agsaDeviceMap_t *pDeviceMap;
319 bit32 maxNumIODevices;
321 static mpiMemReq_t mpiMemoryAllocated;
322 bit32 Tried_NO_HDA = agFALSE;
323 bit32 Double_Reset_HDA = agFALSE;
324 bit32 ret = AGSA_RC_SUCCESS;
326 void *fr; /* saFastRequest_t */
332 SA_ASSERT((agNULL != agRoot), "");
333 SA_ASSERT((agNULL != memoryAllocated), "");
334 SA_ASSERT((agNULL != hwConfig), "");
335 SA_ASSERT((agNULL != swConfig), "");
336 SA_ASSERT((LLROOT_MEM_INDEX < memoryAllocated->count), "");
337 SA_ASSERT((DEVICELINK_MEM_INDEX < memoryAllocated->count), "");
338 SA_ASSERT((IOREQLINK_MEM_INDEX < memoryAllocated->count), "");
339 SA_ASSERT((TIMERLINK_MEM_INDEX < memoryAllocated->count), "");
341 si_memset(&mpiMemoryAllocated, 0, sizeof(mpiMemReq_t));
343 si_macro_check(agRoot);
345 SA_DBG1(("saInitialize: WAIT_INCREMENT %d\n", WAIT_INCREMENT ));
346 SA_DBG1(("saInitialize: usecsPerTick %d\n", usecsPerTick ));
347 if(! smIS_SPC(agRoot))
349 if(! smIS_SPCV(agRoot))
351 SA_DBG1(("saInitialize: ossaHwRegReadConfig32 ID reads as %08X\n", ossaHwRegReadConfig32(agRoot,0 ) ));
352 SA_DBG1(("saInitialize: expect %08X or %08X or\n", VEN_DEV_SPCV, VEN_DEV_SPCVE));
353 SA_DBG1(("saInitialize: expect %08X or %08X or\n", VEN_DEV_SPCVP, VEN_DEV_SPCVEP));
354 SA_DBG1(("saInitialize: expect %08X or %08X\n", VEN_DEV_ADAPVEP, VEN_DEV_ADAPVP));
355 return AGSA_RC_FAILURE;
359 if( smIS_SPC(agRoot) && smIS_SPCV(agRoot))
361 SA_DBG1(("saInitialize: Macro error !smIS_SPC %d smIS_SPCv %d smIS_SFC %d\n",smIS_SPC(agRoot),smIS_SPCV(agRoot), smIS_SFC(agRoot) ));
362 return AGSA_RC_FAILURE;
365 /* Check the memory allocated */
366 for ( i = 0; i < memoryAllocated->count; i ++ )
368 /* If memory allocation failed */
369 if (memoryAllocated->agMemory[i].singleElementLength &&
370 memoryAllocated->agMemory[i].numElements)
372 if ( (0 != memoryAllocated->agMemory[i].numElements)
373 && (0 == memoryAllocated->agMemory[i].totalLength) )
376 SA_DBG1(("saInitialize:AGSA_RC_FAILURE Memory[%d] singleElementLength = 0x%x numElements = 0x%x NOT allocated\n",
378 memoryAllocated->agMemory[i].singleElementLength,
379 memoryAllocated->agMemory[i].numElements));
380 ret = AGSA_RC_FAILURE;
385 SA_DBG1(("saInitialize: Memory[%d] singleElementLength = 0x%x numElements = 0x%x allocated %p\n",
387 memoryAllocated->agMemory[i].singleElementLength,
388 memoryAllocated->agMemory[i].numElements,
389 memoryAllocated->agMemory[i].virtPtr));
394 /* Get the saRoot memory address */
395 saRoot = (agsaLLRoot_t *) (memoryAllocated->agMemory[LLROOT_MEM_INDEX].virtPtr);
396 SA_ASSERT((agNULL != saRoot), "saRoot");
399 SA_DBG1(("saInitialize:AGSA_RC_FAILURE saRoot\n"));
400 return AGSA_RC_FAILURE;
403 agRoot->sdkData = (void *) saRoot;
405 SA_DBG1(("saInitialize: saRoot %p\n",saRoot));
407 if ( (memoryAllocated != &saRoot->memoryAllocated) ||
408 (hwConfig != &saRoot->hwConfig) ||
409 (swConfig != &saRoot->swConfig) )
411 agsaMemoryRequirement_t *memA = &saRoot->memoryAllocated;
412 agsaHwConfig_t *hwC = &saRoot->hwConfig;
413 agsaSwConfig_t *swC = &saRoot->swConfig;
417 *memA = *memoryAllocated;
423 #if defined(SALLSDK_DEBUG)
424 if(gLLDebugLevelSet == 0)
426 gLLDebugLevelSet = 1;
427 gLLDebugLevel = swConfig->sallDebugLevel & 0xF;
428 SA_DBG1(("saInitialize: gLLDebugLevel %x\n",gLLDebugLevel));
430 #endif /* SALLSDK_DEBUG */
432 #ifdef SA_ENABLE_TRACE_FUNCTIONS
434 saRoot->TraceBufferLength = memoryAllocated->agMemory[LL_FUNCTION_TRACE].totalLength;
435 saRoot->TraceBuffer = memoryAllocated->agMemory[LL_FUNCTION_TRACE].virtPtr;
437 siEnableTracing ( agRoot );
441 #endif /* SA_ENABLE_TRACE_FUNCTIONS */
445 agsaMem_t *agMemory = memoryAllocated->agMemory;
447 /* memory requirement for Super IO CACHE memory */
448 size = sizeof(saRoot->freeFastReq) / sizeof(saRoot->freeFastReq[0]);
450 SA_ASSERT(size == agMemory[LL_FAST_IO].numElements, "");
451 SA_ASSERT(agMemory[LL_FAST_IO].virtPtr, "");
452 SA_ASSERT((agMemory[LL_FAST_IO].singleElementLength ==
453 sizeof(saFastRequest_t)) &&
454 (agMemory[LL_FAST_IO].numElements == LL_FAST_IO_SIZE) &&
455 (agMemory[LL_FAST_IO].totalLength == agMemory[LL_FAST_IO].numElements *
456 agMemory[LL_FAST_IO].singleElementLength), "");
458 for (i = 0, alignment = agMemory[LL_FAST_IO].alignment,
459 fr = agMemory[LL_FAST_IO].virtPtr;
461 fr = (void*)((bitptr)fr + (bitptr)(((bit32)sizeof(saFastRequest_t) +
462 alignment - 1) & ~(alignment - 1))))
464 saRoot->freeFastReq[i] = fr;
466 saRoot->freeFastIdx = size;
468 #endif /* FAST_IO_TEST*/
470 smTraceFuncEnter(hpDBG_VERY_LOUD, "m1");
472 SA_DBG1(("saInitialize: swConfig->PortRecoveryResetTimer %x\n",swConfig->PortRecoveryResetTimer ));
474 SA_DBG1(("saInitialize: hwDEVICE_ID_VENDID 0x%08x\n", ossaHwRegReadConfig32(agRoot,0)));
475 SA_DBG1(("saInitialize: CFGSTAT CFGCMD 0x%08x\n", ossaHwRegReadConfig32(agRoot,4)));
476 SA_DBG1(("saInitialize: CLSCODE REVID 0x%08x\n", ossaHwRegReadConfig32(agRoot,8)));
477 SA_DBG1(("saInitialize: BIST DT HDRTYPE LATTIM CLSIZE 0x%08x\n", ossaHwRegReadConfig32(agRoot,12)));
478 SA_DBG1(("saInitialize: hwSVID 0x%08x\n", ossaHwRegReadConfig32(agRoot,44)));
481 #ifdef SA_ENABLE_PCI_TRIGGER
483 SA_DBG1(("saInitialize: SA_ENABLE_PCI_TRIGGER a 0x%08x %p\n", saRoot->swConfig.PCI_trigger,&saRoot->swConfig.PCI_trigger));
485 if( saRoot->swConfig.PCI_trigger & PCI_TRIGGER_INIT_TEST )
487 SA_DBG1(("saInitialize: SA_ENABLE_PCI_TRIGGER 0x%08x %p\n", saRoot->swConfig.PCI_trigger,&saRoot->swConfig.PCI_trigger));
488 saRoot->swConfig.PCI_trigger &= ~PCI_TRIGGER_INIT_TEST;
491 #endif /* SA_ENABLE_PCI_TRIGGER */
494 saRoot->ChipId = (ossaHwRegReadConfig32(agRoot,0) & 0xFFFF0000);
496 SA_DBG1(("saInitialize: saRoot->ChipId 0x%08x\n", saRoot->ChipId));
497 siUpdateBarOffsetTable(agRoot,saRoot->ChipId);
499 if(saRoot->ChipId == VEN_DEV_SPC)
501 if(! smIS_SPC(agRoot))
503 SA_DBG1(("saInitialize: smIS_SPC macro fail !!!!\n" ));
504 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m1");
505 return AGSA_RC_FAILURE;
508 SA_DBG1(("saInitialize: SPC \n" ));
510 else if(saRoot->ChipId == VEN_DEV_HIL )
512 SA_DBG1(("saInitialize: SPC HIL\n" ));
513 if(! smIS_SPC(agRoot))
515 SA_DBG1(("saInitialize: smIS_SPC macro fail !!!!\n" ));
516 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "m1");
517 return AGSA_RC_FAILURE;
520 else if(saRoot->ChipId == VEN_DEV_SPCV)
522 SA_DBG1(("saInitialize: SPC V\n" ));
523 if(! smIS_SPCV(agRoot))
525 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
526 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "m1");
527 return AGSA_RC_FAILURE;
530 else if(saRoot->ChipId == VEN_DEV_SPCVE)
532 SA_DBG1(("saInitialize: SPC VE\n" ));
533 if(! smIS_SPCV(agRoot))
535 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
536 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "m1");
537 return AGSA_RC_FAILURE;
540 else if(saRoot->ChipId == VEN_DEV_SPCVP)
542 SA_DBG1(("saInitialize: SPC VP\n" ));
543 if(! smIS_SPCV(agRoot))
545 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
546 smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "m1");
547 return AGSA_RC_FAILURE;
550 else if(saRoot->ChipId == VEN_DEV_SPCVEP)
552 SA_DBG1(("saInitialize: SPC VEP\n" ));
553 if(! smIS_SPCV(agRoot))
555 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
556 smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "m1");
557 return AGSA_RC_FAILURE;
560 else if(saRoot->ChipId == VEN_DEV_ADAPVP)
562 SA_DBG1(("saInitialize: Adaptec 8088\n" ));
564 else if(saRoot->ChipId == VEN_DEV_ADAPVEP)
566 SA_DBG1(("saInitialize: Adaptec 8089\n" ));
568 else if(saRoot->ChipId == VEN_DEV_SPC12V)
570 SA_DBG1(("saInitialize: SPC 12V\n" ));
571 if(! smIS_SPCV(agRoot))
573 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
574 smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "m1");
575 return AGSA_RC_FAILURE;
578 else if(saRoot->ChipId == VEN_DEV_SPC12VE)
580 SA_DBG1(("saInitialize: SPC 12VE\n" ));
581 if(! smIS_SPCV(agRoot))
583 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
584 smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "m1");
585 return AGSA_RC_FAILURE;
588 else if(saRoot->ChipId == VEN_DEV_SPC12VP)
590 SA_DBG1(("saInitialize: SPC 12VP\n" ));
591 if(! smIS_SPCV(agRoot))
593 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
594 smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "m1");
595 return AGSA_RC_FAILURE;
598 else if(saRoot->ChipId == VEN_DEV_SPC12VEP)
600 SA_DBG1(("saInitialize: SPC 12VEP\n" ));
601 if(! smIS_SPCV(agRoot))
603 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
604 smTraceFuncExit(hpDBG_VERY_LOUD, 'j', "m1");
605 return AGSA_RC_FAILURE;
608 else if(saRoot->ChipId == VEN_DEV_SPC12ADP)
610 SA_DBG1(("saInitialize: SPC 12ADP\n" ));
611 if(! smIS_SPCV(agRoot))
613 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
614 smTraceFuncExit(hpDBG_VERY_LOUD, 'k', "m1");
615 return AGSA_RC_FAILURE;
618 else if(saRoot->ChipId == VEN_DEV_SPC12ADPE)
620 SA_DBG1(("saInitialize: SPC 12ADPE\n" ));
621 if(! smIS_SPCV(agRoot))
623 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
624 smTraceFuncExit(hpDBG_VERY_LOUD, 'l', "m1");
625 return AGSA_RC_FAILURE;
628 else if(saRoot->ChipId == VEN_DEV_SPC12ADPP)
630 SA_DBG1(("saInitialize: SPC 12ADPP\n" ));
631 if(! smIS_SPCV(agRoot))
633 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
634 smTraceFuncExit(hpDBG_VERY_LOUD, 'm', "m1");
635 return AGSA_RC_FAILURE;
638 else if(saRoot->ChipId == VEN_DEV_SPC12ADPEP)
640 SA_DBG1(("saInitialize: SPC 12ADPEP\n" ));
641 if(! smIS_SPCV(agRoot))
643 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
644 smTraceFuncExit(hpDBG_VERY_LOUD, 'n', "m1");
645 return AGSA_RC_FAILURE;
648 else if(saRoot->ChipId == VEN_DEV_SPC12SATA)
650 SA_DBG1(("saInitialize: SPC12SATA\n" ));
651 if(! smIS_SPCV(agRoot))
653 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
654 smTraceFuncExit(hpDBG_VERY_LOUD, 'o', "m1");
655 return AGSA_RC_FAILURE;
658 else if(saRoot->ChipId == VEN_DEV_9015)
660 SA_DBG1(("saInitialize: SPC 12V FPGA\n" ));
661 if(! smIS_SPCV(agRoot))
663 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
664 smTraceFuncExit(hpDBG_VERY_LOUD, 'p', "m1");
665 return AGSA_RC_FAILURE;
668 else if(saRoot->ChipId == VEN_DEV_9060)
670 SA_DBG1(("saInitialize: SPC 12V FPGA B\n" ));
671 if(! smIS_SPCV(agRoot))
673 SA_DBG1(("saInitialize: smIS_SPCV macro fail !!!!\n" ));
674 smTraceFuncExit(hpDBG_VERY_LOUD, 'q', "m1");
675 return AGSA_RC_FAILURE;
678 else if(saRoot->ChipId == VEN_DEV_SFC)
680 SA_DBG1(("saInitialize: SFC \n" ));
684 SA_DBG1(("saInitialize saRoot->ChipId %8X expect %8X or %8X\n", saRoot->ChipId,VEN_DEV_SPC, VEN_DEV_SPCV));
685 SA_ASSERT(0, "ChipId");
686 smTraceFuncExit(hpDBG_VERY_LOUD, 'r', "m1");
687 return AGSA_RC_FAILURE;
690 if( smIS_SPC(agRoot))
692 SA_DBG1(("saInitialize: Rev is A %d B %d C %d\n",smIsCfgSpcREV_A(agRoot),smIsCfgSpcREV_B(agRoot),smIsCfgSpcREV_C(agRoot)));
696 SA_DBG1(("saInitialize: Rev is A %d B %d C %d\n",smIsCfgVREV_A(agRoot),smIsCfgVREV_B(agRoot),smIsCfgVREV_C(agRoot)));
699 if( smIS_SPC(agRoot))
701 SA_DBG1(("saInitialize: LINK_CTRL 0x%08x Speed 0x%X Lanes 0x%X \n", ossaHwRegReadConfig32(agRoot,128),
702 ((ossaHwRegReadConfig32(agRoot,128) & 0x000F0000) >> 16),
703 ((ossaHwRegReadConfig32(agRoot,128) & 0x0FF00000) >> 20) ));
707 SA_DBG1(("saInitialize: LINK_CTRL 0x%08x Speed 0x%X Lanes 0x%X \n", ossaHwRegReadConfig32(agRoot,208),
708 ((ossaHwRegReadConfig32(agRoot,208) & 0x000F0000) >> 16),
709 ((ossaHwRegReadConfig32(agRoot,208) & 0x0FF00000) >> 20) ));
712 SA_DBG1(("saInitialize: V_SoftResetRegister %08X\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_SoftResetRegister )));
715 SA_DBG1(("saInitialize:TOP_BOOT_STRAP STRAP_BIT %X\n", ossaHwRegReadExt(agRoot, PCIBAR1, 0) ));
717 SA_DBG1(("SPC_REG_TOP_DEVICE_ID %8X expect %08X\n", ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_TOP_DEVICE_ID), SPC_TOP_DEVICE_ID));
718 SA_DBG1(("SPC_REG_TOP_DEVICE_ID %8X expect %08X\n", siHalRegReadExt( agRoot, GEN_SPC_REG_TOP_DEVICE_ID,SPC_REG_TOP_DEVICE_ID ) , SPC_TOP_DEVICE_ID));
720 SA_DBG1(("SPC_REG_TOP_BOOT_STRAP %8X expect %08X\n", ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_TOP_BOOT_STRAP), SPC_TOP_BOOT_STRAP));
722 SA_DBG1(("swConfig->numSASDevHandles =%d\n", swConfig->numDevHandles));
724 smTrace(hpDBG_VERY_LOUD,"29",swConfig->numDevHandles);
725 /* TP:29 swConfig->numDevHandles */
727 /* Setup Device link */
728 /* Save the information of allocated device Link memory */
729 saRoot->deviceLinkMem = memoryAllocated->agMemory[DEVICELINK_MEM_INDEX];
730 if(agNULL == saRoot->deviceLinkMem.virtPtr)
732 SA_ASSERT(0, "deviceLinkMem");
733 smTraceFuncExit(hpDBG_VERY_LOUD, 'q', "m1");
734 return AGSA_RC_FAILURE;
737 si_memset(saRoot->deviceLinkMem.virtPtr, 0, saRoot->deviceLinkMem.totalLength);
738 SA_DBG2(("saInitialize: [%d] saRoot->deviceLinkMem VirtPtr=%p PhysicalLo=%x Count=%x Total=%x type %x\n",
739 DEVICELINK_MEM_INDEX,
740 saRoot->deviceLinkMem.virtPtr,
741 saRoot->deviceLinkMem.phyAddrLower,
742 saRoot->deviceLinkMem.numElements,
743 saRoot->deviceLinkMem.totalLength,
744 saRoot->deviceLinkMem.type));
746 maxNumIODevices = swConfig->numDevHandles;
747 SA_DBG2(("saInitialize: maxNumIODevices=%d, swConfig->numDevHandles=%d \n",
749 swConfig->numDevHandles));
751 #ifdef SA_ENABLE_PCI_TRIGGER
752 SA_DBG1(("saInitialize: swConfig->PCI_trigger= 0x%x\n", swConfig->PCI_trigger));
753 #endif /* SA_ENABLE_PCI_TRIGGER */
755 /* Setup free IO Devices link list */
756 saLlistInitialize(&(saRoot->freeDevicesList));
757 for ( i = 0; i < (bit32) maxNumIODevices; i ++ )
759 /* get the pointer to the device descriptor */
760 pDeviceDesc = (agsaDeviceDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->deviceLinkMem), i);
761 /* Initialize device descriptor */
762 saLlinkInitialize(&(pDeviceDesc->linkNode));
764 pDeviceDesc->initiatorDevHandle.osData = agNULL;
765 pDeviceDesc->initiatorDevHandle.sdkData = agNULL;
766 pDeviceDesc->targetDevHandle.osData = agNULL;
767 pDeviceDesc->targetDevHandle.sdkData = agNULL;
768 pDeviceDesc->deviceType = SAS_SATA_UNKNOWN_DEVICE;
769 pDeviceDesc->pPort = agNULL;
770 pDeviceDesc->DeviceMapIndex = 0;
772 saLlistInitialize(&(pDeviceDesc->pendingIORequests));
774 /* Add the device descriptor to the free IO device link list */
775 saLlistAdd(&(saRoot->freeDevicesList), &(pDeviceDesc->linkNode));
778 /* Setup IO Request link */
779 /* Save the information of allocated IO Request Link memory */
780 saRoot->IORequestMem = memoryAllocated->agMemory[IOREQLINK_MEM_INDEX];
781 si_memset(saRoot->IORequestMem.virtPtr, 0, saRoot->IORequestMem.totalLength);
783 SA_DBG2(("saInitialize: [%d] saRoot->IORequestMem VirtPtr=%p PhysicalLo=%x Count=%x Total=%x type %x\n",
785 saRoot->IORequestMem.virtPtr,
786 saRoot->IORequestMem.phyAddrLower,
787 saRoot->IORequestMem.numElements,
788 saRoot->IORequestMem.totalLength,
789 saRoot->IORequestMem.type));
791 /* Setup free IO Request link list */
792 saLlistIOInitialize(&(saRoot->freeIORequests));
793 saLlistIOInitialize(&(saRoot->freeReservedRequests));
794 for ( i = 0; i < swConfig->maxActiveIOs; i ++ )
796 /* get the pointer to the request descriptor */
797 pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), i);
798 /* Initialize request descriptor */
799 saLlinkInitialize(&(pRequestDesc->linkNode));
801 pRequestDesc->valid = agFALSE;
802 pRequestDesc->requestType = AGSA_REQ_TYPE_UNKNOWN;
803 pRequestDesc->pIORequestContext = agNULL;
804 pRequestDesc->HTag = i;
805 pRequestDesc->pDevice = agNULL;
806 pRequestDesc->pPort = agNULL;
808 /* Add the request descriptor to the free Reserved Request link list */
809 /* SMP request must get service so reserve one request when first SMP completes */
810 if(saLlistIOGetCount(&(saRoot->freeReservedRequests)) < SA_RESERVED_REQUEST_COUNT)
812 saLlistIOAdd(&(saRoot->freeReservedRequests), &(pRequestDesc->linkNode));
816 /* Add the request descriptor to the free IO Request link list */
817 saLlistIOAdd(&(saRoot->freeIORequests), &(pRequestDesc->linkNode));
822 /* Setup timer link */
823 /* Save the information of allocated timer Link memory */
824 saRoot->timerLinkMem = memoryAllocated->agMemory[TIMERLINK_MEM_INDEX];
825 si_memset(saRoot->timerLinkMem.virtPtr, 0, saRoot->timerLinkMem.totalLength);
826 SA_DBG2(("saInitialize: [%d] saRoot->timerLinkMem VirtPtr=%p PhysicalLo=%x Count=%x Total=%x type %x\n",
828 saRoot->timerLinkMem.virtPtr,
829 saRoot->timerLinkMem.phyAddrLower,
830 saRoot->timerLinkMem.numElements,
831 saRoot->timerLinkMem.totalLength,
832 saRoot->timerLinkMem.type ));
834 /* Setup free timer link list */
835 saLlistInitialize(&(saRoot->freeTimers));
836 for ( i = 0; i < NUM_TIMERS; i ++ )
838 /* get the pointer to the timer descriptor */
839 pTimerDesc = (agsaTimerDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->timerLinkMem), i);
840 /* Initialize timer descriptor */
841 saLlinkInitialize(&(pTimerDesc->linkNode));
843 pTimerDesc->valid = agFALSE;
844 pTimerDesc->timeoutTick = 0;
845 pTimerDesc->pfnTimeout = agNULL;
846 pTimerDesc->Event = 0;
847 pTimerDesc->pParm = agNULL;
849 /* Add the timer descriptor to the free timer link list */
850 saLlistAdd(&(saRoot->freeTimers), &(pTimerDesc->linkNode));
852 /* Setup valid timer link list */
853 saLlistInitialize(&(saRoot->validTimers));
857 saRoot->phyCount = (bit8) hwConfig->phyCount;
858 /* Init Phy data structure */
859 for ( i = 0; i < saRoot->phyCount; i ++ )
861 saRoot->phys[i].pPort = agNULL;
862 saRoot->phys[i].phyId = (bit8) i;
864 /* setup phy status is PHY_STOPPED */
865 PHY_STATUS_SET(&(saRoot->phys[i]), PHY_STOPPED);
869 /* Setup PortCount */
870 saRoot->portCount = saRoot->phyCount;
871 /* Setup free port link list */
872 saLlistInitialize(&(saRoot->freePorts));
873 for ( i = 0; i < saRoot->portCount; i ++ )
875 /* get the pointer to the port */
876 pPort = &(saRoot->ports[i]);
877 /* Initialize port */
878 saLlinkInitialize(&(pPort->linkNode));
880 pPort->portContext.osData = agNULL;
881 pPort->portContext.sdkData = pPort;
883 pPort->portIdx = (bit8) i;
884 pPort->status = PORT_NORMAL;
886 for ( j = 0; j < saRoot->phyCount; j ++ )
888 pPort->phyMap[j] = agFALSE;
891 saLlistInitialize(&(pPort->listSASATADevices));
893 /* Add the port to the free port link list */
894 saLlistAdd(&(saRoot->freePorts), &(pPort->linkNode));
896 /* Setup valid port link list */
897 saLlistInitialize(&(saRoot->validPorts));
899 /* Init sysIntsActive - default is interrupt enable */
900 saRoot->sysIntsActive = agFALSE;
902 /* setup timer tick granunarity */
903 saRoot->usecsPerTick = usecsPerTick;
905 /* setup smallest timer increment for stall */
906 saRoot->minStallusecs = swConfig->stallUsec;
908 SA_DBG1(("saInitialize: WAIT_INCREMENT %d\n" ,WAIT_INCREMENT ));
909 if (0 == WAIT_INCREMENT)
911 saRoot->minStallusecs = WAIT_INCREMENT_DEFAULT;
914 /* initialize LL timer tick */
915 saRoot->timeTick = 0;
917 /* initialize device (de)registration callback fns */
918 saRoot->DeviceRegistrationCB = agNULL;
919 saRoot->DeviceDeregistrationCB = agNULL;
921 /* Initialize the PortMap for port context */
922 for ( i = 0; i < saRoot->portCount; i ++ )
924 pPortMap = &(saRoot->PortMap[i]);
926 pPortMap->PortContext = agNULL;
927 pPortMap->PortID = PORT_MARK_OFF;
928 pPortMap->PortStatus = PORT_NORMAL;
929 saRoot->autoDeregDeviceflag[i] = 0;
932 /* Initialize the DeviceMap for device handle */
933 for ( i = 0; i < MAX_IO_DEVICE_ENTRIES; i ++ )
935 pDeviceMap = &(saRoot->DeviceMap[i]);
937 pDeviceMap->DeviceHandle = agNULL;
938 pDeviceMap->DeviceIdFromFW = i;
941 /* Initialize the IOMap for IOrequest */
942 for ( i = 0; i < MAX_ACTIVE_IO_REQUESTS; i ++ )
944 pIOMap = &(saRoot->IOMap[i]);
946 pIOMap->IORequest = agNULL;
947 pIOMap->Tag = MARK_OFF;
950 /* setup mpi configuration */
951 if (!swConfig->param3)
953 /* default configuration */
954 siConfiguration(agRoot, &saRoot->mpiConfig, hwConfig, swConfig);
958 /* get from TD layer and save it */
959 agsaQueueConfig_t *dCFG = &saRoot->QueueConfig;
960 agsaQueueConfig_t *sCFG = (agsaQueueConfig_t *)swConfig->param3;
966 if ((hwConfig->hwInterruptCoalescingTimer) || (hwConfig->hwInterruptCoalescingControl))
968 for ( i = 0; i < sCFG->numOutboundQueues; i ++ )
970 /* disable FW assisted coalescing */
971 sCFG->outboundQueues[i].interruptDelay = 0;
972 sCFG->outboundQueues[i].interruptCount = 0;
977 if (hwConfig->hwInterruptCoalescingTimer == 0)
979 hwConfig->hwInterruptCoalescingTimer = 1;
980 SA_DBG1(("saInitialize:InterruptCoalescingTimer should not be zero. Force to 1\n"));
984 ret = siConfiguration(agRoot, &saRoot->mpiConfig, hwConfig, swConfig);
985 if (AGSA_RC_FAILURE == ret)
987 SA_DBG1(("saInitialize failure queue number=%d\n", saRoot->QueueConfig.numInboundQueues));
988 agRoot->sdkData = agNULL;
989 smTraceFuncExit(hpDBG_VERY_LOUD, 'r', "m1");
996 saRoot->swConfig.param3 = &saRoot->QueueConfig;
998 mpiMemoryAllocated.count = memoryAllocated->count - MPI_MEM_INDEX;
999 for ( i = 0; i < mpiMemoryAllocated.count; i ++ )
1001 mpiMemoryAllocated.region[i].virtPtr = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].virtPtr;
1002 mpiMemoryAllocated.region[i].appHandle = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].osHandle;
1003 mpiMemoryAllocated.region[i].physAddrUpper = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].phyAddrUpper;
1004 mpiMemoryAllocated.region[i].physAddrLower = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].phyAddrLower;
1005 mpiMemoryAllocated.region[i].totalLength = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].totalLength;
1006 mpiMemoryAllocated.region[i].numElements = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].numElements;
1007 mpiMemoryAllocated.region[i].elementSize = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].singleElementLength;
1008 mpiMemoryAllocated.region[i].alignment = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].alignment;
1009 mpiMemoryAllocated.region[i].type = memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].type;
1010 SA_DBG2(("saInitialize: memoryAllocated->agMemory[%d] VirtPtr=%p PhysicalLo=%x Count=%x Total=%x type %x\n",
1011 (MPI_IBQ_OBQ_INDEX + i),
1012 memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].virtPtr,
1013 memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].phyAddrLower,
1014 memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].numElements,
1015 memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].totalLength,
1016 memoryAllocated->agMemory[MPI_IBQ_OBQ_INDEX + i].type));
1019 SA_DBG1(("saInitialize: Zero memory region %d virt %p allocated %d\n",
1020 i,mpiMemoryAllocated.region[i].virtPtr, mpiMemoryAllocated.region[i].totalLength));
1021 si_memset(mpiMemoryAllocated.region[i].virtPtr , 0,mpiMemoryAllocated.region[i].totalLength);
1025 if ((!swConfig->max_MSI_InterruptVectors) &&
1026 (!swConfig->max_MSIX_InterruptVectors) &&
1027 (!swConfig->legacyInt_X))
1030 SA_DBG1(("saInitialize: configured as polling mode\n"));
1035 SA_DBG1(("saInitialize: swConfig->max_MSI_InterruptVectors %d\n",swConfig->max_MSI_InterruptVectors));
1036 SA_DBG1(("saInitialize: swConfig->max_MSIX_InterruptVectors %d\n",swConfig->max_MSIX_InterruptVectors));
1038 if ((swConfig->legacyInt_X > 1) || (swConfig->max_MSI_InterruptVectors > 32) ||
1039 (swConfig->max_MSIX_InterruptVectors > 64))
1042 agRoot->sdkData = agNULL;
1043 SA_DBG1(("saInitialize:AGSA_RC_FAILURE InterruptVectors A\n"));
1044 smTraceFuncExit(hpDBG_VERY_LOUD, 's', "m1");
1045 return AGSA_RC_FAILURE;
1047 if ((swConfig->legacyInt_X) && (swConfig->max_MSI_InterruptVectors))
1050 agRoot->sdkData = agNULL;
1051 SA_DBG1(("saInitialize:AGSA_RC_FAILURE InterruptVectors B\n"));
1052 smTraceFuncExit(hpDBG_VERY_LOUD, 't', "m1");
1053 return AGSA_RC_FAILURE;
1055 else if ((swConfig->legacyInt_X) && (swConfig->max_MSIX_InterruptVectors))
1058 agRoot->sdkData = agNULL;
1059 SA_DBG1(("saInitialize:AGSA_RC_FAILURE InterruptVectors C\n"));
1060 smTraceFuncExit(hpDBG_VERY_LOUD, 'u', "m1");
1061 return AGSA_RC_FAILURE;
1063 else if ((swConfig->max_MSI_InterruptVectors) && (swConfig->max_MSIX_InterruptVectors))
1066 agRoot->sdkData = agNULL;
1067 SA_DBG1(("saInitialize:AGSA_RC_FAILURE InterruptVectors D\n"));
1068 smTraceFuncExit(hpDBG_VERY_LOUD, 'v', "m1");
1069 return AGSA_RC_FAILURE;
1073 /* This section sets common interrupt for Legacy(IRQ) and MSI and MSIX types */
1074 if(smIS_SPC(agRoot))
1076 SA_DBG1(("saInitialize: SPC interrupts\n" ));
1078 if (swConfig->legacyInt_X)
1080 saRoot->OurInterrupt = siOurLegacyInterrupt; /* Called in ISR*/
1081 saRoot->DisableInterrupts = siDisableLegacyInterrupts; /* Called in ISR*/
1082 saRoot->ReEnableInterrupts = siReenableLegacyInterrupts;/* Called in Delayed Int handler*/
1084 else if (swConfig->max_MSIX_InterruptVectors)
1086 saRoot->OurInterrupt = siOurMSIXInterrupt;
1087 saRoot->DisableInterrupts = siDisableMSIXInterrupts;
1088 saRoot->ReEnableInterrupts = siReenableMSIXInterrupts;
1090 else if (swConfig->max_MSI_InterruptVectors)
1092 saRoot->OurInterrupt = siOurMSIInterrupt;
1093 saRoot->DisableInterrupts = siDisableMSIInterrupts;
1094 saRoot->ReEnableInterrupts = siReenableMSIInterrupts;
1099 saRoot->OurInterrupt = siOurLegacyInterrupt; /* Called in ISR*/
1100 saRoot->DisableInterrupts = siDisableLegacyInterrupts; /* Called in ISR*/
1101 saRoot->ReEnableInterrupts = siReenableLegacyInterrupts;/* Called in Delayed Int handler*/
1106 SA_DBG1(("saInitialize: SPC V interrupts\n" ));
1107 if (swConfig->legacyInt_X )
1109 SA_DBG1(("saInitialize: SPC V legacyInt_X\n" ));
1110 saRoot->OurInterrupt = siOurLegacy_V_Interrupt; /* Called in ISR*/
1111 saRoot->DisableInterrupts = siDisableLegacy_V_Interrupts; /* Called in ISR*/
1112 saRoot->ReEnableInterrupts = siReenableLegacy_V_Interrupts;/* Called in Delayed Int handler*/
1114 else if (swConfig->max_MSIX_InterruptVectors)
1116 SA_DBG1(("saInitialize: SPC V max_MSIX_InterruptVectors %X\n", swConfig->max_MSIX_InterruptVectors));
1117 saRoot->OurInterrupt = siOurMSIX_V_Interrupt; /* */
1118 saRoot->DisableInterrupts = siDisableMSIX_V_Interrupts;
1119 saRoot->ReEnableInterrupts = siReenableMSIX_V_Interrupts;
1121 else if (swConfig->max_MSI_InterruptVectors)
1123 SA_DBG1(("saInitialize: SPC V max_MSI_InterruptVectors\n" ));
1124 saRoot->OurInterrupt = siOurMSIX_V_Interrupt; /* */
1125 saRoot->DisableInterrupts = siDisableMSIX_V_Interrupts;
1126 saRoot->ReEnableInterrupts = siReenableMSIX_V_Interrupts;
1131 SA_DBG1(("saInitialize: SPC V polling mode\n" ));
1132 saRoot->OurInterrupt = siOurLegacy_V_Interrupt; /* Called in ISR*/
1133 saRoot->DisableInterrupts = siDisableLegacy_V_Interrupts; /* Called in ISR*/
1134 saRoot->ReEnableInterrupts = siReenableLegacy_V_Interrupts;/* Called in Delayed Int handler*/
1136 SA_DBG1(("saInitialize: SPC V\n" ));
1139 saRoot->Use64bit = (saRoot->QueueConfig.numOutboundQueues > 32 ) ? 1 : 0;
1140 if( smIS64bInt(agRoot))
1142 SA_DBG1(("saInitialize: Use 64 bits for interrupts %d %d\n" ,saRoot->Use64bit, saRoot->QueueConfig.numOutboundQueues ));
1146 SA_DBG1(("saInitialize: Use 32 bits for interrupts %d %d\n",saRoot->Use64bit , saRoot->QueueConfig.numOutboundQueues ));
1149 #ifdef SA_LL_IBQ_PROTECT
1150 SA_DBG1(("saInitialize: Inbound locking defined since LL_IOREQ_IBQ0_LOCK %d\n",LL_IOREQ_IBQ0_LOCK));
1151 #endif /* SA_LL_IBQ_PROTECT */
1153 /* Disable interrupt */
1154 saRoot->DisableInterrupts(agRoot, 0);
1155 SA_DBG1(("saInitialize: DisableInterrupts sysIntsActive %X\n" ,saRoot->sysIntsActive));
1157 #ifdef SA_FW_TEST_BUNCH_STARTS
1158 saRoot->BunchStarts_Enable = FALSE;
1159 saRoot->BunchStarts_Threshold = 5;
1160 saRoot->BunchStarts_Pending = 0;
1161 saRoot->BunchStarts_TimeoutTicks = 10; // N x 100 ms
1162 #endif /* SA_FW_TEST_BUNCH_STARTS */
1164 /* clear the interrupt vector bitmap */
1165 for ( i = 0; i < MAX_NUM_VECTOR; i ++ )
1167 saRoot->interruptVecIndexBitMap[i] = 0;
1168 saRoot->interruptVecIndexBitMap1[i] = 0;
1171 #if defined(SALLSDK_DEBUG)
1172 smTrace(hpDBG_VERY_LOUD,"2Y",0);
1173 /* TP:2Y SCRATCH_PAD */
1175 SA_DBG1(("saInitialize: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_0)));
1176 SA_DBG1(("saInitialize: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1)));
1177 SA_DBG1(("saInitialize: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_2)));
1178 SA_DBG1(("saInitialize: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_3)));
1179 #endif /* SALLSDK_DEBUG */
1181 if(smIS_SPCV(agRoot))
1183 bit32 ScratchPad1 =0;
1184 bit32 ScratchPad3 =0;
1186 ScratchPad1 = ossaHwRegRead(agRoot,V_Scratchpad_1_Register);
1187 ScratchPad3 = ossaHwRegRead(agRoot,V_Scratchpad_3_Register);
1188 if((ScratchPad1 & SCRATCH_PAD1_V_RAAE_MASK) == SCRATCH_PAD1_V_RAAE_MASK)
1190 if(((ScratchPad3 & SCRATCH_PAD3_V_ENC_MASK ) == SCRATCH_PAD3_V_ENC_DIS_ERR ) ||
1191 ((ScratchPad3 & SCRATCH_PAD3_V_ENC_MASK ) == SCRATCH_PAD3_V_ENC_ENA_ERR ) )
1193 SA_DBG1(("saInitialize:Warning Encryption Issue SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_3)));
1198 if( smIS_SPC(agRoot))
1200 #ifdef SA_ENABLE_HDA_FUNCTIONS
1202 Double_Reset_HDA = TRUE;
1204 if (swConfig->hostDirectAccessSupport)
1206 if (AGSA_RC_FAILURE == siHDAMode(agRoot, swConfig->hostDirectAccessMode, (agsaFwImg_t *)swConfig->param4))
1208 SA_DBG1(("saInitialize:AGSA_RC_FAILURE siHDAMode\n"));
1209 agRoot->sdkData = agNULL;
1210 smTraceFuncExit(hpDBG_VERY_LOUD, 'w', "m1");
1211 return AGSA_RC_FAILURE;
1215 SA_DBG1(("saInitialize:1 Going to HDA mode HDA 0x%X \n",ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET)));
1216 if(Double_Reset_HDA == agFALSE)
1218 siSpcSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1219 SA_DBG1(("saInitialize: Double_Reset_HDA HDA 0x%X \n",ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET)));
1220 Double_Reset_HDA = TRUE;
1227 /* check FW is running */
1228 if (BOOTTLOADERHDA_IDLE == (ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_STATUS_BITS))
1231 SA_DBG1(("saInitialize: No HDA mode enable and FW is not running.\n"));
1232 if(Tried_NO_HDA != agTRUE )
1235 Tried_NO_HDA = TRUE;
1236 swConfig->hostDirectAccessSupport = 1;
1237 swConfig->hostDirectAccessMode = 1;
1238 siSpcSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1239 SA_DBG1(("saInitialize: 2 Going to HDA mode HDA %X \n",ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET)));
1244 SA_DBG1(("saInitialize: could not start HDA mode HDA %X \n",ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET)));
1245 smTraceFuncExit(hpDBG_VERY_LOUD, 'x', "m1");
1247 return AGSA_RC_FAILURE;
1249 smTraceFuncExit(hpDBG_VERY_LOUD, 'y', "m1");
1250 return AGSA_RC_FAILURE;
1253 #else /* SA_ENABLE_HDA_FUNCTIONS */
1254 /* check FW is running */
1255 if (BOOTTLOADERHDA_IDLE == (ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_STATUS_BITS) )
1258 SA_DBG1(("saInitialize: No HDA mode enable and FW is not running.\n"));
1259 smTraceFuncExit(hpDBG_VERY_LOUD, 'z', "m1");
1260 return AGSA_RC_FAILURE;
1262 #endif /* SA_ENABLE_HDA_FUNCTIONS */
1266 SA_DBG1(("saInitialize: SPCv swConfig->hostDirectAccessMode %d swConfig->hostDirectAccessSupport %d\n",swConfig->hostDirectAccessMode,swConfig->hostDirectAccessSupport));
1267 if (swConfig->hostDirectAccessSupport)
1270 bit32 soft_reset_status = AGSA_RC_SUCCESS;
1272 SA_DBG1(("saInitialize: SPCv load HDA\n"));
1274 hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28));
1276 SA_DBG1(("saInitialize: hda_status 0x%x\n",hda_status));
1278 siScratchDump(agRoot);
1280 if( swConfig->hostDirectAccessMode == 0)
1282 soft_reset_status = siSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1283 if(soft_reset_status != AGSA_RC_SUCCESS)
1285 agRoot->sdkData = agNULL;
1286 SA_DBG1(("saInitialize:AGSA_RC_FAILURE soft_reset_status\n"));
1288 smTraceFuncExit(hpDBG_VERY_LOUD, 'A', "m1");
1289 return AGSA_RC_FAILURE;
1293 if((hda_status & SPC_V_HDAR_RSPCODE_MASK) != SPC_V_HDAR_IDLE)
1295 SA_DBG1(("saInitialize: hda_status not SPC_V_HDAR_IDLE 0x%08x\n", hda_status));
1296 soft_reset_status = siSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1297 hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28));
1298 if((hda_status & SPC_V_HDAR_RSPCODE_MASK) != SPC_V_HDAR_IDLE)
1300 SA_DBG1(("saInitialize: 2 reset hda_status not SPC_V_HDAR_IDLE 0x%08x\n", hda_status));
1303 if(soft_reset_status != AGSA_RC_SUCCESS)
1305 agRoot->sdkData = agNULL;
1306 SA_DBG1(("saInitialize:AGSA_RC_FAILURE soft_reset_status A\n"));
1307 smTraceFuncExit(hpDBG_VERY_LOUD, 'B', "m1");
1308 return AGSA_RC_FAILURE;
1311 #ifdef SA_ENABLE_HDA_FUNCTIONS
1312 if (AGSA_RC_FAILURE == siHDAMode_V(agRoot, swConfig->hostDirectAccessMode, (agsaFwImg_t *)swConfig->param4))
1314 SA_DBG1(("saInitialize:AGSA_RC_FAILURE siHDAMode_V\n"));
1316 siChipResetV(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1317 agRoot->sdkData = agNULL;
1318 smTraceFuncExit(hpDBG_VERY_LOUD, 'C', "m1");
1319 return AGSA_RC_FAILURE;
1321 #endif /* SA_ENABLE_HDA_FUNCTIONS */
1326 SA_DBG1(("saInitialize: SPCv normal\n"));
1331 /* copy the table to the LL layer */
1332 si_memcpy(&saRoot->mpiConfig.phyAnalogConfig, &hwConfig->phyAnalogConfig, sizeof(agsaPhyAnalogSetupTable_t));
1334 #ifdef SALL_API_TEST
1335 /* Initialize the LL IO counter */
1336 si_memset(&saRoot->LLCounters, 0, sizeof(agsaIOCountInfo_t));
1339 si_memset(&saRoot->IoErrorCount, 0, sizeof(agsaIOErrorEventStats_t));
1340 si_memset(&saRoot->IoEventCount, 0, sizeof(agsaIOErrorEventStats_t));
1341 if(smIS_SPC(agRoot))
1343 if( smIS_spc8081(agRoot))
1345 if (AGSA_RC_FAILURE == siBar4Shift(agRoot, MBIC_GSM_SM_BASE))
1347 SA_DBG1(("saInitialize: siBar4Shift FAILED ******************************************\n"));
1350 siSpcSoftReset(agRoot, SPC_SOFT_RESET_SIGNATURE);
1352 if(smIS_SPCV(agRoot))
1354 SA_DBG1(("saInitialize: saRoot->ChipId == VEN_DEV_SPCV\n"));
1355 siChipResetV(agRoot, SPC_SOFT_RESET_SIGNATURE);
1358 /* MPI Initialization */
1359 ret = mpiInitialize(agRoot, &mpiMemoryAllocated, &saRoot->mpiConfig);
1360 SA_DBG1(("saInitialize: MaxOutstandingIO 0x%x swConfig->maxActiveIOs 0x%x\n", saRoot->ControllerInfo.maxPendingIO,saRoot->swConfig.maxActiveIOs ));
1362 #ifdef SA_ENABLE_HDA_FUNCTIONS
1363 if( ret == AGSA_RC_FAILURE && Tried_NO_HDA == agFALSE && smIS_SPC(agRoot))
1364 { /* FW not flashed */
1365 Tried_NO_HDA=agTRUE;
1366 swConfig->hostDirectAccessSupport = 1;
1367 swConfig->hostDirectAccessMode = 1;
1368 siSoftReset(agRoot, SPC_SOFT_RESET_SIGNATURE);
1369 SA_DBG1(("saInitialize: 3 Going to HDA mode HDA %X \n",ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET)));
1373 #endif /* SA_ENABLE_HDA_FUNCTIONS */
1375 if( ret == AGSA_RC_FAILURE)
1377 SA_DBG1(("saInitialize: AGSA_RC_FAILURE mpiInitialize\n"));
1378 SA_DBG1(("saInitialize: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_0_Register)));
1379 SA_DBG1(("saInitialize: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_1_Register)));
1380 SA_DBG1(("saInitialize: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_2_Register)));
1381 SA_DBG1(("saInitialize: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, V_Scratchpad_3_Register)));
1383 if(saRoot->swConfig.fatalErrorInterruptEnable)
1385 ossaDisableInterrupts(agRoot,saRoot->swConfig.fatalErrorInterruptVector );
1388 agRoot->sdkData = agNULL;
1389 smTraceFuncExit(hpDBG_VERY_LOUD, 'D', "m1");
1393 /* setup hardware interrupt coalescing control and timer registers */
1394 if(smIS_SPCV(agRoot))
1396 SA_DBG1(("saInitialize: SPC_V Not set hwInterruptCoalescingTimer\n" ));
1397 SA_DBG1(("saInitialize: SPC_V Not set hwInterruptCoalescingControl\n" ));
1401 ossaHwRegWriteExt(agRoot, PCIBAR1, SPC_ICTIMER,hwConfig->hwInterruptCoalescingTimer );
1402 ossaHwRegWriteExt(agRoot, PCIBAR1, SPC_ICCONTROL, hwConfig->hwInterruptCoalescingControl);
1406 SA_DBG1(("saInitialize: swConfig->fatalErrorInterruptEnable %X\n",swConfig->fatalErrorInterruptEnable));
1408 SA_DBG1(("saInitialize: saRoot->swConfig.fatalErrorInterruptVector %X\n",saRoot->swConfig.fatalErrorInterruptVector));
1409 SA_DBG1(("saInitialize: swConfig->max_MSI_InterruptVectors %X\n",swConfig->max_MSI_InterruptVectors));
1410 SA_DBG1(("saInitialize: swConfig->max_MSIX_InterruptVectors %X\n",swConfig->max_MSIX_InterruptVectors));
1411 SA_DBG1(("saInitialize: swConfig->legacyInt_X %X\n",swConfig->legacyInt_X));
1412 SA_DBG1(("saInitialize: swConfig->hostDirectAccessSupport %X\n",swConfig->hostDirectAccessSupport));
1413 SA_DBG1(("saInitialize: swConfig->hostDirectAccessMode %X\n",swConfig->hostDirectAccessMode));
1415 #ifdef SA_CONFIG_MDFD_REGISTRY
1416 SA_DBG1(("saInitialize: swConfig->disableMDF %X\n",swConfig->disableMDF));
1417 #endif /*SA_CONFIG_MDFD_REGISTRY*/
1418 /*SA_DBG1(("saInitialize: swConfig->enableDIF %X\n",swConfig->enableDIF));*/
1419 /*SA_DBG1(("saInitialize: swConfig->enableEncryption %X\n",swConfig->enableEncryption));*/
1422 /* log message if failure */
1423 if (AGSA_RC_FAILURE == ret)
1425 SA_DBG1(("saInitialize:AGSA_RC_FAILURE mpiInitialize\n"));
1426 /* Assign chip status */
1427 saRoot->chipStatus = CHIP_FATAL_ERROR;
1431 /* Assign chip status */
1432 saRoot->chipStatus = CHIP_NORMAL;
1433 #ifdef SA_FW_TIMER_READS_STATUS
1434 siTimerAdd(agRoot,SA_FW_TIMER_READS_STATUS_INTERVAL, siReadControllerStatus,0,agNULL );
1435 #endif /* SA_FW_TIMER_READS_STATUS */
1439 if( ret == AGSA_RC_SUCCESS || ret == AGSA_RC_VERSION_UNTESTED)
1441 if(gPollForMissingInt)
1443 mpiOCQueue_t *circularQ;
1444 SA_DBG1(("saInitialize: saRoot->sysIntsActive %X\n",saRoot->sysIntsActive));
1446 circularQ = &saRoot->outboundQueue[0];
1447 OSSA_READ_LE_32(circularQ->agRoot, &circularQ->producerIdx, circularQ->piPointer, 0);
1448 SA_DBG1(("saInitialize: PI 0x%03x CI 0x%03x\n",circularQ->producerIdx, circularQ->consumerIdx));
1452 /* If fatal error interrupt enable we need checking it during the interrupt */
1453 SA_DBG1(("saInitialize: swConfig.fatalErrorInterruptEnable %d\n",saRoot->swConfig.fatalErrorInterruptEnable));
1454 SA_DBG1(("saInitialize: swConfig.fatalErrorInterruptVector %d\n",saRoot->swConfig.fatalErrorInterruptVector));
1455 SA_DBG1(("saInitialize: swConfig->max_MSIX_InterruptVectors %X\n",swConfig->max_MSIX_InterruptVectors));
1457 if(saRoot->swConfig.fatalErrorInterruptEnable)
1460 SA_DBG1(("saInitialize: Doorbell_Set %08X U %08X\n",
1461 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Set_Register),
1462 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Set_RegisterU)));
1463 SA_DBG1(("saInitialize: Doorbell_Mask %08X U %08X\n",
1464 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Mask_Set_Register ),
1465 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Mask_Set_RegisterU )));
1467 ossaReenableInterrupts(agRoot,saRoot->swConfig.fatalErrorInterruptVector );
1469 SA_DBG1(("saInitialize: Doorbell_Set %08X U %08X\n",
1470 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Set_Register),
1471 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Set_RegisterU)));
1472 SA_DBG1(("saInitialize: Doorbell_Mask %08X U %08X\n",
1473 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Mask_Set_Register ),
1474 ossaHwRegReadExt(agRoot, PCIBAR0, V_Outbound_Doorbell_Mask_Set_RegisterU )));
1478 SA_DBG1(("saInitialize: siDumpActiveIORequests\n"));
1479 siDumpActiveIORequests(agRoot, saRoot->swConfig.maxActiveIOs);
1481 smTraceFuncExit(hpDBG_VERY_LOUD, 'E', "m1");
1488 #ifdef SA_FW_TIMER_READS_STATUS
1490 bit32 siReadControllerStatus(
1497 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
1498 mpiReadGSTable(agRoot, &saRoot->mpiGSTable);
1500 if(smIS_SPCV_2_IOP(agRoot))
1502 if(saRoot->Iop1Tcnt_last == saRoot->mpiGSTable.Iop1Tcnt )
1503 SA_DBG2(("siReadControllerStatus: Iop1 %d STUCK\n", saRoot->mpiGSTable.Iop1Tcnt));
1506 if( saRoot->MsguTcnt_last == saRoot->mpiGSTable.MsguTcnt || saRoot->IopTcnt_last == saRoot->mpiGSTable.IopTcnt )
1508 SA_DBG1(("siReadControllerStatus: Msgu %d Iop %d\n",saRoot->mpiGSTable.MsguTcnt, saRoot->mpiGSTable.IopTcnt));
1509 saFatalInterruptHandler(agRoot, saRoot->swConfig.fatalErrorInterruptVector );
1511 SA_DBG2(("siReadControllerStatus: Msgu %d Iop %d\n",saRoot->mpiGSTable.MsguTcnt, saRoot->mpiGSTable.IopTcnt));
1513 saRoot->MsguTcnt_last = saRoot->mpiGSTable.MsguTcnt;
1514 saRoot->IopTcnt_last = saRoot->mpiGSTable.IopTcnt;
1515 saRoot->Iop1Tcnt_last = saRoot->mpiGSTable.Iop1Tcnt;
1518 if(gPollForMissingInt)
1520 mpiOCQueue_t *circularQ;
1521 SA_DBG4(("siReadControllerStatus: saRoot->sysIntsActive %X\n",saRoot->sysIntsActive));
1523 circularQ = &saRoot->outboundQueue[0];
1524 OSSA_READ_LE_32(circularQ->agRoot, &circularQ->producerIdx, circularQ->piPointer, 0);
1525 if(circularQ->producerIdx != circularQ->consumerIdx)
1527 SA_DBG1(("siReadControllerStatus: saRoot->sysIntsActive %X\n",saRoot->sysIntsActive));
1528 SA_DBG1(("siReadControllerStatus: PI 0x%03x CI 0x%03x\n",circularQ->producerIdx, circularQ->consumerIdx));
1530 SA_DBG1(("siReadControllerStatus:IN MSGU_READ_ODMR %08X\n",siHalRegReadExt(agRoot, GEN_MSGU_ODMR, V_Outbound_Doorbell_Mask_Set_Register )));
1531 SA_DBG1(("siReadControllerStatus:MSGU_READ_ODR %08X\n",siHalRegReadExt(agRoot, GEN_MSGU_ODR, V_Outbound_Doorbell_Set_Register)));
1532 ossaHwRegWriteExt(agRoot, PCIBAR0,V_Outbound_Doorbell_Clear_Register, 0xFFFFFFFF );
1537 siTimerAdd(agRoot,SA_FW_TIMER_READS_STATUS_INTERVAL, siReadControllerStatus,Event,pParm );
1542 #endif /* SA_FW_TIMER_READS_STATUS */
1544 /******************************************************************************/
1545 /*! \brief Routine to do SPC configuration with default or specified values
1547 * Set up configuration table in LL Layer
1549 * \param agRoot handles for this instance of SAS/SATA hardware
1550 * \param mpiConfig MPI Configuration
1551 * \param swConfig Pointer to the software configuration
1555 /*******************************************************************************/
1556 GLOBAL bit32 siConfiguration(
1558 mpiConfig_t *mpiConfig,
1559 agsaHwConfig_t *hwConfig,
1560 agsaSwConfig_t *swConfig
1563 agsaQueueConfig_t *queueConfig;
1564 bit32 intOption, enable64 = 0;
1569 SA_ASSERT( (agNULL != agRoot), "");
1571 smTraceFuncEnter(hpDBG_VERY_LOUD,"m2");
1573 si_memset(mpiConfig, 0, sizeof(mpiConfig_t));
1574 SA_DBG1(("siConfiguration: si_memset mpiConfig\n"));
1576 #if defined(SALLSDK_DEBUG)
1577 sidump_swConfig(swConfig);
1579 mpiConfig->mainConfig.custset = swConfig->FWConfig;
1581 SA_DBG1(("siConfiguration:custset %8X %8X\n",mpiConfig->mainConfig.custset,swConfig->FWConfig));
1583 if (swConfig->param3 == agNULL)
1585 SA_DBG1(("siConfiguration: swConfig->param3 == agNULL\n"));
1586 /* initialize the mpiConfig */
1587 /* We configure the Host main part of configuration table */
1588 mpiConfig->mainConfig.iQNPPD_HPPD_GEvent = 0;
1589 mpiConfig->mainConfig.outboundHWEventPID0_3 = 0;
1590 mpiConfig->mainConfig.outboundHWEventPID4_7 = 0;
1591 mpiConfig->mainConfig.outboundNCQEventPID0_3 = 0;
1592 mpiConfig->mainConfig.outboundNCQEventPID4_7 = 0;
1593 mpiConfig->mainConfig.outboundTargetITNexusEventPID0_3 = 0;
1594 mpiConfig->mainConfig.outboundTargetITNexusEventPID4_7 = 0;
1595 mpiConfig->mainConfig.outboundTargetSSPEventPID0_3 = 0;
1596 mpiConfig->mainConfig.outboundTargetSSPEventPID4_7 = 0;
1598 mpiConfig->mainConfig.ioAbortDelay = 0;
1600 mpiConfig->mainConfig.upperEventLogAddress = 0;
1601 mpiConfig->mainConfig.lowerEventLogAddress = 0;
1602 mpiConfig->mainConfig.eventLogSize = MPI_LOGSIZE;
1603 mpiConfig->mainConfig.eventLogOption = 0;
1604 mpiConfig->mainConfig.upperIOPeventLogAddress = 0;
1605 mpiConfig->mainConfig.lowerIOPeventLogAddress = 0;
1606 mpiConfig->mainConfig.IOPeventLogSize = MPI_LOGSIZE;
1607 mpiConfig->mainConfig.IOPeventLogOption = 0;
1608 mpiConfig->mainConfig.FatalErrorInterrupt = 0;
1610 /* save the default value */
1611 mpiConfig->numInboundQueues = AGSA_MAX_INBOUND_Q;
1612 mpiConfig->numOutboundQueues = AGSA_MAX_OUTBOUND_Q;
1613 mpiConfig->maxNumInboundQueues = AGSA_MAX_INBOUND_Q;
1614 mpiConfig->maxNumOutboundQueues = AGSA_MAX_OUTBOUND_Q;
1616 /* configure inbound queues */
1617 for ( i = 0; i < AGSA_MAX_INBOUND_Q; i ++ )
1619 mpiConfig->inboundQueues[i].numElements = INBOUND_DEPTH_SIZE;
1620 mpiConfig->inboundQueues[i].elementSize = IOMB_SIZE64;
1621 mpiConfig->inboundQueues[i].priority = MPI_QUEUE_NORMAL;
1624 /* configure outbound queues */
1625 for ( i = 0; i < AGSA_MAX_OUTBOUND_Q; i ++ )
1627 mpiConfig->outboundQueues[i].numElements = OUTBOUND_DEPTH_SIZE;
1628 mpiConfig->outboundQueues[i].elementSize = IOMB_SIZE64;
1629 mpiConfig->outboundQueues[i].interruptVector = 0;
1630 mpiConfig->outboundQueues[i].interruptDelay = 0;
1631 mpiConfig->outboundQueues[i].interruptThreshold = 0;
1632 /* always enable OQ interrupt */
1633 mpiConfig->outboundQueues[i].interruptEnable = 1;
1637 { /* Parm3 is not null */
1638 queueConfig = (agsaQueueConfig_t *)swConfig->param3;
1640 #if defined(SALLSDK_DEBUG)
1641 sidump_Q_config( queueConfig );
1644 SA_DBG1(("siConfiguration: swConfig->param3 == %p\n",queueConfig));
1646 if ((queueConfig->numInboundQueues > AGSA_MAX_INBOUND_Q) ||
1647 (queueConfig->numOutboundQueues > AGSA_MAX_OUTBOUND_Q))
1649 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m2");
1650 SA_DBG1(("siConfiguration:AGSA_RC_FAILURE MAX_Q\n"));
1652 return AGSA_RC_FAILURE;
1655 if ((queueConfig->numInboundQueues == 0 ||
1656 queueConfig->numOutboundQueues == 0 ))
1658 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "m2");
1659 SA_DBG1(("siConfiguration:AGSA_RC_FAILURE NO_Q\n"));
1660 return AGSA_RC_FAILURE;
1662 mpiConfig->mainConfig.eventLogSize = swConfig->sizefEventLog1 * KBYTES;
1663 mpiConfig->mainConfig.eventLogOption = swConfig->eventLog1Option;
1664 mpiConfig->mainConfig.IOPeventLogSize = swConfig->sizefEventLog2 * KBYTES;
1665 mpiConfig->mainConfig.IOPeventLogOption = swConfig->eventLog2Option;
1667 if ((queueConfig->numInboundQueues > IQ_NUM_32) || (queueConfig->numOutboundQueues > OQ_NUM_32))
1672 if (agNULL == hwConfig)
1679 #if defined(SALLSDK_DEBUG)
1680 sidump_hwConfig(hwConfig);
1684 if(smIS_SPCV(agRoot))
1690 intOption = hwConfig->intReassertionOption & INT_OPTION;
1696 swConfig->sgpioSupportEnable = 1;
1698 /* set bit for normal priority or high priority path */
1699 /* set fatal error interrupt enable and vector */
1700 /* set Interrupt Reassertion enable and 64 IQ/OQ enable */
1701 mpiConfig->mainConfig.FatalErrorInterrupt =
1702 (swConfig->fatalErrorInterruptEnable) /* bit 0*/ |
1703 (hwConfig == agNULL ? 0: (hwConfig->hwOption & HW_CFG_PICI_EFFECTIVE_ADDRESS ? (0x1 << SHIFT1): 0))|
1704 (swConfig->sgpioSupportEnable ? (0x1 << SHIFT2): 0) |
1705 /* compile option SA_ENABLE_POISION_TLP */(SA_PTNFE_POISION_TLP << SHIFT3) |
1706 #ifdef SA_CONFIG_MDFD_REGISTRY
1707 (swConfig->disableMDF ? (0x1 << SHIFT4): 0) |
1709 /* compile option SA_DISABLE_MDFD */ (SA_MDFD_MULTI_DATA_FETCH << SHIFT4) |
1710 #endif /*SA_CONFIG_MDFD_REGISTRY*/
1711 /* compile option SA_DISABLE_OB_COAL */(SA_OUTBOUND_COALESCE << SHIFT5) |
1712 /* compile option SA_ENABLE_ARBTE */(SA_ARBTE << SHIFT6) |
1713 ((swConfig->fatalErrorInterruptVector & FATAL_ERROR_INT_BITS) << SHIFT8) |
1714 (enable64 << SHIFT16) |
1715 (intOption << SHIFT17);
1718 SA_DBG1(("siConfiguration: swConfig->fatalErrorInterruptEnable %X\n",swConfig->fatalErrorInterruptEnable));
1719 SA_DBG1(("siConfiguration: swConfig->fatalErrorInterruptVector %X\n",swConfig->fatalErrorInterruptVector));
1723 /* initialize the mpiConfig */
1724 /* We configure the Host main part of configuration table */
1725 mpiConfig->mainConfig.outboundTargetITNexusEventPID0_3 = 0;
1726 mpiConfig->mainConfig.outboundTargetITNexusEventPID4_7 = 0;
1727 mpiConfig->mainConfig.outboundTargetSSPEventPID0_3 = 0;
1728 mpiConfig->mainConfig.outboundTargetSSPEventPID4_7 = 0;
1729 mpiConfig->mainConfig.ioAbortDelay = 0;
1730 mpiConfig->mainConfig.PortRecoveryTimerPortResetTimer = swConfig->PortRecoveryResetTimer;
1732 /* get parameter from queueConfig */
1733 mpiConfig->mainConfig.iQNPPD_HPPD_GEvent = queueConfig->iqNormalPriorityProcessingDepth |
1734 (queueConfig->iqHighPriorityProcessingDepth << SHIFT8) |
1735 (queueConfig->generalEventQueue << SHIFT16) |
1736 (queueConfig->tgtDeviceRemovedEventQueue << SHIFT24);
1738 mpiConfig->mainConfig.outboundHWEventPID0_3 = queueConfig->sasHwEventQueue[0] |
1739 (queueConfig->sasHwEventQueue[1] << SHIFT8) |
1740 (queueConfig->sasHwEventQueue[2] << SHIFT16) |
1741 (queueConfig->sasHwEventQueue[3] << SHIFT24);
1742 mpiConfig->mainConfig.outboundHWEventPID4_7 = queueConfig->sasHwEventQueue[4] |
1743 (queueConfig->sasHwEventQueue[5] << SHIFT8) |
1744 (queueConfig->sasHwEventQueue[6] << SHIFT16) |
1745 (queueConfig->sasHwEventQueue[7] << SHIFT24);
1746 mpiConfig->mainConfig.outboundNCQEventPID0_3 = queueConfig->sataNCQErrorEventQueue[0] |
1747 (queueConfig->sataNCQErrorEventQueue[1] << SHIFT8) |
1748 (queueConfig->sataNCQErrorEventQueue[2] << SHIFT16) |
1749 (queueConfig->sataNCQErrorEventQueue[3] << SHIFT24);
1750 mpiConfig->mainConfig.outboundNCQEventPID4_7 = queueConfig->sataNCQErrorEventQueue[4] |
1751 (queueConfig->sataNCQErrorEventQueue[5] << SHIFT8) |
1752 (queueConfig->sataNCQErrorEventQueue[6] << SHIFT16) |
1753 (queueConfig->sataNCQErrorEventQueue[7] << SHIFT24);
1755 mpiConfig->numInboundQueues = queueConfig->numInboundQueues;
1756 mpiConfig->numOutboundQueues = queueConfig->numOutboundQueues;
1757 mpiConfig->queueOption = queueConfig->queueOption;
1759 SA_DBG2(("siConfiguration: numInboundQueues=%d numOutboundQueues=%d\n",
1760 queueConfig->numInboundQueues,
1761 queueConfig->numOutboundQueues));
1763 /* configure inbound queues */
1764 /* We configure the size of queue based on swConfig */
1765 for( i = 0; i < queueConfig->numInboundQueues; i ++ )
1767 mpiConfig->inboundQueues[i].numElements = (bit16)queueConfig->inboundQueues[i].elementCount;
1768 mpiConfig->inboundQueues[i].elementSize = (bit16)queueConfig->inboundQueues[i].elementSize;;
1769 mpiConfig->inboundQueues[i].priority = queueConfig->inboundQueues[i].priority;
1771 SA_DBG2(("siConfiguration: IBQ%d:elementCount=%d elementSize=%d priority=%d Total Size 0x%X\n",
1773 queueConfig->inboundQueues[i].elementCount,
1774 queueConfig->inboundQueues[i].elementSize,
1775 queueConfig->inboundQueues[i].priority,
1776 queueConfig->inboundQueues[i].elementCount * queueConfig->inboundQueues[i].elementSize ));
1779 /* configura outbound queues */
1780 /* We configure the size of queue based on swConfig */
1781 for( i = 0; i < queueConfig->numOutboundQueues; i ++ )
1783 mpiConfig->outboundQueues[i].numElements = (bit16)queueConfig->outboundQueues[i].elementCount;
1784 mpiConfig->outboundQueues[i].elementSize = (bit16)queueConfig->outboundQueues[i].elementSize;
1785 mpiConfig->outboundQueues[i].interruptVector = (bit8)queueConfig->outboundQueues[i].interruptVectorIndex;
1786 mpiConfig->outboundQueues[i].interruptDelay = (bit16)queueConfig->outboundQueues[i].interruptDelay;
1787 mpiConfig->outboundQueues[i].interruptThreshold = (bit8)queueConfig->outboundQueues[i].interruptCount;
1788 mpiConfig->outboundQueues[i].interruptEnable = (bit32)queueConfig->outboundQueues[i].interruptEnable;
1790 SA_DBG2(("siConfiguration: OBQ%d:elementCount=%d elementSize=%d interruptCount=%d interruptEnable=%d\n",
1792 queueConfig->outboundQueues[i].elementCount,
1793 queueConfig->outboundQueues[i].elementSize,
1794 queueConfig->outboundQueues[i].interruptCount,
1795 queueConfig->outboundQueues[i].interruptEnable));
1799 SA_DBG1(("siConfiguration:mpiConfig->mainConfig.FatalErrorInterrupt 0x%X\n",mpiConfig->mainConfig.FatalErrorInterrupt));
1800 SA_DBG1(("siConfiguration:swConfig->fatalErrorInterruptVector 0x%X\n",swConfig->fatalErrorInterruptVector));
1801 SA_DBG1(("siConfiguration:enable64 0x%X\n",enable64));
1802 SA_DBG1(("siConfiguration:PortRecoveryResetTimer 0x%X\n",swConfig->PortRecoveryResetTimer));
1804 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "m2");
1807 return AGSA_RC_SUCCESS;
1810 #ifdef FW_EVT_LOG_TST
1811 void saLogDump(agsaRoot_t *agRoot,
1813 U32 **eventLogAddress_)
1815 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
1816 //mpiConfig_t *mpiConfig = &saRoot->mpiConfig;
1817 mpiHostLLConfigDescriptor_t *mpiConfig = &saRoot->mainConfigTable;
1819 *eventLogAddress_ = (U32*)eventLogAddress;
1820 *eventLogSize = (U32)mpiConfig->eventLogSize;
1824 /*******************************************************************************/
1825 /** \fn mpiInitialize(agsaRoot *agRoot, mpiMemReq_t* memoryAllocated, mpiConfig_t* config)
1826 * \brief Initializes the MPI Message Unit
1827 * \param agRoot Pointer to a data structure containing LL layer context handles
1828 * \param memoryAllocated Data structure that holds the different chunks of memory that are allocated
1829 * \param config MPI configuration
1831 * This function is called to initialize SPC_HOST_MPI internal data structures and the SPC hardware.
1832 * This function is competed synch->ronously (there is no callback)
1835 * AGSA_RC_SUCCESS if initialization succeeded.
1836 * AGSA_RC_FAILURE if initialization failed.
1838 /*******************************************************************************/
1839 GLOBAL bit32 mpiInitialize(agsaRoot_t *agRoot,
1840 mpiMemReq_t* memoryAllocated,
1841 mpiConfig_t* config)
1843 static spc_configMainDescriptor_t mainCfg; /* main part of MPI configuration */
1844 static spc_inboundQueueDescriptor_t inQueueCfg; /* Inbound queue HW configuration structure */
1845 static spc_outboundQueueDescriptor_t outQueueCfg; /* Outbound queue HW configuration structure */
1846 bit16 qIdx, i, indexoffset; /* Queue index */
1847 bit16 mIdx = 0; /* Memory region index */
1848 bit32 MSGUCfgTblDWIdx, GSTLenMPIS;
1849 bit32 MSGUCfgTblBase, ret = AGSA_RC_SUCCESS;
1850 bit32 value, togglevalue;
1852 bit32 inboundoffset, outboundoffset;
1854 bit16 maxinbound = AGSA_MAX_INBOUND_Q;
1855 bit16 maxoutbound = AGSA_MAX_OUTBOUND_Q;
1858 bit32 max_wait_time;
1859 bit32 max_wait_count;
1861 agsaLLRoot_t *saRoot;
1862 mpiICQueue_t *circularIQ = agNULL;
1863 mpiOCQueue_t *circularOQ;
1865 bit32 mpiUnInitFailed = 0;
1866 bit32 mpiStartToggleFailed = 0;
1869 #if defined(SALLSDK_DEBUG)
1870 bit8 phycount = AGSA_MAX_VALID_PHYS;
1871 #endif /* SALLSDK_DEBUG */
1873 SA_DBG1(("mpiInitialize: Entering\n"));
1874 SA_ASSERT(NULL != agRoot, "agRoot argument cannot be null");
1875 SA_ASSERT(NULL != memoryAllocated, "memoryAllocated argument cannot be null");
1876 SA_ASSERT(NULL != config, "config argument cannot be null");
1877 SA_ASSERT(0 == (sizeof(spc_inboundQueueDescriptor_t) % 4), "spc_inboundQueueDescriptor_t type size has to be divisible by 4");
1879 saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
1881 si_memset(&mainCfg,0,sizeof(spc_configMainDescriptor_t));
1882 si_memset(&inQueueCfg,0,sizeof(spc_inboundQueueDescriptor_t));
1883 si_memset(&outQueueCfg,0,sizeof(spc_outboundQueueDescriptor_t));
1885 SA_ASSERT((agNULL !=saRoot ), "");
1886 if(saRoot == agNULL)
1888 SA_DBG1(("mpiInitialize: saRoot == agNULL\n"));
1889 return(AGSA_RC_FAILURE);
1891 smTraceFuncEnter(hpDBG_VERY_LOUD,"m3");
1893 /*Shift BAR 4 for SPC HAILEAH*/
1894 if(smIS_SPC(agRoot))
1896 if( smIS_HIL(agRoot))
1898 if (AGSA_RC_FAILURE == siBar4Shift(agRoot, MBIC_GSM_SM_BASE))
1900 SA_DBG1(("mpiInitialize: siBar4Shift FAILED ******************************************\n"));
1901 return AGSA_RC_FAILURE;
1906 /* Wait for the SPC Configuration Table to be ready */
1907 ret = mpiWaitForConfigTable(agRoot, &mainCfg);
1908 if (AGSA_RC_FAILURE == ret)
1910 /* return error if MPI Configuration Table not ready */
1911 SA_DBG1(("mpiInitialize: mpiWaitForConfigTable FAILED ******************************************\n"));
1912 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m3");
1916 /* read scratch pad0 to get PCI BAR and offset of configuration table */
1917 MSGUCfgTblBase = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
1919 MSGUCfgTblBase = (MSGUCfgTblBase & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
1920 /* get pci Bar index */
1921 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, MSGUCfgTblBase);
1923 SA_DBG1(("mpiInitialize: MSGUCfgTblBase = 0x%x\n", MSGUCfgTblBase));
1924 #if defined(SALLSDK_DEBUG)
1925 /* get Phy count from configuration table */
1926 phycount = (bit8)((mainCfg.ContrlCapFlag & PHY_COUNT_BITS) >> SHIFT19);
1928 SA_DBG1(("mpiInitialize: Number of PHYs = 0x%x\n", phycount));
1930 smTrace(hpDBG_VERY_LOUD,"70",phycount);
1931 /* TP:70 phycount */
1932 #endif /* SALLSDK_DEBUG */
1934 /* get High Priority IQ support flag */
1935 if (mainCfg.ContrlCapFlag & HP_SUPPORT_BIT)
1937 SA_DBG1(("mpiInitialize: High Priority IQ support from SPC\n"));
1939 /* get Interrupt Coalescing Support flag */
1940 if (mainCfg.ContrlCapFlag & INT_COL_BIT)
1942 SA_DBG1(("mpiInitialize: Interrupt Coalescing support from SPC\n"));
1945 /* get configured the number of inbound/outbound queues */
1946 if (memoryAllocated->count == TOTAL_MPI_MEM_CHUNKS)
1948 config->maxNumInboundQueues = AGSA_MAX_INBOUND_Q;
1949 config->maxNumOutboundQueues = AGSA_MAX_OUTBOUND_Q;
1953 config->maxNumInboundQueues = config->numInboundQueues;
1954 config->maxNumOutboundQueues = config->numOutboundQueues;
1955 maxinbound = config->numInboundQueues;
1956 maxoutbound = config->numOutboundQueues;
1959 SA_DBG1(("mpiInitialize: Number of IQ %d\n", maxinbound));
1960 SA_DBG1(("mpiInitialize: Number of OQ %d\n", maxoutbound));
1962 /* get inbound queue offset */
1963 inboundoffset = mainCfg.inboundQueueOffset;
1964 /* get outbound queue offset */
1965 outboundoffset = mainCfg.outboundQueueOffset;
1967 if(smIS_SPCV(agRoot))
1969 SA_DBG2(("mpiInitialize: Offset of IQ %d\n", (inboundoffset & 0xFF000000) >> 24));
1970 SA_DBG2(("mpiInitialize: Offset of OQ %d\n", (outboundoffset & 0xFF000000) >> 24));
1971 inboundoffset &= 0x00FFFFFF;
1972 outboundoffset &= 0x00FFFFFF;
1974 /* get offset of the configuration table */
1975 MSGUCfgTblDWIdx = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
1976 MSGUCfgTblDWIdx = MSGUCfgTblDWIdx & SCRATCH_PAD0_OFFSET_MASK;
1978 saveOffset = MSGUCfgTblDWIdx;
1980 /* Checks if the configuration memory region size is the same as the mpiConfigMain */
1981 if(memoryAllocated->region[mIdx].totalLength != sizeof(bit8) * config->mainConfig.eventLogSize)
1983 SA_DBG1(("ERROR: The memory region [%d] 0x%X != 0x%X does not have the size of the MSGU event log ******************************************\n",
1984 mIdx,memoryAllocated->region[mIdx].totalLength,config->mainConfig.eventLogSize));
1985 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "m3");
1986 return AGSA_RC_FAILURE;
1989 mainCfg.iQNPPD_HPPD_GEvent = config->mainConfig.iQNPPD_HPPD_GEvent;
1991 if(smIS_SPCV(agRoot))
1993 mainCfg.outboundHWEventPID0_3 = 0;
1994 mainCfg.outboundHWEventPID4_7 = 0;
1995 mainCfg.outboundNCQEventPID0_3 = 0;
1996 mainCfg.outboundNCQEventPID4_7 = 0;
1997 mainCfg.outboundTargetITNexusEventPID0_3 = 0;
1998 mainCfg.outboundTargetITNexusEventPID4_7 = 0;
1999 mainCfg.outboundTargetSSPEventPID0_3 = 0;
2000 mainCfg.outboundTargetSSPEventPID4_7 = 0;
2001 mainCfg.ioAbortDelay = 0; /* SPCV reserved */
2002 mainCfg.custset = 0;
2003 mainCfg.portRecoveryResetTimer = config->mainConfig.PortRecoveryTimerPortResetTimer;
2004 SA_DBG1(("mpiInitialize:custset V %8X\n",mainCfg.custset));
2005 SA_DBG1(("mpiInitialize:portRecoveryResetTimer V %8X\n",mainCfg.portRecoveryResetTimer));
2007 mainCfg.interruptReassertionDelay = saRoot->hwConfig.intReassertionOption;
2008 SA_DBG1(("mpiInitialize:interruptReassertionDelay V %8X\n", mainCfg.interruptReassertionDelay));
2014 mainCfg.outboundHWEventPID0_3 = config->mainConfig.outboundHWEventPID0_3;
2015 mainCfg.outboundHWEventPID4_7 = config->mainConfig.outboundHWEventPID4_7;
2016 mainCfg.outboundNCQEventPID0_3 = config->mainConfig.outboundNCQEventPID0_3;
2017 mainCfg.outboundNCQEventPID4_7 = config->mainConfig.outboundNCQEventPID4_7;
2018 mainCfg.outboundTargetITNexusEventPID0_3 = config->mainConfig.outboundTargetITNexusEventPID0_3;
2019 mainCfg.outboundTargetITNexusEventPID4_7 = config->mainConfig.outboundTargetITNexusEventPID4_7;
2020 mainCfg.outboundTargetSSPEventPID0_3 = config->mainConfig.outboundTargetSSPEventPID0_3;
2021 mainCfg.outboundTargetSSPEventPID4_7 = config->mainConfig.outboundTargetSSPEventPID4_7;
2022 mainCfg.ioAbortDelay = config->mainConfig.ioAbortDelay;
2023 mainCfg.custset = config->mainConfig.custset;
2025 SA_DBG1(("mpiInitialize:custset spc %8X\n",mainCfg.custset));
2028 #ifdef FW_EVT_LOG_TST
2029 eventLogAddress = memoryAllocated->region[mIdx].virtPtr;
2031 mainCfg.upperEventLogAddress = memoryAllocated->region[mIdx].physAddrUpper;
2032 mainCfg.lowerEventLogAddress = memoryAllocated->region[mIdx].physAddrLower;
2033 mainCfg.eventLogSize = config->mainConfig.eventLogSize;
2034 mainCfg.eventLogOption = config->mainConfig.eventLogOption;
2038 /* Checks if the configuration memory region size is the same as the mpiConfigMain */
2039 if(memoryAllocated->region[mIdx].totalLength != sizeof(bit8) * config->mainConfig.IOPeventLogSize)
2041 SA_DBG1(("ERROR: The memory region does not have the size of the IOP event log\n"));
2042 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "m3");
2043 return AGSA_RC_FAILURE;
2046 mainCfg.upperIOPeventLogAddress = memoryAllocated->region[mIdx].physAddrUpper;
2047 mainCfg.lowerIOPeventLogAddress = memoryAllocated->region[mIdx].physAddrLower;
2048 mainCfg.IOPeventLogSize = config->mainConfig.IOPeventLogSize;
2049 mainCfg.IOPeventLogOption = config->mainConfig.IOPeventLogOption;
2050 mainCfg.FatalErrorInterrupt = config->mainConfig.FatalErrorInterrupt;
2052 SA_DBG1(("mpiInitialize: iQNPPD_HPPD_GEvent 0x%x\n", mainCfg.iQNPPD_HPPD_GEvent));
2053 if(smIS_SPCV(agRoot))
2058 SA_DBG3(("mpiInitialize: outboundHWEventPID0_3 0x%x\n", mainCfg.outboundHWEventPID0_3));
2059 SA_DBG3(("mpiInitialize: outboundHWEventPID4_7 0x%x\n", mainCfg.outboundHWEventPID4_7));
2060 SA_DBG3(("mpiInitialize: outboundNCQEventPID0_3 0x%x\n", mainCfg.outboundNCQEventPID0_3));
2061 SA_DBG3(("mpiInitialize: outboundNCQEventPID4_7 0x%x\n", mainCfg.outboundNCQEventPID4_7));
2062 SA_DBG3(("mpiInitialize: outboundTargetITNexusEventPID0_3 0x%x\n", mainCfg.outboundTargetITNexusEventPID0_3));
2063 SA_DBG3(("mpiInitialize: outboundTargetITNexusEventPID4_7 0x%x\n", mainCfg.outboundTargetITNexusEventPID4_7));
2064 SA_DBG3(("mpiInitialize: outboundTargetSSPEventPID0_3 0x%x\n", mainCfg.outboundTargetSSPEventPID0_3));
2065 SA_DBG3(("mpiInitialize: outboundTargetSSPEventPID4_7 0x%x\n", mainCfg.outboundTargetSSPEventPID4_7));
2068 SA_DBG3(("mpiInitialize: upperEventLogAddress 0x%x\n", mainCfg.upperEventLogAddress));
2069 SA_DBG3(("mpiInitialize: lowerEventLogAddress 0x%x\n", mainCfg.lowerEventLogAddress));
2070 SA_DBG3(("mpiInitialize: eventLogSize 0x%x\n", mainCfg.eventLogSize));
2071 SA_DBG3(("mpiInitialize: eventLogOption 0x%x\n", mainCfg.eventLogOption));
2072 #ifdef FW_EVT_LOG_TST
2073 SA_DBG3(("mpiInitialize: eventLogAddress 0x%p\n", eventLogAddress));
2075 SA_DBG3(("mpiInitialize: upperIOPLogAddress 0x%x\n", mainCfg.upperIOPeventLogAddress));
2076 SA_DBG3(("mpiInitialize: lowerIOPLogAddress 0x%x\n", mainCfg.lowerIOPeventLogAddress));
2077 SA_DBG3(("mpiInitialize: IOPeventLogSize 0x%x\n", mainCfg.IOPeventLogSize));
2078 SA_DBG3(("mpiInitialize: IOPeventLogOption 0x%x\n", mainCfg.IOPeventLogOption));
2079 SA_DBG3(("mpiInitialize: FatalErrorInterrupt 0x%x\n", mainCfg.FatalErrorInterrupt));
2080 SA_DBG3(("mpiInitialize: HDAModeFlags 0x%x\n", mainCfg.HDAModeFlags));
2081 SA_DBG3(("mpiInitialize: analogSetupTblOffset 0x%08x\n", mainCfg.analogSetupTblOffset));
2083 saRoot->mainConfigTable.iQNPPD_HPPD_GEvent = mainCfg.iQNPPD_HPPD_GEvent;
2085 if(smIS_SPCV(agRoot))
2087 /* SPCV - reserved fields */
2088 saRoot->mainConfigTable.outboundHWEventPID0_3 = 0;
2089 saRoot->mainConfigTable.outboundHWEventPID4_7 = 0;
2090 saRoot->mainConfigTable.outboundNCQEventPID0_3 = 0;
2091 saRoot->mainConfigTable.outboundNCQEventPID4_7 = 0;
2092 saRoot->mainConfigTable.outboundTargetITNexusEventPID0_3 = 0;
2093 saRoot->mainConfigTable.outboundTargetITNexusEventPID4_7 = 0;
2094 saRoot->mainConfigTable.outboundTargetSSPEventPID0_3 = 0;
2095 saRoot->mainConfigTable.outboundTargetSSPEventPID4_7 = 0;
2096 saRoot->mainConfigTable.ioAbortDelay = 0;
2097 saRoot->mainConfigTable.custset = 0;
2102 saRoot->mainConfigTable.outboundHWEventPID0_3 = mainCfg.outboundHWEventPID0_3;
2103 saRoot->mainConfigTable.outboundHWEventPID4_7 = mainCfg.outboundHWEventPID4_7;
2104 saRoot->mainConfigTable.outboundNCQEventPID0_3 = mainCfg.outboundNCQEventPID0_3;
2105 saRoot->mainConfigTable.outboundNCQEventPID4_7 = mainCfg.outboundNCQEventPID4_7;
2106 saRoot->mainConfigTable.outboundTargetITNexusEventPID0_3 = mainCfg.outboundTargetITNexusEventPID0_3;
2107 saRoot->mainConfigTable.outboundTargetITNexusEventPID4_7 = mainCfg.outboundTargetITNexusEventPID4_7;
2108 saRoot->mainConfigTable.outboundTargetSSPEventPID0_3 = mainCfg.outboundTargetSSPEventPID0_3;
2109 saRoot->mainConfigTable.outboundTargetSSPEventPID4_7 = mainCfg.outboundTargetSSPEventPID4_7;
2110 saRoot->mainConfigTable.ioAbortDelay = mainCfg.ioAbortDelay;
2111 saRoot->mainConfigTable.custset = mainCfg.custset;
2115 saRoot->mainConfigTable.upperEventLogAddress = mainCfg.upperEventLogAddress;
2116 saRoot->mainConfigTable.lowerEventLogAddress = mainCfg.lowerEventLogAddress;
2117 saRoot->mainConfigTable.eventLogSize = mainCfg.eventLogSize;
2118 saRoot->mainConfigTable.eventLogOption = mainCfg.eventLogOption;
2119 saRoot->mainConfigTable.upperIOPeventLogAddress = mainCfg.upperIOPeventLogAddress;
2120 saRoot->mainConfigTable.lowerIOPeventLogAddress = mainCfg.lowerIOPeventLogAddress;
2121 saRoot->mainConfigTable.IOPeventLogSize = mainCfg.IOPeventLogSize;
2122 saRoot->mainConfigTable.IOPeventLogOption = mainCfg.IOPeventLogOption;
2123 saRoot->mainConfigTable.FatalErrorInterrupt = mainCfg.FatalErrorInterrupt;
2126 if(smIS_SPCV(agRoot))
2128 ;/* SPCV - reserved fields */
2132 saRoot->mainConfigTable.HDAModeFlags = mainCfg.HDAModeFlags;
2135 saRoot->mainConfigTable.analogSetupTblOffset = mainCfg.analogSetupTblOffset;
2137 smTrace(hpDBG_VERY_LOUD,"71",mIdx);
2142 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IQNPPD_HPPD_OFFSET),
2143 mainCfg.iQNPPD_HPPD_GEvent);
2145 SA_DBG3(("mpiInitialize: Offset 0x%08x mainCfg.iQNPPD_HPPD_GEvent 0x%x\n", (bit32)(MSGUCfgTblDWIdx + MAIN_IQNPPD_HPPD_OFFSET), mainCfg.iQNPPD_HPPD_GEvent));
2147 if(smIS_SPC6V(agRoot))
2149 if(smIsCfgVREV_B(agRoot))
2151 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IO_ABORT_DELAY),
2152 MAIN_IO_ABORT_DELAY_END_TO_END_CRC_DISABLE);
2154 SA_DBG1(("mpiInitialize:SPCV - MAIN_IO_ABORT_DELAY_END_TO_END_CRC_DISABLE\n" ));
2156 if(smIsCfgVREV_C(agRoot))
2158 SA_DBG1(("mpiInitialize:SPCV - END_TO_END_CRC On\n" ));
2160 SA_DBG3(("mpiInitialize:SPCV - rest reserved field \n" ));
2161 ;/* SPCV - reserved field */
2163 else if(smIS_SPC(agRoot))
2165 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_OB_HW_EVENT_PID03_OFFSET),
2166 mainCfg.outboundHWEventPID0_3);
2167 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_OB_HW_EVENT_PID47_OFFSET),
2168 mainCfg.outboundHWEventPID4_7);
2169 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_OB_NCQ_EVENT_PID03_OFFSET),
2170 mainCfg.outboundNCQEventPID0_3);
2171 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_OB_NCQ_EVENT_PID47_OFFSET),
2172 mainCfg.outboundNCQEventPID4_7);
2173 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_TITNX_EVENT_PID03_OFFSET),
2174 mainCfg.outboundTargetITNexusEventPID0_3);
2175 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_TITNX_EVENT_PID47_OFFSET),
2176 mainCfg.outboundTargetITNexusEventPID4_7);
2177 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_OB_SSP_EVENT_PID03_OFFSET),
2178 mainCfg.outboundTargetSSPEventPID0_3);
2179 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_OB_SSP_EVENT_PID47_OFFSET),
2180 mainCfg.outboundTargetSSPEventPID4_7);
2181 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_CUSTOMER_SETTING),
2185 if(smIsCfgVREV_A(agRoot))
2187 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IO_ABORT_DELAY),
2188 MAIN_IO_ABORT_DELAY_END_TO_END_CRC_DISABLE); /* */
2189 SA_DBG1(("mpiInitialize:SPCV12G - offset MAIN_IO_ABORT_DELAY 0x%x value MAIN_IO_ABORT_DELAY_END_TO_END_CRC_DISABLE 0x%x\n",MAIN_IO_ABORT_DELAY ,MAIN_IO_ABORT_DELAY_END_TO_END_CRC_DISABLE));
2190 SA_DBG1(("mpiInitialize:SPCV12G - END_TO_END_CRC OFF for rev A %d\n",smIsCfgVREV_A(agRoot) ));
2192 else if(smIsCfgVREV_B(agRoot))
2194 SA_DBG1(("mpiInitialize:SPCV12G - END_TO_END_CRC ON rev B %d ****************************\n",smIsCfgVREV_B(agRoot) ));
2195 /*ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IO_ABORT_DELAY),
2196 MAIN_IO_ABORT_DELAY_END_TO_END_CRC_DISABLE);
2199 else if(smIsCfgVREV_C(agRoot))
2201 SA_DBG1(("mpiInitialize:SPCV12G - END_TO_END_CRC on rev C %d\n",smIsCfgVREV_C(agRoot) ));
2205 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IO_ABORT_DELAY),
2206 MAIN_IO_ABORT_DELAY_END_TO_END_CRC_DISABLE);
2207 SA_DBG1(("mpiInitialize:SPCV12G - END_TO_END_CRC Off unknown rev 0x%x\n", ossaHwRegReadConfig32((agRoot), 8 )));
2211 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_ADDR_HI), mainCfg.upperEventLogAddress);
2212 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_ADDR_LO), mainCfg.lowerEventLogAddress);
2213 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_BUFF_SIZE), mainCfg.eventLogSize);
2214 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_OPTION), mainCfg.eventLogOption);
2215 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_ADDR_HI), mainCfg.upperIOPeventLogAddress);
2216 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_ADDR_LO), mainCfg.lowerIOPeventLogAddress);
2217 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_BUFF_SIZE), mainCfg.IOPeventLogSize);
2218 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_OPTION), mainCfg.IOPeventLogOption);
2219 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_FATAL_ERROR_INTERRUPT), mainCfg.FatalErrorInterrupt);
2220 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_PRECTD_PRESETD), mainCfg.portRecoveryResetTimer);
2222 SA_DBG3(("mpiInitialize: Offset 0x%08x upperEventLogAddress 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_ADDR_HI), mainCfg.upperEventLogAddress ));
2223 SA_DBG3(("mpiInitialize: Offset 0x%08x lowerEventLogAddress 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_ADDR_LO), mainCfg.lowerEventLogAddress ));
2224 SA_DBG3(("mpiInitialize: Offset 0x%08x eventLogSize 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_BUFF_SIZE), mainCfg.eventLogSize ));
2225 SA_DBG3(("mpiInitialize: Offset 0x%08x eventLogOption 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_OPTION), mainCfg.eventLogOption ));
2226 SA_DBG3(("mpiInitialize: Offset 0x%08x upperIOPeventLogAddress 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_ADDR_HI), mainCfg.upperIOPeventLogAddress ));
2227 SA_DBG3(("mpiInitialize: Offset 0x%08x lowerIOPeventLogAddress 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_ADDR_LO), mainCfg.lowerIOPeventLogAddress ));
2228 SA_DBG3(("mpiInitialize: Offset 0x%08x IOPeventLogSize 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_BUFF_SIZE), mainCfg.IOPeventLogSize ));
2229 SA_DBG3(("mpiInitialize: Offset 0x%08x IOPeventLogOption 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_OPTION), mainCfg.IOPeventLogOption ));
2230 SA_DBG3(("mpiInitialize: Offset 0x%08x FatalErrorInterrupt 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_FATAL_ERROR_INTERRUPT), mainCfg.FatalErrorInterrupt ));
2231 SA_DBG3(("mpiInitialize: Offset 0x%08x PortRecoveryResetTimer 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_PRECTD_PRESETD), mainCfg.portRecoveryResetTimer ));
2233 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IRAD_RESERVED), mainCfg.interruptReassertionDelay);
2234 SA_DBG3(("mpiInitialize: Offset 0x%08x InterruptReassertionDelay 0x%x\n",(bit32)(MSGUCfgTblDWIdx + MAIN_IRAD_RESERVED), mainCfg.interruptReassertionDelay ));
2238 /* skip the ci and pi memory region */
2242 smTrace(hpDBG_VERY_LOUD,"72",mIdx);
2244 smTrace(hpDBG_VERY_LOUD,"Bc",maxinbound);
2245 /* TP:Bc maxinbound */
2246 smTrace(hpDBG_VERY_LOUD,"Bd",pcibar);
2253 /* Memory regions for the inbound queues */
2254 for(qIdx = 0; qIdx < maxinbound; qIdx++)
2256 /* point back to the begin then plus offset to next queue */
2257 smTrace(hpDBG_VERY_LOUD,"Bd",pcibar);
2259 MSGUCfgTblDWIdx = saveOffset;
2260 MSGUCfgTblDWIdx += inboundoffset;
2261 MSGUCfgTblDWIdx += (sizeof(spc_inboundQueueDescriptor_t) * qIdx);
2262 SA_DBG1(("mpiInitialize: A saveOffset 0x%x MSGUCfgTblDWIdx 0x%x\n",saveOffset ,MSGUCfgTblDWIdx));
2264 /* if the MPI configuration says that this queue is disabled ... */
2265 if(0 == config->inboundQueues[qIdx].numElements)
2267 /* ... Clears the configuration table for this queue */
2269 inQueueCfg.elementPriSizeCount= 0;
2270 inQueueCfg.upperBaseAddress = 0;
2271 inQueueCfg.lowerBaseAddress = 0;
2272 inQueueCfg.ciUpperBaseAddress = 0;
2273 inQueueCfg.ciLowerBaseAddress = 0;
2274 /* skip inQueueCfg.PIPCIBar (PM8000 write access) */
2275 /* skip inQueueCfg.PIOffset (PM8000 write access) */
2277 /* Update the inbound configuration table in SPC GSM */
2278 mpiUpdateIBQueueCfgTable(agRoot, &inQueueCfg, MSGUCfgTblDWIdx, pcibar);
2281 /* If the queue is enabled, then ... */
2284 bit32 memSize = config->inboundQueues[qIdx].numElements * config->inboundQueues[qIdx].elementSize;
2285 bit32 remainder = memSize & 127;
2287 /* Calculate the size of this queue padded to 128 bytes */
2290 memSize += (128 - remainder);
2293 /* ... first checks that the memory region has the right size */
2294 if( (memoryAllocated->region[mIdx].totalLength - memOffset < memSize) ||
2295 (NULL == memoryAllocated->region[mIdx].virtPtr) ||
2296 (0 == memoryAllocated->region[mIdx].totalLength))
2298 SA_DBG1(("mpiInitialize: ERROR The memory region does not have the right size for this inbound queue"));
2299 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "m3");
2300 return AGSA_RC_FAILURE;
2304 /* Then, using the MPI configuration argument, initializes the corresponding element on the saRoot */
2305 saRoot->inboundQueue[qIdx].numElements = config->inboundQueues[qIdx].numElements;
2306 saRoot->inboundQueue[qIdx].elementSize = config->inboundQueues[qIdx].elementSize;
2307 saRoot->inboundQueue[qIdx].priority = config->inboundQueues[qIdx].priority;
2308 si_memcpy(&saRoot->inboundQueue[qIdx].memoryRegion, &memoryAllocated->region[mIdx], sizeof(mpiMem_t));
2309 saRoot->inboundQueue[qIdx].memoryRegion.virtPtr =
2310 (bit8 *)saRoot->inboundQueue[qIdx].memoryRegion.virtPtr + memOffset;
2311 saRoot->inboundQueue[qIdx].memoryRegion.physAddrLower += memOffset;
2312 saRoot->inboundQueue[qIdx].memoryRegion.elementSize = memSize;
2313 saRoot->inboundQueue[qIdx].memoryRegion.totalLength = memSize;
2314 saRoot->inboundQueue[qIdx].memoryRegion.numElements = 1;
2316 /* Initialize the local copy of PIs, CIs */
2317 SA_DBG1(("mpiInitialize: queue %d PI CI zero\n",qIdx));
2318 saRoot->inboundQueue[qIdx].producerIdx = 0;
2319 saRoot->inboundQueue[qIdx].consumerIdx = 0;
2320 saRoot->inboundQueue[qIdx].agRoot = agRoot;
2322 /* MPI memory region for inbound CIs are 2 */
2323 saRoot->inboundQueue[qIdx].ciPointer = (((bit8 *)(memoryAllocated->region[MPI_CI_INDEX].virtPtr)) + qIdx * 4);
2324 /* ... and in the local structure we will use to copy to the HW configuration table */
2326 /* CI base address */
2327 inQueueCfg.elementPriSizeCount= config->inboundQueues[qIdx].numElements |
2328 (config->inboundQueues[qIdx].elementSize << SHIFT16) |
2329 (config->inboundQueues[qIdx].priority << SHIFT30);
2330 inQueueCfg.upperBaseAddress = saRoot->inboundQueue[qIdx].memoryRegion.physAddrUpper;
2331 inQueueCfg.lowerBaseAddress = saRoot->inboundQueue[qIdx].memoryRegion.physAddrLower;
2332 inQueueCfg.ciUpperBaseAddress = memoryAllocated->region[MPI_CI_INDEX].physAddrUpper;
2333 inQueueCfg.ciLowerBaseAddress = memoryAllocated->region[MPI_CI_INDEX].physAddrLower + qIdx * 4;
2335 /* write the configured data of inbound queue to SPC GSM */
2336 mpiUpdateIBQueueCfgTable(agRoot, &inQueueCfg, MSGUCfgTblDWIdx, pcibar);
2337 /* get inbound PI PCI Bar and Offset */
2338 /* get the PI PCI Bar offset and convert it to logical BAR */
2339 IB_PIPCIBar = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + IB_PIPCI_BAR));
2340 saRoot->inboundQueue[qIdx].PIPCIBar = mpiGetPCIBarIndex(agRoot, IB_PIPCIBar);
2341 saRoot->inboundQueue[qIdx].PIPCIOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + IB_PIPCI_BAR_OFFSET));
2342 saRoot->inboundQueue[qIdx].qNumber = qIdx;
2344 memOffset += memSize;
2346 if ((0 == ((qIdx + 1) % MAX_QUEUE_EACH_MEM)) ||
2347 (qIdx == (maxinbound - 1)))
2350 indexoffset += MAX_QUEUE_EACH_MEM;
2354 } /* else for memeory ok */
2355 } /* queue enable */
2356 } /* loop for inbound queue */
2358 smTrace(hpDBG_VERY_LOUD,"73",0);
2359 /* TP:73 outbound queues */
2364 /* Let's process the memory regions for the outbound queues */
2365 for(qIdx = 0; qIdx < maxoutbound; qIdx++)
2367 /* point back to the begin then plus offset to next queue */
2368 MSGUCfgTblDWIdx = saveOffset;
2369 MSGUCfgTblDWIdx += outboundoffset;
2370 MSGUCfgTblDWIdx += (sizeof(spc_outboundQueueDescriptor_t) * qIdx);
2372 /* if the MPI configuration says that this queue is disabled ... */
2373 if(0 == config->outboundQueues[qIdx].numElements)
2375 /* ... Clears the configuration table for this queue */
2376 outQueueCfg.upperBaseAddress = 0;
2377 outQueueCfg.lowerBaseAddress = 0;
2378 outQueueCfg.piUpperBaseAddress = 0;
2379 outQueueCfg.piLowerBaseAddress = 0;
2380 /* skip outQueueCfg.CIPCIBar = 0; read access only */
2381 /* skip outQueueCfg.CIOffset = 0; read access only */
2382 outQueueCfg.elementSizeCount = 0;
2383 outQueueCfg.interruptVecCntDelay = 0;
2385 /* Updated the configuration table in SPC GSM */
2386 mpiUpdateOBQueueCfgTable(agRoot, &outQueueCfg, MSGUCfgTblDWIdx, pcibar);
2389 /* If the outbound queue is enabled, then ... */
2392 bit32 memSize = config->outboundQueues[qIdx].numElements * config->outboundQueues[qIdx].elementSize;
2393 bit32 remainder = memSize & 127;
2395 /* Calculate the size of this queue padded to 128 bytes */
2398 memSize += (128 - remainder);
2401 /* ... first checks that the memory region has the right size */
2402 if((memoryAllocated->region[mIdx].totalLength - memOffset < memSize) ||
2403 (NULL == memoryAllocated->region[mIdx].virtPtr) ||
2404 (0 == memoryAllocated->region[mIdx].totalLength))
2406 SA_DBG1(("ERROR: The memory region does not have the right size for this outbound queue"));
2407 smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "m3");
2408 return AGSA_RC_FAILURE;
2412 /* Then, using the MPI configuration argument, initializes the corresponding element on the MPI context ... */
2413 saRoot->outboundQueue[qIdx].numElements = config->outboundQueues[qIdx].numElements;
2414 saRoot->outboundQueue[qIdx].elementSize = config->outboundQueues[qIdx].elementSize;
2415 si_memcpy(&saRoot->outboundQueue[qIdx].memoryRegion, &memoryAllocated->region[mIdx], sizeof(mpiMem_t));
2416 saRoot->outboundQueue[qIdx].memoryRegion.virtPtr =
2417 (bit8 *)saRoot->outboundQueue[qIdx].memoryRegion.virtPtr + memOffset;
2418 saRoot->outboundQueue[qIdx].memoryRegion.physAddrLower += memOffset;
2419 saRoot->outboundQueue[qIdx].memoryRegion.elementSize = memSize;
2420 saRoot->outboundQueue[qIdx].memoryRegion.totalLength = memSize;
2421 saRoot->outboundQueue[qIdx].memoryRegion.numElements = 1;
2422 saRoot->outboundQueue[qIdx].producerIdx = 0;
2423 saRoot->outboundQueue[qIdx].consumerIdx = 0;
2424 saRoot->outboundQueue[qIdx].agRoot = agRoot;
2426 /* MPI memory region for outbound PIs are 3 */
2427 saRoot->outboundQueue[qIdx].piPointer = (((bit8 *)(memoryAllocated->region[MPI_CI_INDEX + 1].virtPtr))+ qIdx * 4);
2428 /* ... and in the local structure we will use to copy to the HW configuration table */
2429 outQueueCfg.upperBaseAddress = saRoot->outboundQueue[qIdx].memoryRegion.physAddrUpper;
2430 outQueueCfg.lowerBaseAddress = saRoot->outboundQueue[qIdx].memoryRegion.physAddrLower;
2432 /* PI base address */
2433 outQueueCfg.piUpperBaseAddress = memoryAllocated->region[MPI_CI_INDEX + 1].physAddrUpper;
2434 outQueueCfg.piLowerBaseAddress = memoryAllocated->region[MPI_CI_INDEX + 1].physAddrLower + qIdx * 4;
2435 outQueueCfg.elementSizeCount = config->outboundQueues[qIdx].numElements |
2436 (config->outboundQueues[qIdx].elementSize << SHIFT16);
2438 /* enable/disable interrupt - use saSystemInterruptsActive() API */
2439 /* instead of ossaHwRegWrite(agRoot, MSGU_ODMR, 0); */
2440 /* Outbound Doorbell Auto disable */
2441 /* LL does not use ossaHwRegWriteExt(agRoot, PCIBAR1, SPC_ODAR, 0xffffffff); */
2442 if (config->outboundQueues[qIdx].interruptEnable)
2444 /* enable interrupt flag bit30 of outbound table */
2445 outQueueCfg.elementSizeCount |= OB_PROPERTY_INT_ENABLE;
2447 if(smIS_SPCV(agRoot))
2449 outQueueCfg.interruptVecCntDelay = ((config->outboundQueues[qIdx].interruptVector & INT_VEC_BITS ) << SHIFT24);
2453 outQueueCfg.interruptVecCntDelay = (config->outboundQueues[qIdx].interruptDelay & INT_DELAY_BITS) |
2454 ((config->outboundQueues[qIdx].interruptThreshold & INT_THR_BITS ) << SHIFT16) |
2455 ((config->outboundQueues[qIdx].interruptVector & INT_VEC_BITS ) << SHIFT24);
2458 /* create a VectorIndex Bit Map */
2459 if (qIdx < OQ_NUM_32)
2461 saRoot->interruptVecIndexBitMap[config->outboundQueues[qIdx].interruptVector] |= (1 << qIdx);
2462 SA_DBG2(("mpiInitialize:below 32 saRoot->interruptVecIndexBitMap[config->outboundQueues[qIdx].interruptVector] 0x%08x\n",saRoot->interruptVecIndexBitMap[config->outboundQueues[qIdx].interruptVector]));
2466 saRoot->interruptVecIndexBitMap1[config->outboundQueues[qIdx].interruptVector] |= (1 << (qIdx - OQ_NUM_32));
2467 SA_DBG2(("mpiInitialize:Above 32 saRoot->interruptVecIndexBitMap1[config->outboundQueues[qIdx].interruptVector] 0x%08x\n",saRoot->interruptVecIndexBitMap1[config->outboundQueues[qIdx].interruptVector]));
2469 /* Update the outbound configuration table */
2470 mpiUpdateOBQueueCfgTable(agRoot, &outQueueCfg, MSGUCfgTblDWIdx, pcibar);
2472 /* read the CI PCIBar offset and convert it to logical bar */
2473 OB_CIPCIBar = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + OB_CIPCI_BAR));
2474 saRoot->outboundQueue[qIdx].CIPCIBar = mpiGetPCIBarIndex(agRoot, OB_CIPCIBar);
2475 saRoot->outboundQueue[qIdx].CIPCIOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + OB_CIPCI_BAR_OFFSET));
2476 saRoot->outboundQueue[qIdx].DIntTOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + OB_DYNAMIC_COALES_OFFSET));
2477 saRoot->outboundQueue[qIdx].qNumber = qIdx;
2479 memOffset += memSize;
2481 if ((0 == ((qIdx + 1) % MAX_QUEUE_EACH_MEM)) ||
2482 (qIdx == (maxoutbound - 1)))
2485 indexoffset += MAX_QUEUE_EACH_MEM;
2492 /* calculate number of vectors */
2493 saRoot->numInterruptVectors = 0;
2494 for (qIdx = 0; qIdx < MAX_NUM_VECTOR; qIdx++)
2496 if ((saRoot->interruptVecIndexBitMap[qIdx]) || (saRoot->interruptVecIndexBitMap1[qIdx]))
2498 (saRoot->numInterruptVectors)++;
2502 SA_DBG2(("mpiInitialize:(saRoot->numInterruptVectors) 0x%x\n",(saRoot->numInterruptVectors)));
2504 if(smIS_SPCV(agRoot))
2506 /* setup interrupt vector table */
2507 mpiWrIntVecTable(agRoot,config);
2510 if(smIS_SPCV(agRoot))
2512 mpiWrAnalogSetupTable(agRoot,config);
2515 /* setup phy analog registers */
2516 mpiWriteCALAll(agRoot, &config->phyAnalogConfig);
2521 pcibar = siGetPciBar(agRoot);
2522 TableOffset = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
2523 TableOffset &= SCRATCH_PAD0_OFFSET_MASK;
2524 SA_DBG1(("mpiInitialize: mpiContextTable TableOffset 0x%08X contains 0x%08X\n",TableOffset,ossaHwRegReadExt(agRoot, pcibar, TableOffset )));
2526 SA_ASSERT( (ossaHwRegReadExt(agRoot, pcibar, TableOffset ) == 0x53434D50), "Config table signiture");
2528 SA_DBG1(("mpiInitialize: AGSA_MPI_MAIN_CONFIGURATION_TABLE 0x%08X\n", 0));
2529 SA_DBG1(("mpiInitialize: AGSA_MPI_GENERAL_STATUS_TABLE 0x%08X\n", (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_GST_OFFSET) & 0xFFFF )));
2530 SA_DBG1(("mpiInitialize: AGSA_MPI_INBOUND_QUEUE_CONFIGURATION_TABLE 0x%08X\n", (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_IBQ_OFFSET) & 0xFFFF)));
2531 SA_DBG1(("mpiInitialize: AGSA_MPI_OUTBOUND_QUEUE_CONFIGURATION_TABLE 0x%08X\n", (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_OBQ_OFFSET) & 0xFFFF)));
2532 SA_DBG1(("mpiInitialize: AGSA_MPI_SAS_PHY_ANALOG_SETUP_TABLE 0x%08X\n", (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_ANALOG_SETUP_OFFSET) & 0xFFFF )));
2533 SA_DBG1(("mpiInitialize: AGSA_MPI_INTERRUPT_VECTOR_TABLE 0x%08X\n", (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_INT_VEC_TABLE_OFFSET) & 0xFFFF)));
2534 SA_DBG1(("mpiInitialize: AGSA_MPI_PER_SAS_PHY_ATTRIBUTE_TABLE 0x%08X\n", (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_PHY_ATTRIBUTE_OFFSET) & 0xFFFF)));
2535 SA_DBG1(("mpiInitialize: AGSA_MPI_OUTBOUND_QUEUE_FAILOVER_TABLE 0x%08X\n", (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_MOQFOT_MOQFOES) & 0xFFFF)));
2539 if(agNULL != saRoot->swConfig.mpiContextTable )
2541 agsaMPIContext_t * context = (agsaMPIContext_t * )saRoot->swConfig.mpiContextTable;
2542 bit32 length = saRoot->swConfig.mpiContextTablelen;
2545 pcibar = siGetPciBar(agRoot);
2546 TableOffset = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
2547 TableOffset &= SCRATCH_PAD0_OFFSET_MASK;
2548 SA_DBG1(("mpiInitialize: mpiContextTable TableOffset 0x%08X contains 0x%08X\n",TableOffset,ossaHwRegReadExt(agRoot, pcibar, TableOffset )));
2550 SA_ASSERT( (ossaHwRegReadExt(agRoot, pcibar, TableOffset ) == 0x53434D50), "Config table signiture");
2551 if ( (ossaHwRegReadExt(agRoot, pcibar, TableOffset ) != 0x53434D50))
2553 SA_DBG1(("mpiInitialize: TableOffset 0x%x reads 0x%x expect 0x%x \n",TableOffset,ossaHwRegReadExt(agRoot, pcibar, TableOffset ),0x53434D50));
2558 SA_DBG1(("mpiInitialize: MPITableType 0x%x context->offset 0x%x context->value 0x%x\n",context->MPITableType,context->offset,context->value));
2561 switch(context->MPITableType)
2565 case AGSA_MPI_MAIN_CONFIGURATION_TABLE:
2566 SA_DBG1(("mpiInitialize: AGSA_MPI_MAIN_CONFIGURATION_TABLE %d 0x%x + 0x%x = 0x%x\n",context->MPITableType,TableOffset, context->offset, context->value));
2567 OffsetInMain = TableOffset;
2568 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4) , context->value);
2570 case AGSA_MPI_GENERAL_STATUS_TABLE:
2571 SA_DBG1(("mpiInitialize: AGSA_MPI_GENERAL_STATUS_TABLE %d offset 0x%x + 0x%x = 0x%x\n",context->MPITableType ,TableOffset+MAIN_GST_OFFSET, context->offset, context->value ));
2572 OffsetInMain = (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_GST_OFFSET ) & 0xFFFF) + TableOffset;
2573 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4), context->value);
2575 case AGSA_MPI_INBOUND_QUEUE_CONFIGURATION_TABLE:
2576 SA_DBG1(("mpiInitialize: AGSA_MPI_INBOUND_QUEUE_CONFIGURATION_TABLE %d offset 0x%x + 0x%x = 0x%x\n",context->MPITableType,TableOffset+MAIN_IBQ_OFFSET, context->offset, context->value));
2577 OffsetInMain = (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_IBQ_OFFSET ) & 0xFFFF) + TableOffset;
2578 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4), context->value);
2580 case AGSA_MPI_OUTBOUND_QUEUE_CONFIGURATION_TABLE:
2581 SA_DBG1(("mpiInitialize: AGSA_MPI_OUTBOUND_QUEUE_CONFIGURATION_TABLE %d offset 0x%x + 0x%x = 0x%x\n",context->MPITableType,TableOffset+MAIN_OBQ_OFFSET, context->offset, context->value));
2582 OffsetInMain = (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_OBQ_OFFSET ) & 0xFFFF) + TableOffset;
2583 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4), context->value);
2585 case AGSA_MPI_SAS_PHY_ANALOG_SETUP_TABLE:
2586 SA_DBG1(("mpiInitialize: AGSA_MPI_SAS_PHY_ANALOG_SETUP_TABLE %d offset 0x%x + 0x%x = 0x%x\n",context->MPITableType,TableOffset+MAIN_ANALOG_SETUP_OFFSET, context->offset, context->value));
2587 OffsetInMain = (ossaHwRegReadExt(agRoot, pcibar, TableOffset+ MAIN_ANALOG_SETUP_OFFSET) & 0xFFFF) + TableOffset;
2588 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4), context->value);
2590 case AGSA_MPI_INTERRUPT_VECTOR_TABLE:
2591 SA_DBG1(("mpiInitialize: AGSA_MPI_INTERRUPT_VECTOR_TABLE %d offset 0x%x + 0x%x = 0x%x\n",context->MPITableType,TableOffset+MAIN_INT_VEC_TABLE_OFFSET, context->offset, context->value));
2592 OffsetInMain = (ossaHwRegReadExt(agRoot, pcibar, TableOffset+ MAIN_INT_VEC_TABLE_OFFSET) & 0xFFFF) + TableOffset;
2593 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4), context->value);
2595 case AGSA_MPI_PER_SAS_PHY_ATTRIBUTE_TABLE:
2596 SA_DBG1(("mpiInitialize: AGSA_MPI_PER_SAS_PHY_ATTRIBUTE_TABLE %d offset 0x%x + 0x%x = 0x%x\n",context->MPITableType,TableOffset+MAIN_PHY_ATTRIBUTE_OFFSET, context->offset, context->value));
2597 OffsetInMain = (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_PHY_ATTRIBUTE_OFFSET ) & 0xFFFF) + TableOffset;
2598 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4), context->value);
2600 case AGSA_MPI_OUTBOUND_QUEUE_FAILOVER_TABLE:
2601 SA_DBG1(("mpiInitialize: AGSA_MPI_OUTBOUND_QUEUE_FAILOVER_TABLE %d offset 0x%x + 0x%x = 0x%x\n",context->MPITableType,TableOffset+MAIN_MOQFOT_MOQFOES, context->offset, context->value));
2602 OffsetInMain = (ossaHwRegReadExt(agRoot, pcibar, TableOffset+MAIN_MOQFOT_MOQFOES ) & 0xFFFF) + TableOffset;
2603 ossaHwRegWriteExt(agRoot, pcibar, OffsetInMain + (context->offset * 4), context->value);
2606 SA_DBG1(("mpiInitialize: error MPITableType unknown %d offset 0x%x value 0x%x\n",context->MPITableType, context->offset, context->value));
2609 if(smIS_SPC12V(agRoot))
2611 if (saRoot->ControllerInfo.fwInterfaceRev > 0x301 )
2613 SA_DBG1(("mpiInitialize: MAIN_AWT_MIDRANGE 0x%08X\n",
2614 ossaHwRegReadExt(agRoot, pcibar, TableOffset + MAIN_AWT_MIDRANGE)
2618 if(length >= sizeof(agsaMPIContext_t))
2620 length -= sizeof(agsaMPIContext_t);
2632 SA_DBG1(("mpiInitialize: context %p saRoot->swConfig.mpiContextTable %p %d\n",context,saRoot->swConfig.mpiContextTable,context == saRoot->swConfig.mpiContextTable ? 1 : 0));
2634 if ( (ossaHwRegReadExt(agRoot, pcibar, TableOffset ) != 0x53434D50))
2636 SA_DBG1(("mpiInitialize:TableOffset 0x%x reads 0x%x expect 0x%x \n",TableOffset,ossaHwRegReadExt(agRoot, pcibar, TableOffset ),0x53434D50));
2639 SA_ASSERT( (ossaHwRegReadExt(agRoot, pcibar, TableOffset ) == 0x53434D50), "Config table signiture After");
2641 /* At this point the Message Unit configuration table is set up. Now we need to ring the doorbell */
2644 smTrace(hpDBG_VERY_LOUD,"74", siHalRegReadExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET ));
2645 /* TP:74 Doorbell */
2647 /* Write bit0=1 to Inbound DoorBell Register to tell the SPC FW the table is updated */
2648 siHalRegWriteExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET, SPC_MSGU_CFG_TABLE_UPDATE);
2650 if(siHalRegReadExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET ) & SPC_MSGU_CFG_TABLE_UPDATE)
2652 SA_DBG1(("mpiInitialize: SPC_MSGU_CFG_TABLE_UPDATE (0x%X) \n", siHalRegReadExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET)));
2656 SA_DBG1(("mpiInitialize: SPC_MSGU_CFG_TABLE_UPDATE not set (0x%X)\n", siHalRegReadExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET)));
2657 ossaStallThread(agRoot, WAIT_INCREMENT);
2660 smTrace(hpDBG_VERY_LOUD,"A5", siHalRegReadExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET ));
2661 /* TP:A5 Doorbell */
2664 // ossaHwRegWrite(agRoot, MSGU_IBDB_SET, SPC_MSGU_CFG_TABLE_UPDATE);
2665 MSGU_WRITE_IDR(SPC_MSGU_CFG_TABLE_UPDATE);
2669 /* wait until Inbound DoorBell Clear Register toggled */
2671 max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
2672 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
2675 ossaStallThread(agRoot, WAIT_INCREMENT);
2676 value = MSGU_READ_IDR;
2677 value &= SPC_MSGU_CFG_TABLE_UPDATE;
2678 } while ((value != togglevalue) && (max_wait_count -= WAIT_INCREMENT));
2680 smTrace(hpDBG_VERY_LOUD,"80", max_wait_count);
2681 /* TP:80 TP max_wait_count */
2682 if (!max_wait_count && mpiStartToggleFailed < 5 )
2684 SA_DBG1(("mpiInitialize: mpiStartToggleFailed count %d\n", mpiStartToggleFailed));
2685 mpiStartToggleFailed++;
2689 if (!max_wait_count )
2692 SA_DBG1(("mpiInitialize: TIMEOUT:IBDB value/toggle = 0x%x 0x%x\n", value, togglevalue));
2693 MSGUCfgTblDWIdx = saveOffset;
2694 GSTLenMPIS = ossaHwRegReadExt(agRoot, pcibar, (bit32)MSGUCfgTblDWIdx + (bit32)(mainCfg.GSTOffset + GST_GSTLEN_MPIS_OFFSET));
2695 SA_DBG1(("mpiInitialize: MPI State = 0x%x\n", GSTLenMPIS));
2696 smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "m3");
2697 return AGSA_RC_FAILURE;
2699 smTrace(hpDBG_VERY_LOUD,"81", mpiStartToggleFailed );
2702 /* check the MPI-State for initialization */
2703 MSGUCfgTblDWIdx = saveOffset;
2704 GSTLenMPIS = ossaHwRegReadExt(agRoot, pcibar, (bit32)MSGUCfgTblDWIdx + (bit32)(mainCfg.GSTOffset + GST_GSTLEN_MPIS_OFFSET));
2705 if ( (GST_MPI_STATE_UNINIT == (GSTLenMPIS & GST_MPI_STATE_MASK)) && ( mpiUnInitFailed < 5 ) )
2707 SA_DBG1(("mpiInitialize: MPI State = 0x%x mpiUnInitFailed count %d\n", GSTLenMPIS & GST_MPI_STATE_MASK,mpiUnInitFailed));
2708 ossaStallThread(agRoot, (20 * 1000));
2714 if (GST_MPI_STATE_INIT != (GSTLenMPIS & GST_MPI_STATE_MASK))
2716 SA_DBG1(("mpiInitialize: Error Not GST_MPI_STATE_INIT MPI State = 0x%x\n", GSTLenMPIS & GST_MPI_STATE_MASK));
2717 smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "m3");
2718 return AGSA_RC_FAILURE;
2720 smTrace(hpDBG_VERY_LOUD,"82", 0);
2723 /* check MPI Initialization error */
2724 GSTLenMPIS = GSTLenMPIS >> SHIFT16;
2725 if (0x0000 != GSTLenMPIS)
2727 SA_DBG1(("mpiInitialize: MPI Error = 0x%x\n", GSTLenMPIS));
2728 smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "m3");
2729 return AGSA_RC_FAILURE;
2731 smTrace(hpDBG_VERY_LOUD,"83", 0);
2734 /* reread IQ PI offset from SPC if IQ/OQ > 32 */
2735 if ((maxinbound > IQ_NUM_32) || (maxoutbound > OQ_NUM_32))
2737 for(qIdx = 0; qIdx < maxinbound; qIdx++)
2739 /* point back to the begin then plus offset to next queue */
2740 MSGUCfgTblDWIdx = saveOffset;
2741 MSGUCfgTblDWIdx += inboundoffset;
2742 MSGUCfgTblDWIdx += (sizeof(spc_inboundQueueDescriptor_t) * qIdx);
2743 saRoot->inboundQueue[qIdx].PIPCIOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + IB_PIPCI_BAR_OFFSET));
2746 smTrace(hpDBG_VERY_LOUD,"84", 0);
2749 /* at least one inbound queue and one outbound queue enabled */
2750 if ((0 == config->inboundQueues[0].numElements) || (0 == config->outboundQueues[0].numElements))
2752 SA_DBG1(("mpiInitialize: Error,IQ0 or OQ0 have to enable\n"));
2753 smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "m3");
2754 return AGSA_RC_FAILURE;
2756 smTrace(hpDBG_VERY_LOUD,"85", 0);
2759 /* clean the inbound queues */
2760 for (i = 0; i < config->numInboundQueues; i ++)
2762 if(0 != config->inboundQueues[i].numElements)
2764 circularIQ = &saRoot->inboundQueue[i];
2765 si_memset(circularIQ->memoryRegion.virtPtr, 0, circularIQ->memoryRegion.totalLength);
2766 si_memset(saRoot->inboundQueue[i].ciPointer, 0, sizeof(bit32));
2768 if(smIS_SPCV(agRoot))
2770 ossaHwRegWriteExt(circularIQ->agRoot, circularIQ->PIPCIBar, circularIQ->PIPCIOffset, 0);
2771 SA_DBG1(("mpiInitialize: SPC V writes IQ %2d offset 0x%x\n",i ,circularIQ->PIPCIOffset));
2775 smTrace(hpDBG_VERY_LOUD,"86", 0);
2778 /* clean the outbound queues */
2779 for (i = 0; i < config->numOutboundQueues; i ++)
2781 if(0 != config->outboundQueues[i].numElements)
2783 circularOQ = &saRoot->outboundQueue[i];
2784 si_memset(circularOQ->memoryRegion.virtPtr, 0, circularOQ->memoryRegion.totalLength);
2785 si_memset(saRoot->outboundQueue[i].piPointer, 0, sizeof(bit32));
2786 if(smIS_SPCV(agRoot))
2788 ossaHwRegWriteExt(circularOQ->agRoot, circularOQ->CIPCIBar, circularOQ->CIPCIOffset, 0);
2789 SA_DBG2(("mpiInitialize: SPC V writes OQ %2d offset 0x%x\n",i ,circularOQ->CIPCIOffset));
2796 smTrace(hpDBG_VERY_LOUD,"75",0);
2797 /* TP:75 AAP1 IOP */
2799 /* read back AAP1 and IOP event log address and size */
2800 MSGUCfgTblDWIdx = saveOffset;
2801 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_ADDR_HI));
2802 saRoot->mainConfigTable.upperEventLogAddress = value;
2803 SA_DBG1(("mpiInitialize: upperEventLogAddress 0x%x\n", value));
2804 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_ADDR_LO));
2805 saRoot->mainConfigTable.lowerEventLogAddress = value;
2806 SA_DBG1(("mpiInitialize: lowerEventLogAddress 0x%x\n", value));
2807 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_BUFF_SIZE));
2808 saRoot->mainConfigTable.eventLogSize = value;
2809 SA_DBG1(("mpiInitialize: eventLogSize 0x%x\n", value));
2810 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_EVENT_LOG_OPTION));
2811 saRoot->mainConfigTable.eventLogOption = value;
2812 SA_DBG1(("mpiInitialize: eventLogOption 0x%x\n", value));
2813 SA_DBG1(("mpiInitialize: EventLog dd /p %08X`%08X L %x\n",saRoot->mainConfigTable.upperEventLogAddress,saRoot->mainConfigTable.lowerEventLogAddress,saRoot->mainConfigTable.eventLogSize/4 ));
2815 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_ADDR_HI));
2816 saRoot->mainConfigTable.upperIOPeventLogAddress = value;
2817 SA_DBG1(("mpiInitialize: upperIOPLogAddress 0x%x\n", value));
2818 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_ADDR_LO));
2819 saRoot->mainConfigTable.lowerIOPeventLogAddress = value;
2820 SA_DBG1(("mpiInitialize: lowerIOPLogAddress 0x%x\n", value));
2821 SA_DBG1(("mpiInitialize: IOPLog dd /p %08X`%08X L %x\n",saRoot->mainConfigTable.upperIOPeventLogAddress,saRoot->mainConfigTable.lowerIOPeventLogAddress,saRoot->mainConfigTable.IOPeventLogSize/4 ));
2822 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_BUFF_SIZE));
2823 saRoot->mainConfigTable.IOPeventLogSize = value;
2824 SA_DBG1(("mpiInitialize: IOPeventLogSize 0x%x\n", value));
2825 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IOP_EVENT_LOG_OPTION));
2826 saRoot->mainConfigTable.IOPeventLogOption = value;
2827 SA_DBG1(("mpiInitialize: IOPeventLogOption 0x%x\n", value));
2828 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_FATAL_ERROR_INTERRUPT));
2830 #ifdef SA_PRINTOUT_IN_WINDBG
2832 DbgPrint("mpiInitialize: EventLog (%d) dd /p %08X`%08X L %x\n",
2833 saRoot->mainConfigTable.eventLogOption,
2834 saRoot->mainConfigTable.upperEventLogAddress,
2835 saRoot->mainConfigTable.lowerEventLogAddress,
2836 saRoot->mainConfigTable.eventLogSize/4 );
2837 DbgPrint("mpiInitialize: IOPLog (%d) dd /p %08X`%08X L %x\n",
2838 saRoot->mainConfigTable.IOPeventLogOption,
2839 saRoot->mainConfigTable.upperIOPeventLogAddress,
2840 saRoot->mainConfigTable.lowerIOPeventLogAddress,
2841 saRoot->mainConfigTable.IOPeventLogSize/4 );
2843 #endif /* SA_PRINTOUT_IN_WINDBG */
2845 saRoot->mainConfigTable.FatalErrorInterrupt = value;
2846 smTrace(hpDBG_VERY_LOUD,"76",value);
2847 /* TP:76 FatalErrorInterrupt */
2849 SA_DBG1(("mpiInitialize: hwConfig->hwOption %X\n", saRoot->hwConfig.hwOption ));
2851 SA_DBG1(("mpiInitialize: FatalErrorInterrupt 0x%x\n", value));
2853 /* read back Register Dump offset and length */
2854 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP0_OFFSET));
2855 saRoot->mainConfigTable.FatalErrorDumpOffset0 = value;
2856 SA_DBG1(("mpiInitialize: FatalErrorDumpOffset0 0x%x\n", value));
2857 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP0_LENGTH));
2858 saRoot->mainConfigTable.FatalErrorDumpLength0 = value;
2859 SA_DBG1(("mpiInitialize: FatalErrorDumpLength0 0x%x\n", value));
2860 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP1_OFFSET));
2861 saRoot->mainConfigTable.FatalErrorDumpOffset1 = value;
2862 SA_DBG1(("mpiInitialize: FatalErrorDumpOffset1 0x%x\n", value));
2863 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP1_LENGTH));
2864 saRoot->mainConfigTable.FatalErrorDumpLength1 = value;
2865 SA_DBG1(("mpiInitialize: FatalErrorDumpLength1 0x%x\n", value));
2867 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_PRECTD_PRESETD));
2868 saRoot->mainConfigTable.PortRecoveryTimerPortResetTimer = value;
2870 SA_DBG1(("mpiInitialize: PortRecoveryTimerPortResetTimer 0x%x\n", value));
2871 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(MSGUCfgTblDWIdx + MAIN_IRAD_RESERVED));
2872 saRoot->mainConfigTable.InterruptReassertionDelay = value;
2874 SA_DBG1(("mpiInitialize: InterruptReassertionDelay 0x%x\n", value));
2877 if(smIS_SPCV(agRoot))
2880 sp1= ossaHwRegRead(agRoot,V_Scratchpad_1_Register );
2881 if(SCRATCH_PAD1_V_ERROR_STATE(sp1))
2883 SA_DBG1(("mpiInitialize: SCRATCH_PAD1_V_ERROR_STAT 0x%x\n",sp1 ));
2884 ret = AGSA_RC_FAILURE;
2889 smTraceFuncExit(hpDBG_VERY_LOUD, 'j', "m3");
2893 /*******************************************************************************/
2894 /** \fn mpiWaitForConfigTable(agsaRoot_t *agRoot, spc_configMainDescriptor_t *config)
2895 * \brief Reading and Writing the Configuration Table
2896 * \param agsaRoot Pointer to a data structure containing LL layer context handles
2897 * \param config Pointer to Configuration Table
2900 * AGSA_RC_SUCCESS if read the configuration table from SPC sucessful
2901 * AGSA_RC_FAILURE if read the configuration table from SPC failed
2903 /*******************************************************************************/
2904 GLOBAL bit32 mpiWaitForConfigTable(agsaRoot_t *agRoot,
2905 spc_configMainDescriptor_t *config)
2907 agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
2908 bit32 MSGUCfgTblBase, ret = AGSA_RC_SUCCESS;
2910 bit32 value, value1;
2911 bit32 max_wait_time;
2912 bit32 max_wait_count;
2913 bit32 Signature, ExpSignature;
2916 SA_DBG2(("mpiWaitForConfigTable: Entering\n"));
2917 SA_ASSERT(NULL != agRoot, "agRoot argument cannot be null");
2919 smTraceFuncEnter(hpDBG_VERY_LOUD,"m4");
2922 /* check error state */
2923 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1,MSGU_SCRATCH_PAD_1);
2924 value1 = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2,MSGU_SCRATCH_PAD_2);
2926 if( smIS_SPC(agRoot) )
2928 SA_DBG1(("mpiWaitForConfigTable: Waiting for SPC FW becoming ready.P1 0x%X P2 0x%X\n",value,value1));
2930 /* check AAP error */
2931 if (SCRATCH_PAD1_ERR == (value & SCRATCH_PAD_STATE_MASK))
2934 SA_DBG1(("mpiWaitForConfigTable: AAP error state and code 0x%x, ScratchPad2=0x%x\n", value, value1));
2935 #if defined(SALLSDK_DEBUG)
2936 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD0 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0)));
2937 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD3 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3,MSGU_SCRATCH_PAD_3)));
2939 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m4");
2940 return AGSA_RC_FAILURE;
2943 /* check IOP error */
2944 if (SCRATCH_PAD2_ERR == (value1 & SCRATCH_PAD_STATE_MASK))
2947 SA_DBG1(("mpiWaitForConfigTable: IOP error state and code 0x%x, ScratchPad1=0x%x\n", value1, value));
2948 #if defined(SALLSDK_DEBUG)
2949 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD0 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0)));
2950 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD3 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3,MSGU_SCRATCH_PAD_3)));
2952 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "m4");
2953 return AGSA_RC_FAILURE;
2956 /* bit 4-31 of scratch pad1 should be zeros if it is not in error state */
2957 #ifdef DONT_DO /* */
2958 if (value & SCRATCH_PAD1_STATE_MASK)
2961 SA_DBG1(("mpiWaitForConfigTable: wrong state failure, scratchPad1 0x%x\n", value));
2962 SA_DBG1(("mpiWaitForConfigTable: ScratchPad0 AAP error code 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0)));
2963 #if defined(SALLSDK_DEBUG)
2964 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD2 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2,MSGU_SCRATCH_PAD_0)));
2965 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD3 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3,MSGU_SCRATCH_PAD_3)));
2967 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "m4");
2968 return AGSA_RC_FAILURE;
2971 /* bit 4-31 of scratch pad2 should be zeros if it is not in error state */
2972 if (value1 & SCRATCH_PAD2_STATE_MASK)
2975 SA_DBG1(("mpiWaitForConfigTable: wrong state failure, scratchPad2 0x%x\n", value1));
2976 SA_DBG1(("mpiWaitForConfigTable: ScratchPad3 IOP error code 0x%x\n",siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3,MSGU_SCRATCH_PAD_3) ));
2977 #if defined(SALLSDK_DEBUG)
2978 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD0 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0)));
2979 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD1 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1,MSGU_SCRATCH_PAD_1)));
2981 smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "m4");
2983 return AGSA_RC_FAILURE;
2985 #endif /* DONT_DO */
2987 /* checking the fw and IOP in ready state */
2988 max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec timeout */
2989 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
2990 /* wait until scratch pad 1 and 2 registers in ready state */
2993 ossaStallThread(agRoot, WAIT_INCREMENT);
2994 value =siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1,MSGU_SCRATCH_PAD_1) & SCRATCH_PAD1_RDY;
2995 value1 =siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2,MSGU_SCRATCH_PAD_2) & SCRATCH_PAD2_RDY;
2996 if(smIS_SPCV(agRoot))
2998 SA_DBG1(("mpiWaitForConfigTable:VEN_DEV_SPCV force SCRATCH_PAD2 RDY 1 %08X 2 %08X\n" ,value,value1));
3002 if ((max_wait_count -= WAIT_INCREMENT) == 0)
3004 SA_DBG1(("mpiWaitForConfigTable: Timeout!! SCRATCH_PAD1/2 value = 0x%x 0x%x\n", value, value1));
3007 } while ((value != SCRATCH_PAD1_RDY) || (value1 != SCRATCH_PAD2_RDY));
3009 if (!max_wait_count)
3011 SA_DBG1(("mpiWaitForConfigTable: timeout failure\n"));
3012 #if defined(SALLSDK_DEBUG)
3013 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD0 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0)));
3014 SA_DBG1(("mpiWaitForConfigTable: SCRATCH_PAD3 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3,MSGU_SCRATCH_PAD_3)));
3016 smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "m4");
3017 return AGSA_RC_FAILURE;
3023 if(((value & SCRATCH_PAD1_V_BOOTSTATE_HDA_SEEPROM ) == SCRATCH_PAD1_V_BOOTSTATE_HDA_SEEPROM))
3025 SA_DBG1(("mpiWaitForConfigTable: HDA mode set in SEEPROM SP1 0x%X\n",value));
3027 if(((value & SCRATCH_PAD1_V_READY) != SCRATCH_PAD1_V_READY) ||
3028 (value == 0xffffffff))
3030 SA_DBG1(("mpiWaitForConfigTable: Waiting for _V_ FW becoming ready.P1 0x%X P2 0x%X\n",value,value1));
3032 /* checking the fw and IOP in ready state */
3033 max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec timeout */
3034 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
3035 /* wait until scratch pad 1 and 2 registers in ready state */
3038 ossaStallThread(agRoot, WAIT_INCREMENT);
3039 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1,MSGU_SCRATCH_PAD_1);
3040 value1 = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2,MSGU_SCRATCH_PAD_2);
3042 if ((max_wait_count -= WAIT_INCREMENT) == 0)
3044 SA_DBG1(("mpiWaitForConfigTable: Timeout!! SCRATCH_PAD1/2 value = 0x%x 0x%x\n", value, value1));
3045 return AGSA_RC_FAILURE;
3047 } while (((value & SCRATCH_PAD1_V_READY) != SCRATCH_PAD1_V_READY) ||
3048 (value == 0xffffffff));
3053 SA_DBG1(("mpiWaitForConfigTable: FW Ready, SCRATCH_PAD1/2 value = 0x%x 0x%x\n", value, value1));
3055 /* read scratch pad0 to get PCI BAR and offset of configuration table */
3056 MSGUCfgTblBase = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
3058 CfgTblDWIdx = MSGUCfgTblBase & SCRATCH_PAD0_OFFSET_MASK;
3060 MSGUCfgTblBase = (MSGUCfgTblBase & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
3062 if(smIS_SPC(agRoot))
3064 if( smIS_spc8081(agRoot))
3066 if (BAR4 != MSGUCfgTblBase)
3068 SA_DBG1(("mpiWaitForConfigTable: smIS_spc8081 PCI BAR is not BAR4, bar=0x%x - failure\n", MSGUCfgTblBase));
3069 smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "m4");
3070 return AGSA_RC_FAILURE;
3075 if (BAR5 != MSGUCfgTblBase)
3077 SA_DBG1(("mpiWaitForConfigTable: PCI BAR is not BAR5, bar=0x%x - failure\n", MSGUCfgTblBase));
3078 smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "m4");
3079 return AGSA_RC_FAILURE;
3084 /* convert the PCI BAR to logical bar number */
3085 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, MSGUCfgTblBase);
3087 /* read signature from the configuration table */
3088 Signature = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx);
3090 /* Error return if the signature is not "PMCS" */
3091 ExpSignature = ('P') | ('M' << SHIFT8) | ('C' << SHIFT16) | ('S' << SHIFT24);
3093 if (Signature != ExpSignature)
3095 SA_DBG1(("mpiWaitForConfigTable: Signature value = 0x%x\n", Signature));
3096 smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "m4");
3097 return AGSA_RC_FAILURE;
3100 /* save Signature */
3101 si_memcpy(&config->Signature, &Signature, sizeof(Signature));
3103 /* read Interface Revsion from the configuration table */
3104 config->InterfaceRev = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_INTERFACE_REVISION);
3106 /* read FW Revsion from the configuration table */
3107 config->FWRevision = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_FW_REVISION);
3109 /* read Max Outstanding IO from the configuration table */
3110 config->MaxOutstandingIO = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_MAX_OUTSTANDING_IO_OFFSET);
3112 /* read Max SGL and Max Devices from the configuration table */
3113 config->MDevMaxSGL = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_MAX_SGL_OFFSET);
3115 /* read Controller Cap Flags from the configuration table */
3116 config->ContrlCapFlag = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_CNTRL_CAP_OFFSET);
3118 /* read GST Table Offset from the configuration table */
3119 config->GSTOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_GST_OFFSET);
3121 /* read Inbound Queue Offset from the configuration table */
3122 config->inboundQueueOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_IBQ_OFFSET);
3124 /* read Outbound Queue Offset from the configuration table */
3125 config->outboundQueueOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_OBQ_OFFSET);
3128 if(smIS_SPCV(agRoot))
3130 ;/* SPCV - reserved field */
3134 /* read HDA Flags from the configuration table */
3135 config->HDAModeFlags = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_HDA_FLAGS_OFFSET);
3138 /* read analog Setting offset from the configuration table */
3139 config->analogSetupTblOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_ANALOG_SETUP_OFFSET);
3141 if(smIS_SPCV(agRoot))
3143 ;/* SPCV - reserved field */
3144 /* read interrupt vector table offset */
3145 config->InterruptVecTblOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_INT_VEC_TABLE_OFFSET);
3146 /* read phy attribute table offset */
3147 config->phyAttributeTblOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_PHY_ATTRIBUTE_OFFSET);
3148 SA_DBG1(("mpiWaitForConfigTable: INT Vector Tble Offset = 0x%x\n", config->InterruptVecTblOffset));
3149 SA_DBG1(("mpiWaitForConfigTable: Phy Attribute Tble Offset = 0x%x\n", config->phyAttributeTblOffset));
3153 ;/* SPC - Not used */
3156 /* read Error Dump Offset and Length */
3157 config->FatalErrorDumpOffset0 = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP0_OFFSET);
3158 config->FatalErrorDumpLength0 = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP0_LENGTH);
3159 config->FatalErrorDumpOffset1 = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP1_OFFSET);
3160 config->FatalErrorDumpLength1 = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_FATAL_ERROR_RDUMP1_LENGTH);
3162 SA_DBG1(("mpiWaitForConfigTable: Interface Revision value = 0x%08x\n", config->InterfaceRev));
3163 SA_DBG1(("mpiWaitForConfigTable: FW Revision value = 0x%08x\n", config->FWRevision));
3165 if(smIS_SPC(agRoot))
3167 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%08x\n", STSDK_LL_SPC_VERSION));
3169 if(smIS_SPC6V(agRoot))
3171 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%08x\n",STSDK_LL_VERSION ));
3173 if(smIS_SPC12V(agRoot))
3175 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%08x\n",STSDK_LL_12G_VERSION ));
3178 SA_DBG1(("mpiWaitForConfigTable: MaxOutstandingIO value = 0x%08x\n", config->MaxOutstandingIO));
3179 SA_DBG1(("mpiWaitForConfigTable: MDevMaxSGL value = 0x%08x\n", config->MDevMaxSGL));
3180 SA_DBG1(("mpiWaitForConfigTable: ContrlCapFlag value = 0x%08x\n", config->ContrlCapFlag));
3181 SA_DBG1(("mpiWaitForConfigTable: GSTOffset value = 0x%08x\n", config->GSTOffset));
3182 SA_DBG1(("mpiWaitForConfigTable: inboundQueueOffset value = 0x%08x\n", config->inboundQueueOffset));
3183 SA_DBG1(("mpiWaitForConfigTable: outboundQueueOffset value = 0x%08x\n", config->outboundQueueOffset));
3184 SA_DBG1(("mpiWaitForConfigTable: FatalErrorDumpOffset0 value = 0x%08x\n", config->FatalErrorDumpOffset0));
3185 SA_DBG1(("mpiWaitForConfigTable: FatalErrorDumpLength0 value = 0x%08x\n", config->FatalErrorDumpLength0));
3186 SA_DBG1(("mpiWaitForConfigTable: FatalErrorDumpOffset1 value = 0x%08x\n", config->FatalErrorDumpOffset1));
3187 SA_DBG1(("mpiWaitForConfigTable: FatalErrorDumpLength1 value = 0x%08x\n", config->FatalErrorDumpLength1));
3190 SA_DBG1(("mpiWaitForConfigTable: HDAModeFlags value = 0x%08x\n", config->HDAModeFlags));
3191 SA_DBG1(("mpiWaitForConfigTable: analogSetupTblOffset value = 0x%08x\n", config->analogSetupTblOffset));
3193 /* check interface version */
3195 if(smIS_SPC6V(agRoot))
3197 if (config->InterfaceRev != STSDK_LL_INTERFACE_VERSION)
3199 SA_DBG1(("mpiWaitForConfigTable: V sTSDK interface ver. 0x%x does not match InterfaceRev 0x%x warning!\n", STSDK_LL_INTERFACE_VERSION, config->InterfaceRev));
3200 ret = AGSA_RC_VERSION_UNTESTED;
3201 if ((config->InterfaceRev & STSDK_LL_INTERFACE_VERSION_IGNORE_MASK) != (STSDK_LL_INTERFACE_VERSION & STSDK_LL_INTERFACE_VERSION_IGNORE_MASK))
3203 SA_DBG1(("mpiWaitForConfigTable: V sTSDK interface ver. 0x%x incompatible with InterfaceRev 0x%x warning!\n", STSDK_LL_INTERFACE_VERSION, config->InterfaceRev));
3204 ret = AGSA_RC_VERSION_INCOMPATIBLE;
3205 smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "m4");
3210 else if(smIS_SPC12V(agRoot))
3212 if (config->InterfaceRev != STSDK_LL_12G_INTERFACE_VERSION)
3214 SA_DBG1(("mpiWaitForConfigTable: 12g V sTSDK interface ver. 0x%x does not match InterfaceRev 0x%x warning!\n", STSDK_LL_12G_INTERFACE_VERSION, config->InterfaceRev));
3215 ret = AGSA_RC_VERSION_UNTESTED;
3216 if ((config->InterfaceRev & STSDK_LL_INTERFACE_VERSION_IGNORE_MASK) != (STSDK_LL_12G_INTERFACE_VERSION & STSDK_LL_INTERFACE_VERSION_IGNORE_MASK))
3218 SA_DBG1(("mpiWaitForConfigTable: V sTSDK interface ver. 0x%x incompatible with InterfaceRev 0x%x warning!\n", STSDK_LL_12G_INTERFACE_VERSION, config->InterfaceRev));
3219 ret = AGSA_RC_VERSION_INCOMPATIBLE;
3220 ret = AGSA_RC_VERSION_UNTESTED;
3221 smTraceFuncExit(hpDBG_VERY_LOUD, 'j', "m4");
3228 if (config->InterfaceRev != STSDK_LL_OLD_INTERFACE_VERSION)
3230 SA_DBG1(("mpiWaitForConfigTable: SPC sTSDK interface ver. 0x%08x not compatible with InterfaceRev 0x%x warning!\n", STSDK_LL_INTERFACE_VERSION, config->InterfaceRev));
3231 ret = AGSA_RC_VERSION_INCOMPATIBLE;
3232 smTraceFuncExit(hpDBG_VERY_LOUD, 'k', "m4");
3239 /* Check FW versions */
3240 if(smIS_SPC6V(agRoot))
3242 SA_DBG1(("mpiWaitForConfigTable:6 sTSDK ver. sa.h 0x%08x config 0x%08x\n", STSDK_LL_VERSION, config->FWRevision));
3243 /* check FW and LL sTSDK version */
3244 if (config->FWRevision != MATCHING_V_FW_VERSION )
3246 if (config->FWRevision > MATCHING_V_FW_VERSION)
3248 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x hadn't tested with FW ver. 0x%08x warning!\n", STSDK_LL_VERSION, config->FWRevision));
3249 ret = AGSA_RC_VERSION_UNTESTED;
3252 else if (config->FWRevision < MIN_FW_SPCVE_VERSION_SUPPORTED)
3254 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x not compatible with FW ver. 0x%08x warning!\n", STSDK_LL_VERSION, config->FWRevision));
3255 ret = AGSA_RC_VERSION_INCOMPATIBLE;
3256 smTraceFuncExit(hpDBG_VERY_LOUD, 'l', "m4");
3261 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x mismatch with FW ver. 0x%08x warning!\n",STSDK_LL_VERSION , config->FWRevision));
3262 ret = AGSA_RC_VERSION_UNTESTED;
3265 }else if(smIS_SPC12V(agRoot))
3267 SA_DBG1(("mpiWaitForConfigTable:12 sTSDK ver. sa.h 0x%08x config 0x%08x\n", STSDK_LL_12G_VERSION, config->FWRevision));
3268 /* check FW and LL sTSDK version */
3269 if (config->FWRevision != MATCHING_12G_V_FW_VERSION )
3271 if (config->FWRevision > MATCHING_12G_V_FW_VERSION)
3273 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x hadn't tested with FW ver. 0x%08x warning!\n", STSDK_LL_12G_VERSION, config->FWRevision));
3274 ret = AGSA_RC_VERSION_UNTESTED;
3277 else if (config->FWRevision < MIN_FW_12G_SPCVE_VERSION_SUPPORTED)
3279 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x not compatible with FW ver. 0x%08x warning!\n", STSDK_LL_12G_VERSION, config->FWRevision));
3280 ret = AGSA_RC_VERSION_INCOMPATIBLE;
3281 smTraceFuncExit(hpDBG_VERY_LOUD, 'm', "m4");
3286 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x mismatch with FW ver. 0x%08x warning!\n",STSDK_LL_12G_VERSION , config->FWRevision));
3287 ret = AGSA_RC_VERSION_UNTESTED;
3293 if (config->FWRevision != MATCHING_SPC_FW_VERSION )
3295 if (config->FWRevision > MATCHING_SPC_FW_VERSION)
3297 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x hadn't tested with FW ver. 0x%08x warning!\n", STSDK_LL_SPC_VERSION, config->FWRevision));
3298 ret = AGSA_RC_VERSION_UNTESTED;
3300 else if (config->FWRevision < MIN_FW_SPC_VERSION_SUPPORTED)
3302 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x not compatible with FW ver. 0x%08x warning!\n", STSDK_LL_SPC_VERSION, config->FWRevision));
3303 ret = AGSA_RC_VERSION_INCOMPATIBLE;
3304 smTraceFuncExit(hpDBG_VERY_LOUD, 'n', "m4");
3309 SA_DBG1(("mpiWaitForConfigTable: sTSDK ver. 0x%x mismatch with FW ver. 0x%08x warning!\n",STSDK_LL_SPC_VERSION , config->FWRevision));
3310 ret = AGSA_RC_VERSION_UNTESTED;
3314 SA_DBG1(("mpiWaitForConfigTable: ILA version 0x%08X\n", ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_ILAT_ILAV_ILASMRN_ILAMRN_ILAMJN) ));
3317 if(smIS_SPC12V(agRoot))
3319 if (config->InterfaceRev > 0x301 )
3321 SA_DBG1(("mpiWaitForConfigTable: MAIN_INACTIVE_ILA_REVSION 0x%08X\n", ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_INACTIVE_ILA_REVSION) ));
3322 SA_DBG1(("mpiWaitForConfigTable: MAIN_SEEPROM_REVSION 0x%08X\n", ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_SEEPROM_REVSION) ));
3326 if(smIS_SPC12V(agRoot))
3328 if (config->InterfaceRev > 0x301 )
3330 SA_DBG1(("mpiWaitForConfigTable: MAIN_AWT_MIDRANGE 0x%08X\n", ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_AWT_MIDRANGE) ));
3335 if(smIS_SFC(agRoot))
3337 /* always success for SFC*/
3338 ret = AGSA_RC_SUCCESS;
3341 if (agNULL != saRoot)
3343 /* save the information */
3344 saRoot->ControllerInfo.signature = Signature;
3345 saRoot->ControllerInfo.fwInterfaceRev = config->InterfaceRev;
3347 if(smIS_SPCV(agRoot))
3349 saRoot->ControllerInfo.hwRevision = (ossaHwRegReadConfig32(agRoot,8) & 0xFF);
3350 SA_DBG1(("mpiWaitForConfigTable: hwRevision 0x%x\n",saRoot->ControllerInfo.hwRevision ));
3354 saRoot->ControllerInfo.hwRevision = SPC_READ_DEV_REV;
3357 saRoot->ControllerInfo.fwRevision = config->FWRevision;
3358 saRoot->ControllerInfo.ilaRevision = config->ilaRevision;
3359 saRoot->ControllerInfo.maxPendingIO = config->MaxOutstandingIO;
3360 saRoot->ControllerInfo.maxSgElements = config->MDevMaxSGL & 0xFFFF;
3361 saRoot->ControllerInfo.maxDevices = (config->MDevMaxSGL & MAX_DEV_BITS) >> SHIFT16;
3362 saRoot->ControllerInfo.queueSupport = config->ContrlCapFlag & Q_SUPPORT_BITS;
3363 saRoot->ControllerInfo.phyCount = (bit8)((config->ContrlCapFlag & PHY_COUNT_BITS) >> SHIFT19);
3364 saRoot->ControllerInfo.sasSpecsSupport = (config->ContrlCapFlag & SAS_SPEC_BITS) >> SHIFT25;
3365 SA_DBG1(("mpiWaitForConfigTable: MaxOutstandingIO 0x%x swConfig->maxActiveIOs 0x%x\n", config->MaxOutstandingIO,saRoot->swConfig.maxActiveIOs ));
3367 if(smIS_SPCV(agRoot))
3369 ;/* SPCV - reserved field */
3373 saRoot->ControllerInfo.controllerSetting = (bit8)config->HDAModeFlags;
3376 saRoot->ControllerInfo.sdkInterfaceRev = STSDK_LL_INTERFACE_VERSION;
3377 saRoot->ControllerInfo.sdkRevision = STSDK_LL_VERSION;
3378 saRoot->mainConfigTable.regDumpPCIBAR = pcibar;
3379 saRoot->mainConfigTable.FatalErrorDumpOffset0 = config->FatalErrorDumpOffset0;
3380 saRoot->mainConfigTable.FatalErrorDumpLength0 = config->FatalErrorDumpLength0;
3381 saRoot->mainConfigTable.FatalErrorDumpOffset1 = config->FatalErrorDumpOffset1;
3382 saRoot->mainConfigTable.FatalErrorDumpLength1 = config->FatalErrorDumpLength1;
3384 if(smIS_SPCV(agRoot))
3386 ;/* SPCV - reserved field */
3390 saRoot->mainConfigTable.HDAModeFlags = config->HDAModeFlags;
3393 saRoot->mainConfigTable.analogSetupTblOffset = config->analogSetupTblOffset;
3395 if(smIS_SPCV(agRoot))
3397 saRoot->mainConfigTable.InterruptVecTblOffset = config->InterruptVecTblOffset;
3398 saRoot->mainConfigTable.phyAttributeTblOffset = config->phyAttributeTblOffset;
3399 saRoot->mainConfigTable.PortRecoveryTimerPortResetTimer = config->portRecoveryResetTimer;
3402 SA_DBG1(("mpiWaitForConfigTable: Signature = 0x%x\n", Signature));
3403 SA_DBG1(("mpiWaitForConfigTable: hwRevision = 0x%x\n", saRoot->ControllerInfo.hwRevision));
3404 SA_DBG1(("mpiWaitForConfigTable: FW Revision = 0x%x\n", config->FWRevision));
3405 SA_DBG1(("mpiWaitForConfigTable: Max Sgl = 0x%x\n", saRoot->ControllerInfo.maxSgElements));
3406 SA_DBG1(("mpiWaitForConfigTable: Max Device = 0x%x\n", saRoot->ControllerInfo.maxDevices));
3407 SA_DBG1(("mpiWaitForConfigTable: Queue Support = 0x%x\n", saRoot->ControllerInfo.queueSupport));
3408 SA_DBG1(("mpiWaitForConfigTable: Phy Count = 0x%x\n", saRoot->ControllerInfo.phyCount));
3409 SA_DBG1(("mpiWaitForConfigTable: sas Specs Support = 0x%x\n", saRoot->ControllerInfo.sasSpecsSupport));
3414 if(ret != AGSA_RC_SUCCESS )
3416 SA_DBG1(("mpiWaitForConfigTable: return 0x%x not AGSA_RC_SUCCESS warning!\n", ret));
3420 smTraceFuncExit(hpDBG_VERY_LOUD, 'o', "m4");
3424 /*******************************************************************************/
3425 /** \fn mpiUnInitConfigTable(agsaRoot_t *agRoot, spc_configMainDescriptor_t *config)
3426 * \brief UnInitialization Configuration Table
3427 * \param agsaRoot Pointer to a data structure containing LL layer context handles
3430 * AGSA_RC_SUCCESS if Un-initialize the configuration table sucessful
3431 * AGSA_RC_FAILURE if Un-initialize the configuration table failed
3433 /*******************************************************************************/
3434 GLOBAL bit32 mpiUnInitConfigTable(agsaRoot_t *agRoot)
3436 bit32 MSGUCfgTblBase;
3437 bit32 CfgTblDWIdx, GSTOffset, GSTLenMPIS;
3438 bit32 value, togglevalue;
3439 bit32 max_wait_time;
3440 bit32 max_wait_count;
3443 smTraceFuncEnter(hpDBG_VERY_LOUD,"m7");
3444 SA_DBG1(("mpiUnInitConfigTable: agRoot %p\n",agRoot));
3445 SA_ASSERT(NULL != agRoot, "agRoot argument cannot be null");
3449 /* read scratch pad0 to get PCI BAR and offset of configuration table */
3450 MSGUCfgTblBase =siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
3452 if(MSGUCfgTblBase == 0xFFFFFFFF)
3454 SA_DBG1(("mpiUnInitConfigTable: MSGUCfgTblBase = 0x%x AGSA_RC_FAILURE\n",MSGUCfgTblBase));
3455 return AGSA_RC_FAILURE;
3459 CfgTblDWIdx = MSGUCfgTblBase & SCRATCH_PAD0_OFFSET_MASK;
3461 MSGUCfgTblBase = (MSGUCfgTblBase & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
3463 /* convert the PCI BAR to logical bar number */
3464 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, MSGUCfgTblBase);
3466 /* Write bit 1 to Inbound DoorBell Register */
3467 siHalRegWriteExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET, SPC_MSGU_CFG_TABLE_RESET);
3469 /* wait until Inbound DoorBell Clear Register toggled */
3470 max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
3471 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
3474 ossaStallThread(agRoot, WAIT_INCREMENT);
3475 value = MSGU_READ_IDR;
3476 value &= SPC_MSGU_CFG_TABLE_RESET;
3477 } while ((value != togglevalue) && (max_wait_count -= WAIT_INCREMENT));
3479 if (!max_wait_count)
3481 SA_DBG1(("mpiUnInitConfigTable: TIMEOUT:IBDB value/toggle = 0x%x 0x%x\n", value, togglevalue));
3482 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m7");
3484 if(smIS_SPC(agRoot) )
3486 return AGSA_RC_FAILURE;
3491 /* check the MPI-State for termination in progress */
3492 /* wait until Inbound DoorBell Clear Register toggled */
3493 max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
3494 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
3495 GSTOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + MAIN_GST_OFFSET);
3498 ossaStallThread(agRoot, WAIT_INCREMENT);
3500 if(GSTOffset == 0xFFFFFFFF)
3502 SA_DBG1(("mpiUnInitConfigTable:AGSA_RC_FAILURE GSTOffset = 0x%x\n",GSTOffset));
3503 return AGSA_RC_FAILURE;
3506 GSTLenMPIS = ossaHwRegReadExt(agRoot, pcibar, (bit32)CfgTblDWIdx + (bit32)(GSTOffset + GST_GSTLEN_MPIS_OFFSET));
3507 if (GST_MPI_STATE_UNINIT == (GSTLenMPIS & GST_MPI_STATE_MASK))
3511 } while (max_wait_count -= WAIT_INCREMENT);
3513 if (!max_wait_count)
3515 SA_DBG1(("mpiUnInitConfigTable: TIMEOUT, MPI State = 0x%x\n", GSTLenMPIS & GST_MPI_STATE_MASK));
3516 #if defined(SALLSDK_DEBUG)
3518 SA_DBG1(("mpiUnInitConfigTable: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_0)));
3519 SA_DBG1(("mpiUnInitConfigTable: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1)));
3520 SA_DBG1(("mpiUnInitConfigTable: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_2)));
3521 SA_DBG1(("mpiUnInitConfigTable: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_3)));
3524 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "m7");
3525 return AGSA_RC_FAILURE;
3528 smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "m7");
3529 return AGSA_RC_SUCCESS;
3532 /*******************************************************************************/
3533 /** \fn void mpiUpdateIBQueueCfgTable(agsaRoot_t *agRoot, spc_inboundQueueDescriptor_t *outQueueCfg,
3534 * bit32 QueueTableOffset,bit8 pcibar)
3535 * \brief Writing to the inbound queue of the Configuration Table
3536 * \param agsaRoot Pointer to a data structure containing both application and LL layer context handles
3537 * \param outQueueCfg Pointer to inbuond configuration area
3538 * \param QueueTableOffset Queue configuration table offset
3539 * \param pcibar PCI BAR
3544 /*******************************************************************************/
3545 GLOBAL void mpiUpdateIBQueueCfgTable(agsaRoot_t *agRoot,
3546 spc_inboundQueueDescriptor_t *inQueueCfg,
3547 bit32 QueueTableOffset,
3550 smTraceFuncEnter(hpDBG_VERY_LOUD,"m5");
3552 smTrace(hpDBG_VERY_LOUD,"Ba",QueueTableOffset);
3553 /* TP:Ba QueueTableOffset */
3554 smTrace(hpDBG_VERY_LOUD,"Bb",pcibar);
3557 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + IB_PROPERITY_OFFSET), inQueueCfg->elementPriSizeCount);
3558 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + IB_BASE_ADDR_HI_OFFSET), inQueueCfg->upperBaseAddress);
3559 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + IB_BASE_ADDR_LO_OFFSET), inQueueCfg->lowerBaseAddress);
3560 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + IB_CI_BASE_ADDR_HI_OFFSET), inQueueCfg->ciUpperBaseAddress);
3561 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + IB_CI_BASE_ADDR_LO_OFFSET), inQueueCfg->ciLowerBaseAddress);
3564 SA_DBG3(("mpiUpdateIBQueueCfgTable: Offset 0x%08x elementPriSizeCount 0x%x\n",(bit32)(QueueTableOffset + IB_PROPERITY_OFFSET), inQueueCfg->elementPriSizeCount));
3565 SA_DBG3(("mpiUpdateIBQueueCfgTable: Offset 0x%08x upperBaseAddress 0x%x\n",(bit32)(QueueTableOffset + IB_BASE_ADDR_HI_OFFSET), inQueueCfg->upperBaseAddress));
3566 SA_DBG3(("mpiUpdateIBQueueCfgTable: Offset 0x%08x lowerBaseAddress 0x%x\n",(bit32)(QueueTableOffset + IB_BASE_ADDR_LO_OFFSET), inQueueCfg->lowerBaseAddress));
3567 SA_DBG3(("mpiUpdateIBQueueCfgTable: Offset 0x%08x ciUpperBaseAddress 0x%x\n",(bit32)(QueueTableOffset + IB_CI_BASE_ADDR_HI_OFFSET), inQueueCfg->ciUpperBaseAddress));
3568 SA_DBG3(("mpiUpdateIBQueueCfgTable: Offset 0x%08x ciLowerBaseAddress 0x%x\n",(bit32)(QueueTableOffset + IB_CI_BASE_ADDR_LO_OFFSET), inQueueCfg->ciLowerBaseAddress));
3570 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m5");
3573 /*******************************************************************************/
3574 /** \fn void mpiUpdateOBQueueCfgTable(agsaRoot_t *agRoot, spc_outboundQueueDescriptor_t *outQueueCfg,
3575 * bit32 QueueTableOffset,bit8 pcibar)
3576 * \brief Writing to the inbound queue of the Configuration Table
3577 * \param agsaRoot Pointer to a data structure containing both application
3578 * and LL layer context handles
3579 * \param outQueueCfg Pointer to outbuond configuration area
3580 * \param QueueTableOffset Queue configuration table offset
3581 * \param pcibar PCI BAR
3586 /*******************************************************************************/
3587 GLOBAL void mpiUpdateOBQueueCfgTable(agsaRoot_t *agRoot,
3588 spc_outboundQueueDescriptor_t *outQueueCfg,
3589 bit32 QueueTableOffset,
3593 smTraceFuncEnter(hpDBG_VERY_LOUD,"m8");
3595 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + OB_PROPERITY_OFFSET), outQueueCfg->elementSizeCount);
3596 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + OB_BASE_ADDR_HI_OFFSET), outQueueCfg->upperBaseAddress);
3597 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + OB_BASE_ADDR_LO_OFFSET), outQueueCfg->lowerBaseAddress);
3598 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + OB_PI_BASE_ADDR_HI_OFFSET), outQueueCfg->piUpperBaseAddress);
3599 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + OB_PI_BASE_ADDR_LO_OFFSET), outQueueCfg->piLowerBaseAddress);
3600 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(QueueTableOffset + OB_INTERRUPT_COALES_OFFSET), outQueueCfg->interruptVecCntDelay);
3602 SA_DBG3(("mpiUpdateOBQueueCfgTable: Offset 0x%08x elementSizeCount 0x%x\n",(bit32)(QueueTableOffset + OB_PROPERITY_OFFSET), outQueueCfg->elementSizeCount));
3603 SA_DBG3(("mpiUpdateOBQueueCfgTable: Offset 0x%08x upperBaseAddress 0x%x\n",(bit32)(QueueTableOffset + OB_BASE_ADDR_HI_OFFSET), outQueueCfg->upperBaseAddress));
3604 SA_DBG3(("mpiUpdateOBQueueCfgTable: Offset 0x%08x lowerBaseAddress 0x%x\n",(bit32)(QueueTableOffset + OB_BASE_ADDR_LO_OFFSET), outQueueCfg->lowerBaseAddress));
3605 SA_DBG3(("mpiUpdateOBQueueCfgTable: Offset 0x%08x piUpperBaseAddress 0x%x\n",(bit32)(QueueTableOffset + OB_PI_BASE_ADDR_HI_OFFSET), outQueueCfg->piUpperBaseAddress));
3606 SA_DBG3(("mpiUpdateOBQueueCfgTable: Offset 0x%08x piLowerBaseAddress 0x%x\n",(bit32)(QueueTableOffset + OB_PI_BASE_ADDR_LO_OFFSET), outQueueCfg->piLowerBaseAddress));
3607 SA_DBG3(("mpiUpdateOBQueueCfgTable: Offset 0x%08x interruptVecCntDelay 0x%x\n",(bit32)(QueueTableOffset + OB_INTERRUPT_COALES_OFFSET), outQueueCfg->interruptVecCntDelay));
3608 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m8");
3613 /*******************************************************************************/
3614 /** \fn void mpiUpdateOBQueueCfgTable(agsaRoot_t *agRoot, spc_outboundQueueDescriptor_t *outQueueCfg,
3615 * bit32 QueueTableOffset,bit8 pcibar)
3616 * \brief Writing to the inbound queue of the Configuration Table
3617 * \param agsaRoot Pointer to a data structure containing both application
3618 * and LL layer context handles
3619 * \param outQueueCfg Pointer to outbuond configuration area
3620 * \param QueueTableOffset Queue configuration table offset
3621 * \param pcibar PCI BAR
3626 /*******************************************************************************/
3627 GLOBAL void mpiUpdateFatalErrorTable(agsaRoot_t *agRoot,
3628 bit32 FerrTableOffset,
3629 bit32 lowerBaseAddress,
3630 bit32 upperBaseAddress,
3635 smTraceFuncEnter(hpDBG_VERY_LOUD,"2U");
3637 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(FerrTableOffset + MPI_FATAL_EDUMP_TABLE_LO_OFFSET), lowerBaseAddress);
3638 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(FerrTableOffset + MPI_FATAL_EDUMP_TABLE_HI_OFFSET), upperBaseAddress);
3639 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(FerrTableOffset + MPI_FATAL_EDUMP_TABLE_LENGTH), length);
3640 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(FerrTableOffset + MPI_FATAL_EDUMP_TABLE_HANDSHAKE), 0);
3641 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(FerrTableOffset + MPI_FATAL_EDUMP_TABLE_STATUS), 0);
3644 SA_DBG3(("mpiUpdateFatalErrorTable: Offset 0x%08x MPI_FATAL_EDUMP_TABLE_LO_OFFSET 0x%x\n",FerrTableOffset + MPI_FATAL_EDUMP_TABLE_LO_OFFSET, lowerBaseAddress));
3645 SA_DBG3(("mpiUpdateFatalErrorTable: Offset 0x%08x MPI_FATAL_EDUMP_TABLE_HI_OFFSET 0x%x\n",FerrTableOffset + MPI_FATAL_EDUMP_TABLE_HI_OFFSET,upperBaseAddress ));
3646 SA_DBG3(("mpiUpdateFatalErrorTable: Offset 0x%08x MPI_FATAL_EDUMP_TABLE_LENGTH 0x%x\n",FerrTableOffset + MPI_FATAL_EDUMP_TABLE_LENGTH, length));
3647 SA_DBG3(("mpiUpdateFatalErrorTable: Offset 0x%08x MPI_FATAL_EDUMP_TABLE_HANDSHAKE 0x%x\n",FerrTableOffset + MPI_FATAL_EDUMP_TABLE_HANDSHAKE,0 ));
3648 SA_DBG3(("mpiUpdateFatalErrorTable: Offset 0x%08x MPI_FATAL_EDUMP_TABLE_STATUS 0x%x\n",FerrTableOffset + MPI_FATAL_EDUMP_TABLE_STATUS,0 ));
3649 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "2U");
3653 /*******************************************************************************/
3654 /** \fn bit32 mpiGetPCIBarIndex(agsaRoot_t *agRoot, pciBar)
3655 * \brief Get PCI BAR Index from PCI BAR
3656 * \param agsaRoot Pointer to a data structure containing both application and LL layer context handles
3657 * \param pciBar - PCI BAR
3662 /*******************************************************************************/
3663 GLOBAL bit32 mpiGetPCIBarIndex(agsaRoot_t *agRoot, bit32 pciBar)
3689 /*******************************************************************************/
3690 /** \fn void mpiReadGSTTable(agsaRoot_t *agRoot, spc_GSTableDescriptor_t *mpiGSTable)
3691 * \brief Reading the General Status Table
3693 * \param agsaRoot Handles for this instance of SAS/SATA LLL
3694 * \param mpiGSTable Pointer of General Status Table
3699 /*******************************************************************************/
3700 GLOBAL void mpiReadGSTable(agsaRoot_t *agRoot,
3701 spc_GSTableDescriptor_t *mpiGSTable)
3703 bit32 CFGTableOffset, TableOffset;
3704 bit32 GSTableOffset;
3707 smTraceFuncEnter(hpDBG_VERY_LOUD,"m9");
3709 /* get offset of the configuration table */
3710 TableOffset = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
3712 if(0xFFFFFFFF == TableOffset)
3714 SA_ASSERT(0xFFFFFFFF == TableOffset, "Chip PCI dead");
3716 SA_DBG1(("mpiReadGSTable: Chip PCI dead TableOffset 0x%x\n", TableOffset));
3720 // SA_DBG1(("mpiReadGSTable: TableOffset 0x%x\n", TableOffset));
3721 CFGTableOffset = TableOffset & SCRATCH_PAD0_OFFSET_MASK;
3724 TableOffset = (TableOffset & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
3725 /* convert the PCI BAR to logical bar number */
3726 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, TableOffset);
3728 /* read GST Table Offset from the configuration table */
3729 GSTableOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CFGTableOffset + MAIN_GST_OFFSET);
3730 // SA_DBG1(("mpiReadGSTable: GSTableOffset 0x%x\n",GSTableOffset ));
3732 GSTableOffset = CFGTableOffset + GSTableOffset;
3734 mpiGSTable->GSTLenMPIS = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_GSTLEN_MPIS_OFFSET));
3735 mpiGSTable->IQFreezeState0 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_IQ_FREEZE_STATE0_OFFSET));
3736 mpiGSTable->IQFreezeState1 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_IQ_FREEZE_STATE1_OFFSET));
3737 mpiGSTable->MsguTcnt = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_MSGUTCNT_OFFSET));
3738 mpiGSTable->IopTcnt = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_IOPTCNT_OFFSET));
3739 mpiGSTable->Iop1Tcnt = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_IOP1TCNT_OFFSET));
3741 SA_DBG4(("mpiReadGSTable: GSTLenMPIS 0x%x\n", mpiGSTable->GSTLenMPIS));
3742 SA_DBG4(("mpiReadGSTable: GSTLen 0x%x\n", (mpiGSTable->GSTLenMPIS & 0xfff8) >> SHIFT3));
3743 SA_DBG4(("mpiReadGSTable: IQFreezeState0 0x%x\n", mpiGSTable->IQFreezeState0));
3744 SA_DBG4(("mpiReadGSTable: IQFreezeState1 0x%x\n", mpiGSTable->IQFreezeState1));
3745 SA_DBG4(("mpiReadGSTable: MsguTcnt 0x%x\n", mpiGSTable->MsguTcnt));
3746 SA_DBG4(("mpiReadGSTable: IopTcnt 0x%x\n", mpiGSTable->IopTcnt));
3747 SA_DBG4(("mpiReadGSTable: Iop1Tcnt 0x%x\n", mpiGSTable->Iop1Tcnt));
3750 if(smIS_SPCV(agRoot))
3752 /***** read Phy State from SAS Phy Attribute Table */
3753 TableOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CFGTableOffset + MAIN_PHY_ATTRIBUTE_OFFSET);
3754 TableOffset &= 0x00FFFFFF;
3755 TableOffset = TableOffset + CFGTableOffset;
3756 for (i = 0; i < 8; i++)
3758 mpiGSTable->PhyState[i] = ossaHwRegReadExt(agRoot, pcibar, (bit32)(TableOffset + i * sizeof(phyAttrb_t)));
3759 SA_DBG4(("mpiReadGSTable: PhyState[0x%x] 0x%x\n", i, mpiGSTable->PhyState[i]));
3764 for (i = 0; i < 8; i++)
3766 mpiGSTable->PhyState[i] = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_PHYSTATE_OFFSET + i * 4));
3767 SA_DBG4(("mpiReadGSTable: PhyState[0x%x] 0x%x\n", i, mpiGSTable->PhyState[i]));
3771 mpiGSTable->GPIOpins = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_GPIO_PINS_OFFSET));
3772 SA_DBG4(("mpiReadGSTable: GPIOpins 0x%x\n", mpiGSTable->GPIOpins));
3774 for (i = 0; i < 8; i++)
3776 mpiGSTable->recoverErrInfo[i] = ossaHwRegReadExt(agRoot, pcibar, (bit32)(GSTableOffset + GST_RERRINFO_OFFSET));
3777 SA_DBG4(("mpiReadGSTable: recoverErrInfo[0x%x] 0x%x\n", i, mpiGSTable->recoverErrInfo[i]));
3780 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m9");
3784 /*******************************************************************************/
3785 /** \fn void siInitResources(agsaRoot_t *agRoot)
3786 * Initialization of LL resources
3788 * \param agsaRoot Handles for this instance of SAS/SATA LLL
3789 * \param memoryAllocated Point to the data structure that holds the different
3790 * chunks of memory that are required
3795 /*******************************************************************************/
3796 GLOBAL void siInitResources(agsaRoot_t *agRoot,
3797 agsaMemoryRequirement_t *memoryAllocated,
3798 agsaHwConfig_t *hwConfig,
3799 agsaSwConfig_t *swConfig,
3802 agsaLLRoot_t *saRoot;
3803 agsaDeviceDesc_t *pDeviceDesc;
3804 agsaIORequestDesc_t *pRequestDesc;
3805 agsaTimerDesc_t *pTimerDesc;
3807 agsaPortMap_t *pPortMap;
3808 agsaDeviceMap_t *pDeviceMap;
3809 agsaIOMap_t *pIOMap;
3810 bit32 maxNumIODevices;
3812 mpiICQueue_t *circularIQ;
3813 mpiOCQueue_t *circularOQ;
3815 if (agNULL == agRoot)
3820 /* Get the saRoot memory address */
3821 saRoot = (agsaLLRoot_t *) (memoryAllocated->agMemory[LLROOT_MEM_INDEX].virtPtr);
3822 agRoot->sdkData = (void *) saRoot;
3824 /* Setup Device link */
3825 /* Save the information of allocated device Link memory */
3826 saRoot->deviceLinkMem = memoryAllocated->agMemory[DEVICELINK_MEM_INDEX];
3827 si_memset(saRoot->deviceLinkMem.virtPtr, 0, saRoot->deviceLinkMem.totalLength);
3828 SA_DBG2(("siInitResources: [%d] saRoot->deviceLinkMem VirtPtr=%p PhysicalLo=%x Count=%x Total=%x type %x\n" ,
3829 DEVICELINK_MEM_INDEX,
3830 saRoot->deviceLinkMem.virtPtr,
3831 saRoot->deviceLinkMem.phyAddrLower,
3832 saRoot->deviceLinkMem.numElements,
3833 saRoot->deviceLinkMem.totalLength,
3834 saRoot->deviceLinkMem.type));
3836 maxNumIODevices = swConfig->numDevHandles;
3837 SA_DBG2(("siInitResources: maxNumIODevices=%d, swConfig->numDevHandles=%d \n",
3839 swConfig->numDevHandles));
3841 /* Setup free IO Devices link list */
3842 saLlistInitialize(&(saRoot->freeDevicesList));
3843 for ( i = 0; i < (bit32) maxNumIODevices; i ++ )
3845 /* get the pointer to the device descriptor */
3846 pDeviceDesc = (agsaDeviceDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->deviceLinkMem), i);
3847 /* Initialize device descriptor */
3848 saLlinkInitialize(&(pDeviceDesc->linkNode));
3850 pDeviceDesc->initiatorDevHandle.osData = agNULL;
3851 pDeviceDesc->initiatorDevHandle.sdkData = agNULL;
3852 pDeviceDesc->targetDevHandle.osData = agNULL;
3853 pDeviceDesc->targetDevHandle.sdkData = agNULL;
3854 pDeviceDesc->deviceType = SAS_SATA_UNKNOWN_DEVICE;
3855 pDeviceDesc->pPort = agNULL;
3856 pDeviceDesc->DeviceMapIndex = 0;
3858 saLlistInitialize(&(pDeviceDesc->pendingIORequests));
3860 /* Add the device descriptor to the free IO device link list */
3861 saLlistAdd(&(saRoot->freeDevicesList), &(pDeviceDesc->linkNode));
3864 /* Setup IO Request link */
3865 /* Save the information of allocated IO Request Link memory */
3866 saRoot->IORequestMem = memoryAllocated->agMemory[IOREQLINK_MEM_INDEX];
3867 si_memset(saRoot->IORequestMem.virtPtr, 0, saRoot->IORequestMem.totalLength);
3869 SA_DBG2(("siInitResources: [%d] saRoot->IORequestMem VirtPtr=%p PhysicalLo=%x Count=%x Total=%x type %x\n",
3870 IOREQLINK_MEM_INDEX,
3871 saRoot->IORequestMem.virtPtr,
3872 saRoot->IORequestMem.phyAddrLower,
3873 saRoot->IORequestMem.numElements,
3874 saRoot->IORequestMem.totalLength,
3875 saRoot->IORequestMem.type));
3877 /* Setup free IO Request link list */
3878 saLlistIOInitialize(&(saRoot->freeIORequests));
3879 saLlistIOInitialize(&(saRoot->freeReservedRequests));
3880 for ( i = 0; i < swConfig->maxActiveIOs; i ++ )
3882 /* get the pointer to the request descriptor */
3883 pRequestDesc = (agsaIORequestDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->IORequestMem), i);
3884 /* Initialize request descriptor */
3885 saLlinkIOInitialize(&(pRequestDesc->linkNode));
3887 pRequestDesc->valid = agFALSE;
3888 pRequestDesc->requestType = AGSA_REQ_TYPE_UNKNOWN;
3889 pRequestDesc->pIORequestContext = agNULL;
3890 pRequestDesc->HTag = i;
3891 pRequestDesc->pDevice = agNULL;
3892 pRequestDesc->pPort = agNULL;
3894 /* Add the request descriptor to the free IO Request link list */
3895 /* Add the request descriptor to the free Reserved Request link list */
3896 /* SMP request must get service so reserve one request when first SMP completes */
3897 if(saLlistIOGetCount(&(saRoot->freeReservedRequests)) < SA_RESERVED_REQUEST_COUNT)
3899 saLlistIOAdd(&(saRoot->freeReservedRequests), &(pRequestDesc->linkNode));
3903 saLlistIOAdd(&(saRoot->freeIORequests), &(pRequestDesc->linkNode));
3908 /* Setup timer link */
3909 /* Save the information of allocated timer Link memory */
3910 saRoot->timerLinkMem = memoryAllocated->agMemory[TIMERLINK_MEM_INDEX];
3911 si_memset(saRoot->timerLinkMem.virtPtr, 0, saRoot->timerLinkMem.totalLength);
3912 SA_DBG2(("siInitResources: [%d] saRoot->timerLinkMem VirtPtr=%p PhysicalLo=%x Count=%x Total=%x type %x\n",
3913 TIMERLINK_MEM_INDEX,
3914 saRoot->timerLinkMem.virtPtr,
3915 saRoot->timerLinkMem.phyAddrLower,
3916 saRoot->timerLinkMem.numElements,
3917 saRoot->timerLinkMem.totalLength,
3918 saRoot->timerLinkMem.type));
3920 /* Setup free timer link list */
3921 saLlistInitialize(&(saRoot->freeTimers));
3922 for ( i = 0; i < NUM_TIMERS; i ++ )
3924 /* get the pointer to the timer descriptor */
3925 pTimerDesc = (agsaTimerDesc_t *) AGSAMEM_ELEMENT_READ(&(saRoot->timerLinkMem), i);
3926 /* Initialize timer descriptor */
3927 saLlinkInitialize(&(pTimerDesc->linkNode));
3929 pTimerDesc->valid = agFALSE;
3930 pTimerDesc->timeoutTick = 0;
3931 pTimerDesc->pfnTimeout = agNULL;
3932 pTimerDesc->Event = 0;
3933 pTimerDesc->pParm = agNULL;
3935 /* Add the timer descriptor to the free timer link list */
3936 saLlistAdd(&(saRoot->freeTimers), &(pTimerDesc->linkNode));
3938 /* Setup valid timer link list */
3939 saLlistInitialize(&(saRoot->validTimers));
3942 /* Setup PhyCount */
3943 saRoot->phyCount = (bit8) hwConfig->phyCount;
3944 /* Init Phy data structure */
3945 for ( i = 0; i < saRoot->phyCount; i ++ )
3947 saRoot->phys[i].pPort = agNULL;
3948 saRoot->phys[i].phyId = (bit8) i;
3950 /* setup phy status is PHY_STOPPED */
3951 PHY_STATUS_SET(&(saRoot->phys[i]), PHY_STOPPED);
3955 /* Setup PortCount */
3956 saRoot->portCount = saRoot->phyCount;
3957 /* Setup free port link list */
3958 saLlistInitialize(&(saRoot->freePorts));
3959 for ( i = 0; i < saRoot->portCount; i ++ )
3961 /* get the pointer to the port */
3962 pPort = &(saRoot->ports[i]);
3963 /* Initialize port */
3964 saLlinkInitialize(&(pPort->linkNode));
3966 pPort->portContext.osData = agNULL;
3967 pPort->portContext.sdkData = pPort;
3969 pPort->portIdx = (bit8) i;
3970 pPort->status = PORT_NORMAL;
3972 for ( j = 0; j < saRoot->phyCount; j ++ )
3974 pPort->phyMap[j] = agFALSE;
3977 saLlistInitialize(&(pPort->listSASATADevices));
3979 /* Add the port to the free port link list */
3980 saLlistAdd(&(saRoot->freePorts), &(pPort->linkNode));
3982 /* Setup valid port link list */
3983 saLlistInitialize(&(saRoot->validPorts));
3985 /* Init sysIntsActive */
3986 saRoot->sysIntsActive = agFALSE;
3988 /* setup timer tick granunarity */
3989 saRoot->usecsPerTick = usecsPerTick;
3991 /* initialize LL timer tick */
3992 saRoot->timeTick = 0;
3994 /* initialize device (de)registration callback fns */
3995 saRoot->DeviceRegistrationCB = agNULL;
3996 saRoot->DeviceDeregistrationCB = agNULL;
3998 /* Initialize the PortMap for port context */
3999 for ( i = 0; i < saRoot->portCount; i ++ )
4001 pPortMap = &(saRoot->PortMap[i]);
4003 pPortMap->PortContext = agNULL;
4004 pPortMap->PortID = PORT_MARK_OFF;
4005 pPortMap->PortStatus = PORT_NORMAL;
4006 saRoot->autoDeregDeviceflag[i] = 0;
4009 /* Initialize the DeviceMap for device handle */
4010 for ( i = 0; i < MAX_IO_DEVICE_ENTRIES; i ++ )
4012 pDeviceMap = &(saRoot->DeviceMap[i]);
4014 pDeviceMap->DeviceHandle = agNULL;
4015 pDeviceMap->DeviceIdFromFW = i;
4018 /* Initialize the IOMap for IOrequest */
4019 for ( i = 0; i < MAX_ACTIVE_IO_REQUESTS; i ++ )
4021 pIOMap = &(saRoot->IOMap[i]);
4023 pIOMap->IORequest = agNULL;
4024 pIOMap->Tag = MARK_OFF;
4027 /* clean the inbound queues */
4028 for (i = 0; i < saRoot->QueueConfig.numInboundQueues; i ++)
4030 if(0 != saRoot->inboundQueue[i].numElements)
4032 circularIQ = &saRoot->inboundQueue[i];
4033 si_memset(circularIQ->memoryRegion.virtPtr, 0, circularIQ->memoryRegion.totalLength);
4034 si_memset(saRoot->inboundQueue[i].ciPointer, 0, sizeof(bit32));
4037 /* clean the outbound queues */
4038 for (i = 0; i < saRoot->QueueConfig.numOutboundQueues; i ++)
4040 if(0 != saRoot->outboundQueue[i].numElements)
4042 circularOQ = &saRoot->outboundQueue[i];
4043 si_memset(circularOQ->memoryRegion.virtPtr, 0, circularOQ->memoryRegion.totalLength);
4044 si_memset(saRoot->outboundQueue[i].piPointer, 0, sizeof(bit32));
4045 circularOQ->producerIdx = 0;
4046 circularOQ->consumerIdx = 0;
4047 SA_DBG3(("siInitResource: Q %d Clean PI 0x%03x CI 0x%03x\n", i,circularOQ->producerIdx, circularOQ->consumerIdx));
4054 /*******************************************************************************/
4055 /** \fn void mpiReadCALTable(agsaRoot_t *agRoot,
4056 * spc_SPASTable_t *mpiCALTable, bit32 index)
4057 * \brief Reading the Phy Analog Setup Register Table
4058 * \param agsaRoot Handles for this instance of SAS/SATA LLL
4059 * \param mpiCALTable Pointer of Phy Calibration Table
4064 /*******************************************************************************/
4065 GLOBAL void mpiReadCALTable(agsaRoot_t *agRoot,
4066 spc_SPASTable_t *mpiCALTable,
4069 bit32 CFGTableOffset, TableOffset;
4070 bit32 CALTableOffset;
4073 /* get offset of the configuration table */
4074 TableOffset = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
4076 CFGTableOffset = TableOffset & SCRATCH_PAD0_OFFSET_MASK;
4079 TableOffset = (TableOffset & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
4080 /* convert the PCI BAR to logical bar number */
4081 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, TableOffset);
4083 /* read Calibration Table Offset from the configuration table */
4084 CALTableOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CFGTableOffset + MAIN_ANALOG_SETUP_OFFSET);
4085 if(smIS_SPCV(agRoot))
4087 CALTableOffset &= 0x00FFFFFF;
4089 CALTableOffset = CFGTableOffset + CALTableOffset + (index * ANALOG_SETUP_ENTRY_SIZE * 4);
4091 mpiCALTable->spaReg0 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_PORT_CFG1_OFFSET));
4092 mpiCALTable->spaReg1 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_PORT_CFG2_OFFSET));
4093 mpiCALTable->spaReg2 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_PORT_CFG3_OFFSET));
4094 mpiCALTable->spaReg3 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_CFG_OFFSET));
4095 mpiCALTable->spaReg4 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_PORT_CFG1_OFFSET));
4096 mpiCALTable->spaReg5 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_PORT_CFG2_OFFSET));
4097 mpiCALTable->spaReg6 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_CFG1_OFFSET));
4098 mpiCALTable->spaReg7 = ossaHwRegReadExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_CFG2_OFFSET));
4100 SA_DBG3(("mpiReadCALTable: spaReg0 0x%x\n", mpiCALTable->spaReg0));
4101 SA_DBG3(("mpiReadCALTable: spaReg1 0x%x\n", mpiCALTable->spaReg1));
4102 SA_DBG3(("mpiReadCALTable: spaReg2 0x%x\n", mpiCALTable->spaReg2));
4103 SA_DBG3(("mpiReadCALTable: spaReg3 0x%x\n", mpiCALTable->spaReg3));
4104 SA_DBG3(("mpiReadCALTable: spaReg4 0x%x\n", mpiCALTable->spaReg4));
4105 SA_DBG3(("mpiReadCALTable: spaReg5 0x%x\n", mpiCALTable->spaReg5));
4106 SA_DBG3(("mpiReadCALTable: spaReg6 0x%x\n", mpiCALTable->spaReg6));
4107 SA_DBG3(("mpiReadCALTable: spaReg7 0x%x\n", mpiCALTable->spaReg7));
4110 /*******************************************************************************/
4111 /** \fn void mpiWriteCALTable(agsaRoot_t *agRoot,
4112 * spc_SPASTable_t *mpiCALTable, index)
4113 * \brief Writing the Phy Analog Setup Register Table
4114 * \param agsaRoot Handles for this instance of SAS/SATA LLL
4115 * \param mpiCALTable Pointer of Phy Calibration Table
4120 /*******************************************************************************/
4121 GLOBAL void mpiWriteCALTable(agsaRoot_t *agRoot,
4122 spc_SPASTable_t *mpiCALTable,
4125 bit32 CFGTableOffset, TableOffset;
4126 bit32 CALTableOffset;
4129 smTraceFuncEnter(hpDBG_VERY_LOUD,"m6");
4131 /* get offset of the configuration table */
4132 TableOffset = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
4134 CFGTableOffset = TableOffset & SCRATCH_PAD0_OFFSET_MASK;
4137 TableOffset = (TableOffset & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
4138 /* convert the PCI BAR to logical bar number */
4139 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, TableOffset);
4141 /* read Calibration Table Offset from the configuration table */
4142 CALTableOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CFGTableOffset + MAIN_ANALOG_SETUP_OFFSET);
4143 if(smIS_SPCV(agRoot))
4145 CALTableOffset &= 0x00FFFFFF;
4147 CALTableOffset = CFGTableOffset + CALTableOffset + (index * ANALOG_SETUP_ENTRY_SIZE * 4);
4149 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_PORT_CFG1_OFFSET), mpiCALTable->spaReg0);
4150 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_PORT_CFG2_OFFSET), mpiCALTable->spaReg1);
4151 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_PORT_CFG3_OFFSET), mpiCALTable->spaReg2);
4152 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + TX_CFG_OFFSET), mpiCALTable->spaReg3);
4153 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_PORT_CFG1_OFFSET), mpiCALTable->spaReg4);
4154 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_PORT_CFG2_OFFSET), mpiCALTable->spaReg5);
4155 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_CFG1_OFFSET), mpiCALTable->spaReg6);
4156 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(CALTableOffset + RV_CFG2_OFFSET), mpiCALTable->spaReg7);
4158 SA_DBG4(("mpiWriteCALTable: Offset 0x%08x spaReg0 0x%x 0x%x 0x%x 0x%x\n",(bit32)(CALTableOffset + TX_PORT_CFG1_OFFSET), mpiCALTable->spaReg0, mpiCALTable->spaReg1, mpiCALTable->spaReg2, mpiCALTable->spaReg3));
4159 SA_DBG4(("mpiWriteCALTable: Offset 0x%08x spaReg4 0x%x 0x%x 0x%x 0x%x\n",(bit32)(CALTableOffset + RV_PORT_CFG1_OFFSET), mpiCALTable->spaReg4, mpiCALTable->spaReg5, mpiCALTable->spaReg6, mpiCALTable->spaReg7));
4161 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "m6");
4164 /*******************************************************************************/
4165 /** \fn void mpiWriteCALAll(agsaRoot_t *agRoot,
4166 * agsaPhyAnalogSetupTable_t *mpiCALTable)
4167 * \brief Writing the Phy Analog Setup Register Table
4168 * \param agsaRoot Handles for this instance of SAS/SATA LLL
4169 * \param mpiCALTable Pointer of Phy Calibration Table
4174 /*******************************************************************************/
4175 GLOBAL void mpiWriteCALAll(agsaRoot_t *agRoot,
4176 agsaPhyAnalogSetupTable_t *mpiCALTable)
4179 smTraceFuncEnter(hpDBG_VERY_LOUD,"mz");
4181 if(smIS_SPCV(agRoot))
4183 smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "mz");
4187 for (i = 0; i < MAX_INDEX; i++)
4189 mpiWriteCALTable(agRoot, (spc_SPASTable_t *)&mpiCALTable->phyAnalogSetupRegisters[i], i);
4191 smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "mz");
4194 GLOBAL void mpiWrAnalogSetupTable(agsaRoot_t *agRoot,
4199 bit32 AnalogTableBase,CFGTableOffset, value,phy;
4200 bit32 AnalogtableSize;
4202 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
4203 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, value);
4205 CFGTableOffset = value & SCRATCH_PAD0_OFFSET_MASK;
4206 AnalogtableSize = AnalogTableBase = ossaHwRegReadExt(agRoot,pcibar , (bit32)CFGTableOffset + MAIN_ANALOG_SETUP_OFFSET);
4207 AnalogtableSize &= 0xFF000000;
4208 AnalogtableSize >>= SHIFT24;
4209 AnalogTableBase &= 0x00FFFFFF;
4211 AnalogTableBase = CFGTableOffset + AnalogTableBase;
4213 // config->phyAnalogConfig.phyAnalogSetupRegisters[0].spaRegister0 = 0;
4214 SA_DBG1(("mpiWrAnalogSetupTable:Analogtable Base Offset %08X pcibar %d\n",AnalogTableBase, pcibar ));
4216 SA_DBG1(("mpiWrAnalogSetupTable:%d %d\n",(int)sizeof(agsaPhyAnalogSetupRegisters_t), AnalogtableSize));
4218 for(phy = 0; phy < 10; phy++) /* upto 10 phys See PM*/
4220 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 0 ),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister0 );
4221 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 4 ),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister1 );
4222 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 8 ),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister2 );
4223 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 12),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister3 );
4224 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 16),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister4 );
4225 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 20),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister5 );
4226 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 24),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister6 );
4227 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 28),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister7 );
4228 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 32),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister8 );
4229 ossaHwRegWriteExt(agRoot, pcibar,(AnalogTableBase + ( AnalogtableSize * phy)+ 36),config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister9 );
4231 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister0 0x%x 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) + 0,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister0 ,ossaHwRegReadExt(agRoot, pcibar,AnalogTableBase + ( AnalogtableSize * phy)+ 0 )));
4232 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister1 0x%x 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) + 4,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister1 ,ossaHwRegReadExt(agRoot, pcibar,AnalogTableBase + ( AnalogtableSize * phy)+ 4 )));
4233 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister2 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) + 8,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister2 ));
4234 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister3 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) +12,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister3 ));
4235 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister4 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) +16,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister4 ));
4236 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister5 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) +20,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister5 ));
4237 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister6 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) +24,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister6 ));
4238 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister7 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) +28,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister7 ));
4239 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister8 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) +32,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister8 ));
4240 SA_DBG4(("mpiWrAnalogSetupTable:phy %d Offset 0x%08x spaRegister9 0x%x\n",phy, (bit32) AnalogTableBase+ (AnalogtableSize * phy) +36,config->phyAnalogConfig.phyAnalogSetupRegisters[phy].spaRegister9 ));
4246 GLOBAL void mpiWrIntVecTable(agsaRoot_t *agRoot,
4250 bit32 CFGTableOffset, value;
4251 bit32 INTVTableOffset;
4255 /* get offset of the configuration table */
4256 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
4258 CFGTableOffset = value & SCRATCH_PAD0_OFFSET_MASK;
4261 value = (value & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
4262 /* convert the PCI BAR to logical bar number */
4263 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, value);
4265 /* read Interrupt Table Offset from the main configuration table */
4266 INTVTableOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CFGTableOffset + MAIN_INT_VEC_TABLE_OFFSET);
4267 INTVTableOffset &= 0x00FFFFFF;
4268 INTVTableOffset = CFGTableOffset + INTVTableOffset;
4269 SA_DBG1(("mpiWrIntVecTable: Base Offset %08X\n",(bit32)(INTVTableOffset + INT_VT_Coal_CNT_TO ) ));
4271 for (i = 0; i < MAX_NUM_VECTOR; i ++)
4274 for (obq = 0; obq < MAX_NUM_VECTOR; obq++)
4275 { /* find OBQ for vector i */
4276 if( config->outboundQueues[obq].interruptVector == i )
4288 ValuetoWrite = (( config->outboundQueues[obq].interruptDelay << SHIFT15) | config->outboundQueues[obq].interruptThreshold );
4290 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(INTVTableOffset + INT_VT_Coal_CNT_TO + i * sizeof(InterruptVT_t)), ValuetoWrite );
4292 SA_DBG3(("mpiWrIntVecTable: Q %d interruptDelay 0x%X interruptThreshold 0x%X \n",i,
4293 config->outboundQueues[i].interruptDelay, config->outboundQueues[i].interruptThreshold ));
4295 SA_DBG3(("mpiWrIntVecTable: %d INT_VT_Coal_CNT_TO Bar %d Offset %3X Writing 0x%08x\n",i,
4297 (bit32)(INTVTableOffset + INT_VT_Coal_CNT_TO + i * sizeof(InterruptVT_t)),
4302 for (i = 0; i < MAX_NUM_VECTOR; i++)
4304 /* read interrupt colescing control and timer */
4305 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(INTVTableOffset + INT_VT_Coal_CNT_TO + i * sizeof(InterruptVT_t)));
4306 SA_DBG4(("mpiWrIntVecTable: Offset 0x%08x Interrupt Colescing iccict[%02d] 0x%x\n", (bit32)(INTVTableOffset + INT_VT_Coal_CNT_TO + i * sizeof(InterruptVT_t)), i, value));
4310 GLOBAL void mpiWrPhyAttrbTable(agsaRoot_t *agRoot, sasPhyAttribute_t *phyAttrib)
4312 bit32 CFGTableOffset, value;
4313 bit32 PHYTableOffset;
4316 /* get offset of the configuration table */
4317 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
4319 CFGTableOffset = value & SCRATCH_PAD0_OFFSET_MASK;
4322 value = (value & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
4323 /* convert the PCI BAR to logical bar number */
4324 pcibar = (bit8)mpiGetPCIBarIndex(agRoot, value);
4326 /* read Phy Attribute Table Offset from the configuration table */
4327 PHYTableOffset = ossaHwRegReadExt(agRoot, pcibar, (bit32)CFGTableOffset + MAIN_PHY_ATTRIBUTE_OFFSET);
4329 PHYTableOffset &=0x00FFFFFF;
4331 PHYTableOffset = CFGTableOffset + PHYTableOffset + PHY_EVENT_OQ;
4333 SA_DBG1(("mpiWrPhyAttrbTable: PHYTableOffset 0x%08x\n", PHYTableOffset));
4335 /* write OQ event per phy */
4336 for (i = 0; i < MAX_VALID_PHYS; i ++)
4338 ossaHwRegWriteExt(agRoot, pcibar, (bit32)(PHYTableOffset + i * sizeof(phyAttrb_t)), phyAttrib->phyAttribute[i].phyEventOQ);
4340 SA_DBG3(("mpiWrPhyAttrbTable:%d Offset 0x%08x phyAttribute 0x%x\n",i,(bit32)(PHYTableOffset + i * sizeof(phyAttrb_t)), phyAttrib->phyAttribute[i].phyEventOQ ));
4345 for (i = 0; i < MAX_VALID_PHYS; i ++)
4347 value = ossaHwRegReadExt(agRoot, pcibar, (bit32)(PHYTableOffset + i * sizeof(phyAttrb_t)));
4348 SA_DBG1(("mpiWrPhyAttrbTable: OQ Event per phy[%x] 0x%x\n", i, value));
4353 #ifdef TEST /******************************************************************/
4354 /*******************************************************************************/
4355 /** \fn mpiFreezeInboundQueue(agsaRoot_t *agRoot)
4356 * \brief Freeze the inbound queue
4358 * \param agRoot Handles for this instance of SAS/SATA hardware
4359 * \param bitMapQueueNum0 bit map for inbound queue number 0 - 31 to freeze
4360 * \param bitMapQueueNum1 bit map for inbound queue number 32 - 63 to freeze
4363 * AGSA_RC_SUCCESS if Un-initialize the configuration table sucessful
4364 * AGSA_RC_FAILURE if Un-initialize the configuration table failed
4366 /*******************************************************************************/
4367 GLOBAL bit32 mpiFreezeInboundQueue(agsaRoot_t *agRoot, bit32 bitMapQueueNum0, bit32 bitMapQueueNum1)
4369 bit32 value, togglevalue;
4370 bit32 max_wait_time;
4371 bit32 max_wait_count;
4373 SA_DBG2(("Entering function:mpiFreezeInboundQueue\n"));
4374 SA_ASSERT(NULL != agRoot, "agRoot argument cannot be null");
4378 if (bitMapQueueNum0)
4380 /* update the inbound queue number to HOST_SCRATCH_PAD1 register for queue 0 to 31 */
4381 SA_DBG1(("mpiFreezeInboundQueue: SCRATCH_PAD0 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0)));
4382 SA_DBG1(("mpiFreezeInboundQueue: SCRATCH_PAD3 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3,MSGU_SCRATCH_PAD_3)));
4384 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_1);
4385 value |= bitMapQueueNum0;
4386 siHalRegWriteExt(agRoot, GEN_MSGU_HOST_SCRATCH_PAD_1, MSGU_HOST_SCRATCH_PAD_1, value);
4389 if (bitMapQueueNum1)
4391 /* update the inbound queue number to HOST_SCRATCH_PAD2 register for queue 32 to 63 */
4392 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2,MSGU_SCRATCH_PAD_2);
4393 value |= bitMapQueueNum1;
4394 siHalRegWriteExt(agRoot, GEN_MSGU_HOST_SCRATCH_PAD_2, MSGU_HOST_SCRATCH_PAD_2, value);
4397 /* Write bit 2 to Inbound DoorBell Register */
4398 siHalRegWriteExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET, IBDB_IBQ_FREEZE);
4400 /* wait until Inbound DoorBell Clear Register toggled */
4401 max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
4402 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
4405 ossaStallThread(agRoot, WAIT_INCREMENT);
4406 /* Read Inbound DoorBell Register - for RevB */
4407 // value = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_IBDB_SET);
4408 value = MSGU_READ_IDR;
4409 value &= IBDB_IBQ_FREEZE;
4410 } while ((value != togglevalue) && (max_wait_count -= WAIT_INCREMENT));
4412 if (!max_wait_count)
4414 SA_DBG1(("mpiFreezeInboundQueue: IBDB value/toggle = 0x%x 0x%x\n", value, togglevalue));
4415 return AGSA_RC_FAILURE;
4418 return AGSA_RC_SUCCESS;
4421 /******************************************************************************/
4422 /** \fn mpiUnFreezeInboundQueue(agsaRoot_t *agRoot)
4423 * \brief Freeze the inbound queue
4425 * \param agRoot Handles for this instance of SAS/SATA hardware
4426 * \param bitMapQueueNum0 bit map for inbound queue number 0 - 31 to freeze
4427 * \param bitMapQueueNum1 bit map for inbound queue number 32 - 63 to freeze
4430 * AGSA_RC_SUCCESS if Un-initialize the configuration table sucessful
4431 * AGSA_RC_FAILURE if Un-initialize the configuration table failed
4433 /******************************************************************************/
4434 GLOBAL bit32 mpiUnFreezeInboundQueue(agsaRoot_t *agRoot, bit32 bitMapQueueNum0, bit32 bitMapQueueNum1)
4436 bit32 value, togglevalue;
4437 bit32 max_wait_time;
4438 bit32 max_wait_count;
4440 SA_DBG2(("Entering function:mpiUnFreezeInboundQueue\n"));
4441 SA_ASSERT(NULL != agRoot, "agRoot argument cannot be null");
4445 if (bitMapQueueNum0)
4447 /* update the inbound queue number to HOST_SCRATCH_PAD1 register - for queue 0 to 31 */
4448 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1,MSGU_SCRATCH_PAD_1);
4449 value |= bitMapQueueNum0;
4450 siHalRegWriteExt(agRoot, GEN_MSGU_HOST_SCRATCH_PAD_1, MSGU_HOST_SCRATCH_PAD_1, value);
4453 if (bitMapQueueNum1)
4455 /* update the inbound queue number to HOST_SCRATCH_PAD2 register - for queue 32 to 63 */
4456 value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2,MSGU_SCRATCH_PAD_2);
4457 value |= bitMapQueueNum1;
4458 siHalRegWriteExt(agRoot, GEN_MSGU_HOST_SCRATCH_PAD_2, MSGU_HOST_SCRATCH_PAD_2, value);
4461 /* Write bit 2 to Inbound DoorBell Register */
4462 siHalRegWriteExt(agRoot, GEN_MSGU_IBDB_SET, MSGU_IBDB_SET, IBDB_IBQ_UNFREEZE);
4464 /* wait until Inbound DoorBell Clear Register toggled */
4465 max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
4466 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
4469 ossaStallThread(agRoot, WAIT_INCREMENT);
4470 /* Read Inbound DoorBell Register - for RevB */
4471 value = MSGU_READ_IDR;
4472 value &= IBDB_IBQ_UNFREEZE;
4473 } while ((value != togglevalue) && (max_wait_count -= WAIT_INCREMENT));
4475 if (!max_wait_count)
4477 SA_DBG1(("mpiUnFreezeInboundQueue: IBDB value/toggle = 0x%x 0x%x\n", value, togglevalue));
4478 return AGSA_RC_FAILURE;
4481 return AGSA_RC_SUCCESS;
4484 #endif /* TEST ****************************************************************/
4486 GLOBAL bit32 si_check_V_HDA(agsaRoot_t *agRoot)
4488 bit32 ret = AGSA_RC_SUCCESS;
4489 bit32 hda_status = 0;
4491 hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28));
4493 SA_DBG1(("si_check_V_HDA: hda_status 0x%08X\n",hda_status ));
4495 if((hda_status & SPC_V_HDAR_RSPCODE_MASK) == SPC_V_HDAR_IDLE)
4498 SA_DBG1(("si_check_V_HDA: HDA mode, value = 0x%x\n", hda_status));
4499 ret = AGSA_RC_HDA_NO_FW_RUNNING;
4505 GLOBAL bit32 si_check_V_Ready(agsaRoot_t *agRoot)
4507 bit32 ret = AGSA_RC_SUCCESS;
4509 bit32 max_wait_time;
4510 bit32 max_wait_count;
4512 max_wait_time = (200 * 1000); /* wait 200 milliseconds */
4513 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
4516 ossaStallThread(agRoot, WAIT_INCREMENT);
4517 SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
4518 } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_ILA_MASK) != SCRATCH_PAD1_V_ILA_MASK) && (max_wait_count -= WAIT_INCREMENT));
4520 if (!max_wait_count)
4522 SA_DBG1(("si_check_V_Ready: SCRATCH_PAD1_V_ILA_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_ILA_MASK, SCRATCH_PAD1));
4523 return( AGSA_RC_FAILURE);
4526 max_wait_time = (200 * 1000); /* wait 200 milliseconds */
4527 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
4530 ossaStallThread(agRoot, WAIT_INCREMENT);
4531 SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
4532 } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_RAAE_MASK) != SCRATCH_PAD1_V_RAAE_MASK) && (max_wait_count -= WAIT_INCREMENT));
4534 if (!max_wait_count)
4536 SA_DBG1(("si_check_V_Ready: SCRATCH_PAD1_V_RAAE_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_RAAE_MASK, SCRATCH_PAD1));
4537 return( AGSA_RC_FAILURE);
4541 max_wait_time = (200 * 1000); /* wait 200 milliseconds */
4542 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
4545 ossaStallThread(agRoot, WAIT_INCREMENT);
4546 SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
4547 } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP0_MASK) != SCRATCH_PAD1_V_IOP0_MASK) && (max_wait_count -= WAIT_INCREMENT));
4549 if (!max_wait_count)
4551 SA_DBG1(("si_check_V_Ready: SCRATCH_PAD1_V_IOP0_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_IOP0_MASK ,SCRATCH_PAD1));
4552 return( AGSA_RC_FAILURE);
4557 max_wait_time = (200 * 1000); /* wait 200 milliseconds */
4558 max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT);
4561 ossaStallThread(agRoot, WAIT_INCREMENT);
4562 SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
4563 } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP1_MASK) != SCRATCH_PAD1_V_IOP1_MASK) && (max_wait_count -= WAIT_INCREMENT));
4565 if (!max_wait_count)
4567 SA_DBG1(("si_check_V_Ready: SCRATCH_PAD1_V_IOP1_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_IOP1_MASK, SCRATCH_PAD1));
4568 // return( AGSA_RC_FAILURE);
4574 GLOBAL bit32 siScratchDump(agsaRoot_t *agRoot)
4578 #ifdef SALLSDK_DEBUG
4583 SCRATCH_PAD0 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_0);
4584 SCRATCH_PAD2 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_2);
4585 SCRATCH_PAD3 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_3);
4586 #endif /* SALLSDK_DEBUG */
4587 SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
4588 SA_DBG1(("siScratchDump: SCRATCH_PAD 0 0x%08x 1 0x%08x 2 0x%08x 3 0x%08x\n",SCRATCH_PAD0,SCRATCH_PAD1,SCRATCH_PAD2,SCRATCH_PAD3 ));
4590 if((SCRATCH_PAD1 & SCRATCH_PAD1_V_RESERVED) == SCRATCH_PAD1_V_RESERVED )
4592 SA_DBG1(("siScratchDump: SCRATCH_PAD1 SCRATCH_PAD1_V_RESERVED 0x%08x\n", SCRATCH_PAD1_V_RESERVED));
4596 if((SCRATCH_PAD1 & SCRATCH_PAD1_V_RAAE_MASK) == SCRATCH_PAD1_V_RAAE_MASK )
4598 SA_DBG1(("siScratchDump: SCRATCH_PAD1 valid 0x%08x\n",SCRATCH_PAD0 ));
4599 SA_DBG1(("siScratchDump: RAAE ready 0x%08x\n",SCRATCH_PAD1 & SCRATCH_PAD1_V_RAAE_MASK));
4601 if((SCRATCH_PAD1 & SCRATCH_PAD1_V_ILA_MASK) == SCRATCH_PAD1_V_ILA_MASK)
4603 SA_DBG1(("siScratchDump: ILA ready 0x%08x\n", SCRATCH_PAD1 & SCRATCH_PAD1_V_ILA_MASK));
4606 if(SCRATCH_PAD1 & SCRATCH_PAD1_V_BOOTSTATE_MASK)
4608 SA_DBG1(("siScratchDump: BOOTSTATE not success 0x%08x\n",SCRATCH_PAD1 & SCRATCH_PAD1_V_BOOTSTATE_MASK));
4611 if((SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP0_MASK) == SCRATCH_PAD1_V_IOP0_MASK)
4613 SA_DBG1(("siScratchDump: IOP0 ready 0x%08x\n",SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP0_MASK));
4615 if((SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP1_MASK) == SCRATCH_PAD1_V_IOP1_MASK)
4617 SA_DBG1(("siScratchDump: IOP1 ready 0x%08x\n",SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP1_MASK ));
4619 if((SCRATCH_PAD1 & SCRATCH_PAD1_V_READY) == SCRATCH_PAD1_V_READY)
4621 SA_DBG1(("siScratchDump: SCRATCH_PAD1_V_READY 0x%08x\n",SCRATCH_PAD1 & SCRATCH_PAD1_V_READY ));
4623 if((SCRATCH_PAD1 & SCRATCH_PAD1_V_BOOTSTATE_MASK) == SCRATCH_PAD1_V_BOOTSTATE_MASK)
4625 SA_DBG1(("siScratchDump: SCRATCH_PAD1_V_BOOTSTATE_MASK 0x%08x\n",SCRATCH_PAD1 & SCRATCH_PAD1_V_BOOTSTATE_MASK ));
4633 void si_macro_check(agsaRoot_t *agRoot)
4636 SA_DBG1(("si_macro_check:smIS_SPC %d\n",smIS_SPC(agRoot) ));
4637 SA_DBG1(("si_macro_check:smIS_HIL %d\n",smIS_HIL(agRoot) ));
4638 SA_DBG1(("si_macro_check:smIS_SFC %d\n",smIS_SFC(agRoot) ));
4640 SA_DBG1(("si_macro_check:smIS_spc8001 %d\n",smIS_spc8001(agRoot) ));
4641 SA_DBG1(("si_macro_check:smIS_spc8081 %d\n",smIS_spc8081(agRoot) ));
4643 SA_DBG1(("si_macro_check:smIS_SPCV8008 %d\n",smIS_SPCV8008(agRoot) ));
4644 SA_DBG1(("si_macro_check:smIS_SPCV8009 %d\n",smIS_SPCV8009(agRoot) ));
4645 SA_DBG1(("si_macro_check:smIS_SPCV8018 %d\n",smIS_SPCV8018(agRoot) ));
4646 SA_DBG1(("si_macro_check:smIS_SPCV8019 %d\n",smIS_SPCV8019(agRoot) ));
4647 SA_DBG1(("si_macro_check:smIS_ADAP8088 %d\n",smIS_ADAP8088(agRoot) ));
4648 SA_DBG1(("si_macro_check:smIS_ADAP8089 %d\n",smIS_ADAP8089(agRoot) ));
4649 SA_DBG1(("si_macro_check:smIS_SPCV8070 %d\n",smIS_SPCV8070(agRoot) ));
4650 SA_DBG1(("si_macro_check:smIS_SPCV8071 %d\n",smIS_SPCV8071(agRoot) ));
4651 SA_DBG1(("si_macro_check:smIS_SPCV8072 %d\n",smIS_SPCV8072(agRoot) ));
4652 SA_DBG1(("si_macro_check:smIS_SPCV8073 %d\n",smIS_SPCV8073(agRoot) ));
4653 SA_DBG1(("si_macro_check:smIS_SPCV8074 %d\n",smIS_SPCV8074(agRoot) ));
4654 SA_DBG1(("si_macro_check:smIS_SPCV8075 %d\n",smIS_SPCV8075(agRoot) ));
4655 SA_DBG1(("si_macro_check:smIS_SPCV8076 %d\n",smIS_SPCV8076(agRoot) ));
4656 SA_DBG1(("si_macro_check:smIS_SPCV8077 %d\n",smIS_SPCV8077(agRoot) ));
4657 SA_DBG1(("si_macro_check:smIS_SPCV9015 %d\n",smIS_SPCV9015(agRoot) ));
4658 SA_DBG1(("si_macro_check:smIS_SPCV9060 %d\n",smIS_SPCV9060(agRoot) ));
4659 SA_DBG1(("si_macro_check:smIS_SPCV %d\n",smIS_SPCV(agRoot) ));
4661 SA_DBG1(("si_macro_check:smIS64bInt %d\n", smIS64bInt(agRoot) ));