2 /****************************************************************************
3 **+-----------------------------------------------------------------------+**
5 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
6 **| All rights reserved. |**
8 **| Redistribution and use in source and binary forms, with or without |**
9 **| modification, are permitted provided that the following conditions |**
12 **| * Redistributions of source code must retain the above copyright |**
13 **| notice, this list of conditions and the following disclaimer. |**
14 **| * Redistributions in binary form must reproduce the above copyright |**
15 **| notice, this list of conditions and the following disclaimer in |**
16 **| the documentation and/or other materials provided with the |**
18 **| * Neither the name Texas Instruments nor the names of its |**
19 **| contributors may be used to endorse or promote products derived |**
20 **| from this software without specific prior written permission. |**
22 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
23 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
24 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
25 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
26 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
27 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
28 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
29 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
30 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
31 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
32 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
34 **+-----------------------------------------------------------------------+**
35 ****************************************************************************/
37 /*********************************************************************************/
39 /* MODULE: CmdMBox.h */
40 /* PURPOSE: Acx mailbox object api */
42 /**********************************************************************************/
46 #include "whalCommon.h"
47 #include "whalHwDefs.h"
49 /*****************************************************************************
51 *****************************************************************************/
52 /* wait for a Mail box command to complete */
53 #define CMDMBOX_WAIT_TIMEOUT 500 /* ms */
55 #define CMDMBOX_HEADER_LEN 4
56 #define CMDMBOX_INFO_ELEM_HEADER_LEN 4
57 #define CMDMBOX_WAIT_CMPLT_STALL_TIME 50 /* us */
58 #define CMDMBOX_US_TO_MS 1000
60 /*****************************************************************************
62 *****************************************************************************/
65 CMDMBOX_EVENT_SEND_CMD,
66 CMDMBOX_EVENT_CMD_CMPLT,
67 CMDMBOX_EVENT_BUS_READY,
68 CMDMBOX_EVENT_TXN_CMPLT,
69 CMDMBOX_EVENT_GET_RESULT,
75 CMDMBOX_STATE_SENDCMD_NORMAL_IDLE = 0,
76 CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_BUS,
77 CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_BUF,
78 CMDMBOX_STATE_SENDCMD_NORMAL_WRITE_TRIG_v,
79 CMDMBOX_STATE_SENDCMD_NORMAL_WAIT_TXN_TRIG,
80 } CmdMBox_SMStates_SendCmd_Normal_e;
84 CMDMBOX_STATE_SENDCMD_BLOCKING_IDLE = 10,
85 CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_BUS,
86 CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_BUF,
87 CMDMBOX_STATE_SENDCMD_BLOCKING_WRITE_TRIG_v,
88 CMDMBOX_STATE_SENDCMD_BLOCKING_WAIT_TXN_TRIG,
89 CMDMBOX_STATE_SENDCMD_BLOCKING_POLL_CMPLT_v,
90 CMDMBOX_STATE_SENDCMD_BLOCKING_FINISH_v,
91 } CmdMBox_SMStates_SendCmd_Blocking_e;
95 CMDMBOX_STATE_GETRESULT_NORMAL_IDLE = 20,
96 CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN,
97 } CmdMBox_SMStates_GetResult_Normal_e;
101 CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE = 30,
102 CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN,
104 } CmdMBox_SMStates_GetResult_Blocking_e;
106 /*****************************************************************************
108 *****************************************************************************/
109 typedef struct _CmdMBox_T CmdMBox_T;
110 typedef int (*SM_Func_t)(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
113 /*****************************************************************************
115 *****************************************************************************/
128 CmdMBox_SMStates_GetResult_Normal_e GetResultNormal_State;
129 CmdMBox_SMStates_GetResult_Blocking_e GetResultBlocking_State;
130 CmdMBox_SMStates_SendCmd_Normal_e SendCmdNormal_State;
131 CmdMBox_SMStates_SendCmd_Blocking_e SendCmdBlocking_State;
134 SM_Func_t GetResultSM;
137 /* use a struct to read buffers from the bus - used for extra bytes reserving */
138 PADDING (Command_t HW_CmdMBox)
140 UINT32 CmdMBox_FW_address;
143 UINT8* GetResult_ParamsBuf;
144 UINT32 GetResult_ParamsLen;
148 TNETWIF_callback_t fCb;
152 /*****************************************************************************
153 ** Internal functions definitions **
154 *****************************************************************************/
155 int CmdMBox_SM_GetResultNormal(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
156 int CmdMBox_SM_GetResultBlocking(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
157 int CmdMBox_SM_SendCmdNormal(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
158 int CmdMBox_SM_SendCmdBlocking(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
160 /*****************************************************************************
161 ** CB functions definitions **
162 *****************************************************************************/
163 void CmdMBox_TimeOut(TI_HANDLE hCmdMBox);
164 void CmdMBox_TxnCmplt(TI_HANDLE hCmdMBox, UINT8 module_id ,TI_STATUS status);
165 void CmdMBox_BusReady(TI_HANDLE hCmdMBox, UINT8 module_id ,TI_STATUS status);