0
|
1 |
/*
|
|
2 |
* FwEvent.c
|
|
3 |
*
|
|
4 |
* Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
7 |
* This program and the accompanying materials are made available under the
|
|
8 |
* terms of the Eclipse Public License v1.0 or BSD License which accompanies
|
|
9 |
* this distribution. The Eclipse Public License is available at
|
|
10 |
* http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.
|
|
11 |
*
|
|
12 |
* Redistribution and use in source and binary forms, with or without
|
|
13 |
* modification, are permitted provided that the following conditions
|
|
14 |
* are met:
|
|
15 |
*
|
|
16 |
* * Redistributions of source code must retain the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer.
|
|
18 |
* * Redistributions in binary form must reproduce the above copyright
|
|
19 |
* notice, this list of conditions and the following disclaimer in
|
|
20 |
* the documentation and/or other materials provided with the
|
|
21 |
* distribution.
|
|
22 |
* * Neither the name Texas Instruments nor the names of its
|
|
23 |
* contributors may be used to endorse or promote products derived
|
|
24 |
* from this software without specific prior written permission.
|
|
25 |
*
|
|
26 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
27 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
28 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
29 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
30 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
31 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
32 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
33 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
34 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
35 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
36 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37 |
*/
|
|
38 |
|
|
39 |
|
|
40 |
/** \file FwEvent.c
|
|
41 |
* \brief Handle firmware events
|
|
42 |
*
|
|
43 |
*
|
|
44 |
* \par Description
|
|
45 |
* Call the appropriate event handler.
|
|
46 |
*
|
|
47 |
* \see FwEvent.h
|
|
48 |
*/
|
|
49 |
|
|
50 |
#define __FILE_ID__ FILE_ID_104
|
|
51 |
#include "tidef.h"
|
|
52 |
#include "report.h"
|
|
53 |
#include "context.h"
|
|
54 |
#include "osApi.h"
|
|
55 |
#include "TWDriver.h"
|
|
56 |
#include "TWDriverInternal.h"
|
|
57 |
#include "FwEvent.h"
|
|
58 |
#include "txResult_api.h"
|
|
59 |
#include "CmdMBox_api.h"
|
|
60 |
#include "rxXfer_api.h"
|
|
61 |
#include "txXfer_api.h"
|
|
62 |
#include "txHwQueue_api.h"
|
|
63 |
#include "eventMbox_api.h"
|
|
64 |
#include "TwIf.h"
|
|
65 |
#ifdef TI_DBG
|
|
66 |
#include "tracebuf_api.h"
|
|
67 |
#endif
|
|
68 |
|
|
69 |
#ifdef _VLCT_
|
|
70 |
extern int trigger_another_read;
|
|
71 |
#endif
|
|
72 |
|
|
73 |
#define USE_SDIO_24M_WORKAROUND
|
|
74 |
#define FW_STATUS_MEM_ADDRESS 0x40400
|
|
75 |
|
|
76 |
|
|
77 |
#define TXN_FW_EVENT_SET_MASK_ADDR(pFwEvent) pFwEvent->tMaskTxn.tTxnStruct.uHwAddr = HINT_MASK;
|
|
78 |
#define TXN_FW_EVENT_SET_UNMASK_ADDR(pFwEvent) pFwEvent->tUnMaskTxn.tTxnStruct.uHwAddr = HINT_MASK;
|
|
79 |
#define TXN_FW_EVENT_SET_STATUS_ADDR(pFwEvent) pFwEvent->tFwStatusTxn.tTxnStruct.uHwAddr = ACX_REG_INTERRUPT_CLEAR;
|
|
80 |
#define TXN_FW_EVENT_SET_FW_MEM_ADDR(pFwEvent) pFwEvent->tMemFwStatusTxn.tTxnStruct.uHwAddr = FW_STATUS_MEM_ADDRESS;
|
|
81 |
/********************* static function declerations *************************/
|
|
82 |
|
|
83 |
/*
|
|
84 |
* \brief Call FwEvent client's event handler
|
|
85 |
*
|
|
86 |
* \param hFwEvent - FwEvent Driver handle
|
|
87 |
* \return void
|
|
88 |
*
|
|
89 |
* \par Description
|
|
90 |
*
|
|
91 |
* \sa fwEvent_ReadCompleteCb
|
|
92 |
*/
|
|
93 |
static void fwEvent_CallHandler (TI_HANDLE hFwEvent);
|
|
94 |
|
|
95 |
|
|
96 |
/*
|
|
97 |
* \brief Create the FwEvent module object
|
|
98 |
*
|
|
99 |
* \param hOs - OS module object handle
|
|
100 |
* \return Handle to the created object
|
|
101 |
*
|
|
102 |
* \par Description
|
|
103 |
* Calling this function creates a FwEvent object
|
|
104 |
*
|
|
105 |
* \sa fwEvent_Destroy
|
|
106 |
*/
|
|
107 |
TI_HANDLE fwEvent_Create (TI_HANDLE hOs)
|
|
108 |
{
|
|
109 |
TfwEvent *pFwEvent;
|
|
110 |
|
|
111 |
pFwEvent = os_memoryAlloc (hOs, sizeof(TfwEvent),MemoryNormal);
|
|
112 |
if (pFwEvent == NULL)
|
|
113 |
{
|
|
114 |
return NULL;
|
|
115 |
}
|
|
116 |
|
|
117 |
os_memoryZero (hOs, pFwEvent, sizeof(TfwEvent));
|
|
118 |
|
|
119 |
/* Allocation of Data */
|
|
120 |
pFwEvent->tMaskTxn.pData = os_memoryAlloc (hOs, sizeof (TI_UINT32) + WSPI_PAD_LEN_READ,MemoryDMA);
|
|
121 |
if (pFwEvent->tMaskTxn.pData == NULL)
|
|
122 |
{
|
|
123 |
return NULL;
|
|
124 |
}
|
|
125 |
os_memoryZero (hOs, pFwEvent->tMaskTxn.pData, sizeof (TI_UINT32) + WSPI_PAD_LEN_READ);
|
|
126 |
pFwEvent->tMaskTxn.pData += WSPI_PAD_LEN_READ;
|
|
127 |
|
|
128 |
/* Allocation of Data */
|
|
129 |
pFwEvent->tUnMaskTxn.pData = os_memoryAlloc (hOs, sizeof (TI_UINT32) + WSPI_PAD_LEN_READ,MemoryDMA);
|
|
130 |
if (pFwEvent->tUnMaskTxn.pData == NULL)
|
|
131 |
{
|
|
132 |
return NULL;
|
|
133 |
}
|
|
134 |
os_memoryZero (hOs, pFwEvent->tUnMaskTxn.pData, sizeof (TI_UINT32) + WSPI_PAD_LEN_READ);
|
|
135 |
pFwEvent->tUnMaskTxn.pData += WSPI_PAD_LEN_READ;
|
|
136 |
|
|
137 |
/* Allocation of FW Status buffer */
|
|
138 |
pFwEvent->tFwStatusTxn.pFwStatus = os_memoryAlloc (hOs, sizeof (FwStatus_t) + WSPI_PAD_LEN_READ,MemoryDMA);
|
|
139 |
if (pFwEvent->tFwStatusTxn.pFwStatus == NULL)
|
|
140 |
{
|
|
141 |
return NULL;
|
|
142 |
}
|
|
143 |
os_memoryZero (hOs, pFwEvent->tFwStatusTxn.pFwStatus, sizeof (FwStatus_t) + WSPI_PAD_LEN_READ);
|
|
144 |
pFwEvent->tFwStatusTxn.pFwStatus += WSPI_PAD_LEN_READ;
|
|
145 |
|
|
146 |
/* Allocation of FW Status buffer */
|
|
147 |
pFwEvent->tMemFwStatusTxn.pFwStatus = os_memoryAlloc (hOs, sizeof (FwStatus_t) + WSPI_PAD_LEN_READ,MemoryDMA);
|
|
148 |
if (pFwEvent->tMemFwStatusTxn.pFwStatus == NULL)
|
|
149 |
{
|
|
150 |
return NULL;
|
|
151 |
}
|
|
152 |
os_memoryZero (hOs, pFwEvent->tMemFwStatusTxn.pFwStatus, sizeof (FwStatus_t) + WSPI_PAD_LEN_READ);
|
|
153 |
pFwEvent->tMemFwStatusTxn.pFwStatus += WSPI_PAD_LEN_READ;
|
|
154 |
|
|
155 |
|
|
156 |
pFwEvent->hOs = hOs;
|
|
157 |
|
|
158 |
return (TI_HANDLE)pFwEvent;
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
/*
|
|
163 |
* \brief Destroys the FwEvent object
|
|
164 |
*
|
|
165 |
* \param hFwEvent - The object to free
|
|
166 |
* \return TI_OK
|
|
167 |
*
|
|
168 |
* \par Description
|
|
169 |
* Calling this function destroys a FwEvent object
|
|
170 |
*
|
|
171 |
* \sa fwEvent_Create
|
|
172 |
*/
|
|
173 |
TI_STATUS fwEvent_Destroy (TI_HANDLE hFwEvent)
|
|
174 |
{
|
|
175 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
176 |
|
|
177 |
if (pFwEvent->tMaskTxn.pData)
|
|
178 |
{
|
|
179 |
os_memoryFree (pFwEvent->hOs, pFwEvent->tMaskTxn.pData - WSPI_PAD_LEN_READ, sizeof (TI_UINT32) + WSPI_PAD_LEN_READ);
|
|
180 |
}
|
|
181 |
|
|
182 |
if (pFwEvent->tUnMaskTxn.pData)
|
|
183 |
{
|
|
184 |
os_memoryFree (pFwEvent->hOs, pFwEvent->tUnMaskTxn.pData - WSPI_PAD_LEN_READ, sizeof (TI_UINT32) + WSPI_PAD_LEN_READ);
|
|
185 |
}
|
|
186 |
|
|
187 |
if (pFwEvent->tFwStatusTxn.pFwStatus)
|
|
188 |
{
|
|
189 |
os_memoryFree (pFwEvent->hOs, pFwEvent->tFwStatusTxn.pFwStatus - WSPI_PAD_LEN_READ, sizeof (FwStatus_t) + WSPI_PAD_LEN_READ);
|
|
190 |
}
|
|
191 |
|
|
192 |
if (pFwEvent->tMemFwStatusTxn.pFwStatus)
|
|
193 |
{
|
|
194 |
os_memoryFree (pFwEvent->hOs, pFwEvent->tMemFwStatusTxn.pFwStatus - WSPI_PAD_LEN_READ, sizeof (FwStatus_t) + WSPI_PAD_LEN_READ);
|
|
195 |
}
|
|
196 |
|
|
197 |
if (pFwEvent)
|
|
198 |
{
|
|
199 |
os_memoryFree (pFwEvent->hOs, pFwEvent, sizeof(TfwEvent));
|
|
200 |
}
|
|
201 |
|
|
202 |
return TI_OK;
|
|
203 |
}
|
|
204 |
|
|
205 |
|
|
206 |
/*
|
|
207 |
* \brief Config the FwEvent module object
|
|
208 |
*
|
|
209 |
* \param hFwEvent - FwEvent Driver handle
|
|
210 |
* \param hTWD - Handle to TWD module
|
|
211 |
* \return TI_OK
|
|
212 |
*
|
|
213 |
* \par Description
|
|
214 |
* From hTWD we extract : hOs, hReport, hTwIf, hContext,
|
|
215 |
* hHealthMonitor, hEventMbox, hCmdMbox, hRxXfer,
|
|
216 |
* hTxHwQueue, hTxResult
|
|
217 |
* In this function we also register the FwEvent to the context engine
|
|
218 |
*
|
|
219 |
* \sa
|
|
220 |
*/
|
|
221 |
TI_STATUS fwEvent_Init (TI_HANDLE hFwEvent, TI_HANDLE hTWD)
|
|
222 |
{
|
|
223 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
224 |
TTwd *pTWD = (TTwd *)hTWD;
|
|
225 |
TTxnStruct* pTxn;
|
|
226 |
|
|
227 |
pFwEvent->hTWD = hTWD;
|
|
228 |
pFwEvent->hOs = pTWD->hOs;
|
|
229 |
pFwEvent->hReport = pTWD->hReport;
|
|
230 |
pFwEvent->hContext = pTWD->hContext;
|
|
231 |
pFwEvent->hTwIf = pTWD->hTwIf;
|
|
232 |
pFwEvent->hHealthMonitor = pTWD->hHealthMonitor;
|
|
233 |
pFwEvent->hEventMbox = pTWD->hEventMbox;
|
|
234 |
pFwEvent->hCmdMbox = pTWD->hCmdMbox;
|
|
235 |
pFwEvent->hRxXfer = pTWD->hRxXfer;
|
|
236 |
pFwEvent->hTxHwQueue = pTWD->hTxHwQueue;
|
|
237 |
pFwEvent->hTxXfer = pTWD->hTxXfer;
|
|
238 |
pFwEvent->hTxResult = pTWD->hTxResult;
|
|
239 |
|
|
240 |
pFwEvent->eFwEventState = FW_EVENT_STATE_IDLE;
|
|
241 |
pFwEvent->uEventMask = 0;
|
|
242 |
pFwEvent->uEventVector = 0;
|
|
243 |
pFwEvent->bFwNotificationFlag = TI_FALSE;
|
|
244 |
|
|
245 |
pTxn = (TTxnStruct*)&pFwEvent->tMaskTxn.tTxnStruct;
|
|
246 |
TXN_PARAM_SET(pTxn, TXN_HIGH_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_WRITE, TXN_INC_ADDR)
|
|
247 |
BUILD_TTxnStruct(pTxn, HINT_MASK, pFwEvent->tMaskTxn.pData, REGISTER_SIZE, NULL, NULL)
|
|
248 |
|
|
249 |
pTxn = (TTxnStruct*)&pFwEvent->tUnMaskTxn.tTxnStruct;
|
|
250 |
TXN_PARAM_SET(pTxn, TXN_HIGH_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_WRITE, TXN_INC_ADDR)
|
|
251 |
BUILD_TTxnStruct(pTxn, HINT_MASK, pFwEvent->tUnMaskTxn.pData, REGISTER_SIZE, NULL, NULL)
|
|
252 |
|
|
253 |
#ifdef USE_SDIO_24M_WORKAROUND /* FW_STATUS moved from registers to memory area */
|
|
254 |
/* First txn is HINT_STT_CLR register */
|
|
255 |
pTxn = (TTxnStruct*)&pFwEvent->tFwStatusTxn.tTxnStruct;
|
|
256 |
TXN_PARAM_SET(pTxn, TXN_HIGH_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_READ, TXN_INC_ADDR)
|
|
257 |
BUILD_TTxnStruct(pTxn, ACX_REG_INTERRUPT_CLEAR, pFwEvent->tFwStatusTxn.pFwStatus, REGISTER_SIZE, NULL, NULL)
|
|
258 |
/* FW status from memory area */
|
|
259 |
pTxn = (TTxnStruct*)&pFwEvent->tMemFwStatusTxn.tTxnStruct;
|
|
260 |
TXN_PARAM_SET(pTxn, TXN_HIGH_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_READ, TXN_INC_ADDR)
|
|
261 |
BUILD_TTxnStruct(pTxn, FW_STATUS_MEM_ADDRESS, pFwEvent->tMemFwStatusTxn.pFwStatus, sizeof(FwStatus_t)-REGISTER_SIZE, (TTxnDoneCb)fwEvent_ReadCompleteCb, hFwEvent)
|
|
262 |
#else
|
|
263 |
pTxn = (TTxnStruct*)&pFwEvent->tFwStatusTxn.tTxnStruct;
|
|
264 |
TXN_PARAM_SET(pTxn, TXN_HIGH_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_READ, TXN_INC_ADDR)
|
|
265 |
BUILD_TTxnStruct(pTxn, ACX_REG_INTERRUPT_CLEAR, pFwEvent->tFwStatusTxn.pFwStatus, sizeof(FwStatus_t), (TTxnDoneCb)fwEvent_ReadCompleteCb, hFwEvent)
|
|
266 |
#endif
|
|
267 |
/*
|
|
268 |
* Register the FwEvent to the context engine and get the client ID.
|
|
269 |
* The FwEvent() will be called from the context_DriverTask() after scheduled
|
|
270 |
* by a FW-Interrupt (see fwEvent_InterruptRequest()).
|
|
271 |
*/
|
|
272 |
pFwEvent->uContextId = context_RegisterClient (pFwEvent->hContext,
|
|
273 |
fwEvent_Handle,
|
|
274 |
hFwEvent,
|
|
275 |
TI_FALSE,
|
|
276 |
"FW_EVENT",
|
|
277 |
sizeof("FW_EVENT"));
|
|
278 |
|
|
279 |
return TI_OK;
|
|
280 |
}
|
|
281 |
|
|
282 |
|
|
283 |
/*
|
|
284 |
* \brief Call FwEvent client's event handler
|
|
285 |
*
|
|
286 |
* \param hFwEvent - FwEvent Driver handle
|
|
287 |
* \return void
|
|
288 |
*
|
|
289 |
* \par Description
|
|
290 |
*
|
|
291 |
* \sa fwEvent_ReadCompleteCb
|
|
292 |
*/
|
|
293 |
static void fwEvent_CallHandler (TI_HANDLE hFwEvent)
|
|
294 |
{
|
|
295 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
296 |
|
|
297 |
if (pFwEvent->uEventVector & ACX_INTR_WATCHDOG)
|
|
298 |
{
|
|
299 |
/* Fw watchdog timeout has occured */
|
|
300 |
TWD_WdExpireEvent (pFwEvent->hTWD);
|
|
301 |
}
|
|
302 |
|
|
303 |
if (pFwEvent->uEventVector & ACX_INTR_INIT_COMPLETE)
|
|
304 |
{
|
|
305 |
TRACE0(pFwEvent->hReport, REPORT_SEVERITY_INFORMATION, "fwEvent_CallHandler: INIT_COMPLETE\n");
|
|
306 |
}
|
|
307 |
/* Change to handle the command MBOX before the event MBOX to maintain order for WHA command response
|
|
308 |
* and follow command complete
|
|
309 |
*/
|
|
310 |
if (pFwEvent->uEventVector & ACX_INTR_CMD_COMPLETE)
|
|
311 |
{
|
|
312 |
/* Command Mbox completed */
|
|
313 |
cmdMbox_CommandComplete(pFwEvent->hCmdMbox);
|
|
314 |
}
|
|
315 |
if (pFwEvent->uEventVector & ACX_INTR_EVENT_A)
|
|
316 |
{
|
|
317 |
eventMbox_Handle(pFwEvent->hEventMbox,(FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus));
|
|
318 |
}
|
|
319 |
if (pFwEvent->uEventVector & ACX_INTR_EVENT_B)
|
|
320 |
{
|
|
321 |
eventMbox_Handle(pFwEvent->hEventMbox,(FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus));
|
|
322 |
}
|
|
323 |
|
|
324 |
|
|
325 |
/* The DATA interrupt is shared by all data path events, so call all Tx and Rx clients */
|
|
326 |
if (pFwEvent->uEventVector & ACX_INTR_DATA)
|
|
327 |
{
|
|
328 |
rxXfer_RxEvent (pFwEvent->hRxXfer, (FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus));
|
|
329 |
|
|
330 |
txHwQueue_UpdateFreeResources (pFwEvent->hTxHwQueue, (FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus));
|
|
331 |
|
|
332 |
txResult_TxCmpltIntrCb (pFwEvent->hTxResult, (FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus));
|
|
333 |
}
|
|
334 |
|
|
335 |
/* After handling all raised bits, we can negate them */
|
|
336 |
((FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus))->intrStatus &= pFwEvent->uEventMask;
|
|
337 |
}
|
|
338 |
|
|
339 |
|
|
340 |
/*
|
|
341 |
* \brief Requests the context engine to schedule the driver task
|
|
342 |
*
|
|
343 |
* \param hFwEvent - FwEvent Driver handle
|
|
344 |
* \return void
|
|
345 |
*
|
|
346 |
* \par Description
|
|
347 |
* Called by the FW-Interrupt ISR.
|
|
348 |
* Requests the context engine to schedule the driver task
|
|
349 |
* for handling the FW-Events (FwEvent callback).
|
|
350 |
*
|
|
351 |
* \sa
|
|
352 |
*/
|
|
353 |
void fwEvent_InterruptRequest (TI_HANDLE hFwEvent)
|
|
354 |
{
|
|
355 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
356 |
|
|
357 |
/* Request switch to driver context for handling the FW-Interrupt event */
|
|
358 |
context_RequestSchedule (pFwEvent->hContext, pFwEvent->uContextId);
|
|
359 |
}
|
|
360 |
|
|
361 |
|
|
362 |
/*
|
|
363 |
* \brief Handle the FW interrupts
|
|
364 |
*
|
|
365 |
* \param hFwEvent - FwEvent Driver handle
|
|
366 |
* \return void
|
|
367 |
*
|
|
368 |
* \par Description
|
|
369 |
* Called from context module upon receiving FW interrupt
|
|
370 |
* The function mask the interrupts and reads the FW status
|
|
371 |
*
|
|
372 |
* \sa
|
|
373 |
*/
|
|
374 |
|
|
375 |
void fwEvent_Handle (TI_HANDLE hFwEvent)
|
|
376 |
{
|
|
377 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
378 |
ETxnStatus rc;
|
|
379 |
|
|
380 |
/* NOTE: pFwEvent may be uninitialized at init stage */
|
|
381 |
if (pFwEvent != NULL)
|
|
382 |
{
|
|
383 |
if (pFwEvent->eFwEventState != FW_EVENT_STATE_IDLE)
|
|
384 |
{
|
|
385 |
os_InterruptServiced (pFwEvent->hOs);
|
|
386 |
twIf_HwAvailable(pFwEvent->hTwIf);
|
|
387 |
return;
|
|
388 |
}
|
|
389 |
|
|
390 |
pFwEvent->eFwEventState = FW_EVENT_STATE_READING;
|
|
391 |
pFwEvent->bFwNotificationFlag = TI_TRUE;
|
|
392 |
|
|
393 |
twIf_Awake(pFwEvent->hTwIf);
|
|
394 |
twIf_HwAvailable(pFwEvent->hTwIf);
|
|
395 |
|
|
396 |
/* Write HINT mask */
|
|
397 |
*((TI_UINT32*)(pFwEvent->tMaskTxn.pData)) = ACX_INTR_ALL;
|
|
398 |
TXN_FW_EVENT_SET_MASK_ADDR(pFwEvent)
|
|
399 |
twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tMaskTxn.tTxnStruct));
|
|
400 |
|
|
401 |
#ifdef USE_SDIO_24M_WORKAROUND /* FW_STATUS moved from registers to memory area */
|
|
402 |
/*
|
|
403 |
* Read first register (HINT_STT_CLR) only from registers area
|
|
404 |
*/
|
|
405 |
TXN_FW_EVENT_SET_STATUS_ADDR(pFwEvent)
|
|
406 |
twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tFwStatusTxn.tTxnStruct));
|
|
407 |
|
|
408 |
/*
|
|
409 |
* Read other 16 registers value from memory area FW_STATUS_MEM_ADDRESS
|
|
410 |
*/
|
|
411 |
TXN_FW_EVENT_SET_FW_MEM_ADDR(pFwEvent)
|
|
412 |
rc = twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tMemFwStatusTxn.tTxnStruct));
|
|
413 |
|
|
414 |
if (rc == TXN_STATUS_COMPLETE)
|
|
415 |
{
|
|
416 |
fwEvent_ReadCompleteCb(hFwEvent);
|
|
417 |
}
|
|
418 |
#else
|
|
419 |
|
|
420 |
/* Read the Fw status */
|
|
421 |
TXN_FW_EVENT_SET_STATUS_ADDR(pFwEvent)
|
|
422 |
rc = twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tFwStatusTxn.tTxnStruct));
|
|
423 |
|
|
424 |
if (rc == TXN_STATUS_COMPLETE)
|
|
425 |
{
|
|
426 |
fwEvent_ReadCompleteCb(hFwEvent);
|
|
427 |
}
|
|
428 |
#endif
|
|
429 |
}
|
|
430 |
else
|
|
431 |
{
|
|
432 |
os_InterruptServiced (pFwEvent->hOs);
|
|
433 |
|
|
434 |
/* end of if */
|
|
435 |
}
|
|
436 |
}
|
|
437 |
|
|
438 |
|
|
439 |
/*
|
|
440 |
* \brief Handle the Fw Status information
|
|
441 |
*
|
|
442 |
* \param hFwEvent - FwEvent Driver handle
|
|
443 |
* \return void
|
|
444 |
*
|
|
445 |
* \par Description
|
|
446 |
* This function is called from fwEvent_Handle on a sync read, or from TwIf as a CB on an async read.
|
|
447 |
* It calls fwEvent_CallHandler to handle the triggered interrupts.
|
|
448 |
*
|
|
449 |
* \sa fwEvent_Handle
|
|
450 |
*/
|
|
451 |
void fwEvent_ReadCompleteCb (TI_HANDLE hFwEvent)
|
|
452 |
{
|
|
453 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
454 |
|
|
455 |
#ifdef USE_SDIO_24M_WORKAROUND /* FW_STATUS moved from registers to memory area */
|
|
456 |
/*
|
|
457 |
* copy FW status 16 registers values from memory transaction read area to the original place
|
|
458 |
*/
|
|
459 |
os_memoryCopy (pFwEvent->hOs, &((FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus))->counters, &((FwStatus_t*)(pFwEvent->tMemFwStatusTxn.pFwStatus))->counters, sizeof(FwStatus_t)-REGISTER_SIZE);
|
|
460 |
#endif
|
|
461 |
|
|
462 |
os_InterruptServiced (pFwEvent->hOs);
|
|
463 |
|
|
464 |
/* If we were called because of an interrupt */
|
|
465 |
if (pFwEvent->bFwNotificationFlag)
|
|
466 |
{
|
|
467 |
/* In case of level interrupt we need to clear the line */
|
|
468 |
/*os_InterruptServiced(pFwEvent->hOs);*/
|
|
469 |
|
|
470 |
/*
|
|
471 |
* Sync to fw time so we can update the tx packets
|
|
472 |
* on the delta time that they spent in the driver
|
|
473 |
*/
|
|
474 |
pFwEvent->uFwTimeOffset = (os_timeStampMs (pFwEvent->hOs) * 1000) -
|
|
475 |
ENDIAN_HANDLE_LONG (((FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus))->fwLocalTime);
|
|
476 |
|
|
477 |
pFwEvent->bFwNotificationFlag = TI_FALSE;
|
|
478 |
}
|
|
479 |
|
|
480 |
pFwEvent->uEventVector = ((FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus))->intrStatus;
|
|
481 |
|
|
482 |
/*
|
|
483 |
* Mask unwanted interrupts.
|
|
484 |
*/
|
|
485 |
pFwEvent->uEventVector &= pFwEvent->uEventMask;
|
|
486 |
|
|
487 |
fwEvent_CallHandler(hFwEvent);
|
|
488 |
|
|
489 |
/* Check if the state is changed in the context of the event callbacks */
|
|
490 |
if (pFwEvent->eFwEventState == FW_EVENT_STATE_IDLE)
|
|
491 |
{
|
|
492 |
/*
|
|
493 |
* When fwEvent_stop is called state is changed to IDLE
|
|
494 |
* This is done in the context of the above events callbacks
|
|
495 |
* Don't send the UNMASK transaction because the driver stop process includes power off
|
|
496 |
*/
|
|
497 |
TRACE0(pFwEvent->hReport, REPORT_SEVERITY_WARNING, "fwEvent_ReadCompleteCb : State is IDLE ! don't send the UNMASK");
|
|
498 |
return;
|
|
499 |
}
|
|
500 |
|
|
501 |
/* Write HINT unmask */
|
|
502 |
*((TI_UINT32*)(pFwEvent->tUnMaskTxn.pData)) = ~pFwEvent->uEventMask;
|
|
503 |
TXN_FW_EVENT_SET_UNMASK_ADDR(pFwEvent)
|
|
504 |
twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tUnMaskTxn.tTxnStruct));
|
|
505 |
|
|
506 |
twIf_Sleep(pFwEvent->hTwIf);
|
|
507 |
pFwEvent->eFwEventState = FW_EVENT_STATE_IDLE;
|
|
508 |
}
|
|
509 |
|
|
510 |
|
|
511 |
/*
|
|
512 |
* \brief Translate host to FW time (Usec)
|
|
513 |
*
|
|
514 |
* \param hFwEvent - FwEvent Driver handle
|
|
515 |
* \param uHostTime - The host time in MS to translate
|
|
516 |
*
|
|
517 |
* \return FW Time in Usec
|
|
518 |
*
|
|
519 |
* \par Description
|
|
520 |
*
|
|
521 |
* \sa
|
|
522 |
*/
|
|
523 |
TI_UINT32 fwEvent_TranslateToFwTime (TI_HANDLE hFwEvent, TI_UINT32 uHostTime)
|
|
524 |
{
|
|
525 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
526 |
|
|
527 |
return ((uHostTime * 1000) - pFwEvent->uFwTimeOffset);
|
|
528 |
}
|
|
529 |
|
|
530 |
|
|
531 |
/*
|
|
532 |
* \brief Unmask only cmd-cmplt and events interrupts (needed for init phase)
|
|
533 |
*
|
|
534 |
* \param hFwEvent - FwEvent Driver handle
|
|
535 |
* \return Event mask
|
|
536 |
*
|
|
537 |
* \par Description
|
|
538 |
* Unmask only cmd-cmplt and events interrupts (needed for init phase)
|
|
539 |
* and return interrupt enabled bit mask.
|
|
540 |
*
|
|
541 |
* \sa
|
|
542 |
*/
|
|
543 |
TI_UINT32 fwEvent_GetInitMask (TI_HANDLE hFwEvent)
|
|
544 |
{
|
|
545 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
546 |
|
|
547 |
/* Unmask only the interrupts needed for the FW configuration process. */
|
|
548 |
pFwEvent->uEventMask = ACX_INTR_CMD_COMPLETE | ACX_INTR_EVENT_A | ACX_INTR_EVENT_B;
|
|
549 |
|
|
550 |
return pFwEvent->uEventMask;
|
|
551 |
}
|
|
552 |
|
|
553 |
|
|
554 |
/*
|
|
555 |
* \brief Stop & reset FwEvent (called by the driver stop process)
|
|
556 |
*
|
|
557 |
* \param hFwEvent - FwEvent Driver handle
|
|
558 |
* \return TI_OK
|
|
559 |
*
|
|
560 |
* \par Description
|
|
561 |
*
|
|
562 |
* \sa
|
|
563 |
*/
|
|
564 |
TI_STATUS fwEvent_Stop (TI_HANDLE hFwEvent)
|
|
565 |
{
|
|
566 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
567 |
|
|
568 |
pFwEvent->eFwEventState = FW_EVENT_STATE_IDLE;
|
|
569 |
((FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus))->intrStatus = 0;
|
|
570 |
pFwEvent->uEventMask = 0;
|
|
571 |
pFwEvent->bFwNotificationFlag = TI_FALSE;
|
|
572 |
pFwEvent->uEventVector = 0;
|
|
573 |
|
|
574 |
return TI_OK;
|
|
575 |
}
|
|
576 |
|
|
577 |
|
|
578 |
/*
|
|
579 |
* \brief Unmask all interrupts, set Rx interrupt bit and call FwEvent_Handle
|
|
580 |
*
|
|
581 |
* \param hFwEvent - FwEvent Driver handle
|
|
582 |
* \return void
|
|
583 |
*
|
|
584 |
* \par Description
|
|
585 |
* Called when driver Start or recovery process is completed.
|
|
586 |
* Unmask all interrupts, set Rx interrupt bit and call FwEvent_Handle
|
|
587 |
* (in case we missed an Rx interrupt in a recovery process).
|
|
588 |
*
|
|
589 |
* \sa
|
|
590 |
*/
|
|
591 |
void fwEvent_EnableExternalEvents (TI_HANDLE hFwEvent)
|
|
592 |
{
|
|
593 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
594 |
|
|
595 |
/* Unmask all interrupts */
|
|
596 |
pFwEvent->uEventMask = ALL_EVENTS_VECTOR;
|
|
597 |
|
|
598 |
/* Set Rx interrupt bit to invoke it (in case we missed it in a recovery/start process) */
|
|
599 |
((FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus))->intrStatus |= ACX_INTR_DATA;
|
|
600 |
|
|
601 |
/* If in IDLE state, handle interrupts including the Rx we've just set manually */
|
|
602 |
if (pFwEvent->eFwEventState == FW_EVENT_STATE_IDLE)
|
|
603 |
{
|
|
604 |
fwEvent_GetFwStatus (hFwEvent);
|
|
605 |
}
|
|
606 |
}
|
|
607 |
|
|
608 |
|
|
609 |
/*
|
|
610 |
* \brief Disable the FwEvent client of the context thread handler
|
|
611 |
*
|
|
612 |
* \param hFwEvent - FwEvent Driver handle
|
|
613 |
* \return void
|
|
614 |
*
|
|
615 |
* \par Description
|
|
616 |
*
|
|
617 |
* \sa
|
|
618 |
*/
|
|
619 |
void fwEvent_DisableInterrupts(TI_HANDLE hFwEvent)
|
|
620 |
{
|
|
621 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
622 |
|
|
623 |
context_DisableClient (pFwEvent->hContext,pFwEvent->uContextId);
|
|
624 |
|
|
625 |
}
|
|
626 |
|
|
627 |
|
|
628 |
/*
|
|
629 |
* \brief Enable the FwEvent client of the context thread handler
|
|
630 |
*
|
|
631 |
* \param hFwEvent - FwEvent Driver handle
|
|
632 |
* \return void
|
|
633 |
*
|
|
634 |
* \par Description
|
|
635 |
*
|
|
636 |
* \sa
|
|
637 |
*/
|
|
638 |
void fwEvent_EnableInterrupts(TI_HANDLE hFwEvent)
|
|
639 |
{
|
|
640 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
641 |
|
|
642 |
context_EnableClient (pFwEvent->hContext,pFwEvent->uContextId);
|
|
643 |
|
|
644 |
}
|
|
645 |
|
|
646 |
|
|
647 |
/*
|
|
648 |
* \brief Issue a FW status read (Not in response to any FW interrupt)
|
|
649 |
*
|
|
650 |
* \param hFwEvent - FwEvent Driver handle
|
|
651 |
* \return void
|
|
652 |
*
|
|
653 |
* \par Description
|
|
654 |
* Issue a FW status read (Not in response to any FW interrupt)
|
|
655 |
* Called also from fwEvent_EnableExternalEvents after recovery.
|
|
656 |
*
|
|
657 |
* \sa fwEvent_EnableExternalEvents
|
|
658 |
*/
|
|
659 |
void fwEvent_GetFwStatus (TI_HANDLE hFwEvent)
|
|
660 |
{
|
|
661 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
662 |
ETxnStatus rc;
|
|
663 |
|
|
664 |
/* NOTE: pFwEvent may be uninitialized at init stage */
|
|
665 |
if (pFwEvent != NULL)
|
|
666 |
{
|
|
667 |
if (pFwEvent->eFwEventState != FW_EVENT_STATE_IDLE)
|
|
668 |
{
|
|
669 |
twIf_HwAvailable(pFwEvent->hTwIf);
|
|
670 |
return;
|
|
671 |
}
|
|
672 |
|
|
673 |
pFwEvent->eFwEventState = FW_EVENT_STATE_READING;
|
|
674 |
|
|
675 |
twIf_Awake(pFwEvent->hTwIf);
|
|
676 |
|
|
677 |
/* Write HINT mask */
|
|
678 |
*((TI_UINT32*)(pFwEvent->tMaskTxn.pData)) = ACX_INTR_ALL;
|
|
679 |
TXN_FW_EVENT_SET_MASK_ADDR(pFwEvent)
|
|
680 |
twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tMaskTxn.tTxnStruct));
|
|
681 |
|
|
682 |
#ifdef USE_SDIO_24M_WORKAROUND /* FW_STATUS moved from registers to memory area */
|
|
683 |
/*
|
|
684 |
* Read first register (HINT_STT_CLR) only from registers area
|
|
685 |
*/
|
|
686 |
TXN_FW_EVENT_SET_STATUS_ADDR(pFwEvent)
|
|
687 |
twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tFwStatusTxn.tTxnStruct));
|
|
688 |
|
|
689 |
/*
|
|
690 |
* Read other 16 registers value from memory area 0x40200
|
|
691 |
*/
|
|
692 |
TXN_FW_EVENT_SET_FW_MEM_ADDR(pFwEvent)
|
|
693 |
rc = twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tMemFwStatusTxn.tTxnStruct));
|
|
694 |
|
|
695 |
if (rc == TXN_STATUS_COMPLETE)
|
|
696 |
{
|
|
697 |
fwEvent_ReadCompleteCb(hFwEvent);
|
|
698 |
}
|
|
699 |
#else
|
|
700 |
/* Read the Fw status */
|
|
701 |
TXN_FW_EVENT_SET_STATUS_ADDR(pFwEvent)
|
|
702 |
rc = twIf_Transact(pFwEvent->hTwIf, &(pFwEvent->tFwStatusTxn.tTxnStruct));
|
|
703 |
|
|
704 |
if (rc == TXN_STATUS_COMPLETE)
|
|
705 |
{
|
|
706 |
fwEvent_ReadCompleteCb(hFwEvent);
|
|
707 |
}
|
|
708 |
#endif
|
|
709 |
/* end of if */
|
|
710 |
}
|
|
711 |
}
|
|
712 |
|
|
713 |
|
|
714 |
#ifdef TI_DBG
|
|
715 |
|
|
716 |
void fwEvent_PrintStat (TI_HANDLE hFwEvent)
|
|
717 |
{
|
|
718 |
TfwEvent *pFwEvent = (TfwEvent *)hFwEvent;
|
|
719 |
FwStatus_t *fwStat = (FwStatus_t*)(pFwEvent->tFwStatusTxn.pFwStatus);
|
|
720 |
int i;
|
|
721 |
|
|
722 |
WLAN_OS_REPORT(("Print FW event module info\n"));
|
|
723 |
WLAN_OS_REPORT(("==========================\n"));
|
|
724 |
WLAN_OS_REPORT(("intrStatus = 0x%08x\n", fwStat->intrStatus));
|
|
725 |
WLAN_OS_REPORT(("counters = 0x%08x\n", fwStat->counters));
|
|
726 |
for (i = 0; i < NUM_RX_PKT_DESC; i++)
|
|
727 |
{
|
|
728 |
WLAN_OS_REPORT(("rxPktsDesc[%1d] = 0x%08x\n", i, fwStat->rxPktsDesc[i]));
|
|
729 |
}
|
|
730 |
for (i = 0; i < NUM_TX_QUEUES; i++)
|
|
731 |
{
|
|
732 |
WLAN_OS_REPORT(("txReleasedBlks[%1d] = 0x%08x\n", i, fwStat->txReleasedBlks[i]));
|
|
733 |
}
|
|
734 |
WLAN_OS_REPORT(("fwLocalTime = 0x%08x\n", fwStat->fwLocalTime));
|
|
735 |
}
|
|
736 |
|
|
737 |
#endif /* TI_DBG */
|
|
738 |
|