Home | History | Annotate | Download | only in Cmd_MBox
      1 
      2 /****************************************************************************
      3 **+-----------------------------------------------------------------------+**
      4 **|                                                                       |**
      5 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
      6 **| All rights reserved.                                                  |**
      7 **|                                                                       |**
      8 **| Redistribution and use in source and binary forms, with or without    |**
      9 **| modification, are permitted provided that the following conditions    |**
     10 **| are met:                                                              |**
     11 **|                                                                       |**
     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         |**
     17 **|    distribution.                                                      |**
     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.      |**
     21 **|                                                                       |**
     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.  |**
     33 **|                                                                       |**
     34 **+-----------------------------------------------------------------------+**
     35 ****************************************************************************/
     36 
     37 /*********************************************************************************/
     38 /*                                                                                */
     39 /*   MODULE:  CmdMBox.h                                                       */
     40 /*   PURPOSE: Acx mailbox object api                                              */
     41 /*                                                                                */
     42 /**********************************************************************************/
     43 #ifndef _CMDMBOX_H_
     44 #define _CMDMBOX_H_
     45 
     46 #include "whalCommon.h"
     47 #include "whalHwDefs.h"
     48 
     49 /*****************************************************************************
     50  **         Defines                                                        **
     51  *****************************************************************************/
     52  /* wait for a Mail box command to complete  */
     53 #define CMDMBOX_WAIT_TIMEOUT    500 /* ms */
     54 
     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
     59 
     60 /*****************************************************************************
     61  **         Enums                                                    **
     62  *****************************************************************************/
     63 typedef enum
     64 {
     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,
     70     CMDMBOX_EVENT_NUM,
     71 } CmdMBox_SMEvents_e;
     72 
     73 typedef enum
     74 {
     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;
     81 
     82 typedef enum
     83 {
     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;
     92 
     93 typedef enum
     94 {
     95     CMDMBOX_STATE_GETRESULT_NORMAL_IDLE = 20,
     96     CMDMBOX_STATE_GETRESULT_NORMAL_WAIT_TXN,
     97 } CmdMBox_SMStates_GetResult_Normal_e;
     98 
     99 typedef enum
    100 {
    101     CMDMBOX_STATE_GETRESULT_BLOCKING_IDLE = 30,
    102     CMDMBOX_STATE_GETRESULT_BLOCKING_WAIT_TXN,
    103     CMDMBOX_STATE_NUM,
    104 } CmdMBox_SMStates_GetResult_Blocking_e;
    105 
    106 /*****************************************************************************
    107  **         Types                                                    **
    108  *****************************************************************************/
    109 typedef struct _CmdMBox_T CmdMBox_T;
    110 typedef int (*SM_Func_t)(CmdMBox_T* pCmdMBox, CmdMBox_SMEvents_e event);
    111 
    112 
    113 /*****************************************************************************
    114  **         Structures                                                      **
    115  *****************************************************************************/
    116 
    117 struct _CmdMBox_T
    118 {
    119     /* handles */
    120     TI_HANDLE               hOs;
    121     TI_HANDLE               hReport;
    122     TI_HANDLE               hTNETWIF;
    123     TI_HANDLE               hFwEvent;
    124     TI_HANDLE               hTimer;
    125     TI_HANDLE               hCmdQueue;
    126 
    127     /* SM */
    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;
    132     SM_Func_t               ActiveSM;
    133     SM_Func_t               SendCmdSM;
    134     SM_Func_t               GetResultSM;
    135 
    136     /* HW params */
    137     /* use a struct to read buffers from the bus - used for extra bytes reserving */
    138     PADDING (Command_t  HW_CmdMBox)
    139 
    140     UINT32                  CmdMBox_FW_address;
    141     UINT32                  CmdLen;
    142 
    143     UINT8*                  GetResult_ParamsBuf;
    144     UINT32                  GetResult_ParamsLen;
    145 
    146     BOOLEAN                 useOpt;
    147 
    148     TNETWIF_callback_t      fCb;
    149     TI_HANDLE               hCb;
    150 };
    151 
    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);
    159 
    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);
    166 
    167 #endif
    168