1*4e1bc9a0SAchim Leubner /*******************************************************************************
2*4e1bc9a0SAchim Leubner *Copyright (c) 2014 PMC-Sierra, Inc. All rights reserved.
3*4e1bc9a0SAchim Leubner *
4*4e1bc9a0SAchim Leubner *Redistribution and use in source and binary forms, with or without modification, are permitted provided
5*4e1bc9a0SAchim Leubner *that the following conditions are met:
6*4e1bc9a0SAchim Leubner *1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
7*4e1bc9a0SAchim Leubner *following disclaimer.
8*4e1bc9a0SAchim Leubner *2. Redistributions in binary form must reproduce the above copyright notice,
9*4e1bc9a0SAchim Leubner *this list of conditions and the following disclaimer in the documentation and/or other materials provided
10*4e1bc9a0SAchim Leubner *with the distribution.
11*4e1bc9a0SAchim Leubner *
12*4e1bc9a0SAchim Leubner *THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
13*4e1bc9a0SAchim Leubner *WARRANTIES,INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14*4e1bc9a0SAchim Leubner *FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
15*4e1bc9a0SAchim Leubner *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
16*4e1bc9a0SAchim Leubner *NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
17*4e1bc9a0SAchim Leubner *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18*4e1bc9a0SAchim Leubner *LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19*4e1bc9a0SAchim Leubner *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
20*4e1bc9a0SAchim Leubner
21*4e1bc9a0SAchim Leubner ********************************************************************************/
22*4e1bc9a0SAchim Leubner /*******************************************************************************/
23*4e1bc9a0SAchim Leubner /*! \file sahw.c
24*4e1bc9a0SAchim Leubner * \brief The file implements the functions for reset and shutdown
25*4e1bc9a0SAchim Leubner */
26*4e1bc9a0SAchim Leubner /******************************************************************************/
27*4e1bc9a0SAchim Leubner #include <sys/cdefs.h>
28*4e1bc9a0SAchim Leubner #include <dev/pms/config.h>
29*4e1bc9a0SAchim Leubner
30*4e1bc9a0SAchim Leubner #include <dev/pms/RefTisa/sallsdk/spc/saglobal.h>
31*4e1bc9a0SAchim Leubner #ifdef SA_ENABLE_HDA_FUNCTIONS
32*4e1bc9a0SAchim Leubner #ifndef SA_EXCLUDE_FW_IMG
33*4e1bc9a0SAchim Leubner /*
34*4e1bc9a0SAchim Leubner #include "istrimg.h"
35*4e1bc9a0SAchim Leubner #include "ilaimg.h"
36*4e1bc9a0SAchim Leubner #include "aap1img.h"
37*4e1bc9a0SAchim Leubner #include "iopimg.h"
38*4e1bc9a0SAchim Leubner */
39*4e1bc9a0SAchim Leubner #endif
40*4e1bc9a0SAchim Leubner #endif
41*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
42*4e1bc9a0SAchim Leubner extern bit32 gLLSoftResetCounter;
43*4e1bc9a0SAchim Leubner #endif
44*4e1bc9a0SAchim Leubner
45*4e1bc9a0SAchim Leubner #ifdef SA_ENABLE_TRACE_FUNCTIONS
46*4e1bc9a0SAchim Leubner #ifdef siTraceFileID
47*4e1bc9a0SAchim Leubner #undef siTraceFileID
48*4e1bc9a0SAchim Leubner #endif
49*4e1bc9a0SAchim Leubner #define siTraceFileID 'E'
50*4e1bc9a0SAchim Leubner #endif
51*4e1bc9a0SAchim Leubner
52*4e1bc9a0SAchim Leubner
53*4e1bc9a0SAchim Leubner bit32 gWait_3 = 3;
54*4e1bc9a0SAchim Leubner bit32 gWait_2 = 2;
55*4e1bc9a0SAchim Leubner
56*4e1bc9a0SAchim Leubner bit32 gWaitmSec = 0;
57*4e1bc9a0SAchim Leubner
58*4e1bc9a0SAchim Leubner
59*4e1bc9a0SAchim Leubner
60*4e1bc9a0SAchim Leubner LOCAL bit32 si_V_SoftReset(agsaRoot_t *agRoot, bit32 signature);
61*4e1bc9a0SAchim Leubner
62*4e1bc9a0SAchim Leubner
63*4e1bc9a0SAchim Leubner LOCAL bit32 siSpcSoftResetRDYChk(agsaRoot_t *agRoot);
64*4e1bc9a0SAchim Leubner
65*4e1bc9a0SAchim Leubner #ifdef SA_ENABLE_HDA_FUNCTIONS
66*4e1bc9a0SAchim Leubner LOCAL void siPciMemCpy(agsaRoot_t *agRoot, bit32 dstoffset, void *src,
67*4e1bc9a0SAchim Leubner bit32 DWcount, bit32 busBaseNumber);
68*4e1bc9a0SAchim Leubner
69*4e1bc9a0SAchim Leubner LOCAL bit32 siBar4Cpy(agsaRoot_t *agRoot, bit32 offset, bit8 *parray, bit32 array_size);
70*4e1bc9a0SAchim Leubner #endif
71*4e1bc9a0SAchim Leubner
72*4e1bc9a0SAchim Leubner /******************************************************************************/
73*4e1bc9a0SAchim Leubner /*! \brief Function to reset the Hardware
74*4e1bc9a0SAchim Leubner *
75*4e1bc9a0SAchim Leubner * The saHwReset() function is called to reset the SAS/SATA HW controller
76*4e1bc9a0SAchim Leubner * All outstanding I/Os are explicitly aborted.
77*4e1bc9a0SAchim Leubner * This API need to access before saInitialize() so checking saRoot is needed
78*4e1bc9a0SAchim Leubner *
79*4e1bc9a0SAchim Leubner * \param agRoot Handles for this instance of SAS/SATA hardware
80*4e1bc9a0SAchim Leubner * \param resetType The reset type
81*4e1bc9a0SAchim Leubner * \param resetParm The paramter passed for reset operation
82*4e1bc9a0SAchim Leubner *
83*4e1bc9a0SAchim Leubner * \return -void-
84*4e1bc9a0SAchim Leubner */
85*4e1bc9a0SAchim Leubner /*******************************************************************************/
saHwReset(agsaRoot_t * agRoot,bit32 resetType,bit32 resetParm)86*4e1bc9a0SAchim Leubner GLOBAL void saHwReset(
87*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
88*4e1bc9a0SAchim Leubner bit32 resetType,
89*4e1bc9a0SAchim Leubner bit32 resetParm
90*4e1bc9a0SAchim Leubner )
91*4e1bc9a0SAchim Leubner {
92*4e1bc9a0SAchim Leubner agsaLLRoot_t *saRoot = agNULL;
93*4e1bc9a0SAchim Leubner bit32 ret = AGSA_RC_SUCCESS;
94*4e1bc9a0SAchim Leubner bit32 value;
95*4e1bc9a0SAchim Leubner bit32 sysIntsActive = agFALSE;
96*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
97*4e1bc9a0SAchim Leubner bit32 value1;
98*4e1bc9a0SAchim Leubner agsaControllerStatus_t controllerStatus;
99*4e1bc9a0SAchim Leubner agsaFatalErrorInfo_t fatal_error;
100*4e1bc9a0SAchim Leubner #endif
101*4e1bc9a0SAchim Leubner
102*4e1bc9a0SAchim Leubner #ifdef SOFT_RESET_TEST
103*4e1bc9a0SAchim Leubner DbgPrint("Reset Start\n");
104*4e1bc9a0SAchim Leubner #endif
105*4e1bc9a0SAchim Leubner
106*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD, "5a");
107*4e1bc9a0SAchim Leubner
108*4e1bc9a0SAchim Leubner /* sanity check */
109*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "");
110*4e1bc9a0SAchim Leubner if (agNULL != agRoot)
111*4e1bc9a0SAchim Leubner {
112*4e1bc9a0SAchim Leubner if (agNULL != agRoot->sdkData)
113*4e1bc9a0SAchim Leubner {
114*4e1bc9a0SAchim Leubner saRoot = (agsaLLRoot_t*) agRoot->sdkData;
115*4e1bc9a0SAchim Leubner sysIntsActive = saRoot->sysIntsActive;
116*4e1bc9a0SAchim Leubner if(sysIntsActive)
117*4e1bc9a0SAchim Leubner {
118*4e1bc9a0SAchim Leubner saSystemInterruptsActive(agRoot,agFALSE);
119*4e1bc9a0SAchim Leubner }
120*4e1bc9a0SAchim Leubner }
121*4e1bc9a0SAchim Leubner }
122*4e1bc9a0SAchim Leubner else
123*4e1bc9a0SAchim Leubner {
124*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "5a");
125*4e1bc9a0SAchim Leubner return;
126*4e1bc9a0SAchim Leubner }
127*4e1bc9a0SAchim Leubner
128*4e1bc9a0SAchim Leubner
129*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
130*4e1bc9a0SAchim Leubner {
131*4e1bc9a0SAchim Leubner if (agNULL != agRoot->sdkData)
132*4e1bc9a0SAchim Leubner {
133*4e1bc9a0SAchim Leubner /* check fatal errors */
134*4e1bc9a0SAchim Leubner value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1, MSGU_SCRATCH_PAD_1);
135*4e1bc9a0SAchim Leubner value1 = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2, MSGU_SCRATCH_PAD_2);
136*4e1bc9a0SAchim Leubner /* check AAP error */
137*4e1bc9a0SAchim Leubner if( smIS_SPC(agRoot) )
138*4e1bc9a0SAchim Leubner {
139*4e1bc9a0SAchim Leubner value &= SCRATCH_PAD_STATE_MASK;
140*4e1bc9a0SAchim Leubner value1 &= SCRATCH_PAD_STATE_MASK;
141*4e1bc9a0SAchim Leubner
142*4e1bc9a0SAchim Leubner if ((SCRATCH_PAD1_ERR == value) || (SCRATCH_PAD2_ERR == value1))
143*4e1bc9a0SAchim Leubner {
144*4e1bc9a0SAchim Leubner
145*4e1bc9a0SAchim Leubner si_memset(&fatal_error, 0, sizeof(agsaFatalErrorInfo_t));
146*4e1bc9a0SAchim Leubner /* read detail fatal errors */
147*4e1bc9a0SAchim Leubner value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0, MSGU_SCRATCH_PAD_0);
148*4e1bc9a0SAchim Leubner fatal_error.errorInfo0 = value;
149*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: ScratchPad0 AAP error code 0x%x\n", value));
150*4e1bc9a0SAchim Leubner value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1, MSGU_SCRATCH_PAD_1);
151*4e1bc9a0SAchim Leubner fatal_error.errorInfo1 = value;
152*4e1bc9a0SAchim Leubner /* AAP error state */
153*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: AAP error state and error code 0x%x\n", value));
154*4e1bc9a0SAchim Leubner value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2, MSGU_SCRATCH_PAD_2);
155*4e1bc9a0SAchim Leubner fatal_error.errorInfo2 = value;
156*4e1bc9a0SAchim Leubner /* IOP error state */
157*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: IOP error state and error code 0x%x\n", value));
158*4e1bc9a0SAchim Leubner value = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3, MSGU_SCRATCH_PAD_3);
159*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: ScratchPad3 IOP error code 0x%x\n", value));
160*4e1bc9a0SAchim Leubner fatal_error.errorInfo3 = value;
161*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
162*4e1bc9a0SAchim Leubner {
163*4e1bc9a0SAchim Leubner fatal_error.regDumpBusBaseNum0 = saRoot->mainConfigTable.regDumpPCIBAR;
164*4e1bc9a0SAchim Leubner fatal_error.regDumpBusBaseNum1 = saRoot->mainConfigTable.regDumpPCIBAR;
165*4e1bc9a0SAchim Leubner fatal_error.regDumpLen0 = saRoot->mainConfigTable.FatalErrorDumpLength0;
166*4e1bc9a0SAchim Leubner fatal_error.regDumpLen1 = saRoot->mainConfigTable.FatalErrorDumpLength1;
167*4e1bc9a0SAchim Leubner fatal_error.regDumpOffset0 = saRoot->mainConfigTable.FatalErrorDumpOffset0;
168*4e1bc9a0SAchim Leubner fatal_error.regDumpOffset1 = saRoot->mainConfigTable.FatalErrorDumpOffset1;
169*4e1bc9a0SAchim Leubner }
170*4e1bc9a0SAchim Leubner
171*4e1bc9a0SAchim Leubner /* Call Back with error */
172*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: OSSA_HW_EVENT_MALFUNCTION SPC SP1 0x%x\n", value1));
173*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_MALFUNCTION, 0, (void *)&fatal_error, agNULL);
174*4e1bc9a0SAchim Leubner }
175*4e1bc9a0SAchim Leubner }
176*4e1bc9a0SAchim Leubner else
177*4e1bc9a0SAchim Leubner {
178*4e1bc9a0SAchim Leubner if( ( (value & SCRATCH_PAD1_V_BOOTLDR_ERROR) == SCRATCH_PAD1_V_BOOTLDR_ERROR))
179*4e1bc9a0SAchim Leubner {
180*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: ScratchPad1 SCRATCH_PAD1_V_BOOTLDR_ERROR 0x%x\n", value));
181*4e1bc9a0SAchim Leubner }
182*4e1bc9a0SAchim Leubner if(SCRATCH_PAD1_V_ERROR_STATE(value))
183*4e1bc9a0SAchim Leubner {
184*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: ScratchPad1 SCRATCH_PAD1_V_ERROR_STATE 0x%x\n",SCRATCH_PAD1_V_ERROR_STATE(value) ));
185*4e1bc9a0SAchim Leubner }
186*4e1bc9a0SAchim Leubner if( (value & SCRATCH_PAD1_V_READY) == SCRATCH_PAD1_V_READY )
187*4e1bc9a0SAchim Leubner {
188*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: ScratchPad1 SCRATCH_PAD1_V_READY 0x%x\n", value));
189*4e1bc9a0SAchim Leubner }
190*4e1bc9a0SAchim Leubner }
191*4e1bc9a0SAchim Leubner saGetControllerStatus(agRoot, &controllerStatus);
192*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
193*4e1bc9a0SAchim Leubner {
194*4e1bc9a0SAchim Leubner /* display all pending Ios */
195*4e1bc9a0SAchim Leubner siDumpActiveIORequests(agRoot, saRoot->swConfig.maxActiveIOs);
196*4e1bc9a0SAchim Leubner }
197*4e1bc9a0SAchim Leubner }
198*4e1bc9a0SAchim Leubner }
199*4e1bc9a0SAchim Leubner #endif /* SALLSDK_DEBUG */
200*4e1bc9a0SAchim Leubner
201*4e1bc9a0SAchim Leubner /* Check the resetType */
202*4e1bc9a0SAchim Leubner switch (resetType)
203*4e1bc9a0SAchim Leubner {
204*4e1bc9a0SAchim Leubner /* Reset the whole chip */
205*4e1bc9a0SAchim Leubner case AGSA_CHIP_RESET:
206*4e1bc9a0SAchim Leubner {
207*4e1bc9a0SAchim Leubner /* callback with RESET_START */
208*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_START, OSSA_SUCCESS << SHIFT8, agNULL, agNULL);
209*4e1bc9a0SAchim Leubner
210*4e1bc9a0SAchim Leubner if (agNULL != agRoot->sdkData && agNULL != saRoot)
211*4e1bc9a0SAchim Leubner {
212*4e1bc9a0SAchim Leubner /* Set chip status */
213*4e1bc9a0SAchim Leubner saRoot->chipStatus |= CHIP_RESETTING;
214*4e1bc9a0SAchim Leubner
215*4e1bc9a0SAchim Leubner /* Disable all interrupt */
216*4e1bc9a0SAchim Leubner saSystemInterruptsActive(agRoot,agFALSE);
217*4e1bc9a0SAchim Leubner }
218*4e1bc9a0SAchim Leubner
219*4e1bc9a0SAchim Leubner /* do chip reset */
220*4e1bc9a0SAchim Leubner siChipReset(agRoot);
221*4e1bc9a0SAchim Leubner
222*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
223*4e1bc9a0SAchim Leubner {
224*4e1bc9a0SAchim Leubner /* clear up the internal resource */
225*4e1bc9a0SAchim Leubner siInitResources(agRoot,
226*4e1bc9a0SAchim Leubner &saRoot->memoryAllocated,
227*4e1bc9a0SAchim Leubner &saRoot->hwConfig,
228*4e1bc9a0SAchim Leubner &saRoot->swConfig,
229*4e1bc9a0SAchim Leubner saRoot->usecsPerTick);
230*4e1bc9a0SAchim Leubner }
231*4e1bc9a0SAchim Leubner
232*4e1bc9a0SAchim Leubner /* callback with CHIP_RESET_COMPLETE with OSSA_SUCCESS */
233*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_COMPLETE, OSSA_SUCCESS << SHIFT8, agNULL, agNULL);
234*4e1bc9a0SAchim Leubner
235*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
236*4e1bc9a0SAchim Leubner {
237*4e1bc9a0SAchim Leubner /* mask off reset FW status */
238*4e1bc9a0SAchim Leubner saRoot->chipStatus &= ~CHIP_RESETTING;
239*4e1bc9a0SAchim Leubner }
240*4e1bc9a0SAchim Leubner break;
241*4e1bc9a0SAchim Leubner }
242*4e1bc9a0SAchim Leubner case AGSA_SOFT_RESET:
243*4e1bc9a0SAchim Leubner {
244*4e1bc9a0SAchim Leubner
245*4e1bc9a0SAchim Leubner if( smIS_SPCV(agRoot) )
246*4e1bc9a0SAchim Leubner {
247*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: AGSA_SOFT_RESET chip type V %d\n",smIS_SPCV(agRoot) ));
248*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_START, OSSA_SUCCESS << SHIFT8, agNULL, agNULL);
249*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
250*4e1bc9a0SAchim Leubner {
251*4e1bc9a0SAchim Leubner saRoot->ResetStartTick = saRoot->timeTick;
252*4e1bc9a0SAchim Leubner saCountActiveIORequests( agRoot);
253*4e1bc9a0SAchim Leubner } //delray end
254*4e1bc9a0SAchim Leubner
255*4e1bc9a0SAchim Leubner ret = siChipResetV( agRoot, SPC_SOFT_RESET_SIGNATURE );
256*4e1bc9a0SAchim Leubner
257*4e1bc9a0SAchim Leubner if(agNULL !=saRoot)
258*4e1bc9a0SAchim Leubner {
259*4e1bc9a0SAchim Leubner /* clear up the internal resource */
260*4e1bc9a0SAchim Leubner siInitResources(agRoot,
261*4e1bc9a0SAchim Leubner &saRoot->memoryAllocated,
262*4e1bc9a0SAchim Leubner &saRoot->hwConfig,
263*4e1bc9a0SAchim Leubner &saRoot->swConfig,
264*4e1bc9a0SAchim Leubner saRoot->usecsPerTick);
265*4e1bc9a0SAchim Leubner }
266*4e1bc9a0SAchim Leubner
267*4e1bc9a0SAchim Leubner if (AGSA_RC_SUCCESS == ret)
268*4e1bc9a0SAchim Leubner {
269*4e1bc9a0SAchim Leubner /* callback with CHIP_RESET_COMPLETE with OSSA_SUCCESS */
270*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: siChipResetV AGSA_RC_SUCCESS\n" ));
271*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_COMPLETE, OSSA_SUCCESS << SHIFT8, agNULL, agNULL);
272*4e1bc9a0SAchim Leubner }
273*4e1bc9a0SAchim Leubner else
274*4e1bc9a0SAchim Leubner {
275*4e1bc9a0SAchim Leubner /* callback with CHIP_RESET_COMPLETE with OSSA_FAILURE */
276*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: siChipResetV not AGSA_RC_SUCCESS (0x%x)\n" ,ret));
277*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_COMPLETE, OSSA_FAILURE << SHIFT8, agNULL, agNULL);
278*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
279*4e1bc9a0SAchim Leubner {
280*4e1bc9a0SAchim Leubner saRoot->ResetFailed = agTRUE;
281*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: siChipResetV saRoot->ResetFailed ret (0x%x)\n" ,ret));
282*4e1bc9a0SAchim Leubner }
283*4e1bc9a0SAchim Leubner
284*4e1bc9a0SAchim Leubner }
285*4e1bc9a0SAchim Leubner break;
286*4e1bc9a0SAchim Leubner }
287*4e1bc9a0SAchim Leubner else
288*4e1bc9a0SAchim Leubner {
289*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
290*4e1bc9a0SAchim Leubner {
291*4e1bc9a0SAchim Leubner /* get register dump from GSM and save it to LL local memory */
292*4e1bc9a0SAchim Leubner siGetRegisterDumpGSM(agRoot, (void *)&saRoot->registerDump0[0],
293*4e1bc9a0SAchim Leubner REG_DUMP_NUM0, 0, saRoot->mainConfigTable.FatalErrorDumpLength0);
294*4e1bc9a0SAchim Leubner siGetRegisterDumpGSM(agRoot, (void *)&saRoot->registerDump1[0],
295*4e1bc9a0SAchim Leubner REG_DUMP_NUM1, 0, saRoot->mainConfigTable.FatalErrorDumpLength1);
296*4e1bc9a0SAchim Leubner }
297*4e1bc9a0SAchim Leubner
298*4e1bc9a0SAchim Leubner /* callback with RESET_START */
299*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_START, OSSA_SUCCESS << SHIFT8, agNULL, agNULL);
300*4e1bc9a0SAchim Leubner
301*4e1bc9a0SAchim Leubner if (agNULL != agRoot->sdkData && agNULL != saRoot)
302*4e1bc9a0SAchim Leubner {
303*4e1bc9a0SAchim Leubner /* Set chip status */
304*4e1bc9a0SAchim Leubner saRoot->chipStatus |= CHIP_RESET_FW;
305*4e1bc9a0SAchim Leubner
306*4e1bc9a0SAchim Leubner /* Disable all interrupt */
307*4e1bc9a0SAchim Leubner saSystemInterruptsActive(agRoot,agFALSE);
308*4e1bc9a0SAchim Leubner saCountActiveIORequests( agRoot); //delray start
309*4e1bc9a0SAchim Leubner
310*4e1bc9a0SAchim Leubner }
311*4e1bc9a0SAchim Leubner
312*4e1bc9a0SAchim Leubner /* check HDA mode */
313*4e1bc9a0SAchim Leubner value = ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_STATUS_BITS;
314*4e1bc9a0SAchim Leubner
315*4e1bc9a0SAchim Leubner if (value == BOOTTLOADERHDA_IDLE)
316*4e1bc9a0SAchim Leubner {
317*4e1bc9a0SAchim Leubner /* HDA mode */
318*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: HDA mode, value = 0x%x\n", value));
319*4e1bc9a0SAchim Leubner ret = AGSA_RC_HDA_NO_FW_RUNNING;
320*4e1bc9a0SAchim Leubner }
321*4e1bc9a0SAchim Leubner else
322*4e1bc9a0SAchim Leubner {
323*4e1bc9a0SAchim Leubner /* do Soft Reset */
324*4e1bc9a0SAchim Leubner ret = siSpcSoftReset(agRoot, SPC_SOFT_RESET_SIGNATURE);
325*4e1bc9a0SAchim Leubner }
326*4e1bc9a0SAchim Leubner if(agNULL !=saRoot)
327*4e1bc9a0SAchim Leubner {
328*4e1bc9a0SAchim Leubner /* clear up the internal resource */
329*4e1bc9a0SAchim Leubner siInitResources(agRoot,
330*4e1bc9a0SAchim Leubner &saRoot->memoryAllocated,
331*4e1bc9a0SAchim Leubner &saRoot->hwConfig,
332*4e1bc9a0SAchim Leubner &saRoot->swConfig,
333*4e1bc9a0SAchim Leubner saRoot->usecsPerTick);
334*4e1bc9a0SAchim Leubner }
335*4e1bc9a0SAchim Leubner if (AGSA_RC_SUCCESS == ret)
336*4e1bc9a0SAchim Leubner {
337*4e1bc9a0SAchim Leubner /* callback with CHIP_RESET_COMPLETE with OSSA_SUCCESS */
338*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_COMPLETE, OSSA_SUCCESS << SHIFT8, agNULL, agNULL);
339*4e1bc9a0SAchim Leubner }
340*4e1bc9a0SAchim Leubner else if (AGSA_RC_HDA_NO_FW_RUNNING == ret)
341*4e1bc9a0SAchim Leubner {
342*4e1bc9a0SAchim Leubner /* callback with CHIP_RESET_COMPLETE with OSSA_CHIP_FAILED */
343*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_COMPLETE, OSSA_SUCCESS << SHIFT8, agNULL, agNULL);
344*4e1bc9a0SAchim Leubner }
345*4e1bc9a0SAchim Leubner else
346*4e1bc9a0SAchim Leubner {
347*4e1bc9a0SAchim Leubner /* callback with CHIP_RESET_COMPLETE with OSSA_FAILURE */
348*4e1bc9a0SAchim Leubner ossaHwCB(agRoot, agNULL, OSSA_HW_EVENT_RESET_COMPLETE, (OSSA_FAILURE << SHIFT8), agNULL, agNULL);
349*4e1bc9a0SAchim Leubner }
350*4e1bc9a0SAchim Leubner
351*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
352*4e1bc9a0SAchim Leubner {
353*4e1bc9a0SAchim Leubner /* mask off reset FW status */
354*4e1bc9a0SAchim Leubner saRoot->chipStatus &= ~CHIP_RESET_FW;
355*4e1bc9a0SAchim Leubner }
356*4e1bc9a0SAchim Leubner break;
357*4e1bc9a0SAchim Leubner }
358*4e1bc9a0SAchim Leubner }
359*4e1bc9a0SAchim Leubner /* Unsupported type */
360*4e1bc9a0SAchim Leubner default:
361*4e1bc9a0SAchim Leubner {
362*4e1bc9a0SAchim Leubner SA_DBG1(("saHwReset: Unsupported reset type %X\n",resetType));
363*4e1bc9a0SAchim Leubner break;
364*4e1bc9a0SAchim Leubner }
365*4e1bc9a0SAchim Leubner }
366*4e1bc9a0SAchim Leubner
367*4e1bc9a0SAchim Leubner if (agNULL != saRoot)
368*4e1bc9a0SAchim Leubner {
369*4e1bc9a0SAchim Leubner if(sysIntsActive && ret == AGSA_RC_SUCCESS)
370*4e1bc9a0SAchim Leubner {
371*4e1bc9a0SAchim Leubner saSystemInterruptsActive(agRoot,agTRUE);
372*4e1bc9a0SAchim Leubner }
373*4e1bc9a0SAchim Leubner
374*4e1bc9a0SAchim Leubner saCountActiveIORequests( agRoot);
375*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "5a");
376*4e1bc9a0SAchim Leubner }
377*4e1bc9a0SAchim Leubner
378*4e1bc9a0SAchim Leubner return;
379*4e1bc9a0SAchim Leubner }
380*4e1bc9a0SAchim Leubner
381*4e1bc9a0SAchim Leubner /******************************************************************************/
382*4e1bc9a0SAchim Leubner /*! \brief Function to shutdown the Hardware
383*4e1bc9a0SAchim Leubner *
384*4e1bc9a0SAchim Leubner * The saHwShutdown() function is called to discontinue the use of the SAS/SATA
385*4e1bc9a0SAchim Leubner * hardware. Upon return, the SASA/SAT hardware instance does not generate any
386*4e1bc9a0SAchim Leubner * interrupts or any other bus accesses. All LL Layer hardware host resources
387*4e1bc9a0SAchim Leubner * (i.e. both cached and noncached memory) are no longer owned by the LL Layer.
388*4e1bc9a0SAchim Leubner *
389*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
390*4e1bc9a0SAchim Leubner *
391*4e1bc9a0SAchim Leubner * \return -void-
392*4e1bc9a0SAchim Leubner */
393*4e1bc9a0SAchim Leubner /*******************************************************************************/
saHwShutdown(agsaRoot_t * agRoot)394*4e1bc9a0SAchim Leubner GLOBAL void saHwShutdown(
395*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot
396*4e1bc9a0SAchim Leubner )
397*4e1bc9a0SAchim Leubner {
398*4e1bc9a0SAchim Leubner agsaLLRoot_t *saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
399*4e1bc9a0SAchim Leubner bit32 spad0 = 0;
400*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"5b");
401*4e1bc9a0SAchim Leubner
402*4e1bc9a0SAchim Leubner /* sanity check */
403*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "");
404*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: Shutting down .....\n"));
405*4e1bc9a0SAchim Leubner
406*4e1bc9a0SAchim Leubner if (agRoot->sdkData)
407*4e1bc9a0SAchim Leubner {
408*4e1bc9a0SAchim Leubner
409*4e1bc9a0SAchim Leubner spad0 = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
410*4e1bc9a0SAchim Leubner
411*4e1bc9a0SAchim Leubner if(0xFFFFFFFF == spad0)
412*4e1bc9a0SAchim Leubner {
413*4e1bc9a0SAchim Leubner SA_ASSERT(0xFFFFFFFF == spad0, "saHwShutdown Chip PCI dead");
414*4e1bc9a0SAchim Leubner
415*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: Chip PCI dead SCRATCH_PAD0 0x%x\n", spad0));
416*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "5b");
417*4e1bc9a0SAchim Leubner return;
418*4e1bc9a0SAchim Leubner }
419*4e1bc9a0SAchim Leubner
420*4e1bc9a0SAchim Leubner
421*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
422*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: SCRATCH_PAD0 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0, MSGU_SCRATCH_PAD_0)));
423*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: SCRATCH_PAD1 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_1, MSGU_SCRATCH_PAD_1)));
424*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: SCRATCH_PAD2 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_2, MSGU_SCRATCH_PAD_2)));
425*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: SCRATCH_PAD3 value = 0x%x\n", siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_3, MSGU_SCRATCH_PAD_3)));
426*4e1bc9a0SAchim Leubner
427*4e1bc9a0SAchim Leubner if(1)
428*4e1bc9a0SAchim Leubner {
429*4e1bc9a0SAchim Leubner mpiOCQueue_t *circularQ;
430*4e1bc9a0SAchim Leubner int i;
431*4e1bc9a0SAchim Leubner SA_DBG4(("saHwShutdown:\n"));
432*4e1bc9a0SAchim Leubner for ( i = 0; i < saRoot->QueueConfig.numOutboundQueues; i++ )
433*4e1bc9a0SAchim Leubner {
434*4e1bc9a0SAchim Leubner circularQ = &saRoot->outboundQueue[i];
435*4e1bc9a0SAchim Leubner OSSA_READ_LE_32(circularQ->agRoot, &circularQ->producerIdx, circularQ->piPointer, 0);
436*4e1bc9a0SAchim Leubner if(circularQ->producerIdx != circularQ->consumerIdx)
437*4e1bc9a0SAchim Leubner {
438*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: PI 0x%03x CI 0x%03x\n",circularQ->producerIdx, circularQ->consumerIdx ));
439*4e1bc9a0SAchim Leubner }
440*4e1bc9a0SAchim Leubner }
441*4e1bc9a0SAchim Leubner }
442*4e1bc9a0SAchim Leubner #endif /* SALLSDK_DBG */
443*4e1bc9a0SAchim Leubner
444*4e1bc9a0SAchim Leubner if(smIS_SPCV(agRoot))
445*4e1bc9a0SAchim Leubner {
446*4e1bc9a0SAchim Leubner
447*4e1bc9a0SAchim Leubner siScratchDump(agRoot);
448*4e1bc9a0SAchim Leubner
449*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: SPC_V\n" ));
450*4e1bc9a0SAchim Leubner }
451*4e1bc9a0SAchim Leubner /* Set chip status */
452*4e1bc9a0SAchim Leubner saRoot->chipStatus |= CHIP_SHUTDOWN;
453*4e1bc9a0SAchim Leubner
454*4e1bc9a0SAchim Leubner /* Un-Initialization Configuration Table */
455*4e1bc9a0SAchim Leubner mpiUnInitConfigTable(agRoot);
456*4e1bc9a0SAchim Leubner if (saRoot->swConfig.hostDirectAccessSupport && !saRoot->swConfig.hostDirectAccessMode)
457*4e1bc9a0SAchim Leubner {
458*4e1bc9a0SAchim Leubner /* HDA mode - do HDAsoftReset */
459*4e1bc9a0SAchim Leubner if(smIS_SPC(agRoot))
460*4e1bc9a0SAchim Leubner {
461*4e1bc9a0SAchim Leubner /* HDA soft reset */
462*4e1bc9a0SAchim Leubner siSpcSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
463*4e1bc9a0SAchim Leubner }
464*4e1bc9a0SAchim Leubner if(smIS_SPCV(agRoot))
465*4e1bc9a0SAchim Leubner {
466*4e1bc9a0SAchim Leubner siChipResetV(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
467*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: HDA saRoot->ChipId == VEN_DEV_SPCV\n"));
468*4e1bc9a0SAchim Leubner }
469*4e1bc9a0SAchim Leubner }
470*4e1bc9a0SAchim Leubner else
471*4e1bc9a0SAchim Leubner {
472*4e1bc9a0SAchim Leubner /* do Normal softReset */
473*4e1bc9a0SAchim Leubner if(smIS_SPC(agRoot))
474*4e1bc9a0SAchim Leubner {
475*4e1bc9a0SAchim Leubner /* Soft Reset the SPC */
476*4e1bc9a0SAchim Leubner siSpcSoftReset(agRoot, SPC_SOFT_RESET_SIGNATURE);
477*4e1bc9a0SAchim Leubner }
478*4e1bc9a0SAchim Leubner if(smIS_SPCV(agRoot))
479*4e1bc9a0SAchim Leubner {
480*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: saRoot->ChipId == VEN_DEV_SPCV\n"));
481*4e1bc9a0SAchim Leubner siChipResetV(agRoot, SPC_SOFT_RESET_SIGNATURE);
482*4e1bc9a0SAchim Leubner }
483*4e1bc9a0SAchim Leubner
484*4e1bc9a0SAchim Leubner }
485*4e1bc9a0SAchim Leubner
486*4e1bc9a0SAchim Leubner /* clean the LL resources */
487*4e1bc9a0SAchim Leubner siInitResources(agRoot,
488*4e1bc9a0SAchim Leubner &saRoot->memoryAllocated,
489*4e1bc9a0SAchim Leubner &saRoot->hwConfig,
490*4e1bc9a0SAchim Leubner &saRoot->swConfig,
491*4e1bc9a0SAchim Leubner saRoot->usecsPerTick);
492*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: Shutting down Complete\n"));
493*4e1bc9a0SAchim Leubner }
494*4e1bc9a0SAchim Leubner else
495*4e1bc9a0SAchim Leubner {
496*4e1bc9a0SAchim Leubner SA_DBG1(("saHwShutdown: No saRoot\n"));
497*4e1bc9a0SAchim Leubner if( smIS_SPCV(agRoot) )
498*4e1bc9a0SAchim Leubner {
499*4e1bc9a0SAchim Leubner siChipResetV(agRoot, SPC_SOFT_RESET_SIGNATURE);
500*4e1bc9a0SAchim Leubner }
501*4e1bc9a0SAchim Leubner else
502*4e1bc9a0SAchim Leubner {
503*4e1bc9a0SAchim Leubner siSpcSoftReset(agRoot, SPC_SOFT_RESET_SIGNATURE);
504*4e1bc9a0SAchim Leubner }
505*4e1bc9a0SAchim Leubner }
506*4e1bc9a0SAchim Leubner /* agroot/saroot null do not access -trace OK */
507*4e1bc9a0SAchim Leubner
508*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "10");
509*4e1bc9a0SAchim Leubner /* return */
510*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "5b");
511*4e1bc9a0SAchim Leubner return;
512*4e1bc9a0SAchim Leubner }
513*4e1bc9a0SAchim Leubner
514*4e1bc9a0SAchim Leubner
515*4e1bc9a0SAchim Leubner /******************************************************************************/
516*4e1bc9a0SAchim Leubner /*! \brief Generic Reset
517*4e1bc9a0SAchim Leubner *
518*4e1bc9a0SAchim Leubner * The siChipReset() function is called to reset the SPC chip. Upon return,
519*4e1bc9a0SAchim Leubner * the SPC chip got reset. The PCIe bus got reset.
520*4e1bc9a0SAchim Leubner *
521*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
522*4e1bc9a0SAchim Leubner *
523*4e1bc9a0SAchim Leubner * \return -void-
524*4e1bc9a0SAchim Leubner */
525*4e1bc9a0SAchim Leubner /*******************************************************************************/
526*4e1bc9a0SAchim Leubner
siChipReset(agsaRoot_t * agRoot)527*4e1bc9a0SAchim Leubner GLOBAL void siChipReset(
528*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot
529*4e1bc9a0SAchim Leubner )
530*4e1bc9a0SAchim Leubner {
531*4e1bc9a0SAchim Leubner agsaLLRoot_t *saRoot;
532*4e1bc9a0SAchim Leubner
533*4e1bc9a0SAchim Leubner /* sanity check */
534*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "");
535*4e1bc9a0SAchim Leubner
536*4e1bc9a0SAchim Leubner saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
537*4e1bc9a0SAchim Leubner if(agNULL != saRoot)
538*4e1bc9a0SAchim Leubner {
539*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"2C");
540*4e1bc9a0SAchim Leubner
541*4e1bc9a0SAchim Leubner SA_DBG1(("siChipReset: saRoot->ChipId == VEN_DEV_SPCV\n"));
542*4e1bc9a0SAchim Leubner if(smIS_SPC(agRoot) )
543*4e1bc9a0SAchim Leubner {
544*4e1bc9a0SAchim Leubner /* Soft Reset the SPC */
545*4e1bc9a0SAchim Leubner siChipResetSpc( agRoot);
546*4e1bc9a0SAchim Leubner }else /* saRoot->ChipId == VEN_DEV_SPCV */
547*4e1bc9a0SAchim Leubner {
548*4e1bc9a0SAchim Leubner siChipResetV( agRoot, SPC_SOFT_RESET_SIGNATURE);
549*4e1bc9a0SAchim Leubner }
550*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "2C");
551*4e1bc9a0SAchim Leubner }
552*4e1bc9a0SAchim Leubner
553*4e1bc9a0SAchim Leubner }
554*4e1bc9a0SAchim Leubner
555*4e1bc9a0SAchim Leubner
556*4e1bc9a0SAchim Leubner /******************************************************************************/
557*4e1bc9a0SAchim Leubner /*! \brief Function to Reset the SPC V Hardware
558*4e1bc9a0SAchim Leubner *
559*4e1bc9a0SAchim Leubner * The siChipResetV() function is called to reset the SPC chip. Upon return,
560*4e1bc9a0SAchim Leubner * the SPC chip got reset. The PCIe bus got reset.
561*4e1bc9a0SAchim Leubner *
562*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
563*4e1bc9a0SAchim Leubner *
564*4e1bc9a0SAchim Leubner * \return -void-
565*4e1bc9a0SAchim Leubner */
566*4e1bc9a0SAchim Leubner /*******************************************************************************/
567*4e1bc9a0SAchim Leubner
siChipResetV(agsaRoot_t * agRoot,bit32 signature)568*4e1bc9a0SAchim Leubner GLOBAL bit32 siChipResetV(
569*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
570*4e1bc9a0SAchim Leubner bit32 signature
571*4e1bc9a0SAchim Leubner )
572*4e1bc9a0SAchim Leubner {
573*4e1bc9a0SAchim Leubner bit32 regVal;
574*4e1bc9a0SAchim Leubner bit32 returnVal = AGSA_RC_SUCCESS;
575*4e1bc9a0SAchim Leubner
576*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"3A");
577*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lr",ossaTimeStamp64(agRoot));
578*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot,PCIBAR0 ,V_SoftResetRegister );
579*4e1bc9a0SAchim Leubner
580*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: signature %X V_SoftResetRegister %X\n",signature,regVal));
581*4e1bc9a0SAchim Leubner
582*4e1bc9a0SAchim Leubner if (signature == SPC_SOFT_RESET_SIGNATURE)
583*4e1bc9a0SAchim Leubner {
584*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_SOFT_RESET_SIGNATURE 0x%X\n",regVal));
585*4e1bc9a0SAchim Leubner regVal = SPCv_Reset_Write_NormalReset;
586*4e1bc9a0SAchim Leubner }
587*4e1bc9a0SAchim Leubner else if (signature == SPC_HDASOFT_RESET_SIGNATURE)
588*4e1bc9a0SAchim Leubner {
589*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPCv load HDA 0x%X\n",regVal));
590*4e1bc9a0SAchim Leubner regVal = SPCv_Reset_Write_SoftResetHDA;
591*4e1bc9a0SAchim Leubner }
592*4e1bc9a0SAchim Leubner else
593*4e1bc9a0SAchim Leubner {
594*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: Invalid SIGNATURE 0x%X regVal 0x%X a\n",signature ,regVal));
595*4e1bc9a0SAchim Leubner regVal = 1;
596*4e1bc9a0SAchim Leubner }
597*4e1bc9a0SAchim Leubner
598*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Ls",ossaTimeStamp64(agRoot));
599*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, V_SoftResetRegister, regVal); /* siChipResetV */
600*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lt",ossaTimeStamp64(agRoot));
601*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, (500 * 1000)); /* wait 500 milliseconds or PCIe will hang */
602*4e1bc9a0SAchim Leubner /* Soft reset sequence (Normal mode) */
603*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lv",ossaTimeStamp64(agRoot));
604*4e1bc9a0SAchim Leubner
605*4e1bc9a0SAchim Leubner if (signature == SPC_HDASOFT_RESET_SIGNATURE)
606*4e1bc9a0SAchim Leubner {
607*4e1bc9a0SAchim Leubner bit32 hda_status;
608*4e1bc9a0SAchim Leubner
609*4e1bc9a0SAchim Leubner hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28));
610*4e1bc9a0SAchim Leubner
611*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: hda_status 0x%x\n",hda_status));
612*4e1bc9a0SAchim Leubner
613*4e1bc9a0SAchim Leubner if((hda_status & SPC_V_HDAR_RSPCODE_MASK) != SPC_V_HDAR_IDLE)
614*4e1bc9a0SAchim Leubner {
615*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SPC_HDASOFT_RESET_SIGNATURE SCRATCH_PAD1 = 0x%x \n",ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1)));
616*4e1bc9a0SAchim Leubner }
617*4e1bc9a0SAchim Leubner
618*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_HDASOFT_RESET_SIGNATURE %X\n",regVal));
619*4e1bc9a0SAchim Leubner
620*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR0, V_SoftResetRegister ); /* siChipResetV */
621*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_HDASOFT_RESET_SIGNATURE %X\n",regVal));
622*4e1bc9a0SAchim Leubner
623*4e1bc9a0SAchim Leubner if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_NoReset)
624*4e1bc9a0SAchim Leubner {
625*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_HDASOFT_RESET_SIGNATURE AGSA_RC_FAILURE %X\n",regVal));
626*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
627*4e1bc9a0SAchim Leubner }
628*4e1bc9a0SAchim Leubner if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_NormalResetOccurred )
629*4e1bc9a0SAchim Leubner {
630*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_HDASOFT_RESET_SIGNATURE AGSA_RC_FAILURE %X\n",regVal));
631*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
632*4e1bc9a0SAchim Leubner }
633*4e1bc9a0SAchim Leubner if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_SoftResetHDAOccurred)
634*4e1bc9a0SAchim Leubner {
635*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_HDASOFT_RESET_SIGNATURE AGSA_RC_SUCCESS %X\n",regVal));
636*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_SUCCESS;
637*4e1bc9a0SAchim Leubner }
638*4e1bc9a0SAchim Leubner if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_ChipResetOccurred)
639*4e1bc9a0SAchim Leubner {
640*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_HDASOFT_RESET_SIGNATURE AGSA_RC_FAILURE %X\n",regVal));
641*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
642*4e1bc9a0SAchim Leubner }
643*4e1bc9a0SAchim Leubner if(regVal == 0xFFFFFFFF)
644*4e1bc9a0SAchim Leubner {
645*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_HDASOFT_RESET_SIGNATURE AGSA_RC_FAILURE %X\n",regVal));
646*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
647*4e1bc9a0SAchim Leubner }
648*4e1bc9a0SAchim Leubner
649*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SCRATCH_PAD1 = 0x%x a\n",ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1)));
650*4e1bc9a0SAchim Leubner
651*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "3A");
652*4e1bc9a0SAchim Leubner return returnVal;
653*4e1bc9a0SAchim Leubner }
654*4e1bc9a0SAchim Leubner else if (signature == SPC_SOFT_RESET_SIGNATURE)
655*4e1bc9a0SAchim Leubner {
656*4e1bc9a0SAchim Leubner bit32 SCRATCH_PAD1;
657*4e1bc9a0SAchim Leubner bit32 max_wait_time;
658*4e1bc9a0SAchim Leubner bit32 max_wait_count;
659*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lw",ossaTimeStamp64(agRoot));
660*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR0, V_SoftResetRegister ); /* siChipResetV */
661*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_SOFT_RESET_SIGNATURE 0x%X\n",regVal));
662*4e1bc9a0SAchim Leubner
663*4e1bc9a0SAchim Leubner if(regVal == 0xFFFFFFFF)
664*4e1bc9a0SAchim Leubner {
665*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_SOFT_RESET_SIGNATURE AGSA_RC_FAILURE %X\n",regVal));
666*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
667*4e1bc9a0SAchim Leubner }
668*4e1bc9a0SAchim Leubner else if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_NoReset)
669*4e1bc9a0SAchim Leubner {
670*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SPC_SOFT_RESET_SIGNATURE AGSA_RC_FAILURE %X\n",regVal));
671*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
672*4e1bc9a0SAchim Leubner }
673*4e1bc9a0SAchim Leubner else if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_SoftResetHDAOccurred)
674*4e1bc9a0SAchim Leubner {
675*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_SOFT_RESET_SIGNATURE AGSA_RC_FAILURE 0x%X\n",regVal));
676*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
677*4e1bc9a0SAchim Leubner }
678*4e1bc9a0SAchim Leubner else if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_ChipResetOccurred)
679*4e1bc9a0SAchim Leubner {
680*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_SOFT_RESET_SIGNATURE AGSA_RC_FAILURE 0x%X\n",regVal));
681*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
682*4e1bc9a0SAchim Leubner }
683*4e1bc9a0SAchim Leubner else if((regVal & SPCv_Reset_Read_Mask) == SPCv_Reset_Read_NormalResetOccurred )
684*4e1bc9a0SAchim Leubner {
685*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SPC_SOFT_RESET_SIGNATURE AGSA_RC_SUCCESS 0x%X\n",regVal));
686*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_SUCCESS;
687*4e1bc9a0SAchim Leubner }
688*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SCRATCH_PAD1 = 0x%x b\n",ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1)));
689*4e1bc9a0SAchim Leubner
690*4e1bc9a0SAchim Leubner if( returnVal != AGSA_RC_SUCCESS)
691*4e1bc9a0SAchim Leubner {
692*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1) & SCRATCH_PAD1_V_BOOTSTATE_MASK;
693*4e1bc9a0SAchim Leubner if(SCRATCH_PAD1 == SCRATCH_PAD1_V_BOOTSTATE_HDA_SEEPROM )
694*4e1bc9a0SAchim Leubner {
695*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: Reset done FW did not start BOOTSTATE_HDA_SEEPROM\n"));
696*4e1bc9a0SAchim Leubner return (returnVal);
697*4e1bc9a0SAchim Leubner }
698*4e1bc9a0SAchim Leubner else if(SCRATCH_PAD1 == SCRATCH_PAD1_V_BOOTSTATE_HDA_BOOTSTRAP)
699*4e1bc9a0SAchim Leubner {
700*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: Reset done FW did not start BOOTSTATE_HDA_BOOTSTRAP\n"));
701*4e1bc9a0SAchim Leubner return (returnVal);
702*4e1bc9a0SAchim Leubner }
703*4e1bc9a0SAchim Leubner else if(SCRATCH_PAD1 == SCRATCH_PAD1_V_BOOTSTATE_HDA_SOFTRESET )
704*4e1bc9a0SAchim Leubner {
705*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: Reset done FW did not start BOOTSTATE_HDA_SOFTRESET\n"));
706*4e1bc9a0SAchim Leubner return (returnVal);
707*4e1bc9a0SAchim Leubner }
708*4e1bc9a0SAchim Leubner else if(SCRATCH_PAD1 == SCRATCH_PAD1_V_BOOTSTATE_CRIT_ERROR )
709*4e1bc9a0SAchim Leubner {
710*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: Reset done FW did not start BOOTSTATE_CRIT_ERROR\n"));
711*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "3A");
712*4e1bc9a0SAchim Leubner return (returnVal);
713*4e1bc9a0SAchim Leubner }
714*4e1bc9a0SAchim Leubner }
715*4e1bc9a0SAchim Leubner
716*4e1bc9a0SAchim Leubner /* RESET */
717*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lx",ossaTimeStamp64(agRoot));
718*4e1bc9a0SAchim Leubner max_wait_time = (100 * 1000); /* wait 100 milliseconds */
719*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
720*4e1bc9a0SAchim Leubner do
721*4e1bc9a0SAchim Leubner {
722*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
723*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
724*4e1bc9a0SAchim Leubner } while ((SCRATCH_PAD1 == 0xFFFFFFFF ) && (max_wait_count -= WAIT_INCREMENT));
725*4e1bc9a0SAchim Leubner
726*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Ly",ossaTimeStamp64(agRoot));
727*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SCRATCH_PAD1 = 0x%x (0x%x) PCIe ready took %d\n", SCRATCH_PAD1,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
728*4e1bc9a0SAchim Leubner /* ILA */
729*4e1bc9a0SAchim Leubner max_wait_time = (1000 * 1000); /* wait 1000 milliseconds */
730*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
731*4e1bc9a0SAchim Leubner do
732*4e1bc9a0SAchim Leubner {
733*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
734*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
735*4e1bc9a0SAchim Leubner } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_ILA_MASK) != SCRATCH_PAD1_V_ILA_MASK) && (max_wait_count -= WAIT_INCREMENT));
736*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_ILA_MASK (0x%x)(0x%x) took %d\n", SCRATCH_PAD1,SCRATCH_PAD1_V_ILA_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
737*4e1bc9a0SAchim Leubner
738*4e1bc9a0SAchim Leubner if (!max_wait_count)
739*4e1bc9a0SAchim Leubner {
740*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
741*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:Timeout SCRATCH_PAD1_V_ILA_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_ILA_MASK, SCRATCH_PAD1));
742*4e1bc9a0SAchim Leubner }
743*4e1bc9a0SAchim Leubner /* RAAE */
744*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lz",ossaTimeStamp64(agRoot));
745*4e1bc9a0SAchim Leubner max_wait_time = (1800 * 1000); /* wait 1800 milliseconds */
746*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
747*4e1bc9a0SAchim Leubner do
748*4e1bc9a0SAchim Leubner {
749*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
750*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
751*4e1bc9a0SAchim Leubner } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_RAAE_MASK) != SCRATCH_PAD1_V_RAAE_MASK) && (max_wait_count -= WAIT_INCREMENT));
752*4e1bc9a0SAchim Leubner
753*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_RAAE_MASK (0x%x)(0x%x) took %d\n", SCRATCH_PAD1,SCRATCH_PAD1_V_RAAE_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
754*4e1bc9a0SAchim Leubner
755*4e1bc9a0SAchim Leubner if (!max_wait_count)
756*4e1bc9a0SAchim Leubner {
757*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
758*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:Timeout SCRATCH_PAD1_V_RAAE_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_RAAE_MASK, SCRATCH_PAD1));
759*4e1bc9a0SAchim Leubner }
760*4e1bc9a0SAchim Leubner /* IOP0 */
761*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"La",ossaTimeStamp64(agRoot));
762*4e1bc9a0SAchim Leubner max_wait_time = (600 * 1000); /* wait 600 milliseconds */
763*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
764*4e1bc9a0SAchim Leubner do
765*4e1bc9a0SAchim Leubner {
766*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
767*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
768*4e1bc9a0SAchim Leubner } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP0_MASK) != SCRATCH_PAD1_V_IOP0_MASK) && (max_wait_count -= WAIT_INCREMENT));
769*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_IOP0_MASK(0x%x)(0x%x) took %d\n", SCRATCH_PAD1,SCRATCH_PAD1_V_IOP0_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
770*4e1bc9a0SAchim Leubner
771*4e1bc9a0SAchim Leubner if (!max_wait_count)
772*4e1bc9a0SAchim Leubner {
773*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
774*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:Timeout SCRATCH_PAD1_V_IOP0_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_IOP0_MASK ,SCRATCH_PAD1));
775*4e1bc9a0SAchim Leubner }
776*4e1bc9a0SAchim Leubner
777*4e1bc9a0SAchim Leubner if(smIS_SPCV_2_IOP(agRoot))
778*4e1bc9a0SAchim Leubner {
779*4e1bc9a0SAchim Leubner /* IOP1 */
780*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lb",ossaTimeStamp64(agRoot));
781*4e1bc9a0SAchim Leubner max_wait_time = (200 * 1000); /* wait 200 milliseconds */
782*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
783*4e1bc9a0SAchim Leubner do
784*4e1bc9a0SAchim Leubner {
785*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
786*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
787*4e1bc9a0SAchim Leubner } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP1_MASK) != SCRATCH_PAD1_V_IOP1_MASK) && (max_wait_count -= WAIT_INCREMENT));
788*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_IOP1_MASK (0x%x) (0x%x)(0x%x)\n", SCRATCH_PAD1,SCRATCH_PAD1_V_IOP1_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
789*4e1bc9a0SAchim Leubner
790*4e1bc9a0SAchim Leubner if (!max_wait_count)
791*4e1bc9a0SAchim Leubner {
792*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
793*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: SCRATCH_PAD1_V_IOP1_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_IOP1_MASK, SCRATCH_PAD1));
794*4e1bc9a0SAchim Leubner }
795*4e1bc9a0SAchim Leubner }
796*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Lc",ossaTimeStamp64(agRoot));
797*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot,PCIBAR0 ,V_SoftResetRegister );
798*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: Reset done 0x%X ERROR_STATE 0x%X\n",regVal,
799*4e1bc9a0SAchim Leubner SCRATCH_PAD1_V_ERROR_STATE( ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1) ) ));
800*4e1bc9a0SAchim Leubner if(SCRATCH_PAD1_V_ERROR_STATE( ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1)) )
801*4e1bc9a0SAchim Leubner {
802*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "3A");
803*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
804*4e1bc9a0SAchim Leubner }
805*4e1bc9a0SAchim Leubner
806*4e1bc9a0SAchim Leubner }
807*4e1bc9a0SAchim Leubner else /* signature = unknown */
808*4e1bc9a0SAchim Leubner {
809*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "3A");
810*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
811*4e1bc9a0SAchim Leubner }
812*4e1bc9a0SAchim Leubner
813*4e1bc9a0SAchim Leubner smTrace(hpDBG_LOUD,"Ld",ossaTimeStamp64(agRoot));
814*4e1bc9a0SAchim Leubner
815*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetV: out V_SoftResetRegister %08X\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_SoftResetRegister) ));
816*4e1bc9a0SAchim Leubner #ifdef SOFT_RESET_TEST
817*4e1bc9a0SAchim Leubner DbgPrint("SCRATCH_PAD1 = 0x%x \n",ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1));
818*4e1bc9a0SAchim Leubner #endif
819*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "3A");
820*4e1bc9a0SAchim Leubner return returnVal;
821*4e1bc9a0SAchim Leubner
822*4e1bc9a0SAchim Leubner }
823*4e1bc9a0SAchim Leubner /******************************************************************************/
824*4e1bc9a0SAchim Leubner /*! \brief Function to Reset the SPC Hardware
825*4e1bc9a0SAchim Leubner *
826*4e1bc9a0SAchim Leubner * The siChipResetSpc() function is called to reset the SPC chip. Upon return,
827*4e1bc9a0SAchim Leubner * the SPC chip got reset. The PCIe bus got reset.
828*4e1bc9a0SAchim Leubner *
829*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
830*4e1bc9a0SAchim Leubner *
831*4e1bc9a0SAchim Leubner * \return -void-
832*4e1bc9a0SAchim Leubner */
833*4e1bc9a0SAchim Leubner /*******************************************************************************/
siChipResetSpc(agsaRoot_t * agRoot)834*4e1bc9a0SAchim Leubner GLOBAL void siChipResetSpc(
835*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot
836*4e1bc9a0SAchim Leubner )
837*4e1bc9a0SAchim Leubner {
838*4e1bc9a0SAchim Leubner bit32 regVal;
839*4e1bc9a0SAchim Leubner
840*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"5c");
841*4e1bc9a0SAchim Leubner
842*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetSpc: Chip Reset start\n"));
843*4e1bc9a0SAchim Leubner
844*4e1bc9a0SAchim Leubner /* Reset the chip */
845*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_RESET);
846*4e1bc9a0SAchim Leubner regVal &= ~(SPC_REG_RESET_DEVICE);
847*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_REG_RESET, regVal); /* siChipResetSpc */
848*4e1bc9a0SAchim Leubner
849*4e1bc9a0SAchim Leubner /* delay 10 usec */
850*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
851*4e1bc9a0SAchim Leubner
852*4e1bc9a0SAchim Leubner /* bring chip reset out of reset */
853*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_RESET);
854*4e1bc9a0SAchim Leubner regVal |= SPC_REG_RESET_DEVICE;
855*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_REG_RESET, regVal); /* siChipResetSpc */
856*4e1bc9a0SAchim Leubner
857*4e1bc9a0SAchim Leubner /* delay 10 usec */
858*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
859*4e1bc9a0SAchim Leubner
860*4e1bc9a0SAchim Leubner /* wait for 20 msec until the firmware gets reloaded */
861*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, (20 * 1000));
862*4e1bc9a0SAchim Leubner
863*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "5c");
864*4e1bc9a0SAchim Leubner
865*4e1bc9a0SAchim Leubner SA_DBG1(("siChipResetSpc: Chip Reset Complete\n"));
866*4e1bc9a0SAchim Leubner
867*4e1bc9a0SAchim Leubner return;
868*4e1bc9a0SAchim Leubner }
869*4e1bc9a0SAchim Leubner
870*4e1bc9a0SAchim Leubner
siSoftReset(agsaRoot_t * agRoot,bit32 signature)871*4e1bc9a0SAchim Leubner GLOBAL bit32 siSoftReset(
872*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
873*4e1bc9a0SAchim Leubner bit32 signature
874*4e1bc9a0SAchim Leubner )
875*4e1bc9a0SAchim Leubner {
876*4e1bc9a0SAchim Leubner bit32 ret = AGSA_RC_SUCCESS;
877*4e1bc9a0SAchim Leubner
878*4e1bc9a0SAchim Leubner if(smIS_SPCV(agRoot))
879*4e1bc9a0SAchim Leubner {
880*4e1bc9a0SAchim Leubner ret = si_V_SoftReset(agRoot, signature );
881*4e1bc9a0SAchim Leubner }
882*4e1bc9a0SAchim Leubner else
883*4e1bc9a0SAchim Leubner {
884*4e1bc9a0SAchim Leubner ret = siSpcSoftReset(agRoot, signature );
885*4e1bc9a0SAchim Leubner }
886*4e1bc9a0SAchim Leubner
887*4e1bc9a0SAchim Leubner return(ret);
888*4e1bc9a0SAchim Leubner }
889*4e1bc9a0SAchim Leubner
si_V_SoftReset(agsaRoot_t * agRoot,bit32 signature)890*4e1bc9a0SAchim Leubner LOCAL bit32 si_V_SoftReset(
891*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
892*4e1bc9a0SAchim Leubner bit32 signature
893*4e1bc9a0SAchim Leubner )
894*4e1bc9a0SAchim Leubner {
895*4e1bc9a0SAchim Leubner
896*4e1bc9a0SAchim Leubner bit32 ret = AGSA_RC_SUCCESS;
897*4e1bc9a0SAchim Leubner
898*4e1bc9a0SAchim Leubner ret = siChipResetV(agRoot, signature);
899*4e1bc9a0SAchim Leubner
900*4e1bc9a0SAchim Leubner if (signature == SPC_SOFT_RESET_SIGNATURE)
901*4e1bc9a0SAchim Leubner {
902*4e1bc9a0SAchim Leubner SA_DBG1(("si_V_SoftReset:SPC_SOFT_RESET_SIGNATURE\n"));
903*4e1bc9a0SAchim Leubner }
904*4e1bc9a0SAchim Leubner else if (signature == SPC_HDASOFT_RESET_SIGNATURE)
905*4e1bc9a0SAchim Leubner {
906*4e1bc9a0SAchim Leubner SA_DBG1(("si_V_SoftReset: SPC_HDASOFT_RESET_SIGNATURE\n"));
907*4e1bc9a0SAchim Leubner }
908*4e1bc9a0SAchim Leubner
909*4e1bc9a0SAchim Leubner SA_DBG1(("si_V_SoftReset: Reset Complete status 0x%X\n",ret));
910*4e1bc9a0SAchim Leubner return ret;
911*4e1bc9a0SAchim Leubner }
912*4e1bc9a0SAchim Leubner
913*4e1bc9a0SAchim Leubner /******************************************************************************/
914*4e1bc9a0SAchim Leubner /*! \brief Function to soft/FW reset the SPC
915*4e1bc9a0SAchim Leubner *
916*4e1bc9a0SAchim Leubner * The siSpcSoftReset() function is called to soft reset SPC. Upon return,
917*4e1bc9a0SAchim Leubner * the SPC FW got reset. The PCIe bus is not touched.
918*4e1bc9a0SAchim Leubner *
919*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
920*4e1bc9a0SAchim Leubner * \param signature soft reset normal signature or HDA soft reset signature
921*4e1bc9a0SAchim Leubner *
922*4e1bc9a0SAchim Leubner * \return -void-
923*4e1bc9a0SAchim Leubner */
924*4e1bc9a0SAchim Leubner /*******************************************************************************/
siSpcSoftReset(agsaRoot_t * agRoot,bit32 signature)925*4e1bc9a0SAchim Leubner GLOBAL bit32 siSpcSoftReset(
926*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
927*4e1bc9a0SAchim Leubner bit32 signature
928*4e1bc9a0SAchim Leubner )
929*4e1bc9a0SAchim Leubner {
930*4e1bc9a0SAchim Leubner spc_configMainDescriptor_t mainCfg;
931*4e1bc9a0SAchim Leubner bit32 regVal, toggleVal;
932*4e1bc9a0SAchim Leubner bit32 max_wait_time;
933*4e1bc9a0SAchim Leubner bit32 max_wait_count;
934*4e1bc9a0SAchim Leubner bit32 regVal1, regVal2, regVal3;
935*4e1bc9a0SAchim Leubner
936*4e1bc9a0SAchim Leubner
937*4e1bc9a0SAchim Leubner /* sanity check */
938*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "agNULL != agRoot");
939*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
940*4e1bc9a0SAchim Leubner {
941*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"5t");
942*4e1bc9a0SAchim Leubner }
943*4e1bc9a0SAchim Leubner
944*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: start\n"));
945*4e1bc9a0SAchim Leubner
946*4e1bc9a0SAchim Leubner
947*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
948*4e1bc9a0SAchim Leubner /* count SoftReset */
949*4e1bc9a0SAchim Leubner gLLSoftResetCounter++;
950*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: ResetCount = 0x%x\n", gLLSoftResetCounter));
951*4e1bc9a0SAchim Leubner #endif
952*4e1bc9a0SAchim Leubner
953*4e1bc9a0SAchim Leubner /* step1: Check FW is ready for soft reset */
954*4e1bc9a0SAchim Leubner
955*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q1", 1);
956*4e1bc9a0SAchim Leubner /* TP:Q1 siSpcSoftReset */
957*4e1bc9a0SAchim Leubner
958*4e1bc9a0SAchim Leubner if(AGSA_RC_FAILURE == siSpcSoftResetRDYChk(agRoot))
959*4e1bc9a0SAchim Leubner {
960*4e1bc9a0SAchim Leubner SA_DBG1(("siSoftReset:siSoftResetRDYChk failed\n"));
961*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
962*4e1bc9a0SAchim Leubner {
963*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "5t");
964*4e1bc9a0SAchim Leubner }
965*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
966*4e1bc9a0SAchim Leubner }
967*4e1bc9a0SAchim Leubner
968*4e1bc9a0SAchim Leubner /* step 2: clear NMI status register on AAP1 and IOP, write the same value to clear */
969*4e1bc9a0SAchim Leubner /* map 0x60000 to BAR4(0x20), BAR2(win) */
970*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q2", 2);
971*4e1bc9a0SAchim Leubner /* TP:Q2 siSpcSoftReset */
972*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, MBIC_AAP1_ADDR_BASE))
973*4e1bc9a0SAchim Leubner {
974*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", MBIC_AAP1_ADDR_BASE));
975*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
976*4e1bc9a0SAchim Leubner {
977*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "5t");
978*4e1bc9a0SAchim Leubner }
979*4e1bc9a0SAchim Leubner
980*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",1));
981*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
982*4e1bc9a0SAchim Leubner }
983*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, MBIC_NMI_ENABLE_VPE0_IOP);
984*4e1bc9a0SAchim Leubner SA_DBG1(("MBIC(A) - NMI Enable VPE0 (IOP): = 0x%x\n", regVal));
985*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, MBIC_NMI_ENABLE_VPE0_IOP, 0x0); /* siSpcSoftReset */
986*4e1bc9a0SAchim Leubner
987*4e1bc9a0SAchim Leubner /* map 0x70000 to BAR4(0x20), BAR2(win) */
988*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, MBIC_IOP_ADDR_BASE))
989*4e1bc9a0SAchim Leubner {
990*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", MBIC_IOP_ADDR_BASE));
991*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
992*4e1bc9a0SAchim Leubner {
993*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "5t");
994*4e1bc9a0SAchim Leubner }
995*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",2));
996*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
997*4e1bc9a0SAchim Leubner }
998*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, MBIC_NMI_ENABLE_VPE0_AAP1);
999*4e1bc9a0SAchim Leubner SA_DBG1(("MBIC(A) - NMI Enable VPE0 (AAP1): = 0x%x\n", regVal));
1000*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, MBIC_NMI_ENABLE_VPE0_AAP1, 0x0); /* siSpcSoftReset */
1001*4e1bc9a0SAchim Leubner
1002*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR1, PCIE_EVENT_INTERRUPT_ENABLE);
1003*4e1bc9a0SAchim Leubner SA_DBG1(("PCIE - Event Interrupt Enable Register: = 0x%x\n", regVal));
1004*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR1, PCIE_EVENT_INTERRUPT_ENABLE, 0x0); /* siSpcSoftReset */
1005*4e1bc9a0SAchim Leubner
1006*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR1, PCIE_EVENT_INTERRUPT);
1007*4e1bc9a0SAchim Leubner SA_DBG1(("PCIE - Event Interrupt Register: = 0x%x\n", regVal));
1008*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR1, PCIE_EVENT_INTERRUPT, regVal); /* siSpcSoftReset */
1009*4e1bc9a0SAchim Leubner
1010*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR1, PCIE_ERROR_INTERRUPT_ENABLE);
1011*4e1bc9a0SAchim Leubner SA_DBG1(("PCIE - Error Interrupt Enable Register: = 0x%x\n", regVal));
1012*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR1, PCIE_ERROR_INTERRUPT_ENABLE, 0x0); /* siSpcSoftReset */
1013*4e1bc9a0SAchim Leubner
1014*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR1, PCIE_ERROR_INTERRUPT);
1015*4e1bc9a0SAchim Leubner SA_DBG1(("PCIE - Error Interrupt Register: = 0x%x\n", regVal));
1016*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR1, PCIE_ERROR_INTERRUPT, regVal); /* siSpcSoftReset */
1017*4e1bc9a0SAchim Leubner
1018*4e1bc9a0SAchim Leubner /* read the scratch pad 1 register bit 2 */
1019*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1) & SCRATCH_PAD1_RST;
1020*4e1bc9a0SAchim Leubner toggleVal = regVal ^ SCRATCH_PAD1_RST;
1021*4e1bc9a0SAchim Leubner
1022*4e1bc9a0SAchim Leubner /* set signature in host scratch pad0 register to tell SPC that the host performs the soft reset */
1023*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_0, signature);
1024*4e1bc9a0SAchim Leubner
1025*4e1bc9a0SAchim Leubner /* read required registers for confirmming */
1026*4e1bc9a0SAchim Leubner /* map 0x0700000 to BAR4(0x20), BAR2(win) */
1027*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, GSM_ADDR_BASE))
1028*4e1bc9a0SAchim Leubner {
1029*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", GSM_ADDR_BASE));
1030*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1031*4e1bc9a0SAchim Leubner {
1032*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "5t");
1033*4e1bc9a0SAchim Leubner }
1034*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",3));
1035*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1036*4e1bc9a0SAchim Leubner }
1037*4e1bc9a0SAchim Leubner
1038*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x0 (0x00007b88) - GSM Configuration and Reset = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_CONFIG_RESET)));
1039*4e1bc9a0SAchim Leubner
1040*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q3", 3);
1041*4e1bc9a0SAchim Leubner /* TP:Q3 siSpcSoftReset */
1042*4e1bc9a0SAchim Leubner
1043*4e1bc9a0SAchim Leubner /* step 3: host read GSM Configuration and Reset register */
1044*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_CONFIG_RESET);
1045*4e1bc9a0SAchim Leubner /* Put those bits to low */
1046*4e1bc9a0SAchim Leubner /* GSM XCBI offset = 0x70 0000
1047*4e1bc9a0SAchim Leubner 0x00 Bit 13 COM_SLV_SW_RSTB 1
1048*4e1bc9a0SAchim Leubner 0x00 Bit 12 QSSP_SW_RSTB 1
1049*4e1bc9a0SAchim Leubner 0x00 Bit 11 RAAE_SW_RSTB 1
1050*4e1bc9a0SAchim Leubner 0x00 Bit 9 RB_1_SW_RSTB 1
1051*4e1bc9a0SAchim Leubner 0x00 Bit 8 SM_SW_RSTB 1
1052*4e1bc9a0SAchim Leubner */
1053*4e1bc9a0SAchim Leubner regVal &= ~(0x00003b00);
1054*4e1bc9a0SAchim Leubner /* host write GSM Configuration and Reset register */
1055*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_CONFIG_RESET, regVal); /* siSpcSoftReset */
1056*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x0 (0x00007b88 ==> 0x00004088) - GSM Configuration and Reset is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_CONFIG_RESET)));
1057*4e1bc9a0SAchim Leubner
1058*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1059*4e1bc9a0SAchim Leubner /* debugging messge */
1060*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700018 - RAM ECC Double Bit Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, RAM_ECC_DB_ERR)));
1061*4e1bc9a0SAchim Leubner
1062*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700058 - Read Address Parity Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_INDIC)));
1063*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700060 - Write Address Parity Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_INDIC)));
1064*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700068 - Write Data Parity Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_INDIC)));
1065*4e1bc9a0SAchim Leubner #endif
1066*4e1bc9a0SAchim Leubner
1067*4e1bc9a0SAchim Leubner /* step 4: */
1068*4e1bc9a0SAchim Leubner /* disable GSM - Read Address Parity Check */
1069*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q4", 4);
1070*4e1bc9a0SAchim Leubner /* TP:Q4 siSpcSoftReset */
1071*4e1bc9a0SAchim Leubner regVal1 = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_CHECK);
1072*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700038 - Read Address Parity Check Enable = 0x%x\n", regVal1));
1073*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_CHECK, 0x0); /* siSpcSoftReset */
1074*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700038 - Read Address Parity Check Enable is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_CHECK)));
1075*4e1bc9a0SAchim Leubner
1076*4e1bc9a0SAchim Leubner /* disable GSM - Write Address Parity Check */
1077*4e1bc9a0SAchim Leubner regVal2 = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_CHECK);
1078*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700040 - Write Address Parity Check Enable = 0x%x\n", regVal2));
1079*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_CHECK, 0x0); /* siSpcSoftReset */
1080*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700040 - Write Address Parity Check Enable is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_CHECK)));
1081*4e1bc9a0SAchim Leubner
1082*4e1bc9a0SAchim Leubner /* disable GSM - Write Data Parity Check */
1083*4e1bc9a0SAchim Leubner regVal3 = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_CHECK);
1084*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x300048 - Write Data Parity Check Enable = 0x%x\n", regVal3));
1085*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_CHECK, 0x0); /* siSpcSoftReset */
1086*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700048 - Write Data Parity Check Enable is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_CHECK)));
1087*4e1bc9a0SAchim Leubner /* step 5-a: delay 10 usec */
1088*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q5", 5);
1089*4e1bc9a0SAchim Leubner /* TP:Q5 siSpcSoftReset */
1090*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, 10);
1091*4e1bc9a0SAchim Leubner
1092*4e1bc9a0SAchim Leubner /* step 5-b: set GPIO-0 output control to tristate anyway */
1093*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, GPIO_ADDR_BASE))
1094*4e1bc9a0SAchim Leubner {
1095*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", GPIO_ADDR_BASE));
1096*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1097*4e1bc9a0SAchim Leubner {
1098*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "5t");
1099*4e1bc9a0SAchim Leubner }
1100*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",4));
1101*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1102*4e1bc9a0SAchim Leubner }
1103*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, GPIO_GPIO_0_0UTPUT_CTL_OFFSET);
1104*4e1bc9a0SAchim Leubner SA_DBG1(("GPIO Output Control Register: = 0x%x\n", regVal));
1105*4e1bc9a0SAchim Leubner /* set GPIO-0 output control to tri-state */
1106*4e1bc9a0SAchim Leubner regVal &= 0xFFFFFFFC;
1107*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GPIO_GPIO_0_0UTPUT_CTL_OFFSET, regVal); /* siSpcSoftReset */
1108*4e1bc9a0SAchim Leubner
1109*4e1bc9a0SAchim Leubner /* Step 6: Reset the IOP and AAP1 */
1110*4e1bc9a0SAchim Leubner /* map 0x00000 to BAR4(0x20), BAR2(win) */
1111*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q6", 6);
1112*4e1bc9a0SAchim Leubner /* TP:Q6 siSpcSoftReset */
1113*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, SPC_TOP_LEVEL_ADDR_BASE))
1114*4e1bc9a0SAchim Leubner {
1115*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", SPC_TOP_LEVEL_ADDR_BASE));
1116*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1117*4e1bc9a0SAchim Leubner {
1118*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "5t");
1119*4e1bc9a0SAchim Leubner }
1120*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",5));
1121*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1122*4e1bc9a0SAchim Leubner }
1123*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_RESET);
1124*4e1bc9a0SAchim Leubner SA_DBG1(("Top Register before resetting IOP/AAP1: = 0x%x\n", regVal));
1125*4e1bc9a0SAchim Leubner regVal &= ~(SPC_REG_RESET_PCS_IOP_SS | SPC_REG_RESET_PCS_AAP1_SS);
1126*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_REG_RESET, regVal); /* siSpcSoftReset */
1127*4e1bc9a0SAchim Leubner
1128*4e1bc9a0SAchim Leubner /* step 7: Reset the BDMA/OSSP */
1129*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q7", 7);
1130*4e1bc9a0SAchim Leubner /* TP:Q7 siSpcSoftReset */
1131*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_RESET);
1132*4e1bc9a0SAchim Leubner SA_DBG1(("Top Register before resetting BDMA/OSSP: = 0x%x\n", regVal));
1133*4e1bc9a0SAchim Leubner regVal &= ~(SPC_REG_RESET_BDMA_CORE | SPC_REG_RESET_OSSP);
1134*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_REG_RESET, regVal); /* siSpcSoftReset */
1135*4e1bc9a0SAchim Leubner
1136*4e1bc9a0SAchim Leubner /* step 8: delay 10 usec */
1137*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q8", 8);
1138*4e1bc9a0SAchim Leubner /* TP:Q8 siSpcSoftReset */
1139*4e1bc9a0SAchim Leubner
1140*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1141*4e1bc9a0SAchim Leubner
1142*4e1bc9a0SAchim Leubner /* step 9: bring the BDMA and OSSP out of reset */
1143*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"Q9", 9);
1144*4e1bc9a0SAchim Leubner /* TP:Q9 siSpcSoftReset */
1145*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_RESET);
1146*4e1bc9a0SAchim Leubner SA_DBG1(("Top Register before bringing up BDMA/OSSP: = 0x%x\n", regVal));
1147*4e1bc9a0SAchim Leubner regVal |= (SPC_REG_RESET_BDMA_CORE | SPC_REG_RESET_OSSP);
1148*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_REG_RESET, regVal); /* siSpcSoftReset */
1149*4e1bc9a0SAchim Leubner
1150*4e1bc9a0SAchim Leubner /* step 10: delay 10 usec */
1151*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"QA", 10);
1152*4e1bc9a0SAchim Leubner /* TP:QA siSpcSoftReset */
1153*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1154*4e1bc9a0SAchim Leubner
1155*4e1bc9a0SAchim Leubner /* step 11: reads and sets the GSM Configuration and Reset Register */
1156*4e1bc9a0SAchim Leubner /* map 0x0700000 to BAR4(0x20), BAR2(win) */
1157*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"QB", 11);
1158*4e1bc9a0SAchim Leubner /* TP:QB siSpcSoftReset */
1159*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, GSM_ADDR_BASE))
1160*4e1bc9a0SAchim Leubner {
1161*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", GSM_ADDR_BASE));
1162*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1163*4e1bc9a0SAchim Leubner {
1164*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "5t");
1165*4e1bc9a0SAchim Leubner }
1166*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",5));
1167*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1168*4e1bc9a0SAchim Leubner }
1169*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x0 (0x00007b88) - GSM Configuration and Reset = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_CONFIG_RESET)));
1170*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_CONFIG_RESET);
1171*4e1bc9a0SAchim Leubner /* Put those bits to high */
1172*4e1bc9a0SAchim Leubner /* GSM XCBI offset = 0x70 0000
1173*4e1bc9a0SAchim Leubner 0x00 Bit 13 COM_SLV_SW_RSTB 1
1174*4e1bc9a0SAchim Leubner 0x00 Bit 12 QSSP_SW_RSTB 1
1175*4e1bc9a0SAchim Leubner 0x00 Bit 11 RAAE_SW_RSTB 1
1176*4e1bc9a0SAchim Leubner 0x00 Bit 9 RB_1_SW_RSTB 1
1177*4e1bc9a0SAchim Leubner 0x00 Bit 8 SM_SW_RSTB 1
1178*4e1bc9a0SAchim Leubner */
1179*4e1bc9a0SAchim Leubner regVal |= (GSM_CONFIG_RESET_VALUE);
1180*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_CONFIG_RESET, regVal); /* siSpcSoftReset */
1181*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x0 (0x00004088 ==> 0x00007b88) - GSM Configuration and Reset is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_CONFIG_RESET)));
1182*4e1bc9a0SAchim Leubner
1183*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1184*4e1bc9a0SAchim Leubner /* debugging messge */
1185*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700018 - RAM ECC Double Bit Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, RAM_ECC_DB_ERR)));
1186*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700058 - Read Address Parity Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_INDIC)));
1187*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700060 - Write Address Parity Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_INDIC)));
1188*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700068 - Write Data Parity Error Indication = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_INDIC)));
1189*4e1bc9a0SAchim Leubner #endif
1190*4e1bc9a0SAchim Leubner
1191*4e1bc9a0SAchim Leubner /* step 12: Restore GSM - Read Address Parity Check */
1192*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"QC", 12);
1193*4e1bc9a0SAchim Leubner /* TP:QC siSpcSoftReset */
1194*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_CHECK); /* just for debugging */
1195*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700038 - Read Address Parity Check Enable = 0x%x\n", regVal));
1196*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_CHECK, regVal1); /* siSpcSoftReset */
1197*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700038 - Read Address Parity Check Enable is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_READ_ADDR_PARITY_CHECK)));
1198*4e1bc9a0SAchim Leubner
1199*4e1bc9a0SAchim Leubner /* Restore GSM - Write Address Parity Check */
1200*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_CHECK); /* just for debugging */
1201*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700040 - Write Address Parity Check Enable = 0x%x\n", regVal));
1202*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_CHECK, regVal2); /* siSpcSoftReset */
1203*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700040 - Write Address Parity Check Enable is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_ADDR_PARITY_CHECK)));
1204*4e1bc9a0SAchim Leubner
1205*4e1bc9a0SAchim Leubner /* Restore GSM - Write Data Parity Check */
1206*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_CHECK); /* just for debugging */
1207*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700048 - Write Data Parity Check Enable = 0x%x\n", regVal));
1208*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_CHECK, regVal3); /* siSpcSoftReset */
1209*4e1bc9a0SAchim Leubner SA_DBG1(("GSM 0x700048 - Write Data Parity Check Enable is set to = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR2, GSM_WRITE_DATA_PARITY_CHECK)));
1210*4e1bc9a0SAchim Leubner
1211*4e1bc9a0SAchim Leubner /* step 13: bring the IOP and AAP1 out of reset */
1212*4e1bc9a0SAchim Leubner /* map 0x00000 to BAR4(0x20), BAR2(win) */
1213*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"QD", 13);
1214*4e1bc9a0SAchim Leubner /* TP:QD siSpcSoftReset */
1215*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, SPC_TOP_LEVEL_ADDR_BASE))
1216*4e1bc9a0SAchim Leubner {
1217*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", SPC_TOP_LEVEL_ADDR_BASE));
1218*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1219*4e1bc9a0SAchim Leubner {
1220*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "5t");
1221*4e1bc9a0SAchim Leubner }
1222*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",7));
1223*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1224*4e1bc9a0SAchim Leubner }
1225*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR2, SPC_REG_RESET);
1226*4e1bc9a0SAchim Leubner SA_DBG1(("Top Register before bringing up IOP/AAP1: = 0x%x\n", regVal));
1227*4e1bc9a0SAchim Leubner regVal |= (SPC_REG_RESET_PCS_IOP_SS | SPC_REG_RESET_PCS_AAP1_SS);
1228*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_REG_RESET, regVal); /* siSpcSoftReset */
1229*4e1bc9a0SAchim Leubner
1230*4e1bc9a0SAchim Leubner if (signature == SPC_SOFT_RESET_SIGNATURE)
1231*4e1bc9a0SAchim Leubner {
1232*4e1bc9a0SAchim Leubner /* step 14: delay 20 milli - Normal Mode */
1233*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1234*4e1bc9a0SAchim Leubner }else if (signature == SPC_HDASOFT_RESET_SIGNATURE)
1235*4e1bc9a0SAchim Leubner {
1236*4e1bc9a0SAchim Leubner /* step 14: delay 200 milli - HDA Mode */
1237*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, 200 * 1000);
1238*4e1bc9a0SAchim Leubner }
1239*4e1bc9a0SAchim Leubner
1240*4e1bc9a0SAchim Leubner /* check Soft Reset Normal mode or Soft Reset HDA mode */
1241*4e1bc9a0SAchim Leubner if (signature == SPC_SOFT_RESET_SIGNATURE)
1242*4e1bc9a0SAchim Leubner {
1243*4e1bc9a0SAchim Leubner /* step 15 (Normal Mode): wait until scratch pad1 register bit 2 toggled */
1244*4e1bc9a0SAchim Leubner max_wait_time = WAIT_SECONDS(2); /* 2 sec */
1245*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
1246*4e1bc9a0SAchim Leubner do
1247*4e1bc9a0SAchim Leubner {
1248*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1249*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1) & SCRATCH_PAD1_RST;
1250*4e1bc9a0SAchim Leubner } while ((regVal != toggleVal) && (max_wait_count -=WAIT_INCREMENT));
1251*4e1bc9a0SAchim Leubner
1252*4e1bc9a0SAchim Leubner if ( !max_wait_count)
1253*4e1bc9a0SAchim Leubner {
1254*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1);
1255*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: TIMEOUT:ToggleVal 0x%x, MSGU_SCRATCH_PAD1 = 0x%x\n", toggleVal, regVal));
1256*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1257*4e1bc9a0SAchim Leubner {
1258*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "5t");
1259*4e1bc9a0SAchim Leubner }
1260*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1261*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0)));
1262*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2)));
1263*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3)));
1264*4e1bc9a0SAchim Leubner #endif
1265*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",8));
1266*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1267*4e1bc9a0SAchim Leubner }
1268*4e1bc9a0SAchim Leubner
1269*4e1bc9a0SAchim Leubner /* step 16 (Normal)step 15 (HDA) - Clear ODMR and ODCR */
1270*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"QG", 16);
1271*4e1bc9a0SAchim Leubner /* TP:QG siSpcSoftReset */
1272*4e1bc9a0SAchim Leubner
1273*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_ODCR, ODCR_CLEAR_ALL);
1274*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_ODMR, ODMR_CLEAR_ALL);
1275*4e1bc9a0SAchim Leubner }
1276*4e1bc9a0SAchim Leubner else if (signature == SPC_HDASOFT_RESET_SIGNATURE)
1277*4e1bc9a0SAchim Leubner {
1278*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1279*4e1bc9a0SAchim Leubner {
1280*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: HDA Soft Reset Complete\n"));
1281*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'j', "5t");
1282*4e1bc9a0SAchim Leubner }
1283*4e1bc9a0SAchim Leubner return AGSA_RC_SUCCESS;
1284*4e1bc9a0SAchim Leubner }
1285*4e1bc9a0SAchim Leubner
1286*4e1bc9a0SAchim Leubner
1287*4e1bc9a0SAchim Leubner /* step 17 (Normal Mode): wait for the FW and IOP to get ready - 1 sec timeout */
1288*4e1bc9a0SAchim Leubner /* Wait for the SPC Configuration Table to be ready */
1289*4e1bc9a0SAchim Leubner if (mpiWaitForConfigTable(agRoot, &mainCfg) == AGSA_RC_FAILURE)
1290*4e1bc9a0SAchim Leubner {
1291*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1);
1292*4e1bc9a0SAchim Leubner /* return error if MPI Configuration Table not ready */
1293*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: SPC FW not ready SCRATCH_PAD1 = 0x%x\n", regVal));
1294*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2);
1295*4e1bc9a0SAchim Leubner /* return error if MPI Configuration Table not ready */
1296*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: SPC FW not ready SCRATCH_PAD2 = 0x%x\n", regVal));
1297*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1298*4e1bc9a0SAchim Leubner {
1299*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'k', "5t");
1300*4e1bc9a0SAchim Leubner }
1301*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1302*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0)));
1303*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3)));
1304*4e1bc9a0SAchim Leubner #endif
1305*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset AGSA_RC_FAILURE %d\n",9));
1306*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1307*4e1bc9a0SAchim Leubner }
1308*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"QI", 18);
1309*4e1bc9a0SAchim Leubner /* TP:QI siSpcSoftReset */
1310*4e1bc9a0SAchim Leubner
1311*4e1bc9a0SAchim Leubner if(agNULL != agRoot->sdkData)
1312*4e1bc9a0SAchim Leubner {
1313*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'l', "5t");
1314*4e1bc9a0SAchim Leubner }
1315*4e1bc9a0SAchim Leubner
1316*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset: Soft Reset Complete\n"));
1317*4e1bc9a0SAchim Leubner
1318*4e1bc9a0SAchim Leubner return AGSA_RC_SUCCESS;
1319*4e1bc9a0SAchim Leubner }
1320*4e1bc9a0SAchim Leubner
1321*4e1bc9a0SAchim Leubner /******************************************************************************/
1322*4e1bc9a0SAchim Leubner /*! \brief Function to do BAR shifting
1323*4e1bc9a0SAchim Leubner *
1324*4e1bc9a0SAchim Leubner * The siBarShift() function is called to shift BAR base address
1325*4e1bc9a0SAchim Leubner *
1326*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
1327*4e1bc9a0SAchim Leubner * \param shiftValue shifting value
1328*4e1bc9a0SAchim Leubner *
1329*4e1bc9a0SAchim Leubner * \return success or fail
1330*4e1bc9a0SAchim Leubner */
1331*4e1bc9a0SAchim Leubner /*******************************************************************************/
siBar4Shift(agsaRoot_t * agRoot,bit32 shiftValue)1332*4e1bc9a0SAchim Leubner GLOBAL bit32 siBar4Shift(
1333*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
1334*4e1bc9a0SAchim Leubner bit32 shiftValue
1335*4e1bc9a0SAchim Leubner )
1336*4e1bc9a0SAchim Leubner {
1337*4e1bc9a0SAchim Leubner bit32 regVal;
1338*4e1bc9a0SAchim Leubner bit32 max_wait_time;
1339*4e1bc9a0SAchim Leubner bit32 max_wait_count;
1340*4e1bc9a0SAchim Leubner
1341*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"5e");
1342*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"GA",shiftValue);
1343*4e1bc9a0SAchim Leubner /* TP:GA shiftValue */
1344*4e1bc9a0SAchim Leubner
1345*4e1bc9a0SAchim Leubner SA_DBG2(("siBar4Shift: shiftValue 0x%x\n",shiftValue));
1346*4e1bc9a0SAchim Leubner
1347*4e1bc9a0SAchim Leubner if(smIS_SPCV(agRoot) )
1348*4e1bc9a0SAchim Leubner {
1349*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, V_MEMBASE_II_ShiftRegister, shiftValue);
1350*4e1bc9a0SAchim Leubner /* confirm the setting is written */
1351*4e1bc9a0SAchim Leubner max_wait_time = WAIT_SECONDS(1); /* 1 sec */
1352*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
1353*4e1bc9a0SAchim Leubner do
1354*4e1bc9a0SAchim Leubner {
1355*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1356*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR0, V_MEMBASE_II_ShiftRegister);
1357*4e1bc9a0SAchim Leubner } while ((regVal != shiftValue) && (max_wait_count -= WAIT_INCREMENT));
1358*4e1bc9a0SAchim Leubner
1359*4e1bc9a0SAchim Leubner if (!max_wait_count)
1360*4e1bc9a0SAchim Leubner {
1361*4e1bc9a0SAchim Leubner SA_DBG1(("siBar4Shift: TIMEOUT: SPC_IBW_AXI_TRANSLATION_LOW = 0x%x\n", regVal));
1362*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "5e");
1363*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1364*4e1bc9a0SAchim Leubner }
1365*4e1bc9a0SAchim Leubner }
1366*4e1bc9a0SAchim Leubner else if(smIS_SPC(agRoot))
1367*4e1bc9a0SAchim Leubner {
1368*4e1bc9a0SAchim Leubner /* program the inbound AXI translation Lower Address */
1369*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR1, SPC_IBW_AXI_TRANSLATION_LOW, shiftValue);
1370*4e1bc9a0SAchim Leubner
1371*4e1bc9a0SAchim Leubner /* confirm the setting is written */
1372*4e1bc9a0SAchim Leubner max_wait_time = WAIT_SECONDS(1); /* 1 sec */
1373*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
1374*4e1bc9a0SAchim Leubner do
1375*4e1bc9a0SAchim Leubner {
1376*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1377*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR1, SPC_IBW_AXI_TRANSLATION_LOW);
1378*4e1bc9a0SAchim Leubner } while ((regVal != shiftValue) && (max_wait_count -= WAIT_INCREMENT));
1379*4e1bc9a0SAchim Leubner
1380*4e1bc9a0SAchim Leubner if (!max_wait_count)
1381*4e1bc9a0SAchim Leubner {
1382*4e1bc9a0SAchim Leubner SA_DBG1(("siBar4Shift: TIMEOUT: SPC_IBW_AXI_TRANSLATION_LOW = 0x%x\n", regVal));
1383*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "5e");
1384*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1385*4e1bc9a0SAchim Leubner }
1386*4e1bc9a0SAchim Leubner }
1387*4e1bc9a0SAchim Leubner else
1388*4e1bc9a0SAchim Leubner {
1389*4e1bc9a0SAchim Leubner SA_DBG1(("siBar4Shift: hba type is not support\n"));
1390*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1391*4e1bc9a0SAchim Leubner }
1392*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "5e");
1393*4e1bc9a0SAchim Leubner
1394*4e1bc9a0SAchim Leubner return AGSA_RC_SUCCESS;
1395*4e1bc9a0SAchim Leubner }
1396*4e1bc9a0SAchim Leubner
1397*4e1bc9a0SAchim Leubner #ifdef SA_ENABLE_HDA_FUNCTIONS
1398*4e1bc9a0SAchim Leubner /******************************************************************************/
1399*4e1bc9a0SAchim Leubner /*! \brief Function to force HDA mode the SPC
1400*4e1bc9a0SAchim Leubner *
1401*4e1bc9a0SAchim Leubner * The siHDAMode() function is called to force to HDA mode. Upon return,
1402*4e1bc9a0SAchim Leubner * the SPC FW loaded. The PCIe bus is not touched.
1403*4e1bc9a0SAchim Leubner *
1404*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
1405*4e1bc9a0SAchim Leubner * \param HDAMode 0 - HDA soft reset mode, 1 - HDA mode
1406*4e1bc9a0SAchim Leubner * \param fwImg points to structure containing fw images
1407*4e1bc9a0SAchim Leubner *
1408*4e1bc9a0SAchim Leubner * \return -void-
1409*4e1bc9a0SAchim Leubner */
1410*4e1bc9a0SAchim Leubner /*******************************************************************************/
siHDAMode(agsaRoot_t * agRoot,bit32 HDAMode,agsaFwImg_t * userFwImg)1411*4e1bc9a0SAchim Leubner GLOBAL bit32 siHDAMode(
1412*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
1413*4e1bc9a0SAchim Leubner bit32 HDAMode,
1414*4e1bc9a0SAchim Leubner agsaFwImg_t *userFwImg
1415*4e1bc9a0SAchim Leubner )
1416*4e1bc9a0SAchim Leubner {
1417*4e1bc9a0SAchim Leubner spc_configMainDescriptor_t mainCfg;
1418*4e1bc9a0SAchim Leubner bit32 regVal;
1419*4e1bc9a0SAchim Leubner bit32 max_wait_time;
1420*4e1bc9a0SAchim Leubner bit32 max_wait_count;
1421*4e1bc9a0SAchim Leubner agsaFwImg_t flashImg;
1422*4e1bc9a0SAchim Leubner bit32 startTime, endTime; // TestBase
1423*4e1bc9a0SAchim Leubner bit32 stepTime[12]; // TestBase
1424*4e1bc9a0SAchim Leubner
1425*4e1bc9a0SAchim Leubner bit32 HDA_Been_Reset = agFALSE;
1426*4e1bc9a0SAchim Leubner
1427*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"5d");
1428*4e1bc9a0SAchim Leubner
1429*4e1bc9a0SAchim Leubner /* sanity check */
1430*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "");
1431*4e1bc9a0SAchim Leubner
1432*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: start\n"));
1433*4e1bc9a0SAchim Leubner
1434*4e1bc9a0SAchim Leubner si_memset(&flashImg, 0, sizeof(flashImg));
1435*4e1bc9a0SAchim Leubner #ifndef SA_EXCLUDE_FW_IMG
1436*4e1bc9a0SAchim Leubner
1437*4e1bc9a0SAchim Leubner /* Set up built-in (default) FW image pointers */
1438*4e1bc9a0SAchim Leubner /*
1439*4e1bc9a0SAchim Leubner flashImg.aap1Img = (bit8*)(&aap1array);
1440*4e1bc9a0SAchim Leubner flashImg.aap1Len = sizeof(aap1array);
1441*4e1bc9a0SAchim Leubner flashImg.ilaImg = (bit8*)(&ilaarray);
1442*4e1bc9a0SAchim Leubner flashImg.ilaLen = sizeof(ilaarray);
1443*4e1bc9a0SAchim Leubner flashImg.iopImg = (bit8*)(&ioparray);
1444*4e1bc9a0SAchim Leubner flashImg.iopLen = sizeof(ioparray);
1445*4e1bc9a0SAchim Leubner */
1446*4e1bc9a0SAchim Leubner #endif
1447*4e1bc9a0SAchim Leubner TryAfterReset:
1448*4e1bc9a0SAchim Leubner
1449*4e1bc9a0SAchim Leubner /* Set up user FW image pointers (if passed in) */
1450*4e1bc9a0SAchim Leubner if (userFwImg)
1451*4e1bc9a0SAchim Leubner {
1452*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: User fw structure @ %p\n",userFwImg));
1453*4e1bc9a0SAchim Leubner if (userFwImg->aap1Img && userFwImg->aap1Len)
1454*4e1bc9a0SAchim Leubner {
1455*4e1bc9a0SAchim Leubner flashImg.aap1Img = userFwImg->aap1Img;
1456*4e1bc9a0SAchim Leubner flashImg.aap1Len = userFwImg->aap1Len;
1457*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: User fw aap1 @ %p (%d)\n", flashImg.aap1Img, flashImg.aap1Len));
1458*4e1bc9a0SAchim Leubner }
1459*4e1bc9a0SAchim Leubner if (userFwImg->ilaImg && userFwImg->ilaLen)
1460*4e1bc9a0SAchim Leubner {
1461*4e1bc9a0SAchim Leubner flashImg.ilaImg = userFwImg->ilaImg;
1462*4e1bc9a0SAchim Leubner flashImg.ilaLen = userFwImg->ilaLen;
1463*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: User fw ila @ %p (%d)\n", flashImg.ilaImg, flashImg.ilaLen));
1464*4e1bc9a0SAchim Leubner }
1465*4e1bc9a0SAchim Leubner if (userFwImg->iopImg && userFwImg->iopLen)
1466*4e1bc9a0SAchim Leubner {
1467*4e1bc9a0SAchim Leubner flashImg.iopImg = userFwImg->iopImg;
1468*4e1bc9a0SAchim Leubner flashImg.iopLen = userFwImg->iopLen;
1469*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: User fw iop @ %p (%d)\n", flashImg.iopImg, flashImg.iopLen));
1470*4e1bc9a0SAchim Leubner }
1471*4e1bc9a0SAchim Leubner if (userFwImg->istrImg && userFwImg->istrLen)
1472*4e1bc9a0SAchim Leubner {
1473*4e1bc9a0SAchim Leubner flashImg.istrImg = userFwImg->istrImg;
1474*4e1bc9a0SAchim Leubner flashImg.istrLen = userFwImg->istrLen;
1475*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: User fw istr @ %p (%d)\n", flashImg.istrImg, flashImg.istrLen));
1476*4e1bc9a0SAchim Leubner }
1477*4e1bc9a0SAchim Leubner }
1478*4e1bc9a0SAchim Leubner else
1479*4e1bc9a0SAchim Leubner {
1480*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: user supplied FW is not found\n"));
1481*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "5d");
1482*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1483*4e1bc9a0SAchim Leubner }
1484*4e1bc9a0SAchim Leubner
1485*4e1bc9a0SAchim Leubner #ifdef SA_EXCLUDE_FW_IMG
1486*4e1bc9a0SAchim Leubner /* Check that fw images are setup properly */
1487*4e1bc9a0SAchim Leubner if (!(flashImg.aap1Img && flashImg.aap1Len &&
1488*4e1bc9a0SAchim Leubner flashImg.ilaImg && flashImg.ilaLen &&
1489*4e1bc9a0SAchim Leubner flashImg.iopImg && flashImg.iopLen &&
1490*4e1bc9a0SAchim Leubner flashImg.istrImg && flashImg.istrLen))
1491*4e1bc9a0SAchim Leubner {
1492*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Built-in FW img excluded and not user defined.\n"));
1493*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "5d");
1494*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1495*4e1bc9a0SAchim Leubner }
1496*4e1bc9a0SAchim Leubner #endif
1497*4e1bc9a0SAchim Leubner
1498*4e1bc9a0SAchim Leubner /* Check HDA mode with Soft Reset */
1499*4e1bc9a0SAchim Leubner if (!HDAMode)
1500*4e1bc9a0SAchim Leubner {
1501*4e1bc9a0SAchim Leubner /* Try soft reset until it goes into HDA mode */
1502*4e1bc9a0SAchim Leubner siSpcSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1503*4e1bc9a0SAchim Leubner
1504*4e1bc9a0SAchim Leubner /* read response state */
1505*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_STATUS_BITS;
1506*4e1bc9a0SAchim Leubner if (regVal != BOOTTLOADERHDA_IDLE)
1507*4e1bc9a0SAchim Leubner {
1508*4e1bc9a0SAchim Leubner /* Can not go into HDA mode with 200 ms wait - HDA Soft Reset failed */
1509*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET = 0x%x\n", regVal));
1510*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "5d");
1511*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1512*4e1bc9a0SAchim Leubner }
1513*4e1bc9a0SAchim Leubner
1514*4e1bc9a0SAchim Leubner /* HDA Mode - Clear ODMR and ODCR */
1515*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_ODCR, ODCR_CLEAR_ALL);
1516*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_ODMR, ODMR_CLEAR_ALL);
1517*4e1bc9a0SAchim Leubner }
1518*4e1bc9a0SAchim Leubner
1519*4e1bc9a0SAchim Leubner /* Step 1: Poll BOOTTLOADERHDA_IDLE - HDA mode */
1520*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step1:Poll for HDAR_IDLE\n"));
1521*4e1bc9a0SAchim Leubner max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
1522*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
1523*4e1bc9a0SAchim Leubner do
1524*4e1bc9a0SAchim Leubner {
1525*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1526*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_STATUS_BITS;
1527*4e1bc9a0SAchim Leubner } while ((regVal != BOOTTLOADERHDA_IDLE) && (max_wait_count -= WAIT_INCREMENT));
1528*4e1bc9a0SAchim Leubner
1529*4e1bc9a0SAchim Leubner if (!max_wait_count)
1530*4e1bc9a0SAchim Leubner {
1531*4e1bc9a0SAchim Leubner
1532*4e1bc9a0SAchim Leubner if( !HDA_Been_Reset )
1533*4e1bc9a0SAchim Leubner {
1534*4e1bc9a0SAchim Leubner
1535*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Reset: Step1:regVal =0x%x expect 0x%x\n", regVal,ILAHDA_AAP1_IMG_GET ));
1536*4e1bc9a0SAchim Leubner siSpcSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1537*4e1bc9a0SAchim Leubner HDA_Been_Reset = agTRUE;
1538*4e1bc9a0SAchim Leubner goto TryAfterReset;
1539*4e1bc9a0SAchim Leubner
1540*4e1bc9a0SAchim Leubner }
1541*4e1bc9a0SAchim Leubner
1542*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step1:TIMEOUT: HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET = 0x%x\n", regVal));
1543*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "5d");
1544*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1545*4e1bc9a0SAchim Leubner }
1546*4e1bc9a0SAchim Leubner
1547*4e1bc9a0SAchim Leubner /* Step 2: Push the init string to 0x0047E000 & data compare */
1548*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step2:Push the init string to 0x0047E000!\n"));
1549*4e1bc9a0SAchim Leubner
1550*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Cpy(agRoot, ILA_ISTR_ADDROFFSETHDA, flashImg.istrImg, flashImg.istrLen))
1551*4e1bc9a0SAchim Leubner {
1552*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step2:Copy ISTR array to 0x%x failed\n", ILA_ISTR_ADDROFFSETHDA));
1553*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "5d");
1554*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1555*4e1bc9a0SAchim Leubner }
1556*4e1bc9a0SAchim Leubner
1557*4e1bc9a0SAchim Leubner /* Tell FW ISTR is ready */
1558*4e1bc9a0SAchim Leubner regVal = (HDA_ISTR_DONE | (bit32)flashImg.istrLen);
1559*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_3, regVal);
1560*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step2:Host Scratchpad 3 (AAP1-ISTR): 0x%x\n", regVal));
1561*4e1bc9a0SAchim Leubner
1562*4e1bc9a0SAchim Leubner stepTime[2] = ossaTimeStamp(agRoot); // TestBase
1563*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step2: (step_time[2] = %d)\n", stepTime[2])); // TestBase
1564*4e1bc9a0SAchim Leubner
1565*4e1bc9a0SAchim Leubner /* Step 3: Write the HDA mode SoftReset signature */
1566*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step3:Set Signature!\n"));
1567*4e1bc9a0SAchim Leubner /* set signature in host scratch pad0 register to tell SPC that the host performs the HDA mode */
1568*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_0, SPC_HDASOFT_RESET_SIGNATURE);
1569*4e1bc9a0SAchim Leubner
1570*4e1bc9a0SAchim Leubner stepTime[3] = ossaTimeStamp(agRoot); // TestBase
1571*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step3: (step_time[3] = %d)\n", stepTime[3])); // TestBase
1572*4e1bc9a0SAchim Leubner
1573*4e1bc9a0SAchim Leubner // Priya (Apps) requested that the FW load time measurement be started here
1574*4e1bc9a0SAchim Leubner startTime = ossaTimeStamp(agRoot);
1575*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step4: Ready to push ILA to 0x00400000! (start_time = %d)\n", startTime)); // TestBase
1576*4e1bc9a0SAchim Leubner
1577*4e1bc9a0SAchim Leubner /* Step 4: Push the ILA image to 0x00400000 */
1578*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step4:Push the ILA to 0x00400000!\n"));
1579*4e1bc9a0SAchim Leubner
1580*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Cpy(agRoot, 0x0, flashImg.ilaImg, flashImg.ilaLen))
1581*4e1bc9a0SAchim Leubner {
1582*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode:Step4:Copy ILA array to 0x%x failed\n", 0x0));
1583*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "5d");
1584*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1585*4e1bc9a0SAchim Leubner }
1586*4e1bc9a0SAchim Leubner
1587*4e1bc9a0SAchim Leubner stepTime[4] = ossaTimeStamp(agRoot);
1588*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step4: (step_time[4] = %d, %d ms)\n", stepTime[4], (stepTime[4] - startTime))); // TestBase
1589*4e1bc9a0SAchim Leubner
1590*4e1bc9a0SAchim Leubner /* Step 5: Tell boot ROM to authenticate ILA and execute it */
1591*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR3, HDA_CMD_OFFSET1MB, 0);
1592*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR3, HDA_CMD_OFFSET1MB+HDA_PAR_LEN_OFFSET, flashImg.ilaLen);
1593*4e1bc9a0SAchim Leubner regVal = (ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_SEQ_ID_BITS ) >> SHIFT16;
1594*4e1bc9a0SAchim Leubner regVal ++;
1595*4e1bc9a0SAchim Leubner regVal = (HDA_C_PA << SHIFT24) | (regVal << SHIFT16) | HDAC_EXEC_CMD;
1596*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step5:Execute ILA CMD: 0x%x\n", regVal));
1597*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR3, HDA_CMD_OFFSET1MB+HDA_CMD_CODE_OFFSET, regVal); /* Execute Command */
1598*4e1bc9a0SAchim Leubner
1599*4e1bc9a0SAchim Leubner stepTime[5] = ossaTimeStamp(agRoot);
1600*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step5: (step_time[5] = %d, %d ms)\n", stepTime[5], (stepTime[5] - startTime))); // TestBase
1601*4e1bc9a0SAchim Leubner
1602*4e1bc9a0SAchim Leubner
1603*4e1bc9a0SAchim Leubner /* Step 6: Checking response status from boot ROM, HDAR_EXEC (good), HDAR_BAD_CMD and HDAR_BAD_IMG */
1604*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step6:Checking boot ROM reponse status!\n"));
1605*4e1bc9a0SAchim Leubner max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
1606*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
1607*4e1bc9a0SAchim Leubner do
1608*4e1bc9a0SAchim Leubner {
1609*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1610*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_STATUS_BITS;
1611*4e1bc9a0SAchim Leubner if ((HDAR_EXEC == regVal) || (HDAR_BAD_IMG == regVal) || (HDAR_BAD_CMD == regVal))
1612*4e1bc9a0SAchim Leubner break;
1613*4e1bc9a0SAchim Leubner } while (max_wait_count-=WAIT_INCREMENT);
1614*4e1bc9a0SAchim Leubner
1615*4e1bc9a0SAchim Leubner if (HDAR_BAD_IMG == regVal)
1616*4e1bc9a0SAchim Leubner {
1617*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step6:BAD IMG: HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET = 0x%x\n", regVal));
1618*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "5d");
1619*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1620*4e1bc9a0SAchim Leubner }
1621*4e1bc9a0SAchim Leubner if (HDAR_BAD_CMD == regVal)
1622*4e1bc9a0SAchim Leubner {
1623*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step6:BAD IMG: HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET = 0x%x\n", regVal));
1624*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "5d");
1625*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1626*4e1bc9a0SAchim Leubner }
1627*4e1bc9a0SAchim Leubner if (!max_wait_count)
1628*4e1bc9a0SAchim Leubner {
1629*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step6:TIMEOUT: HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET = 0x%x\n", regVal));
1630*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "5d");
1631*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1632*4e1bc9a0SAchim Leubner }
1633*4e1bc9a0SAchim Leubner
1634*4e1bc9a0SAchim Leubner stepTime[6] = ossaTimeStamp(agRoot);
1635*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step6: (step_time[6] = %d, %d ms)\n", stepTime[6], (stepTime[6] - startTime))); // TestBase
1636*4e1bc9a0SAchim Leubner
1637*4e1bc9a0SAchim Leubner /* Step 7: Poll ILAHDA_AAP1IMGGET/Offset in MSGU Scratchpad 0 */
1638*4e1bc9a0SAchim Leubner /* Check MSGU Scratchpad 1 [1,0] == 00 */
1639*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step7:Poll ILAHDA_AAP1_IMG_GET!\n"));
1640*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1) & SCRATCH_PAD1_RST;
1641*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step7:MSG Scratchpad 1: 0x%x\n", regVal));
1642*4e1bc9a0SAchim Leubner max_wait_time = WAIT_SECONDS(gWait_3); /* 3 sec */
1643*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
1644*4e1bc9a0SAchim Leubner do
1645*4e1bc9a0SAchim Leubner {
1646*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1647*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0) >> SHIFT24;
1648*4e1bc9a0SAchim Leubner } while ((regVal != ILAHDA_AAP1_IMG_GET) && (max_wait_count -= WAIT_INCREMENT));
1649*4e1bc9a0SAchim Leubner
1650*4e1bc9a0SAchim Leubner if (!max_wait_count)
1651*4e1bc9a0SAchim Leubner {
1652*4e1bc9a0SAchim Leubner
1653*4e1bc9a0SAchim Leubner if( !HDA_Been_Reset )
1654*4e1bc9a0SAchim Leubner {
1655*4e1bc9a0SAchim Leubner
1656*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Reset: Step7:regVal =0x%x expect 0x%x\n", regVal,ILAHDA_AAP1_IMG_GET ));
1657*4e1bc9a0SAchim Leubner siSpcSoftReset(agRoot, SPC_HDASOFT_RESET_SIGNATURE);
1658*4e1bc9a0SAchim Leubner HDA_Been_Reset = agTRUE;
1659*4e1bc9a0SAchim Leubner goto TryAfterReset;
1660*4e1bc9a0SAchim Leubner
1661*4e1bc9a0SAchim Leubner }
1662*4e1bc9a0SAchim Leubner
1663*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: TIMEOUT: Step7:regVal =0x%x expect 0x%x\n", regVal,ILAHDA_AAP1_IMG_GET ));
1664*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1665*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0)));
1666*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1)));
1667*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2)));
1668*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3)));
1669*4e1bc9a0SAchim Leubner #endif
1670*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'j', "5d");
1671*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1672*4e1bc9a0SAchim Leubner }
1673*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0);
1674*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step7:MSG Scratchpad 0: 0x%x\n", regVal));
1675*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0) & 0x00FFFFFF;
1676*4e1bc9a0SAchim Leubner
1677*4e1bc9a0SAchim Leubner stepTime[7] = ossaTimeStamp(agRoot);
1678*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step7: (step_time[7] = %d, %d ms)\n", stepTime[7], (stepTime[7] - startTime))); // TestBase
1679*4e1bc9a0SAchim Leubner
1680*4e1bc9a0SAchim Leubner /* Step 8: Copy AAP1 image, update the Host Scratchpad 3 */
1681*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step8:Push the AAP1 to 0x00400000 plus 0x%x\n", regVal));
1682*4e1bc9a0SAchim Leubner
1683*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Cpy(agRoot, regVal, flashImg.aap1Img, flashImg.aap1Len))
1684*4e1bc9a0SAchim Leubner {
1685*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step8:Copy AAP1 array to 0x%x failed\n", regVal));
1686*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1687*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0)));
1688*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1)));
1689*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2)));
1690*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3)));
1691*4e1bc9a0SAchim Leubner #endif
1692*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'k', "5d");
1693*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1694*4e1bc9a0SAchim Leubner }
1695*4e1bc9a0SAchim Leubner
1696*4e1bc9a0SAchim Leubner regVal = (HDA_AAP1_DONE | (bit32)flashImg.aap1Len);
1697*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_3, regVal);
1698*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step8:Host Scratchpad 3 (AAP1): 0x%x\n", regVal));
1699*4e1bc9a0SAchim Leubner
1700*4e1bc9a0SAchim Leubner stepTime[8] = ossaTimeStamp(agRoot);
1701*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step8: (step_time[8] = %d, %d ms)\n", stepTime[8], (stepTime[8] - startTime))); // TestBase
1702*4e1bc9a0SAchim Leubner
1703*4e1bc9a0SAchim Leubner /* Step 9: Poll ILAHDA_IOPIMGGET/Offset in MSGU Scratchpad 0 */
1704*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step9:Poll ILAHDA_IOP_IMG_GET!\n"));
1705*4e1bc9a0SAchim Leubner max_wait_time = WAIT_SECONDS(gWait_2); /* 2 sec */
1706*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
1707*4e1bc9a0SAchim Leubner do
1708*4e1bc9a0SAchim Leubner {
1709*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
1710*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0) >> SHIFT24;
1711*4e1bc9a0SAchim Leubner } while ((regVal != ILAHDA_IOP_IMG_GET) && (max_wait_count -= WAIT_INCREMENT));
1712*4e1bc9a0SAchim Leubner
1713*4e1bc9a0SAchim Leubner if (!max_wait_count)
1714*4e1bc9a0SAchim Leubner {
1715*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step9:TIMEOUT:MSGU_SCRATCH_PAD_0 = 0x%x\n", regVal));
1716*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1717*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1)));
1718*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2)));
1719*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3)));
1720*4e1bc9a0SAchim Leubner #endif
1721*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'l', "5d");
1722*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1723*4e1bc9a0SAchim Leubner }
1724*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0);
1725*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step9:MSG Scratchpad 0: 0x%x\n", regVal));
1726*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0) & HDA_GSM_OFFSET_BITS;
1727*4e1bc9a0SAchim Leubner
1728*4e1bc9a0SAchim Leubner stepTime[9] = ossaTimeStamp(agRoot);
1729*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step9: (step_time[9] = %d, %d ms)\n", stepTime[9], (stepTime[9] - startTime))); // TestBase
1730*4e1bc9a0SAchim Leubner
1731*4e1bc9a0SAchim Leubner // saHdaLoadForceHalt(agRoot); // TestBase
1732*4e1bc9a0SAchim Leubner
1733*4e1bc9a0SAchim Leubner /* Step 10: Copy IOP image, update the Host Scratchpad 3 */
1734*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step10:Push the IOP to 0x00400000 plus 0x%x!\n", regVal));
1735*4e1bc9a0SAchim Leubner
1736*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Cpy(agRoot, regVal, flashImg.iopImg, flashImg.iopLen))
1737*4e1bc9a0SAchim Leubner {
1738*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step10:Copy IOP array to 0x%x failed\n", regVal));
1739*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
1740*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1)));
1741*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2)));
1742*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3)));
1743*4e1bc9a0SAchim Leubner #endif
1744*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'm', "5d");
1745*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1746*4e1bc9a0SAchim Leubner }
1747*4e1bc9a0SAchim Leubner
1748*4e1bc9a0SAchim Leubner regVal = (HDA_IOP_DONE | (bit32)flashImg.iopLen);
1749*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_3, regVal);
1750*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step10:Host Scratchpad 3 (IOP): 0x%x\n", regVal));
1751*4e1bc9a0SAchim Leubner
1752*4e1bc9a0SAchim Leubner stepTime[10] = ossaTimeStamp(agRoot);
1753*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step10: (step_time[10] = %d, %d ms)\n", stepTime[10], (stepTime[10] - startTime))); // TestBase
1754*4e1bc9a0SAchim Leubner
1755*4e1bc9a0SAchim Leubner /* Clear the signature */
1756*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_0, 0);
1757*4e1bc9a0SAchim Leubner
1758*4e1bc9a0SAchim Leubner /* step 11: wait for the FW and IOP to get ready - 1 sec timeout */
1759*4e1bc9a0SAchim Leubner /* Wait for the SPC Configuration Table to be ready */
1760*4e1bc9a0SAchim Leubner stepTime[11] = ossaTimeStamp(agRoot);
1761*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Start Step11: Wait for FW ready. (step_time[11.1] = %d, %d ms)\n", stepTime[11], (stepTime[11] - startTime))); // TestBase
1762*4e1bc9a0SAchim Leubner
1763*4e1bc9a0SAchim Leubner endTime = ossaTimeStamp(agRoot);
1764*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: End Step11: FW ready! (end_time= %d, fw_load_time = %d ms)\n", endTime, endTime - startTime)); // TestBase
1765*4e1bc9a0SAchim Leubner
1766*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step11:Poll for FW ready!\n"));
1767*4e1bc9a0SAchim Leubner if (mpiWaitForConfigTable(agRoot, &mainCfg) == AGSA_RC_FAILURE)
1768*4e1bc9a0SAchim Leubner {
1769*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1);
1770*4e1bc9a0SAchim Leubner /* return error if MPI Configuration Table not ready */
1771*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step11:SPC FW not ready SCRATCH_PAD1 = 0x%x\n", regVal));
1772*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2);
1773*4e1bc9a0SAchim Leubner /* return error if MPI Configuration Table not ready */
1774*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step11:SPC FW not ready SCRATCH_PAD2 = 0x%x\n", regVal));
1775*4e1bc9a0SAchim Leubner /* read detail fatal errors */
1776*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0);
1777*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step11:ScratchPad0 AAP error code 0x%x\n", regVal));
1778*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3);
1779*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: Step11:ScratchPad3 IOP error code 0x%x\n", regVal));
1780*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'n', "5d");
1781*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1782*4e1bc9a0SAchim Leubner }
1783*4e1bc9a0SAchim Leubner
1784*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'o', "5d");
1785*4e1bc9a0SAchim Leubner
1786*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode: HDA Mode Complete\n"));
1787*4e1bc9a0SAchim Leubner
1788*4e1bc9a0SAchim Leubner return AGSA_RC_SUCCESS;
1789*4e1bc9a0SAchim Leubner }
1790*4e1bc9a0SAchim Leubner
1791*4e1bc9a0SAchim Leubner /******************************************************************************/
1792*4e1bc9a0SAchim Leubner /*! \brief memcopy cross PCI from host memory to card memory
1793*4e1bc9a0SAchim Leubner *
1794*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
1795*4e1bc9a0SAchim Leubner * \param dstoffset distination offset
1796*4e1bc9a0SAchim Leubner * \param src source pointer
1797*4e1bc9a0SAchim Leubner * \param DWcount DWord count
1798*4e1bc9a0SAchim Leubner * \param busBaseNumber PCI Bus Base number
1799*4e1bc9a0SAchim Leubner *
1800*4e1bc9a0SAchim Leubner * \return -void-
1801*4e1bc9a0SAchim Leubner *
1802*4e1bc9a0SAchim Leubner */
1803*4e1bc9a0SAchim Leubner /*******************************************************************************/
siPciMemCpy(agsaRoot_t * agRoot,bit32 dstoffset,void * src,bit32 DWcount,bit32 busBaseNumber)1804*4e1bc9a0SAchim Leubner LOCAL void siPciMemCpy(agsaRoot_t *agRoot,
1805*4e1bc9a0SAchim Leubner bit32 dstoffset,
1806*4e1bc9a0SAchim Leubner void *src,
1807*4e1bc9a0SAchim Leubner bit32 DWcount,
1808*4e1bc9a0SAchim Leubner bit32 busBaseNumber
1809*4e1bc9a0SAchim Leubner )
1810*4e1bc9a0SAchim Leubner {
1811*4e1bc9a0SAchim Leubner bit32 i, val;
1812*4e1bc9a0SAchim Leubner bit32 *src1;
1813*4e1bc9a0SAchim Leubner
1814*4e1bc9a0SAchim Leubner src1 = (bit32 *)src;
1815*4e1bc9a0SAchim Leubner
1816*4e1bc9a0SAchim Leubner for (i= 0; i < DWcount; i++)
1817*4e1bc9a0SAchim Leubner {
1818*4e1bc9a0SAchim Leubner val = BIT32_TO_LEBIT32(src1[i]);
1819*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, busBaseNumber, (dstoffset + i * 4), val);
1820*4e1bc9a0SAchim Leubner }
1821*4e1bc9a0SAchim Leubner
1822*4e1bc9a0SAchim Leubner return;
1823*4e1bc9a0SAchim Leubner }
1824*4e1bc9a0SAchim Leubner
1825*4e1bc9a0SAchim Leubner /******************************************************************************/
1826*4e1bc9a0SAchim Leubner /*! \brief Function to copy FW array
1827*4e1bc9a0SAchim Leubner *
1828*4e1bc9a0SAchim Leubner * The siBar4Cpy() function is called to copy FW array via BAR4
1829*4e1bc9a0SAchim Leubner * (PCIe spec: BAR4, MEMBASE-III in PM, PCIBAR2 in host driver)
1830*4e1bc9a0SAchim Leubner * in 64-KB MEMBASE MODE.
1831*4e1bc9a0SAchim Leubner *
1832*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
1833*4e1bc9a0SAchim Leubner * \param offset destination offset
1834*4e1bc9a0SAchim Leubner * \param parray pointer of array
1835*4e1bc9a0SAchim Leubner * \param array_size size of array
1836*4e1bc9a0SAchim Leubner *
1837*4e1bc9a0SAchim Leubner * \return AGSA_RC_SUCCESS or AGSA_RC_FAILURE
1838*4e1bc9a0SAchim Leubner */
1839*4e1bc9a0SAchim Leubner /*******************************************************************************/
siBar4Cpy(agsaRoot_t * agRoot,bit32 offset,bit8 * parray,bit32 array_size)1840*4e1bc9a0SAchim Leubner LOCAL bit32 siBar4Cpy(
1841*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
1842*4e1bc9a0SAchim Leubner bit32 offset,
1843*4e1bc9a0SAchim Leubner bit8 * parray,
1844*4e1bc9a0SAchim Leubner bit32 array_size
1845*4e1bc9a0SAchim Leubner )
1846*4e1bc9a0SAchim Leubner {
1847*4e1bc9a0SAchim Leubner bit32 dest_shift_addr, dest_offset, cpy_size;
1848*4e1bc9a0SAchim Leubner
1849*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"5f");
1850*4e1bc9a0SAchim Leubner
1851*4e1bc9a0SAchim Leubner /* first time to shift */
1852*4e1bc9a0SAchim Leubner dest_shift_addr = (GSMSM_AXI_LOWERADDR+offset) & SHIFT_MASK;
1853*4e1bc9a0SAchim Leubner dest_offset = offset & OFFSET_MASK;
1854*4e1bc9a0SAchim Leubner do
1855*4e1bc9a0SAchim Leubner {
1856*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, dest_shift_addr))
1857*4e1bc9a0SAchim Leubner {
1858*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode:Shift Bar4 to 0x%x failed\n", dest_shift_addr));
1859*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "5f");
1860*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1861*4e1bc9a0SAchim Leubner }
1862*4e1bc9a0SAchim Leubner
1863*4e1bc9a0SAchim Leubner if ((dest_offset+array_size) > SIZE_64KB)
1864*4e1bc9a0SAchim Leubner {
1865*4e1bc9a0SAchim Leubner cpy_size = SIZE_64KB - dest_offset;
1866*4e1bc9a0SAchim Leubner }
1867*4e1bc9a0SAchim Leubner else
1868*4e1bc9a0SAchim Leubner cpy_size = array_size;
1869*4e1bc9a0SAchim Leubner
1870*4e1bc9a0SAchim Leubner siPciMemCpy(agRoot, dest_offset, parray, (bit32)(CEILING(cpy_size,4)), PCIBAR2);
1871*4e1bc9a0SAchim Leubner
1872*4e1bc9a0SAchim Leubner array_size -= cpy_size;
1873*4e1bc9a0SAchim Leubner dest_shift_addr += SIZE_64KB;
1874*4e1bc9a0SAchim Leubner dest_offset = 0;
1875*4e1bc9a0SAchim Leubner parray = parray + cpy_size;
1876*4e1bc9a0SAchim Leubner } while (array_size !=0 );
1877*4e1bc9a0SAchim Leubner
1878*4e1bc9a0SAchim Leubner /* Shift back to BAR4 original address */
1879*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, 0x0))
1880*4e1bc9a0SAchim Leubner {
1881*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode:Shift Bar4 to 0x%x failed\n", 0x0));
1882*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "5f");
1883*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
1884*4e1bc9a0SAchim Leubner }
1885*4e1bc9a0SAchim Leubner
1886*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "5f");
1887*4e1bc9a0SAchim Leubner
1888*4e1bc9a0SAchim Leubner return AGSA_RC_SUCCESS;
1889*4e1bc9a0SAchim Leubner }
1890*4e1bc9a0SAchim Leubner
1891*4e1bc9a0SAchim Leubner GLOBAL
siHDAMode_V(agsaRoot_t * agRoot,bit32 HDAMode,agsaFwImg_t * userFwImg)1892*4e1bc9a0SAchim Leubner bit32 siHDAMode_V(
1893*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
1894*4e1bc9a0SAchim Leubner bit32 HDAMode,
1895*4e1bc9a0SAchim Leubner agsaFwImg_t *userFwImg
1896*4e1bc9a0SAchim Leubner )
1897*4e1bc9a0SAchim Leubner {
1898*4e1bc9a0SAchim Leubner bit32 returnVal = AGSA_RC_FAILURE;
1899*4e1bc9a0SAchim Leubner bit32 save,i,biggest;
1900*4e1bc9a0SAchim Leubner bit32 hda_status;
1901*4e1bc9a0SAchim Leubner bit32 hda_command_complete = 0;
1902*4e1bc9a0SAchim Leubner bit32 max_wait_time;
1903*4e1bc9a0SAchim Leubner bit32 max_wait_count;
1904*4e1bc9a0SAchim Leubner bit32 seq_id = 0;
1905*4e1bc9a0SAchim Leubner bit32 base_Hi = 0;
1906*4e1bc9a0SAchim Leubner bit32 base_Lo = 0;
1907*4e1bc9a0SAchim Leubner bit8 * pbase;
1908*4e1bc9a0SAchim Leubner
1909*4e1bc9a0SAchim Leubner spcv_hda_cmd_t hdacmd;
1910*4e1bc9a0SAchim Leubner spcv_hda_rsp_t hdarsp;
1911*4e1bc9a0SAchim Leubner
1912*4e1bc9a0SAchim Leubner agsaLLRoot_t *saRoot;
1913*4e1bc9a0SAchim Leubner
1914*4e1bc9a0SAchim Leubner /* sanity check */
1915*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "");
1916*4e1bc9a0SAchim Leubner
1917*4e1bc9a0SAchim Leubner saRoot = (agsaLLRoot_t *)(agRoot->sdkData);
1918*4e1bc9a0SAchim Leubner
1919*4e1bc9a0SAchim Leubner /* sanity check */
1920*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != saRoot), "saRoot is NULL");
1921*4e1bc9a0SAchim Leubner
1922*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"2W");
1923*4e1bc9a0SAchim Leubner
1924*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: HDAMode %X\n",HDAMode));
1925*4e1bc9a0SAchim Leubner
1926*4e1bc9a0SAchim Leubner siScratchDump(agRoot);
1927*4e1bc9a0SAchim Leubner if( agNULL == userFwImg)
1928*4e1bc9a0SAchim Leubner {
1929*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: No image agNULL == userFwImg\n" ));
1930*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "2W");
1931*4e1bc9a0SAchim Leubner return returnVal;
1932*4e1bc9a0SAchim Leubner }
1933*4e1bc9a0SAchim Leubner
1934*4e1bc9a0SAchim Leubner hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28));
1935*4e1bc9a0SAchim Leubner
1936*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: hda_status 0x%08X\n",hda_status ));
1937*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: STEP 1\n"));
1938*4e1bc9a0SAchim Leubner
1939*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2X",1 );
1940*4e1bc9a0SAchim Leubner /* TP:2X STEP 1 */
1941*4e1bc9a0SAchim Leubner
1942*4e1bc9a0SAchim Leubner /* Find largest Physical chunk memory */
1943*4e1bc9a0SAchim Leubner for(i=0,biggest = 0,save = 0; i < saRoot->memoryAllocated.count; i++)
1944*4e1bc9a0SAchim Leubner {
1945*4e1bc9a0SAchim Leubner if( saRoot->memoryAllocated.agMemory[i].totalLength > biggest)
1946*4e1bc9a0SAchim Leubner {
1947*4e1bc9a0SAchim Leubner
1948*4e1bc9a0SAchim Leubner if(biggest < saRoot->memoryAllocated.agMemory[i].totalLength)
1949*4e1bc9a0SAchim Leubner {
1950*4e1bc9a0SAchim Leubner save = i;
1951*4e1bc9a0SAchim Leubner biggest = saRoot->memoryAllocated.agMemory[i].totalLength;
1952*4e1bc9a0SAchim Leubner }
1953*4e1bc9a0SAchim Leubner
1954*4e1bc9a0SAchim Leubner }
1955*4e1bc9a0SAchim Leubner }
1956*4e1bc9a0SAchim Leubner /*
1957*4e1bc9a0SAchim Leubner Step 1 The host reads the HDA response field RSP_CODE at byte offset 28:29 of the response block
1958*4e1bc9a0SAchim Leubner for HDAR_IDLE (0x8002) via MEMBASE-I. A value other than HDAR_IDLE (0x8002) indicates that the
1959*4e1bc9a0SAchim Leubner SPCv controller is not in HDA mode. Follow the steps described in Section 4.21.1 to bring the
1960*4e1bc9a0SAchim Leubner SPCv controller into HDA mode. When the host reads the correct RSP_CODE, it indicates that the
1961*4e1bc9a0SAchim Leubner SPCv controller boot ROM is ready to proceed to the next step of HDA initialization
1962*4e1bc9a0SAchim Leubner */
1963*4e1bc9a0SAchim Leubner
1964*4e1bc9a0SAchim Leubner base_Hi = saRoot->memoryAllocated.agMemory[save].phyAddrUpper;
1965*4e1bc9a0SAchim Leubner base_Lo = saRoot->memoryAllocated.agMemory[save].phyAddrLower;
1966*4e1bc9a0SAchim Leubner pbase = saRoot->memoryAllocated.agMemory[save].virtPtr;
1967*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:Use DMA memory at [%d] size 0x%x (%d) DMA Loc U 0x%08x L 0x%08x @%p\n",save,
1968*4e1bc9a0SAchim Leubner biggest,
1969*4e1bc9a0SAchim Leubner biggest,
1970*4e1bc9a0SAchim Leubner base_Hi,
1971*4e1bc9a0SAchim Leubner base_Lo,
1972*4e1bc9a0SAchim Leubner pbase
1973*4e1bc9a0SAchim Leubner ));
1974*4e1bc9a0SAchim Leubner
1975*4e1bc9a0SAchim Leubner
1976*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: HDA aap1Img %p len %8d 0x%x\n", userFwImg->aap1Img, userFwImg->aap1Len , userFwImg->aap1Len ));
1977*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: HDA ilaImg %p len %8d 0x%x\n", userFwImg->ilaImg, userFwImg->ilaLen , userFwImg->ilaLen ));
1978*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: HDA iopImg %p len %8d 0x%x\n", userFwImg->iopImg, userFwImg->iopLen , userFwImg->iopLen ));
1979*4e1bc9a0SAchim Leubner if(userFwImg->aap1Len > biggest)
1980*4e1bc9a0SAchim Leubner {
1981*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: HDA DMA area too small %d < %d aap1Len\n", biggest ,userFwImg->aap1Len));
1982*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "aap1Len > biggest");
1983*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'b', "2W");
1984*4e1bc9a0SAchim Leubner return returnVal;
1985*4e1bc9a0SAchim Leubner }
1986*4e1bc9a0SAchim Leubner if(userFwImg->ilaLen > biggest)
1987*4e1bc9a0SAchim Leubner {
1988*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: HDA DMA area too small %d < %d ilaLen\n", biggest ,userFwImg->ilaLen));
1989*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "ilaLen > biggest");
1990*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'c', "2W");
1991*4e1bc9a0SAchim Leubner return returnVal;
1992*4e1bc9a0SAchim Leubner }
1993*4e1bc9a0SAchim Leubner if(userFwImg->iopLen > biggest)
1994*4e1bc9a0SAchim Leubner {
1995*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: HDA DMA area too small %d < %d iopLen\n", biggest ,userFwImg->iopLen));
1996*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "iopLen > biggest");
1997*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'd', "2W");
1998*4e1bc9a0SAchim Leubner return returnVal;
1999*4e1bc9a0SAchim Leubner }
2000*4e1bc9a0SAchim Leubner
2001*4e1bc9a0SAchim Leubner
2002*4e1bc9a0SAchim Leubner if(HDA_STEP_2)
2003*4e1bc9a0SAchim Leubner { /* ILA */
2004*4e1bc9a0SAchim Leubner si_memset(pbase, 0, biggest);
2005*4e1bc9a0SAchim Leubner
2006*4e1bc9a0SAchim Leubner if( userFwImg->ilaLen < biggest)
2007*4e1bc9a0SAchim Leubner {
2008*4e1bc9a0SAchim Leubner si_memcpy(pbase,userFwImg->ilaImg, userFwImg->ilaLen );
2009*4e1bc9a0SAchim Leubner }
2010*4e1bc9a0SAchim Leubner else
2011*4e1bc9a0SAchim Leubner {
2012*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: userFwImg->ilaLen 0x%x < biggest 0x%x\n",userFwImg->ilaLen,biggest));
2013*4e1bc9a0SAchim Leubner }
2014*4e1bc9a0SAchim Leubner
2015*4e1bc9a0SAchim Leubner si_memset(&hdacmd,0,sizeof(spcv_hda_cmd_t));
2016*4e1bc9a0SAchim Leubner si_memset(&hdarsp,0,sizeof(spcv_hda_rsp_t));
2017*4e1bc9a0SAchim Leubner
2018*4e1bc9a0SAchim Leubner hda_status = ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28);
2019*4e1bc9a0SAchim Leubner if((hda_status & SPC_V_HDAR_RSPCODE_MASK) == SPC_V_HDAR_IDLE)
2020*4e1bc9a0SAchim Leubner {
2021*4e1bc9a0SAchim Leubner
2022*4e1bc9a0SAchim Leubner hdacmd.cmdparm_0 = base_Lo; /* source DmaBase_l*/
2023*4e1bc9a0SAchim Leubner hdacmd.cmdparm_1 = base_Hi; /* source DmaBase_u*/
2024*4e1bc9a0SAchim Leubner hdacmd.cmdparm_2 = 0x1e200000; /* destin */
2025*4e1bc9a0SAchim Leubner hdacmd.cmdparm_3 = 0; /* destin */
2026*4e1bc9a0SAchim Leubner hdacmd.cmdparm_4 = userFwImg->ilaLen ; /* length */
2027*4e1bc9a0SAchim Leubner hdacmd.cmdparm_5 = 0;/* not used */
2028*4e1bc9a0SAchim Leubner hdacmd.cmdparm_6 = 0;/* not used */
2029*4e1bc9a0SAchim Leubner seq_id++;
2030*4e1bc9a0SAchim Leubner hdacmd.C_PA_SEQ_ID_CMD_CODE = ( SPC_V_HDAC_PA << SHIFT24 ) | ( seq_id << SHIFT16 )| SPC_V_HDAC_DMA;
2031*4e1bc9a0SAchim Leubner
2032*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: Write SPC_V_HDAC_DMA STEP 2\n"));
2033*4e1bc9a0SAchim Leubner /*
2034*4e1bc9a0SAchim Leubner Step 2
2035*4e1bc9a0SAchim Leubner The host writes the HDAC_DMA (0x000 24) in the command field CMD_CODE via MEMBASE-I
2036*4e1bc9a0SAchim Leubner for issuing the DMA command to ask the boot ROM to pull the ILA image via DMA into
2037*4e1bc9a0SAchim Leubner GSM with the following parameters set up first:
2038*4e1bc9a0SAchim Leubner Parameter 1:0: Host physical address for holding the HDA-ILA image.
2039*4e1bc9a0SAchim Leubner Parameter 3:2: GSM physical address 0x1E20_0000.
2040*4e1bc9a0SAchim Leubner Parameter 4: the length of the HDAILA image.
2041*4e1bc9a0SAchim Leubner */
2042*4e1bc9a0SAchim Leubner
2043*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: Write ILA to offset %X\n",hdacmd.cmdparm_2));
2044*4e1bc9a0SAchim Leubner
2045*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+0,hdacmd.cmdparm_0);
2046*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+4,hdacmd.cmdparm_1);
2047*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+8,hdacmd.cmdparm_2);
2048*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+12,hdacmd.cmdparm_3);
2049*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+16,hdacmd.cmdparm_4);
2050*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+20,hdacmd.cmdparm_5);
2051*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+24,hdacmd.cmdparm_6);
2052*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+28,hdacmd.C_PA_SEQ_ID_CMD_CODE);
2053*4e1bc9a0SAchim Leubner
2054*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: Command 0 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
2055*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+0),
2056*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+4),
2057*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+8),
2058*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+12),
2059*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+16),
2060*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+20),
2061*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+24),
2062*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+28) ));
2063*4e1bc9a0SAchim Leubner
2064*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: command %X\n",hdacmd.C_PA_SEQ_ID_CMD_CODE ));
2065*4e1bc9a0SAchim Leubner
2066*4e1bc9a0SAchim Leubner max_wait_time = (2000 * 1000); /* wait 2 seconds */
2067*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2068*4e1bc9a0SAchim Leubner hda_command_complete = 0;
2069*4e1bc9a0SAchim Leubner do
2070*4e1bc9a0SAchim Leubner {
2071*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2072*4e1bc9a0SAchim Leubner hda_command_complete = ((ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) & SPC_V_HDAR_SEQID_MASK ) >> SHIFT16) == seq_id;
2073*4e1bc9a0SAchim Leubner } while (!hda_command_complete && (max_wait_count -= WAIT_INCREMENT));
2074*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x STEP 2 took %d\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2075*4e1bc9a0SAchim Leubner
2076*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2Y",(max_wait_time - max_wait_count) );
2077*4e1bc9a0SAchim Leubner /* TP:2Y STEP 2 took */
2078*4e1bc9a0SAchim Leubner
2079*4e1bc9a0SAchim Leubner
2080*4e1bc9a0SAchim Leubner if(! hda_command_complete)
2081*4e1bc9a0SAchim Leubner {
2082*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:2SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2083*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2084*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2085*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2086*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:hda_command_complete failed Step 2\n" ));
2087*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'e', "2W");
2088*4e1bc9a0SAchim Leubner return returnVal;
2089*4e1bc9a0SAchim Leubner }
2090*4e1bc9a0SAchim Leubner
2091*4e1bc9a0SAchim Leubner
2092*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:2SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2093*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2094*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2095*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2096*4e1bc9a0SAchim Leubner
2097*4e1bc9a0SAchim Leubner }
2098*4e1bc9a0SAchim Leubner
2099*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: ILA DMA done\n" ));
2100*4e1bc9a0SAchim Leubner } /* end ila */
2101*4e1bc9a0SAchim Leubner
2102*4e1bc9a0SAchim Leubner if(HDA_STEP_3)
2103*4e1bc9a0SAchim Leubner {
2104*4e1bc9a0SAchim Leubner
2105*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: STEP 3\n"));
2106*4e1bc9a0SAchim Leubner /*
2107*4e1bc9a0SAchim Leubner Step 3
2108*4e1bc9a0SAchim Leubner The host polls the HDA response field RSP_CODE for HDAR_IDLE (0x8002) via MEMBASE-I. The polling timeout
2109*4e1bc9a0SAchim Leubner should be no more than 1 second. The response status, HDAR_IDLE with its status equal to 0x10,
2110*4e1bc9a0SAchim Leubner indicates a DMA success response from the boot ROM. Response states that indicate a failure are:
2111*4e1bc9a0SAchim Leubner HDAR_BAD_CMD HDAR_BAD_IMG HDAR_IDLE with its status equal to 0x11
2112*4e1bc9a0SAchim Leubner
2113*4e1bc9a0SAchim Leubner */
2114*4e1bc9a0SAchim Leubner
2115*4e1bc9a0SAchim Leubner max_wait_time = (2000 * 1000); /* wait 2 seconds */
2116*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2117*4e1bc9a0SAchim Leubner hda_command_complete = 0;
2118*4e1bc9a0SAchim Leubner do
2119*4e1bc9a0SAchim Leubner {
2120*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2121*4e1bc9a0SAchim Leubner hda_command_complete = ((ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) & SPC_V_HDAR_SEQID_MASK ) >> SHIFT16) == seq_id;
2122*4e1bc9a0SAchim Leubner } while (!hda_command_complete && (max_wait_count -= WAIT_INCREMENT));
2123*4e1bc9a0SAchim Leubner
2124*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x STEP 3 took %d\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2125*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2Z",(max_wait_time - max_wait_count) );
2126*4e1bc9a0SAchim Leubner /* TP:2Z STEP 3 took */
2127*4e1bc9a0SAchim Leubner
2128*4e1bc9a0SAchim Leubner if(! hda_command_complete)
2129*4e1bc9a0SAchim Leubner {
2130*4e1bc9a0SAchim Leubner
2131*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: Response 0 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
2132*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+0),
2133*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+4),
2134*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+8),
2135*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+12),
2136*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+16),
2137*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+20),
2138*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+24),
2139*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) ));
2140*4e1bc9a0SAchim Leubner
2141*4e1bc9a0SAchim Leubner
2142*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:3SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2143*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2144*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2145*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2146*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:hda_command_complete failed Step 3\n" ));
2147*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'f', "2W");
2148*4e1bc9a0SAchim Leubner return returnVal;
2149*4e1bc9a0SAchim Leubner }
2150*4e1bc9a0SAchim Leubner
2151*4e1bc9a0SAchim Leubner
2152*4e1bc9a0SAchim Leubner hda_command_complete = ((ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) & SPC_V_HDAR_SEQID_MASK ) >> SHIFT16) == seq_id;
2153*4e1bc9a0SAchim Leubner hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) & SPC_V_HDAR_RSPCODE_MASK );
2154*4e1bc9a0SAchim Leubner
2155*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:ILA is ready hda_status %X hda_command_complete %d\n",hda_status ,hda_command_complete));
2156*4e1bc9a0SAchim Leubner
2157*4e1bc9a0SAchim Leubner /* Tell FW ILA is ready */
2158*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: Response 0 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
2159*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+0),
2160*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+4),
2161*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+8),
2162*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+12),
2163*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+16),
2164*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+20),
2165*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+24),
2166*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) ));
2167*4e1bc9a0SAchim Leubner
2168*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:3SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2169*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2170*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2171*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2172*4e1bc9a0SAchim Leubner
2173*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: Step 3 MSGU_HOST_SCRATCH_PAD_3 write %X\n",HDA_ISTR_DONE));
2174*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0,MSGU_HOST_SCRATCH_PAD_3 ,HDA_ISTR_DONE );
2175*4e1bc9a0SAchim Leubner
2176*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:3SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2177*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2178*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2179*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2180*4e1bc9a0SAchim Leubner
2181*4e1bc9a0SAchim Leubner }
2182*4e1bc9a0SAchim Leubner
2183*4e1bc9a0SAchim Leubner if(HDA_STEP_4)
2184*4e1bc9a0SAchim Leubner {
2185*4e1bc9a0SAchim Leubner
2186*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: Exec ILA\n"));
2187*4e1bc9a0SAchim Leubner si_memset(&hdacmd,0,sizeof(spcv_hda_cmd_t));
2188*4e1bc9a0SAchim Leubner si_memset(&hdarsp,0,sizeof(spcv_hda_rsp_t));
2189*4e1bc9a0SAchim Leubner
2190*4e1bc9a0SAchim Leubner hdacmd.cmdparm_0 = 0x200000; /* length SPC_V_HDAC_EXEC*/;
2191*4e1bc9a0SAchim Leubner hdacmd.cmdparm_1 = userFwImg->ilaLen ; /* length SPC_V_HDAC_EXEC*/;
2192*4e1bc9a0SAchim Leubner seq_id++;
2193*4e1bc9a0SAchim Leubner
2194*4e1bc9a0SAchim Leubner hdacmd.C_PA_SEQ_ID_CMD_CODE = ( SPC_V_HDAC_PA << SHIFT24 ) | ( seq_id << SHIFT16 )| SPC_V_HDAC_EXEC;
2195*4e1bc9a0SAchim Leubner
2196*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: STEP 4\n"));
2197*4e1bc9a0SAchim Leubner
2198*4e1bc9a0SAchim Leubner /*
2199*4e1bc9a0SAchim Leubner Step 4
2200*4e1bc9a0SAchim Leubner The host writes the HDAC_EXEC command (0x0002) via MEMBASE-I for the boot ROM to authenticate
2201*4e1bc9a0SAchim Leubner and execute the HDA-ILA image. The host sets parameter 0 and parameter 1 for the HDA-ILA image
2202*4e1bc9a0SAchim Leubner appropriately:
2203*4e1bc9a0SAchim Leubner Parameter 0: Entry offset this value must be 0x20_0000.
2204*4e1bc9a0SAchim Leubner Parameter 1: the HDA-ILA image length.
2205*4e1bc9a0SAchim Leubner */
2206*4e1bc9a0SAchim Leubner
2207*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+0 ,hdacmd.cmdparm_0);
2208*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+4 ,hdacmd.cmdparm_1);
2209*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+8 ,hdacmd.cmdparm_2);
2210*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+12,hdacmd.cmdparm_3);
2211*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+16,hdacmd.cmdparm_4);
2212*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+20,hdacmd.cmdparm_5);
2213*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+24,hdacmd.cmdparm_6);
2214*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+28,hdacmd.C_PA_SEQ_ID_CMD_CODE);
2215*4e1bc9a0SAchim Leubner
2216*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: Exec ILA\n" ));
2217*4e1bc9a0SAchim Leubner
2218*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: Command 0 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
2219*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+0),
2220*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+4),
2221*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+8),
2222*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+12),
2223*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+16),
2224*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+20),
2225*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+24),
2226*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_COMMAND_OFFSET+28) ));
2227*4e1bc9a0SAchim Leubner
2228*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: command %X\n",hdacmd.C_PA_SEQ_ID_CMD_CODE ));
2229*4e1bc9a0SAchim Leubner
2230*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:4SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2231*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2232*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2233*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2234*4e1bc9a0SAchim Leubner } // End Step 4
2235*4e1bc9a0SAchim Leubner if(HDA_STEP_5)
2236*4e1bc9a0SAchim Leubner {
2237*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: start wait STEP 5\n"));
2238*4e1bc9a0SAchim Leubner
2239*4e1bc9a0SAchim Leubner /*
2240*4e1bc9a0SAchim Leubner Step 5
2241*4e1bc9a0SAchim Leubner The host continues polling for the HDA-ILA status via MEMBASE-I. The polling timeout should
2242*4e1bc9a0SAchim Leubner be no more than 1 second. The response status HDAR_EXEC indicates a good response from the
2243*4e1bc9a0SAchim Leubner boot ROM. Response states that indicate a failure are:
2244*4e1bc9a0SAchim Leubner HDAR_BAD_CMD
2245*4e1bc9a0SAchim Leubner HDAR_BAD_IMG
2246*4e1bc9a0SAchim Leubner */
2247*4e1bc9a0SAchim Leubner
2248*4e1bc9a0SAchim Leubner max_wait_time = (2000 * 1000); /* wait 2 seconds */
2249*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2250*4e1bc9a0SAchim Leubner hda_command_complete = 0;
2251*4e1bc9a0SAchim Leubner hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) & SPC_V_HDAR_RSPCODE_MASK );
2252*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x hda_status 0x%x Begin STEP 5\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),hda_status));
2253*4e1bc9a0SAchim Leubner hda_status = 0;
2254*4e1bc9a0SAchim Leubner do
2255*4e1bc9a0SAchim Leubner {
2256*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2257*4e1bc9a0SAchim Leubner hda_status = (ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) & SPC_V_HDAR_RSPCODE_MASK );
2258*4e1bc9a0SAchim Leubner hda_command_complete = ((ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) & SPC_V_HDAR_SEQID_MASK ) >> SHIFT16) == seq_id;
2259*4e1bc9a0SAchim Leubner } while (hda_status != SPC_V_HDAR_EXEC && (max_wait_count -= WAIT_INCREMENT));
2260*4e1bc9a0SAchim Leubner
2261*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x hda_status 0x%x hda_command_complete 0x%x STEP 5 wait for seq_id took %d\n",
2262*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),
2263*4e1bc9a0SAchim Leubner hda_status,
2264*4e1bc9a0SAchim Leubner hda_command_complete,
2265*4e1bc9a0SAchim Leubner (max_wait_time - max_wait_count)));
2266*4e1bc9a0SAchim Leubner
2267*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2Z",(max_wait_time - max_wait_count) );
2268*4e1bc9a0SAchim Leubner /* TP:2Z STEP 5 took */
2269*4e1bc9a0SAchim Leubner
2270*4e1bc9a0SAchim Leubner if(! hda_command_complete)
2271*4e1bc9a0SAchim Leubner {
2272*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: Response 0 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
2273*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+0),
2274*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+4),
2275*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+8),
2276*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+12),
2277*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+16),
2278*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+20),
2279*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+24),
2280*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) ));
2281*4e1bc9a0SAchim Leubner
2282*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:5SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2283*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2284*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2285*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2286*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:hda_command_complete failed Step 5\n" ));
2287*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'g', "2W");
2288*4e1bc9a0SAchim Leubner return returnVal;
2289*4e1bc9a0SAchim Leubner }
2290*4e1bc9a0SAchim Leubner
2291*4e1bc9a0SAchim Leubner if (hda_status != SPC_V_HDAR_EXEC)
2292*4e1bc9a0SAchim Leubner {
2293*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:ILA_EXEC_ERROR hda_status %X hda_command_complete %d\n",hda_status ,hda_command_complete));
2294*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'h', "2W");
2295*4e1bc9a0SAchim Leubner goto bootrom_err;
2296*4e1bc9a0SAchim Leubner }
2297*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: end seq_id updated STEP 5\n"));
2298*4e1bc9a0SAchim Leubner } // End Step 5
2299*4e1bc9a0SAchim Leubner
2300*4e1bc9a0SAchim Leubner if(HDA_STEP_6)
2301*4e1bc9a0SAchim Leubner {
2302*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: start STEP 6\n"));
2303*4e1bc9a0SAchim Leubner
2304*4e1bc9a0SAchim Leubner /*
2305*4e1bc9a0SAchim Leubner Step 6
2306*4e1bc9a0SAchim Leubner The host polls the upper 8 bits [31:24] 5 of the Scratchpad 0 Register
2307*4e1bc9a0SAchim Leubner (page 609) for the ILAHDA_RAAE_IMG_GET (0x11) state. Polling timeout
2308*4e1bc9a0SAchim Leubner should be no more than 2 seconds. If a polling timeout occurs, the host
2309*4e1bc9a0SAchim Leubner should check for a fatal error as described in Section 12.2.
2310*4e1bc9a0SAchim Leubner If successful, the Host Scratchpad 4 Register (page 620) and Host
2311*4e1bc9a0SAchim Leubner Scratchpad 5 Register (page 621) are set as follows: Host Scratchpad 4
2312*4e1bc9a0SAchim Leubner Register (page 620) holds the lower 32-bit host address of
2313*4e1bc9a0SAchim Leubner the RAAE image. Host Scratchpad 5 Register (page 621)
2314*4e1bc9a0SAchim Leubner holds the upper 32-bit host address of the RAAE image.
2315*4e1bc9a0SAchim Leubner Then the host writes the command ILAHDAC_RAAE_IMG_DONE(0x81) to the upper
2316*4e1bc9a0SAchim Leubner 8 bits [31:24] of the Host Scratchpad 3 Register (page 619) and writes the
2317*4e1bc9a0SAchim Leubner sizeof the RAAE image to the lower 24 bits [23:0].
2318*4e1bc9a0SAchim Leubner */
2319*4e1bc9a0SAchim Leubner
2320*4e1bc9a0SAchim Leubner max_wait_time = (2000 * 1000); /* wait 2 seconds */
2321*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2322*4e1bc9a0SAchim Leubner hda_command_complete = 0;
2323*4e1bc9a0SAchim Leubner do
2324*4e1bc9a0SAchim Leubner {
2325*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2326*4e1bc9a0SAchim Leubner hda_command_complete = ((ossaHwRegReadExt(agRoot, PCIBAR0,V_Scratchpad_0_Register) & 0xff000000 ) >> SHIFT24 ) == ILAHDA_RAAE_IMG_GET;
2327*4e1bc9a0SAchim Leubner } while (!hda_command_complete && (max_wait_count -= WAIT_INCREMENT));
2328*4e1bc9a0SAchim Leubner
2329*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD0 = 0x%x STEP 6 wait for ILAHDA_RAAE_IMG_GET took %d\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register),(max_wait_time - max_wait_count)));
2330*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2b",(max_wait_time - max_wait_count) );
2331*4e1bc9a0SAchim Leubner /* TP:2b STEP 6 took */
2332*4e1bc9a0SAchim Leubner if(! hda_command_complete)
2333*4e1bc9a0SAchim Leubner {
2334*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:hda_command_complete failed Step 6\n" ));
2335*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'i', "2W");
2336*4e1bc9a0SAchim Leubner goto fw_err;
2337*4e1bc9a0SAchim Leubner }
2338*4e1bc9a0SAchim Leubner
2339*4e1bc9a0SAchim Leubner si_memset(pbase, 0, biggest);
2340*4e1bc9a0SAchim Leubner
2341*4e1bc9a0SAchim Leubner if( userFwImg->aap1Len < biggest)
2342*4e1bc9a0SAchim Leubner {
2343*4e1bc9a0SAchim Leubner si_memcpy(pbase,userFwImg->aap1Img, userFwImg->aap1Len );
2344*4e1bc9a0SAchim Leubner }
2345*4e1bc9a0SAchim Leubner else
2346*4e1bc9a0SAchim Leubner {
2347*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: userFwImg->aap1Len 0x%x < biggest 0x%x\n",userFwImg->aap1Len,biggest));
2348*4e1bc9a0SAchim Leubner }
2349*4e1bc9a0SAchim Leubner /*
2350*4e1bc9a0SAchim Leubner */
2351*4e1bc9a0SAchim Leubner /* upper */
2352*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_5, base_Hi );
2353*4e1bc9a0SAchim Leubner SA_DBG3(("siHDAMode_V: MSGU_HOST_SCRATCH_PAD_5 0x%X\n", base_Hi));
2354*4e1bc9a0SAchim Leubner /* lower */
2355*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_4, base_Lo );
2356*4e1bc9a0SAchim Leubner SA_DBG3(("siHDAMode_V: MSGU_HOST_SCRATCH_PAD_4 0x%X\n",base_Lo));
2357*4e1bc9a0SAchim Leubner /* len */
2358*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0,MSGU_HOST_SCRATCH_PAD_3 ,(ILAHDAC_RAAE_IMG_DONE << SHIFT24) | userFwImg->aap1Len );
2359*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: write ILAHDAC_RAAE_IMG_DONE to MSGU_HOST_SCRATCH_PAD_3 0x%X\n",(ILAHDAC_RAAE_IMG_DONE << SHIFT24) | userFwImg->aap1Len));
2360*4e1bc9a0SAchim Leubner // ossaHwRegWriteExt(agRoot, PCIBAR0,MSGU_HOST_SCRATCH_PAD_4 , userFwImg->DmaBase_l);
2361*4e1bc9a0SAchim Leubner
2362*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, gWaitmSec * 1000);
2363*4e1bc9a0SAchim Leubner if(1) /* step in question */
2364*4e1bc9a0SAchim Leubner {
2365*4e1bc9a0SAchim Leubner max_wait_time = (2000 * 1000); /* wait 2 seconds */
2366*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2367*4e1bc9a0SAchim Leubner hda_command_complete = 0;
2368*4e1bc9a0SAchim Leubner do
2369*4e1bc9a0SAchim Leubner {
2370*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2371*4e1bc9a0SAchim Leubner hda_command_complete = ((ossaHwRegReadExt(agRoot, PCIBAR0,V_Scratchpad_0_Register) & 0xff000000 ) >> SHIFT24 ) == ILAHDA_IOP_IMG_GET;
2372*4e1bc9a0SAchim Leubner } while (!hda_command_complete && (max_wait_count -= WAIT_INCREMENT));
2373*4e1bc9a0SAchim Leubner
2374*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x STEP 7 wait for ILAHDA_IOP_IMG_GET took %d\n", ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2375*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2c",(max_wait_time - max_wait_count) );
2376*4e1bc9a0SAchim Leubner /* TP:2c STEP 6a ILAHDA_IOP_IMG_GET took */
2377*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2y",hda_command_complete );
2378*4e1bc9a0SAchim Leubner /* TP:2y hda_command_complete */
2379*4e1bc9a0SAchim Leubner
2380*4e1bc9a0SAchim Leubner if(! hda_command_complete)
2381*4e1bc9a0SAchim Leubner {
2382*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:hda_command_complete failed Step 7\n" ));
2383*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'j', "2W");
2384*4e1bc9a0SAchim Leubner goto fw_err;
2385*4e1bc9a0SAchim Leubner }
2386*4e1bc9a0SAchim Leubner }
2387*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: End V_Scratchpad_0_Register 0x%08X STEP 6\n",ossaHwRegReadExt(agRoot, PCIBAR0,V_Scratchpad_0_Register)));
2388*4e1bc9a0SAchim Leubner }
2389*4e1bc9a0SAchim Leubner
2390*4e1bc9a0SAchim Leubner if(HDA_STEP_7)
2391*4e1bc9a0SAchim Leubner {
2392*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: STEP 7\n"));
2393*4e1bc9a0SAchim Leubner /*
2394*4e1bc9a0SAchim Leubner Step 7
2395*4e1bc9a0SAchim Leubner The host polls (reads) the upper 8 bits 7 [31:24] of the Scratchpad 0 Register (page 609)
2396*4e1bc9a0SAchim Leubner for ILAHDA_IOP_IMG_GET (0x10) state. The polling timeout should be no more than 2 seconds.
2397*4e1bc9a0SAchim Leubner If a polling timeout occurs, the host should check for a fatal error as described in
2398*4e1bc9a0SAchim Leubner Section 12.2. If successful, the Host Scratchpad 4 Register (page 620) and Host
2399*4e1bc9a0SAchim Leubner Scratchpad 5 Register (page 621) are set as follows:
2400*4e1bc9a0SAchim Leubner Host Scratchpad 4 Register (page 620) holds the lower host address of the IOP image.
2401*4e1bc9a0SAchim Leubner Host Scratchpad 5 Register (page 621) holds the upper host address of the IOP image.
2402*4e1bc9a0SAchim Leubner Then host writes the command ILAHDAC_IOP_IMG_DONE(0x80) to the upper 8 bits [31:24] of the
2403*4e1bc9a0SAchim Leubner Host Scratchpad 3 Register (page 614)and writes the sizeof the IOP image to the lower 24
2404*4e1bc9a0SAchim Leubner bits [23:0].
2405*4e1bc9a0SAchim Leubner
2406*4e1bc9a0SAchim Leubner */
2407*4e1bc9a0SAchim Leubner
2408*4e1bc9a0SAchim Leubner si_memset(pbase, 0, biggest);
2409*4e1bc9a0SAchim Leubner
2410*4e1bc9a0SAchim Leubner if( userFwImg->iopLen < biggest)
2411*4e1bc9a0SAchim Leubner {
2412*4e1bc9a0SAchim Leubner si_memcpy(pbase,userFwImg->iopImg, userFwImg->iopLen );
2413*4e1bc9a0SAchim Leubner }
2414*4e1bc9a0SAchim Leubner else
2415*4e1bc9a0SAchim Leubner {
2416*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: userFwImg->iopImg 0x%x < biggest 0x%x\n",userFwImg->iopLen,biggest));
2417*4e1bc9a0SAchim Leubner }
2418*4e1bc9a0SAchim Leubner
2419*4e1bc9a0SAchim Leubner /* upper */
2420*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_5, base_Hi );
2421*4e1bc9a0SAchim Leubner SA_DBG3(("siHDAMode_V: MSGU_HOST_SCRATCH_PAD_5 0x%X\n", base_Hi));
2422*4e1bc9a0SAchim Leubner /* lower */
2423*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, MSGU_HOST_SCRATCH_PAD_4, base_Lo );
2424*4e1bc9a0SAchim Leubner SA_DBG3(("siHDAMode_V: MSGU_HOST_SCRATCH_PAD_4 0x%X\n",base_Lo));
2425*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: MSGU_HOST_SCRATCH_PAD_4\n"));
2426*4e1bc9a0SAchim Leubner /* len */
2427*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR0,MSGU_HOST_SCRATCH_PAD_3 ,(ILAHDAC_IOP_IMG_DONE << SHIFT24) | userFwImg->iopLen );
2428*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: MSGU_HOST_SCRATCH_PAD_3 0x%X\n",(ILAHDAC_IOP_IMG_DONE << SHIFT24) | userFwImg->iopLen));
2429*4e1bc9a0SAchim Leubner
2430*4e1bc9a0SAchim Leubner
2431*4e1bc9a0SAchim Leubner if(saRoot->swConfig.hostDirectAccessMode & 2 )
2432*4e1bc9a0SAchim Leubner {
2433*4e1bc9a0SAchim Leubner /* Hda AES DIF offload */
2434*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot, V_Scratchpad_Rsvd_0_Register, HDA_AES_DIF_FUNC);
2435*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: V_Scratchpad_Rsvd_0_Register, HDA_AES_DIF_FUNC 0x%X\n",HDA_AES_DIF_FUNC));
2436*4e1bc9a0SAchim Leubner /* Hda AES DIF offload */
2437*4e1bc9a0SAchim Leubner }
2438*4e1bc9a0SAchim Leubner
2439*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2440*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2441*4e1bc9a0SAchim Leubner
2442*4e1bc9a0SAchim Leubner
2443*4e1bc9a0SAchim Leubner max_wait_time = (2000 * 1000); /* wait 2 seconds */
2444*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2445*4e1bc9a0SAchim Leubner hda_command_complete = 0;
2446*4e1bc9a0SAchim Leubner do
2447*4e1bc9a0SAchim Leubner {
2448*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2449*4e1bc9a0SAchim Leubner hda_command_complete = ((ossaHwRegReadExt(agRoot, PCIBAR0,V_Scratchpad_0_Register) & 0xff000000 ) >> SHIFT24 ) == ILAHDA_IOP_IMG_GET;
2450*4e1bc9a0SAchim Leubner } while (!hda_command_complete && (max_wait_count -= WAIT_INCREMENT));
2451*4e1bc9a0SAchim Leubner
2452*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2d",(max_wait_time - max_wait_count) );
2453*4e1bc9a0SAchim Leubner /* TP:2d STEP 7 ILAHDA_IOP_IMG_GET took */
2454*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2z",hda_command_complete );
2455*4e1bc9a0SAchim Leubner /* TP:2z hda_command_complete */
2456*4e1bc9a0SAchim Leubner
2457*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:SCRATCH_PAD0 = 0x%x STEP 7 wait for ILAHDA_IOP_IMG_GET took %d\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register),(max_wait_time - max_wait_count)));
2458*4e1bc9a0SAchim Leubner
2459*4e1bc9a0SAchim Leubner if(! hda_command_complete)
2460*4e1bc9a0SAchim Leubner {
2461*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:7SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2462*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2463*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2464*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2465*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:hda_command_complete failed Step 7\n" ));
2466*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'k', "2W");
2467*4e1bc9a0SAchim Leubner return returnVal;
2468*4e1bc9a0SAchim Leubner }
2469*4e1bc9a0SAchim Leubner
2470*4e1bc9a0SAchim Leubner
2471*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:7SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2472*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2473*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2474*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2475*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: End STEP 7\n"));
2476*4e1bc9a0SAchim Leubner }
2477*4e1bc9a0SAchim Leubner
2478*4e1bc9a0SAchim Leubner
2479*4e1bc9a0SAchim Leubner if(HDA_STEP_8)
2480*4e1bc9a0SAchim Leubner {
2481*4e1bc9a0SAchim Leubner bit32 SCRATCH_PAD1;
2482*4e1bc9a0SAchim Leubner
2483*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: Check fw ready Step 8\n"));
2484*4e1bc9a0SAchim Leubner
2485*4e1bc9a0SAchim Leubner /*
2486*4e1bc9a0SAchim Leubner Step 8
2487*4e1bc9a0SAchim Leubner IOP0/1 start-up sequence. The host polls the Scratchpad 1 Register (page 610)
2488*4e1bc9a0SAchim Leubner bits [1:0] for RAAE_STATE, bits [13:12] for IOP1_STATE, and
2489*4e1bc9a0SAchim Leubner bits [11:10] for IOP0_STATE to go to 11b (Ready state).
2490*4e1bc9a0SAchim Leubner The polling timeout should be no more than 1 second. If a polling timeout occurs,
2491*4e1bc9a0SAchim Leubner the host should check for a fatal error in Section 12.2.
2492*4e1bc9a0SAchim Leubner */
2493*4e1bc9a0SAchim Leubner
2494*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_SUCCESS;
2495*4e1bc9a0SAchim Leubner
2496*4e1bc9a0SAchim Leubner max_wait_time = (1000 * 1000); /* wait 1000 milliseconds */
2497*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2498*4e1bc9a0SAchim Leubner do
2499*4e1bc9a0SAchim Leubner {
2500*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2501*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
2502*4e1bc9a0SAchim Leubner } while ((SCRATCH_PAD1 == 0xFFFFFFFF ) && (max_wait_count -= WAIT_INCREMENT));
2503*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"HZ",(max_wait_time - max_wait_count) );
2504*4e1bc9a0SAchim Leubner /* TP:2f Step 8 PCI took */
2505*4e1bc9a0SAchim Leubner
2506*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x (0x%x) Step 8 PCIe took %d\n", SCRATCH_PAD1,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2507*4e1bc9a0SAchim Leubner /* ILA */
2508*4e1bc9a0SAchim Leubner max_wait_time = (1000 * 1000); /* wait 1000 milliseconds */
2509*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2510*4e1bc9a0SAchim Leubner do
2511*4e1bc9a0SAchim Leubner {
2512*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2513*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
2514*4e1bc9a0SAchim Leubner } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_ILA_MASK) != SCRATCH_PAD1_V_ILA_MASK) && (max_wait_count -= WAIT_INCREMENT));
2515*4e1bc9a0SAchim Leubner
2516*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2g",(max_wait_time - max_wait_count) );
2517*4e1bc9a0SAchim Leubner /* TP:2g Step 8 ILA took */
2518*4e1bc9a0SAchim Leubner
2519*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_ILA_MASK (0x%x)(0x%x) took %d\n", SCRATCH_PAD1,SCRATCH_PAD1_V_ILA_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2520*4e1bc9a0SAchim Leubner
2521*4e1bc9a0SAchim Leubner if (!max_wait_count)
2522*4e1bc9a0SAchim Leubner {
2523*4e1bc9a0SAchim Leubner // Ignore for now returnVal = AGSA_RC_FAILURE;
2524*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:Timeout SCRATCH_PAD1_V_ILA_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_ILA_MASK, SCRATCH_PAD1));
2525*4e1bc9a0SAchim Leubner }
2526*4e1bc9a0SAchim Leubner
2527*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_ILA_MASK (0x%x)(0x%x) took %d\n", SCRATCH_PAD1,SCRATCH_PAD1_V_ILA_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2528*4e1bc9a0SAchim Leubner
2529*4e1bc9a0SAchim Leubner /* RAAE */
2530*4e1bc9a0SAchim Leubner max_wait_time = (1800 * 1000); /* wait 1800 milliseconds */
2531*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2532*4e1bc9a0SAchim Leubner do
2533*4e1bc9a0SAchim Leubner {
2534*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2535*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
2536*4e1bc9a0SAchim Leubner } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_RAAE_MASK) != SCRATCH_PAD1_V_RAAE_MASK) && (max_wait_count -= WAIT_INCREMENT));
2537*4e1bc9a0SAchim Leubner
2538*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_RAAE_MASK (0x%x)(0x%x) took %d\n", SCRATCH_PAD1,SCRATCH_PAD1_V_RAAE_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2539*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2h",(max_wait_time - max_wait_count) );
2540*4e1bc9a0SAchim Leubner /* TP:2h Step 8 RAAE took */
2541*4e1bc9a0SAchim Leubner
2542*4e1bc9a0SAchim Leubner if (!max_wait_count)
2543*4e1bc9a0SAchim Leubner {
2544*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:Timeout SCRATCH_PAD1_V_RAAE_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_RAAE_MASK, SCRATCH_PAD1));
2545*4e1bc9a0SAchim Leubner
2546*4e1bc9a0SAchim Leubner }
2547*4e1bc9a0SAchim Leubner /* IOP0 */
2548*4e1bc9a0SAchim Leubner max_wait_time = (600 * 1000); /* wait 600 milliseconds */
2549*4e1bc9a0SAchim Leubner max_wait_count = MAKE_MODULO(max_wait_time,WAIT_INCREMENT) - WAIT_INCREMENT;
2550*4e1bc9a0SAchim Leubner do
2551*4e1bc9a0SAchim Leubner {
2552*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, WAIT_INCREMENT);
2553*4e1bc9a0SAchim Leubner SCRATCH_PAD1 = ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1);
2554*4e1bc9a0SAchim Leubner } while (((SCRATCH_PAD1 & SCRATCH_PAD1_V_IOP0_MASK) != SCRATCH_PAD1_V_IOP0_MASK) && (max_wait_count -= WAIT_INCREMENT));
2555*4e1bc9a0SAchim Leubner
2556*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:SCRATCH_PAD1 = 0x%x SCRATCH_PAD1_V_IOP0_MASK(0x%x)(0x%x) took %d\n", SCRATCH_PAD1,SCRATCH_PAD1_V_IOP0_MASK,ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1),(max_wait_time - max_wait_count)));
2557*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"2i",(max_wait_time - max_wait_count) );
2558*4e1bc9a0SAchim Leubner /* TP:2i Step 8 IOP took */
2559*4e1bc9a0SAchim Leubner
2560*4e1bc9a0SAchim Leubner if (!max_wait_count)
2561*4e1bc9a0SAchim Leubner {
2562*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
2563*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V:Timeout SCRATCH_PAD1_V_IOP0_MASK (0x%x) not set SCRATCH_PAD1 = 0x%x\n",SCRATCH_PAD1_V_IOP0_MASK ,SCRATCH_PAD1));
2564*4e1bc9a0SAchim Leubner
2565*4e1bc9a0SAchim Leubner }
2566*4e1bc9a0SAchim Leubner
2567*4e1bc9a0SAchim Leubner
2568*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: Step 8 0x%X ERROR_STATE 0x%X\n",ossaHwRegReadExt(agRoot,PCIBAR0 ,V_SoftResetRegister ),
2569*4e1bc9a0SAchim Leubner SCRATCH_PAD1_V_ERROR_STATE( ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1) ) ));
2570*4e1bc9a0SAchim Leubner if (SCRATCH_PAD1_V_ERROR_STATE( ossaHwRegReadExt(agRoot, PCIBAR0, MSGU_SCRATCH_PAD_1) ))
2571*4e1bc9a0SAchim Leubner {
2572*4e1bc9a0SAchim Leubner if(smIS_ENCRYPT(agRoot))
2573*4e1bc9a0SAchim Leubner {
2574*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: Encryption and HDA mode not supported - failed Step 8\n" ));
2575*4e1bc9a0SAchim Leubner }
2576*4e1bc9a0SAchim Leubner else
2577*4e1bc9a0SAchim Leubner {
2578*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: ERROR_STATE failed Step 8\n" ));
2579*4e1bc9a0SAchim Leubner }
2580*4e1bc9a0SAchim Leubner returnVal = AGSA_RC_FAILURE;
2581*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'l', "2W");
2582*4e1bc9a0SAchim Leubner goto fw_err;
2583*4e1bc9a0SAchim Leubner }
2584*4e1bc9a0SAchim Leubner
2585*4e1bc9a0SAchim Leubner }
2586*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: returnVal 0x%X Step 8\n",returnVal));
2587*4e1bc9a0SAchim Leubner /*
2588*4e1bc9a0SAchim Leubner Step 10
2589*4e1bc9a0SAchim Leubner The host continues with the normal SPCv Configuration Table initialization sequence
2590*4e1bc9a0SAchim Leubner as described in Section 6.2.8.1.
2591*4e1bc9a0SAchim Leubner */
2592*4e1bc9a0SAchim Leubner if(saRoot->swConfig.hostDirectAccessMode & 2 )
2593*4e1bc9a0SAchim Leubner {
2594*4e1bc9a0SAchim Leubner /* Hda AES DIF offload */
2595*4e1bc9a0SAchim Leubner SA_DBG1(("siHDAMode_V: AES/DIF 0x%08X offload enabled %s\n",ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3 ),
2596*4e1bc9a0SAchim Leubner ((ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3 ) & (1 << SHIFT15)) ? "yes" :"no") ));
2597*4e1bc9a0SAchim Leubner /* Hda AES DIF offload */
2598*4e1bc9a0SAchim Leubner /* ossaHwRegWrite(agRoot, V_Scratchpad_Rsvd_0_Register, 0); */
2599*4e1bc9a0SAchim Leubner /* Hda AES DIF offload */
2600*4e1bc9a0SAchim Leubner }
2601*4e1bc9a0SAchim Leubner
2602*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'm', "2W");
2603*4e1bc9a0SAchim Leubner return returnVal;
2604*4e1bc9a0SAchim Leubner
2605*4e1bc9a0SAchim Leubner bootrom_err:
2606*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: Response 0 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n",
2607*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+0),
2608*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+4),
2609*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+8),
2610*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+12),
2611*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+16),
2612*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+20),
2613*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+24),
2614*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot, PCIBAR0, SPC_V_HDA_RESPONSE_OFFSET+28) ));
2615*4e1bc9a0SAchim Leubner
2616*4e1bc9a0SAchim Leubner fw_err:
2617*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_0_Register)));
2618*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD1 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_1_Register)));
2619*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD2 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_2_Register)));
2620*4e1bc9a0SAchim Leubner SA_DBG2(("siHDAMode_V: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegReadExt(agRoot, PCIBAR0, V_Scratchpad_3_Register)));
2621*4e1bc9a0SAchim Leubner return returnVal;
2622*4e1bc9a0SAchim Leubner }
2623*4e1bc9a0SAchim Leubner
2624*4e1bc9a0SAchim Leubner #endif /* SA_ENABLE_HDA_FUNCTIONS */
2625*4e1bc9a0SAchim Leubner
2626*4e1bc9a0SAchim Leubner
2627*4e1bc9a0SAchim Leubner
2628*4e1bc9a0SAchim Leubner
2629*4e1bc9a0SAchim Leubner /******************************************************************************/
2630*4e1bc9a0SAchim Leubner /*! \brief Function to check FW is ready for soft reset
2631*4e1bc9a0SAchim Leubner *
2632*4e1bc9a0SAchim Leubner * The siSpcSoftResetRDYChk() function is called to check status of FW
2633*4e1bc9a0SAchim Leubner *
2634*4e1bc9a0SAchim Leubner * \param agRoot handles for this instance of SAS/SATA hardware
2635*4e1bc9a0SAchim Leubner *
2636*4e1bc9a0SAchim Leubner * \return success or fail
2637*4e1bc9a0SAchim Leubner */
2638*4e1bc9a0SAchim Leubner /*******************************************************************************/
siSpcSoftResetRDYChk(agsaRoot_t * agRoot)2639*4e1bc9a0SAchim Leubner LOCAL bit32 siSpcSoftResetRDYChk(agsaRoot_t *agRoot)
2640*4e1bc9a0SAchim Leubner {
2641*4e1bc9a0SAchim Leubner bit32 regVal;
2642*4e1bc9a0SAchim Leubner bit32 Scratchpad1;
2643*4e1bc9a0SAchim Leubner bit32 Scratchpad2;
2644*4e1bc9a0SAchim Leubner bit32 spad2notready = 0;
2645*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
2646*4e1bc9a0SAchim Leubner bit32 regVal1;
2647*4e1bc9a0SAchim Leubner bit32 regVal2;
2648*4e1bc9a0SAchim Leubner #endif /* SALLSDK_DEBUG */
2649*4e1bc9a0SAchim Leubner
2650*4e1bc9a0SAchim Leubner /* read the scratch pad 2 register bit 2 */
2651*4e1bc9a0SAchim Leubner regVal = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2) & SCRATCH_PAD2_FWRDY_RST;
2652*4e1bc9a0SAchim Leubner Scratchpad1 = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1);
2653*4e1bc9a0SAchim Leubner if (regVal == SCRATCH_PAD2_FWRDY_RST)
2654*4e1bc9a0SAchim Leubner {
2655*4e1bc9a0SAchim Leubner /* FW assert happened, it is ready for soft reset */
2656*4e1bc9a0SAchim Leubner /* Do nothing */
2657*4e1bc9a0SAchim Leubner }
2658*4e1bc9a0SAchim Leubner else
2659*4e1bc9a0SAchim Leubner {
2660*4e1bc9a0SAchim Leubner /* read bootloader response state */
2661*4e1bc9a0SAchim Leubner regVal = ossaHwRegReadExt(agRoot, PCIBAR3, HDA_RSP_OFFSET1MB+HDA_CMD_CODE_OFFSET) & HDA_STATUS_BITS;
2662*4e1bc9a0SAchim Leubner if (regVal == BOOTTLOADERHDA_IDLE)
2663*4e1bc9a0SAchim Leubner {
2664*4e1bc9a0SAchim Leubner /* For customers wants to do soft reset even the chip is already in HDA mode */
2665*4e1bc9a0SAchim Leubner /* Do not need to trigger RB6 twice */
2666*4e1bc9a0SAchim Leubner ;
2667*4e1bc9a0SAchim Leubner }
2668*4e1bc9a0SAchim Leubner else
2669*4e1bc9a0SAchim Leubner {
2670*4e1bc9a0SAchim Leubner /* Trigger NMI twice via RB6 */
2671*4e1bc9a0SAchim Leubner if (AGSA_RC_FAILURE == siBar4Shift(agRoot, RB6_ACCESS_REG))
2672*4e1bc9a0SAchim Leubner {
2673*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftReset:Shift Bar4 to 0x%x failed\n", RB6_ACCESS_REG));
2674*4e1bc9a0SAchim Leubner return AGSA_RC_FAILURE;
2675*4e1bc9a0SAchim Leubner }
2676*4e1bc9a0SAchim Leubner
2677*4e1bc9a0SAchim Leubner if(Scratchpad1 != (SCRATCH_PAD1_FW_INIT_ERR | SCRATCH_PAD1_AAP_ERROR_STATE))
2678*4e1bc9a0SAchim Leubner {
2679*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_RB6_OFFSET , RB6_MAGIC_NUMBER_RST);
2680*4e1bc9a0SAchim Leubner
2681*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot, PCIBAR2, SPC_RB6_OFFSET , RB6_MAGIC_NUMBER_RST);
2682*4e1bc9a0SAchim Leubner }
2683*4e1bc9a0SAchim Leubner else
2684*4e1bc9a0SAchim Leubner {
2685*4e1bc9a0SAchim Leubner SA_DBG1(("siSoftReset: ILA load fail SKIP RB6 access 0x%x\n",Scratchpad1 ));
2686*4e1bc9a0SAchim Leubner }
2687*4e1bc9a0SAchim Leubner SPAD2_NOT_READY:
2688*4e1bc9a0SAchim Leubner /* wait for 100 ms */
2689*4e1bc9a0SAchim Leubner ossaStallThread(agRoot, ONE_HUNDRED_MILLISECS );
2690*4e1bc9a0SAchim Leubner Scratchpad2 = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2);
2691*4e1bc9a0SAchim Leubner regVal = Scratchpad2 & SCRATCH_PAD2_FWRDY_RST;
2692*4e1bc9a0SAchim Leubner if (regVal != SCRATCH_PAD2_FWRDY_RST)
2693*4e1bc9a0SAchim Leubner {
2694*4e1bc9a0SAchim Leubner if (spad2notready > WAIT_SECONDS(12) / ONE_HUNDRED_MILLISECS ) /**/
2695*4e1bc9a0SAchim Leubner {
2696*4e1bc9a0SAchim Leubner #if defined(SALLSDK_DEBUG)
2697*4e1bc9a0SAchim Leubner regVal1 = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_1);
2698*4e1bc9a0SAchim Leubner regVal2 = ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_2);
2699*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftResetRDYChk: TIMEOUT:MSGU_SCRATCH_PAD1=0x%x, MSGU_SCRATCH_PAD2=0x%x\n", regVal1, regVal2));
2700*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftResetRDYChk: SCRATCH_PAD0 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_0)));
2701*4e1bc9a0SAchim Leubner SA_DBG1(("siSpcSoftResetRDYChk: SCRATCH_PAD3 value = 0x%x\n", ossaHwRegRead(agRoot, MSGU_SCRATCH_PAD_3)));
2702*4e1bc9a0SAchim Leubner #endif /* SALLSDK_DEBUG */
2703*4e1bc9a0SAchim Leubner return AGSA_RC_SUCCESS; /* Timeout Ok reset anyway */
2704*4e1bc9a0SAchim Leubner }
2705*4e1bc9a0SAchim Leubner
2706*4e1bc9a0SAchim Leubner spad2notready++;
2707*4e1bc9a0SAchim Leubner goto SPAD2_NOT_READY;
2708*4e1bc9a0SAchim Leubner }
2709*4e1bc9a0SAchim Leubner }
2710*4e1bc9a0SAchim Leubner }
2711*4e1bc9a0SAchim Leubner
2712*4e1bc9a0SAchim Leubner return AGSA_RC_SUCCESS;
2713*4e1bc9a0SAchim Leubner }
2714*4e1bc9a0SAchim Leubner
2715*4e1bc9a0SAchim Leubner
2716*4e1bc9a0SAchim Leubner agsaBarOffset_t SPCTable[] =
2717*4e1bc9a0SAchim Leubner {
2718*4e1bc9a0SAchim Leubner
2719*4e1bc9a0SAchim Leubner { GEN_MSGU_IBDB_SET, PCIBAR0, MSGU_IBDB_SET, SIZE_DW }, /* 0x00 */
2720*4e1bc9a0SAchim Leubner { GEN_MSGU_ODR, PCIBAR0, MSGU_ODR, SIZE_DW }, /* 0x01 */
2721*4e1bc9a0SAchim Leubner { GEN_MSGU_ODCR, PCIBAR0, MSGU_ODCR, SIZE_DW }, /* 0x02 */
2722*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_0, PCIBAR0, MSGU_SCRATCH_PAD_0, SIZE_DW }, /* 0x03 */
2723*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_1, PCIBAR0, MSGU_SCRATCH_PAD_1, SIZE_DW }, /* 0x04 */
2724*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_2, PCIBAR0, MSGU_SCRATCH_PAD_2, SIZE_DW }, /* 0x05 */
2725*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_3, PCIBAR0, MSGU_SCRATCH_PAD_3, SIZE_DW }, /* 0x06 */
2726*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_0, PCIBAR0, MSGU_HOST_SCRATCH_PAD_0, SIZE_DW }, /* 0x07 */
2727*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_1, PCIBAR0, MSGU_HOST_SCRATCH_PAD_1, SIZE_DW }, /* 0x08 */
2728*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_2, PCIBAR0, MSGU_HOST_SCRATCH_PAD_2, SIZE_DW }, /* 0x09 */
2729*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_3, PCIBAR0, MSGU_HOST_SCRATCH_PAD_3, SIZE_DW }, /* 0x0a */
2730*4e1bc9a0SAchim Leubner { GEN_MSGU_ODMR, PCIBAR0, MSGU_ODMR, SIZE_DW }, /* 0x0b */
2731*4e1bc9a0SAchim Leubner { GEN_PCIE_TRIGGER, PCIBAR0, PCIE_TRIGGER_ON_REGISTER_READ, SIZE_DW }, /* 0x0c */
2732*4e1bc9a0SAchim Leubner { GEN_SPC_REG_RESET, PCIBAR2, SPC_REG_RESET, SIZE_DW }, /* 0x0d */
2733*4e1bc9a0SAchim Leubner };
2734*4e1bc9a0SAchim Leubner
2735*4e1bc9a0SAchim Leubner agsaBarOffset_t SPC_V_Table[] =
2736*4e1bc9a0SAchim Leubner {
2737*4e1bc9a0SAchim Leubner
2738*4e1bc9a0SAchim Leubner { GEN_MSGU_IBDB_SET, PCIBAR0, V_Inbound_Doorbell_Set_Register, SIZE_DW }, /* 0x00 */
2739*4e1bc9a0SAchim Leubner { GEN_MSGU_ODR, PCIBAR0, V_Outbound_Doorbell_Set_Register, SIZE_DW }, /* 0x01 */
2740*4e1bc9a0SAchim Leubner { GEN_MSGU_ODCR, PCIBAR0, V_Outbound_Doorbell_Clear_Register, SIZE_DW }, /* 0x02 */
2741*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_0, PCIBAR0, V_Scratchpad_0_Register, SIZE_DW }, /* 0x03 */
2742*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_1, PCIBAR0, V_Scratchpad_1_Register, SIZE_DW }, /* 0x04 */
2743*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_2, PCIBAR0, V_Scratchpad_2_Register, SIZE_DW }, /* 0x05 */
2744*4e1bc9a0SAchim Leubner { GEN_MSGU_SCRATCH_PAD_3, PCIBAR0, V_Scratchpad_3_Register, SIZE_DW }, /* 0x06 */
2745*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_0, PCIBAR0, V_Host_Scratchpad_0_Register, SIZE_DW }, /* 0x07 */
2746*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_1, PCIBAR0, V_Host_Scratchpad_1_Register, SIZE_DW }, /* 0x08 */
2747*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_2, PCIBAR0, V_Host_Scratchpad_2_Register, SIZE_DW }, /* 0x09 */
2748*4e1bc9a0SAchim Leubner { GEN_MSGU_HOST_SCRATCH_PAD_3, PCIBAR0, V_Host_Scratchpad_3_Register, SIZE_DW }, /* 0x0a */
2749*4e1bc9a0SAchim Leubner { GEN_MSGU_ODMR, PCIBAR0, V_Outbound_Doorbell_Mask_Set_Register, SIZE_DW }, /* 0x0b */
2750*4e1bc9a0SAchim Leubner { GEN_PCIE_TRIGGER, PCIBAR0, PCIE_TRIGGER_ON_REGISTER_READ, SIZE_DW }, /* 0x0c */
2751*4e1bc9a0SAchim Leubner { GEN_SPC_REG_RESET, PCIBAR0, V_SoftResetRegister, SIZE_DW }, /* 0x0d */
2752*4e1bc9a0SAchim Leubner };
2753*4e1bc9a0SAchim Leubner
2754*4e1bc9a0SAchim Leubner
2755*4e1bc9a0SAchim Leubner /*******************************************************************************/
2756*4e1bc9a0SAchim Leubner /**
2757*4e1bc9a0SAchim Leubner *
2758*4e1bc9a0SAchim Leubner * \brief
2759*4e1bc9a0SAchim Leubner * \param agsaRoot Pointer to a data structure containing both application
2760*4e1bc9a0SAchim Leubner * and LL layer context handles
2761*4e1bc9a0SAchim Leubner * \param Spc_type Device Id of hardware
2762*4e1bc9a0SAchim Leubner *
2763*4e1bc9a0SAchim Leubner * Return:
2764*4e1bc9a0SAchim Leubner * None
2765*4e1bc9a0SAchim Leubner */
2766*4e1bc9a0SAchim Leubner /*******************************************************************************/
siUpdateBarOffsetTable(agsaRoot_t * agRoot,bit32 Spc_Type)2767*4e1bc9a0SAchim Leubner GLOBAL void siUpdateBarOffsetTable(agsaRoot_t *agRoot,
2768*4e1bc9a0SAchim Leubner bit32 Spc_Type
2769*4e1bc9a0SAchim Leubner )
2770*4e1bc9a0SAchim Leubner {
2771*4e1bc9a0SAchim Leubner
2772*4e1bc9a0SAchim Leubner agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
2773*4e1bc9a0SAchim Leubner bit32 x;
2774*4e1bc9a0SAchim Leubner
2775*4e1bc9a0SAchim Leubner smTraceFuncEnter(hpDBG_VERY_LOUD,"mf");
2776*4e1bc9a0SAchim Leubner
2777*4e1bc9a0SAchim Leubner smTrace(hpDBG_VERY_LOUD,"9A",Spc_Type);
2778*4e1bc9a0SAchim Leubner /* TP:9A Spc_Type */
2779*4e1bc9a0SAchim Leubner
2780*4e1bc9a0SAchim Leubner if(Spc_Type == VEN_DEV_SPC)
2781*4e1bc9a0SAchim Leubner {
2782*4e1bc9a0SAchim Leubner si_memcpy(&saRoot->SpcBarOffset, SPCTable, sizeof(SPCTable));
2783*4e1bc9a0SAchim Leubner SA_DBG5(("siUpdateBarOffsetTable:sizeof(SPCTable) sizeof(agsaBarOffset_t)sizeof(SPCTable) / sizeof(agsaBarOffset_t) %X %X %X\n",
2784*4e1bc9a0SAchim Leubner (unsigned int)sizeof(SPCTable), (unsigned int)sizeof(agsaBarOffset_t),
2785*4e1bc9a0SAchim Leubner (unsigned int)(sizeof(SPCTable) / sizeof(agsaBarOffset_t))
2786*4e1bc9a0SAchim Leubner ));
2787*4e1bc9a0SAchim Leubner }
2788*4e1bc9a0SAchim Leubner else /* VEN_DEV_SPCV */
2789*4e1bc9a0SAchim Leubner {
2790*4e1bc9a0SAchim Leubner si_memcpy(&saRoot->SpcBarOffset, SPC_V_Table, sizeof(SPC_V_Table));
2791*4e1bc9a0SAchim Leubner SA_DBG5(("siUpdateBarOffsetTable:sizeof(SPC_V_Table) sizeof(agsaBarOffset_t)sizeof(SPC_V_Table) / sizeof(agsaBarOffset_t) %X %X %X\n",
2792*4e1bc9a0SAchim Leubner (unsigned int)sizeof(SPC_V_Table),
2793*4e1bc9a0SAchim Leubner (unsigned int)sizeof(agsaBarOffset_t),
2794*4e1bc9a0SAchim Leubner (unsigned int)(sizeof(SPC_V_Table) / sizeof(agsaBarOffset_t))
2795*4e1bc9a0SAchim Leubner ));
2796*4e1bc9a0SAchim Leubner }
2797*4e1bc9a0SAchim Leubner
2798*4e1bc9a0SAchim Leubner for(x=0;x < sizeof(SPCTable) / sizeof(agsaBarOffset_t);x++)
2799*4e1bc9a0SAchim Leubner {
2800*4e1bc9a0SAchim Leubner
2801*4e1bc9a0SAchim Leubner SA_DBG4(("%8X: %8X %8X %8X\n",saRoot->SpcBarOffset[x].Generic,
2802*4e1bc9a0SAchim Leubner saRoot->SpcBarOffset[x].Bar,
2803*4e1bc9a0SAchim Leubner saRoot->SpcBarOffset[x].Offset,
2804*4e1bc9a0SAchim Leubner saRoot->SpcBarOffset[x].Length
2805*4e1bc9a0SAchim Leubner ));
2806*4e1bc9a0SAchim Leubner if(saRoot->SpcBarOffset[x].Generic != x)
2807*4e1bc9a0SAchim Leubner {
2808*4e1bc9a0SAchim Leubner SA_DBG1(("siUpdateBarOffsetTable: saRoot->SpcBarOffset[%x].Generic %X != %X\n",x, saRoot->SpcBarOffset[x].Generic, x));
2809*4e1bc9a0SAchim Leubner }
2810*4e1bc9a0SAchim Leubner }
2811*4e1bc9a0SAchim Leubner
2812*4e1bc9a0SAchim Leubner smTraceFuncExit(hpDBG_VERY_LOUD, 'a', "mf");
2813*4e1bc9a0SAchim Leubner }
2814*4e1bc9a0SAchim Leubner
2815*4e1bc9a0SAchim Leubner
2816*4e1bc9a0SAchim Leubner
siHalRegReadExt(agsaRoot_t * agRoot,bit32 generic,bit32 regOffset)2817*4e1bc9a0SAchim Leubner GLOBAL bit32 siHalRegReadExt( agsaRoot_t *agRoot,
2818*4e1bc9a0SAchim Leubner bit32 generic,
2819*4e1bc9a0SAchim Leubner bit32 regOffset
2820*4e1bc9a0SAchim Leubner )
2821*4e1bc9a0SAchim Leubner {
2822*4e1bc9a0SAchim Leubner
2823*4e1bc9a0SAchim Leubner agsaBarOffset_t * Table = agNULL;
2824*4e1bc9a0SAchim Leubner bit32 retVal;
2825*4e1bc9a0SAchim Leubner
2826*4e1bc9a0SAchim Leubner /* sanity check */
2827*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "agRoot");
2828*4e1bc9a0SAchim Leubner Table = WHATTABLE(agRoot);
2829*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != Table), "Table");
2830*4e1bc9a0SAchim Leubner
2831*4e1bc9a0SAchim Leubner /*
2832*4e1bc9a0SAchim Leubner if(Table[generic].Offset != regOffset)
2833*4e1bc9a0SAchim Leubner {
2834*4e1bc9a0SAchim Leubner
2835*4e1bc9a0SAchim Leubner SA_DBG1(("siHalRegReadExt: Table[%x].Offset %x != regOffset %x\n",generic,
2836*4e1bc9a0SAchim Leubner Table[generic].Offset,
2837*4e1bc9a0SAchim Leubner regOffset ));
2838*4e1bc9a0SAchim Leubner }
2839*4e1bc9a0SAchim Leubner */
2840*4e1bc9a0SAchim Leubner
2841*4e1bc9a0SAchim Leubner if(Table[generic].Bar)
2842*4e1bc9a0SAchim Leubner {
2843*4e1bc9a0SAchim Leubner retVal = ossaHwRegReadExt(agRoot,
2844*4e1bc9a0SAchim Leubner Table[generic].Bar,
2845*4e1bc9a0SAchim Leubner Table[generic].Offset);
2846*4e1bc9a0SAchim Leubner }
2847*4e1bc9a0SAchim Leubner else
2848*4e1bc9a0SAchim Leubner {
2849*4e1bc9a0SAchim Leubner retVal = ossaHwRegRead(agRoot,
2850*4e1bc9a0SAchim Leubner Table[generic].Offset);
2851*4e1bc9a0SAchim Leubner }
2852*4e1bc9a0SAchim Leubner
2853*4e1bc9a0SAchim Leubner return(retVal);
2854*4e1bc9a0SAchim Leubner }
2855*4e1bc9a0SAchim Leubner
2856*4e1bc9a0SAchim Leubner
siHalRegWriteExt(agsaRoot_t * agRoot,bit32 generic,bit32 regOffset,bit32 regValue)2857*4e1bc9a0SAchim Leubner GLOBAL void siHalRegWriteExt(
2858*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
2859*4e1bc9a0SAchim Leubner bit32 generic,
2860*4e1bc9a0SAchim Leubner bit32 regOffset,
2861*4e1bc9a0SAchim Leubner bit32 regValue
2862*4e1bc9a0SAchim Leubner )
2863*4e1bc9a0SAchim Leubner {
2864*4e1bc9a0SAchim Leubner agsaBarOffset_t * Table = agNULL;
2865*4e1bc9a0SAchim Leubner
2866*4e1bc9a0SAchim Leubner /* sanity check */
2867*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != agRoot), "agRoot");
2868*4e1bc9a0SAchim Leubner
2869*4e1bc9a0SAchim Leubner Table = WHATTABLE(agRoot);
2870*4e1bc9a0SAchim Leubner SA_ASSERT( (agNULL != Table), "Table");
2871*4e1bc9a0SAchim Leubner
2872*4e1bc9a0SAchim Leubner
2873*4e1bc9a0SAchim Leubner /*
2874*4e1bc9a0SAchim Leubner if(Table[generic].Offset != regOffset)
2875*4e1bc9a0SAchim Leubner {
2876*4e1bc9a0SAchim Leubner
2877*4e1bc9a0SAchim Leubner SA_DBG1(("siHalRegWriteExt: Table[%x].Offset %x != regOffset %x\n",generic,
2878*4e1bc9a0SAchim Leubner Table[generic].Offset,
2879*4e1bc9a0SAchim Leubner regOffset ));
2880*4e1bc9a0SAchim Leubner }
2881*4e1bc9a0SAchim Leubner */
2882*4e1bc9a0SAchim Leubner
2883*4e1bc9a0SAchim Leubner SA_DBG6(("siHalRegWriteExt: Bar %x Offset %8X Wrote %8X\n",
2884*4e1bc9a0SAchim Leubner Table[generic].Bar,
2885*4e1bc9a0SAchim Leubner Table[generic].Offset,
2886*4e1bc9a0SAchim Leubner regValue ));
2887*4e1bc9a0SAchim Leubner
2888*4e1bc9a0SAchim Leubner
2889*4e1bc9a0SAchim Leubner if(Table[generic].Bar)
2890*4e1bc9a0SAchim Leubner {
2891*4e1bc9a0SAchim Leubner ossaHwRegWriteExt(agRoot,
2892*4e1bc9a0SAchim Leubner Table[generic].Bar,
2893*4e1bc9a0SAchim Leubner Table[generic].Offset,
2894*4e1bc9a0SAchim Leubner regValue );
2895*4e1bc9a0SAchim Leubner }else
2896*4e1bc9a0SAchim Leubner {
2897*4e1bc9a0SAchim Leubner ossaHwRegWrite(agRoot,
2898*4e1bc9a0SAchim Leubner Table[generic].Offset,
2899*4e1bc9a0SAchim Leubner regValue );
2900*4e1bc9a0SAchim Leubner }
2901*4e1bc9a0SAchim Leubner }
2902*4e1bc9a0SAchim Leubner
2903*4e1bc9a0SAchim Leubner
2904*4e1bc9a0SAchim Leubner
2905*4e1bc9a0SAchim Leubner
siPCITriger(agsaRoot_t * agRoot)2906*4e1bc9a0SAchim Leubner GLOBAL void siPCITriger(agsaRoot_t *agRoot)
2907*4e1bc9a0SAchim Leubner {
2908*4e1bc9a0SAchim Leubner
2909*4e1bc9a0SAchim Leubner SA_DBG1(("siPCITriger: Read PCIe Bar zero plus 0x%x\n", PCIE_TRIGGER_ON_REGISTER_READ));
2910*4e1bc9a0SAchim Leubner ossaHwRegReadExt(agRoot,PCIBAR0 ,PCIE_TRIGGER_ON_REGISTER_READ );
2911*4e1bc9a0SAchim Leubner }
2912*4e1bc9a0SAchim Leubner
2913*4e1bc9a0SAchim Leubner
siGetPciBar(agsaRoot_t * agRoot)2914*4e1bc9a0SAchim Leubner GLOBAL bit32 siGetPciBar(
2915*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot
2916*4e1bc9a0SAchim Leubner )
2917*4e1bc9a0SAchim Leubner {
2918*4e1bc9a0SAchim Leubner bit32 MSGUCfgTblBase = 0;
2919*4e1bc9a0SAchim Leubner bit32 pcibar = 0;
2920*4e1bc9a0SAchim Leubner MSGUCfgTblBase = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
2921*4e1bc9a0SAchim Leubner pcibar = (MSGUCfgTblBase & SCRATCH_PAD0_BAR_MASK) >> SHIFT26;
2922*4e1bc9a0SAchim Leubner /* get pci Bar index */
2923*4e1bc9a0SAchim Leubner pcibar = (bit8)mpiGetPCIBarIndex(agRoot, pcibar);
2924*4e1bc9a0SAchim Leubner
2925*4e1bc9a0SAchim Leubner return(pcibar);
2926*4e1bc9a0SAchim Leubner }
2927*4e1bc9a0SAchim Leubner
siGetTableOffset(agsaRoot_t * agRoot,bit32 TableOffsetInTable)2928*4e1bc9a0SAchim Leubner GLOBAL bit32 siGetTableOffset(
2929*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot,
2930*4e1bc9a0SAchim Leubner bit32 TableOffsetInTable
2931*4e1bc9a0SAchim Leubner )
2932*4e1bc9a0SAchim Leubner {
2933*4e1bc9a0SAchim Leubner bit32 TableOffset;
2934*4e1bc9a0SAchim Leubner bit32 MSGUCfgTblBase;
2935*4e1bc9a0SAchim Leubner /* read scratch pad0 to get PCI BAR and offset of configuration table */
2936*4e1bc9a0SAchim Leubner MSGUCfgTblBase = siHalRegReadExt(agRoot, GEN_MSGU_SCRATCH_PAD_0,MSGU_SCRATCH_PAD_0);
2937*4e1bc9a0SAchim Leubner
2938*4e1bc9a0SAchim Leubner MSGUCfgTblBase &= SCRATCH_PAD0_OFFSET_MASK;
2939*4e1bc9a0SAchim Leubner
2940*4e1bc9a0SAchim Leubner TableOffset = ossaHwRegReadExt(agRoot,siGetPciBar(agRoot) ,MSGUCfgTblBase +TableOffsetInTable );
2941*4e1bc9a0SAchim Leubner SA_DBG4(("GetTableOffset:TableOffset with size 0x%x\n", TableOffset));
2942*4e1bc9a0SAchim Leubner
2943*4e1bc9a0SAchim Leubner /* Mask off size */
2944*4e1bc9a0SAchim Leubner TableOffset &= 0xFFFFFF;
2945*4e1bc9a0SAchim Leubner TableOffset +=MSGUCfgTblBase;
2946*4e1bc9a0SAchim Leubner return(TableOffset);
2947*4e1bc9a0SAchim Leubner
2948*4e1bc9a0SAchim Leubner }
2949*4e1bc9a0SAchim Leubner
2950*4e1bc9a0SAchim Leubner
siCheckQs(agsaRoot_t * agRoot)2951*4e1bc9a0SAchim Leubner GLOBAL void siCheckQs(
2952*4e1bc9a0SAchim Leubner agsaRoot_t *agRoot
2953*4e1bc9a0SAchim Leubner )
2954*4e1bc9a0SAchim Leubner {
2955*4e1bc9a0SAchim Leubner agsaLLRoot_t *saRoot = (agsaLLRoot_t *) (agRoot->sdkData);
2956*4e1bc9a0SAchim Leubner
2957*4e1bc9a0SAchim Leubner mpiOCQueue_t *circularOQ;
2958*4e1bc9a0SAchim Leubner mpiICQueue_t *circularIQ;
2959*4e1bc9a0SAchim Leubner int i;
2960*4e1bc9a0SAchim Leubner
2961*4e1bc9a0SAchim Leubner for ( i = 0; i < saRoot->QueueConfig.numInboundQueues; i++ )
2962*4e1bc9a0SAchim Leubner {
2963*4e1bc9a0SAchim Leubner circularIQ = &saRoot->inboundQueue[i];
2964*4e1bc9a0SAchim Leubner
2965*4e1bc9a0SAchim Leubner OSSA_READ_LE_32(circularIQ->agRoot, &circularIQ->consumerIdx, circularIQ->ciPointer, 0);
2966*4e1bc9a0SAchim Leubner if(circularIQ->producerIdx != circularIQ->consumerIdx)
2967*4e1bc9a0SAchim Leubner {
2968*4e1bc9a0SAchim Leubner SA_DBG1(("siCheckQs: In Q %d PI 0x%03x CI 0x%03x (%d) \n",i,
2969*4e1bc9a0SAchim Leubner circularIQ->producerIdx,
2970*4e1bc9a0SAchim Leubner circularIQ->consumerIdx,
2971*4e1bc9a0SAchim Leubner (circularIQ->producerIdx > circularIQ->consumerIdx ? (circularIQ->producerIdx - circularIQ->consumerIdx) : (circularIQ->numElements - circularIQ->consumerIdx ) + circularIQ->producerIdx)));
2972*4e1bc9a0SAchim Leubner }
2973*4e1bc9a0SAchim Leubner }
2974*4e1bc9a0SAchim Leubner
2975*4e1bc9a0SAchim Leubner for ( i = 0; i < saRoot->QueueConfig.numOutboundQueues; i++ )
2976*4e1bc9a0SAchim Leubner {
2977*4e1bc9a0SAchim Leubner circularOQ = &saRoot->outboundQueue[i];
2978*4e1bc9a0SAchim Leubner OSSA_READ_LE_32(circularOQ->agRoot, &circularOQ->producerIdx, circularOQ->piPointer, 0);
2979*4e1bc9a0SAchim Leubner if(circularOQ->producerIdx != circularOQ->consumerIdx)
2980*4e1bc9a0SAchim Leubner {
2981*4e1bc9a0SAchim Leubner SA_DBG1(("siCheckQs: Out Q %d PI 0x%03x CI 0x%03x (%d) \n",i,
2982*4e1bc9a0SAchim Leubner circularOQ->producerIdx,
2983*4e1bc9a0SAchim Leubner circularOQ->consumerIdx,
2984*4e1bc9a0SAchim Leubner (circularOQ->producerIdx > circularOQ->consumerIdx ? (circularOQ->producerIdx - circularOQ->consumerIdx) : (circularOQ->numElements - circularOQ->consumerIdx ) + circularOQ->producerIdx)));
2985*4e1bc9a0SAchim Leubner
2986*4e1bc9a0SAchim Leubner }
2987*4e1bc9a0SAchim Leubner }
2988*4e1bc9a0SAchim Leubner
2989*4e1bc9a0SAchim Leubner }
siPciCpyMem(agsaRoot_t * agRoot,bit32 soffset,const void * dst,bit32 DWcount,bit32 busBaseNumber)2990*4e1bc9a0SAchim Leubner GLOBAL void siPciCpyMem(agsaRoot_t *agRoot,
2991*4e1bc9a0SAchim Leubner bit32 soffset,
2992*4e1bc9a0SAchim Leubner const void *dst,
2993*4e1bc9a0SAchim Leubner bit32 DWcount,
2994*4e1bc9a0SAchim Leubner bit32 busBaseNumber
2995*4e1bc9a0SAchim Leubner )
2996*4e1bc9a0SAchim Leubner {
2997*4e1bc9a0SAchim Leubner bit32 i, val,offset;
2998*4e1bc9a0SAchim Leubner bit32 *dst1;
2999*4e1bc9a0SAchim Leubner
3000*4e1bc9a0SAchim Leubner dst1 = (bit32 *)dst;
3001*4e1bc9a0SAchim Leubner
3002*4e1bc9a0SAchim Leubner SA_DBG1(("siPciCpyMem:copy DWcount %d from offset 0x%x to %p\n",DWcount,soffset,dst));
3003*4e1bc9a0SAchim Leubner
3004*4e1bc9a0SAchim Leubner for (i= 0; i < DWcount; i+=4,dst1++)
3005*4e1bc9a0SAchim Leubner {
3006*4e1bc9a0SAchim Leubner offset = (soffset + i / 4);
3007*4e1bc9a0SAchim Leubner SA_ASSERT( (offset < (64 * 1024)), "siPciCpyMem offset too large");
3008*4e1bc9a0SAchim Leubner if(offset < (64 * 1024))
3009*4e1bc9a0SAchim Leubner {
3010*4e1bc9a0SAchim Leubner val = ossaHwRegReadExt(agRoot, busBaseNumber, offset);
3011*4e1bc9a0SAchim Leubner *dst1 = BIT32_TO_LEBIT32(val);
3012*4e1bc9a0SAchim Leubner }
3013*4e1bc9a0SAchim Leubner }
3014*4e1bc9a0SAchim Leubner
3015*4e1bc9a0SAchim Leubner return;
3016*4e1bc9a0SAchim Leubner }
3017