1 /* 2 * CmdMBox_api.h 3 * 4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name Texas Instruments nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 35 /** \file CmdMBox_api.h 36 * \brief CmdMbox api 37 * 38 * \see CmdMBox.c 39 */ 40 41 #ifndef _CMDMBOX_API_H_ 42 #define _CMDMBOX_API_H_ 43 44 #include "TWDriverInternal.h" 45 46 47 /***************************************************************************** 48 ** Types ** 49 *****************************************************************************/ 50 typedef TI_STATUS (*TCmdMboxErrorCb) (TI_HANDLE hCmdQueue, TI_UINT32 command, TI_UINT32 status, void *param); 51 52 53 /***************************************************************************** 54 ** API functions definitions ** 55 *****************************************************************************/ 56 57 /* 58 * \brief Create the mailbox object 59 * 60 * \param hOs - OS module object handle 61 * \return Handle to the created object 62 * 63 * \par Description 64 * Calling this function creates a CmdMbox object 65 * 66 * \sa cmdMbox_Destroy 67 */ 68 TI_HANDLE cmdMbox_Create (TI_HANDLE hOs); 69 70 71 /* 72 * \brief Destroys the mailbox object 73 * 74 * \param hCmdMbox - The object to free 75 * \return TI_OK 76 * 77 * \par Description 78 * Calling this function destroys a CmdMbox object 79 * 80 * \sa cmdMbox_Create 81 */ 82 TI_STATUS cmdMbox_Destroy (TI_HANDLE hCmdMbox); 83 84 85 /* 86 * \brief Configure the CmdMbox object 87 * 88 * \param hCmdMbox - Handle to CmdMbox 89 * \param hReport - Handle to report module 90 * \param hTwIf - Handle to TwIf 91 * \param hTimer - Handle to os timer 92 * \param hCmdQueue - Handle to CmdQueue 93 * \param fErrorCb - Handle to error handling function 94 * \return TI_OK on success or TI_NOK on failure 95 * 96 * \par Description 97 * 98 * \sa 99 */ 100 TI_STATUS cmdMbox_Init (TI_HANDLE hCmdMbox, 101 TI_HANDLE hReport, 102 TI_HANDLE hTwIf, 103 TI_HANDLE hTimer, 104 TI_HANDLE hCmdQueue, 105 TCmdMboxErrorCb fErrorCb); 106 107 108 /* 109 * \brief configure the mailbox address. 110 * 111 * \param hCmdMbox - Handle to CmdMbox 112 * \param fCb - Pointer to the CB 113 * \param hCb - Cb's handle 114 * \return TI_OK or TI_PENDING 115 * 116 * \par Description 117 * Called from HwInit to read the command mailbox address. 118 * 119 * \sa 120 */ 121 TI_STATUS cmdMbox_ConfigHw (TI_HANDLE hCmdMbox, fnotify_t fCb, TI_HANDLE hCb); 122 123 124 /* 125 * \brief Send the Command to the Mailbox 126 * 127 * \param hCmdMbox - Handle to CmdMbox 128 * \param cmdType - 129 * \param pParamsBuf - The buffer that will be written to the mailbox 130 * \param uWriteLen - Length of data to write to the mailbox 131 * \param uReadLen - Length of data to read from the mailbox (when the result is received) 132 * \return TI_PENDING 133 * 134 * \par Description 135 * Copy the buffer given to a local struct, update the write & read lengths 136 * and send to the FW's mailbox. 137 * 138 * ------------------------------------------------------ 139 * | CmdMbox Header | Cmd Header | Command parameters | 140 * ------------------------------------------------------ 141 * | ID | Status | Type | Length | Command parameters | 142 * ------------------------------------------------------ 143 * 16bit 16bit 16bit 16bit 144 * 145 * \sa cmdMbox_CommandComplete 146 */ 147 TI_STATUS cmdMbox_SendCommand (TI_HANDLE hCmdMbox, Command_e cmdType, TI_UINT8* pParamsBuf, TI_UINT32 uWriteLen, TI_UINT32 uReadLen); 148 149 150 /* 151 * \brief Read the command's result 152 * 153 * \param hCmdMbox - Handle to CmdMbox 154 * \return void 155 * 156 * \par Description 157 * This function is called for FwEvent module uppon receiving command complete interrupt. 158 * It issues a read transaction from the mailbox with a CB. 159 * 160 * \sa cmdMbox_SendCommand, cmdMbox_TransferComplete 161 */ 162 ETxnStatus cmdMbox_CommandComplete (TI_HANDLE hCmdMbox); 163 164 165 /* 166 * \brief Calls the cmdQueue_ResultReceived. 167 * 168 * \param hCmdMbox - Handle to CmdMbox 169 * \return TI_OK 170 * 171 * \par Description 172 * This function is called from cmdMbox_CommandComplete on a sync read, or from TwIf as a CB on an async read. 173 * It calls cmdQueue_ResultReceived to continue the result handling procces & switch the bCmdInProgress flag to TI_FALSE, 174 * meaning other commands can be sent to the FW. 175 * 176 * \sa cmdMbox_SendCommand, cmdMbox_TransferComplete 177 */ 178 TI_STATUS cmdMbox_TransferComplete (TI_HANDLE hCmdMbox); 179 180 181 /* 182 * \brief Restart the module upon driver stop or restart 183 * 184 * \param hCmdMbox - Handle to CmdMbox 185 * \return TI_OK 186 * 187 * \par Description 188 * 189 * \sa 190 */ 191 TI_STATUS cmdMbox_Restart (TI_HANDLE hCmdMbox); 192 193 194 /* 195 * \brief Return the latest command status 196 * 197 * \param hCmdMbox - Handle to CmdMbox 198 * \return TI_OK or TI_NOK 199 * 200 * \par Description 201 * 202 * \sa 203 */ 204 TI_STATUS cmdMbox_GetStatus (TI_HANDLE hCmdMbox, CommandStatus_e *cmdStatus); 205 206 207 /* 208 * \brief Return the MBox address 209 * 210 * \param hCmdMbox - Handle to CmdMbox 211 * \return MBox address 212 * 213 * \par Description 214 * 215 * \sa 216 */ 217 TI_UINT32 cmdMbox_GetMboxAddress (TI_HANDLE hCmdMbox); 218 219 220 /* 221 * \brief Return the Command parameters buffer 222 * 223 * \param hCmdMbox - Handle to CmdMbox 224 * \param pParamBuf - Holds the returned buffer 225 * \return 226 * 227 * \par Description 228 * Copying the command's data to pParamBuf 229 * 230 * \sa 231 */ 232 void cmdMbox_GetCmdParams (TI_HANDLE hCmdMbox, TI_UINT8* pParamBuf); 233 234 235 #ifdef TI_DBG 236 void cmdMbox_PrintInfo (TI_HANDLE hCmdMbox); 237 #endif 238 239 240 #endif 241