PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/hal/hl_ctrl/whalDebug.c

http://github.com/CyanogenMod/cm-kernel
C | 346 lines | 147 code | 49 blank | 150 comment | 6 complexity | 6d37ed4e567770e07d92b601c6d9c0ee MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 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. /****************************************************************************
  36. *
  37. * MODULE: whalDebug.c
  38. * PURPOSE: Handle Debug requests in the Hal
  39. *
  40. * Register Mac/Phy Read/Write
  41. * Register Dump
  42. * Register RxDump
  43. * Register TxDump
  44. * Debug trace print
  45. *
  46. ****************************************************************************/
  47. #include "whalCommon.h"
  48. #include "whalCtrl_api.h"
  49. #include "whalCtrl.h"
  50. #include "whalSecurity.h"
  51. #include "commonTypes.h"
  52. #include "CmdQueue_api.h"
  53. #include "whalBus_Api.h"
  54. #include "TNETW_Driver.h"
  55. /************************************************
  56. * definitions *
  57. ************************************************/
  58. #define BB_REGISTER_ADDR_BASE 0x820000 /*phony address used by host access*/
  59. /*
  60. * ----------------------------------------------------------------------------
  61. * Function : whalCtrlReadMacReg
  62. *
  63. * Input :
  64. * Output :
  65. * Process :
  66. * Note(s) : Done
  67. * -----------------------------------------------------------------------------
  68. */
  69. UINT32 whalCtrlReadMacReg(TI_HANDLE hWhalCtrl, UINT32 addr)
  70. {
  71. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  72. return whalBus_MacRegRead(pWhalCtrl->pHwCtrl->hWhalBus, addr);
  73. }
  74. /*
  75. * ----------------------------------------------------------------------------
  76. * Function : whalCtrlWriteMacReg
  77. *
  78. * Input :
  79. * Output :
  80. * Process :
  81. * Note(s) : Done
  82. * -----------------------------------------------------------------------------
  83. */
  84. void whalCtrlWriteMacReg(TI_HANDLE hWhalCtrl, UINT32 addr, UINT32 val)
  85. {
  86. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  87. whalBus_MacRegWrite(pWhalCtrl->pHwCtrl->hWhalBus, addr, val);
  88. }
  89. /*
  90. * ----------------------------------------------------------------------------
  91. * Function : whalCtrlReadPhyReg
  92. *
  93. * Input :
  94. * Output :
  95. * Process :
  96. * Note(s) : Done
  97. * -----------------------------------------------------------------------------
  98. */
  99. UINT32 whalCtrlReadPhyReg(TI_HANDLE hWhalCtrl, UINT32 addr)
  100. {
  101. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  102. return whalBus_PhyRegRead(pWhalCtrl->pHwCtrl->hWhalBus, addr);
  103. }
  104. /*
  105. * ----------------------------------------------------------------------------
  106. * Function : whalCtrlWritePhyReg
  107. *
  108. * Input :
  109. * Output :
  110. * Process :
  111. * Note(s) : Done
  112. * -----------------------------------------------------------------------------
  113. */
  114. void whalCtrlWritePhyReg(TI_HANDLE hWhalCtrl, UINT32 addr, UINT32 val)
  115. {
  116. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  117. whalBus_PhyRegWrite(pWhalCtrl->pHwCtrl->hWhalBus, addr, val);
  118. }
  119. /*
  120. * ----------------------------------------------------------------------------
  121. * Function : whalCtrl_PrintAll
  122. *
  123. * Input :
  124. * Output :
  125. * Process :
  126. * Note(s) : Done
  127. * -----------------------------------------------------------------------------
  128. */
  129. #ifdef TI_DBG
  130. void whalCtrl_PrintAll (TI_HANDLE hWhalCtrl)
  131. {
  132. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  133. WLAN_OS_REPORT((" whalCtrl_PrintAll: \n\n"));
  134. CmdQueue_Print(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue);
  135. whalBus_PrintInfo(pWhalCtrl->hWhalBus, BUS_PRINT_ALL, 0);
  136. whal_hwInfoElemMemoryMapPrint(pWhalCtrl->pHwCtrl->pHwMboxConfig);
  137. whal_hwInfoElemStatisticsPrint(pWhalCtrl->pHwCtrl->pHwMboxConfig);
  138. whal_ParamsHwNvramPrint(pWhalCtrl->pWhalParams);
  139. }
  140. #endif
  141. /*
  142. * ----------------------------------------------------------------------------
  143. * Function : whalCtrl_getMaxNumberOfCommandsInQueue
  144. *
  145. * Input :
  146. * Output :
  147. * Process : returns the maximum number of commands in the mailbox queue ever
  148. * Note(s) : Done
  149. * -----------------------------------------------------------------------------
  150. */
  151. int whalCtrl_getMaxNumberOfCommandsInQueue (TI_HANDLE hWhalCtrl)
  152. {
  153. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  154. return (CmdQueue_GetMaxNumberOfCommands(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue));
  155. }
  156. /*
  157. * ----------------------------------------------------------------------------
  158. * Function : whalCtrl_PrintMailBoxHistory
  159. *
  160. * Input :
  161. * Output :
  162. * Process : Prints the mailbox command history
  163. * Note(s) : Done
  164. * -----------------------------------------------------------------------------
  165. */
  166. void whalCtrl_PrintMailBoxHistory (TI_HANDLE hWhalCtrl)
  167. {
  168. #ifdef TI_DBG
  169. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  170. CmdQueue_PrintHistory(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, 5);
  171. #endif
  172. }
  173. /*
  174. * ----------------------------------------------------------------------------
  175. * Function : whalCtrl_PrintMem_Regs_CB
  176. *
  177. * Input :
  178. * Output :
  179. * Process :
  180. * Note(s) : Done
  181. * -----------------------------------------------------------------------------
  182. */
  183. void whalCtrl_PrintMem_Regs_CB (TI_HANDLE hWhalCtrl, UINT32 cmdCbStatus)
  184. {
  185. int i;
  186. UINT8 *pBuf;
  187. UINT32 result;
  188. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  189. if (cmdCbStatus != OK)
  190. {
  191. WLAN_OS_REPORT((" whalCtrl_PrintMem_Regs_CB: command complete error \n\n"));
  192. return;
  193. }
  194. result = (((UINT32)pWhalCtrl->printRegsBuf.addr)&0xFFFF0000);
  195. switch (result)
  196. {
  197. case ACX_MAC_REG_READ_WRITE_PREFIX:
  198. WLAN_OS_REPORT(("MAC REGS (Base=0x%08x) = 0x%08x\n", ((UINT32)pWhalCtrl->printRegsBuf.addr)&0xFFFF,
  199. *(UINT32*)(pWhalCtrl->printRegsBuf.value)));
  200. break;
  201. case BB_REGISTER_ADDR_BASE:
  202. WLAN_OS_REPORT(("PHY REGS (Base=0x%08x) = 0x%08x\n", ((UINT32)pWhalCtrl->printRegsBuf.addr)&0xFFFF,
  203. *(UINT32*)(pWhalCtrl->printRegsBuf.value)));
  204. break;
  205. default: /* Memory*/
  206. for (i=0, pBuf=pWhalCtrl->printRegsBuf.value; i<256; i+=16, pBuf+=16)
  207. {
  208. WLAN_REPORT_REPLY(pWhalCtrl->hReport, HAL_HW_CTRL_MODULE_LOG,
  209. ("PrintBuf: 0x%08x: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n",
  210. pWhalCtrl->printRegsBuf.addr+i,
  211. pBuf[0], pBuf[1], pBuf[2], pBuf[3], pBuf[4], pBuf[5], pBuf[6], pBuf[7],
  212. pBuf[8], pBuf[9], pBuf[10], pBuf[11], pBuf[12], pBuf[13], pBuf[14], pBuf[15]));
  213. }
  214. break;
  215. }
  216. }
  217. /*
  218. * ----------------------------------------------------------------------------
  219. * Function : whalCtrl_Print_Mem_Regs
  220. *
  221. * Input :
  222. * Output :
  223. * Process :
  224. * Note(s) : Reading from memory or registers is done through IE (interrogate)
  225. * -----------------------------------------------------------------------------
  226. */
  227. void whalCtrl_Print_Mem_Regs (TI_HANDLE hWhalCtrl, UINT32 address, UINT32 len, readWrite_MemoryType_e memType)
  228. {
  229. ReadWriteCommand_t AcxCmd_ReadMemory;
  230. ReadWriteCommand_t* pCmd = &AcxCmd_ReadMemory;
  231. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  232. os_memoryZero(pWhalCtrl->hOs, (void *)pCmd, sizeof(*pCmd));
  233. switch (memType)
  234. {
  235. case TNETW_INTERNAL_RAM:
  236. pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(address);
  237. pCmd->size = ENDIAN_HANDLE_LONG(len);
  238. break;
  239. case TNETW_MAC_REGISTERS:
  240. pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(( (address&0xFFFF) | ACX_MAC_REG_READ_WRITE_PREFIX ));
  241. pCmd->size = 4;
  242. break;
  243. case TNETW_PHY_REGISTERS:
  244. pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(( (address&0xFFFF) | BB_REGISTER_ADDR_BASE ));
  245. pCmd->size = 4;
  246. break;
  247. default:
  248. WLAN_OS_REPORT((" whalCtrl_Print_Mem_Regs: ERROR, wrong memory type %d\n\n", memType));
  249. return;
  250. }
  251. os_memoryZero (pWhalCtrl->hOs, (void *)&pWhalCtrl->printRegsBuf, sizeof(pWhalCtrl->printRegsBuf));
  252. CmdQueue_CommandWithCb(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, CMD_READ_MEMORY, (char *)pCmd,
  253. sizeof(*pCmd), (void *)whalCtrl_PrintMem_Regs_CB, hWhalCtrl,
  254. &pWhalCtrl->printRegsBuf);
  255. }
  256. /*
  257. * ----------------------------------------------------------------------------
  258. * Function : whalCtrl_Set_Mem_Regs
  259. *
  260. * Input :
  261. * Output :
  262. * Process :
  263. * Note(s) : Writing to memory or registers is done through command to the ACX
  264. * This function overrides the len parameter and write only 4 bytes!
  265. * -----------------------------------------------------------------------------
  266. */
  267. int whalCtrl_Set_Mem_Regs (TI_HANDLE hWhalCtrl, UINT32 address, UINT32 len, UINT32 aWriteVal,
  268. readWrite_MemoryType_e memType)
  269. {
  270. WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
  271. ReadWriteCommand_t AcxCmd_WriteMemory;
  272. ReadWriteCommand_t* pCmd = &AcxCmd_WriteMemory;
  273. os_memoryZero(pWhalCtrl->hOs, (void *)pCmd, sizeof(*pCmd));
  274. switch (memType)
  275. {
  276. case TNETW_INTERNAL_RAM:
  277. pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG(address);
  278. pCmd->size = ENDIAN_HANDLE_LONG(len);
  279. WLAN_OS_REPORT((" whalCtrl_Set_Mem_Regs: write to Internal Ram addr=0x%x Val=0x%x\n\n", pCmd->addr, aWriteVal));
  280. break;
  281. case TNETW_MAC_REGISTERS:
  282. pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG( (address&0xFFFF) | ACX_MAC_REG_READ_WRITE_PREFIX);
  283. pCmd->size = ENDIAN_HANDLE_LONG(len);
  284. WLAN_OS_REPORT((" whalCtrl_Set_Mem_Regs: write to Mac register addr=0x%x Val=0x%x\n\n", pCmd->addr, aWriteVal));
  285. break;
  286. case TNETW_PHY_REGISTERS:
  287. pCmd->addr = (UINT32)ENDIAN_HANDLE_LONG( (address&0xFFFF) | BB_REGISTER_ADDR_BASE);
  288. pCmd->size = ENDIAN_HANDLE_LONG(len);
  289. WLAN_OS_REPORT((" whalCtrl_Set_Mem_Regs: write to Phy register addr=0x%x Val=0x%x\n\n", pCmd->addr, aWriteVal));
  290. break;
  291. default:
  292. WLAN_OS_REPORT((" whalCtrl_Print_Mem_Regs: ERROR, wrong memory type 0x%x\n\n", memType));
  293. return NOK;
  294. }
  295. os_memoryCopy (pWhalCtrl->hOs, (void *)pCmd->value, (void *)&aWriteVal, pCmd->size);
  296. return (CmdQueue_Command(((TnetwDrv_t*)pWhalCtrl->hTNETW_Driver)->hCmdQueue, CMD_WRITE_MEMORY, (char *)pCmd, sizeof(*pCmd)));
  297. }