odm_interface.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. #ifndef __ODM_INTERFACE_H__
  21. #define __ODM_INTERFACE_H__
  22. //
  23. // =========== Constant/Structure/Enum/... Define
  24. //
  25. //
  26. // =========== Macro Define
  27. //
  28. #define _reg_all(_name) ODM_##_name
  29. #define _reg_ic(_name, _ic) ODM_##_name##_ic
  30. #define _bit_all(_name) BIT_##_name
  31. #define _bit_ic(_name, _ic) BIT_##_name##_ic
  32. // _cat: implemented by Token-Pasting Operator.
  33. #if 0
  34. #define _cat(_name, _ic_type, _func) \
  35. ( \
  36. _func##_all(_name) \
  37. )
  38. #endif
  39. /*===================================
  40. #define ODM_REG_DIG_11N 0xC50
  41. #define ODM_REG_DIG_11AC 0xDDD
  42. ODM_REG(DIG,_pDM_Odm)
  43. =====================================*/
  44. #define _reg_11N(_name) ODM_REG_##_name##_11N
  45. #define _reg_11AC(_name) ODM_REG_##_name##_11AC
  46. #define _bit_11N(_name) ODM_BIT_##_name##_11N
  47. #define _bit_11AC(_name) ODM_BIT_##_name##_11AC
  48. #if 1 //TODO: enable it if we need to support run-time to differentiate between 92C_SERIES and JAGUAR_SERIES.
  49. #define _cat(_name, _ic_type, _func) \
  50. ( \
  51. ((_ic_type) & ODM_IC_11N_SERIES)? _func##_11N(_name): \
  52. _func##_11AC(_name) \
  53. )
  54. #endif
  55. #if 0 // only sample code
  56. #define _cat(_name, _ic_type, _func) \
  57. ( \
  58. ((_ic_type) & ODM_RTL8192C)? _func##_ic(_name, _8192C): \
  59. ((_ic_type) & ODM_RTL8192D)? _func##_ic(_name, _8192D): \
  60. ((_ic_type) & ODM_RTL8192S)? _func##_ic(_name, _8192S): \
  61. ((_ic_type) & ODM_RTL8723A)? _func##_ic(_name, _8723A): \
  62. ((_ic_type) & ODM_RTL8188E)? _func##_ic(_name, _8188E): \
  63. _func##_ic(_name, _8195) \
  64. )
  65. #endif
  66. // _name: name of register or bit.
  67. // Example: "ODM_REG(R_A_AGC_CORE1, pDM_Odm)"
  68. // gets "ODM_R_A_AGC_CORE1" or "ODM_R_A_AGC_CORE1_8192C", depends on SupportICType.
  69. #define ODM_REG(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _reg)
  70. #define ODM_BIT(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _bit)
  71. typedef enum _ODM_H2C_CMD
  72. {
  73. ODM_H2C_RSSI_REPORT = 0,
  74. ODM_H2C_PSD_RESULT=1,
  75. ODM_H2C_PathDiv = 2,
  76. ODM_MAX_H2CCMD
  77. }ODM_H2C_CMD;
  78. //
  79. // 2012/02/17 MH For non-MP compile pass only. Linux does not support workitem.
  80. // Suggest HW team to use thread instead of workitem. Windows also support the feature.
  81. //
  82. #if (DM_ODM_SUPPORT_TYPE != ODM_WIN)
  83. typedef void *PRT_WORK_ITEM ;
  84. typedef void RT_WORKITEM_HANDLE,*PRT_WORKITEM_HANDLE;
  85. typedef VOID (*RT_WORKITEM_CALL_BACK)(PVOID pContext);
  86. #if 0
  87. typedef struct tasklet_struct RT_WORKITEM_HANDLE, *PRT_WORKITEM_HANDLE;
  88. typedef struct _RT_WORK_ITEM
  89. {
  90. RT_WORKITEM_HANDLE Handle; // Platform-dependent handle for this workitem, e.g. Ndis Workitem object.
  91. PVOID Adapter; // Pointer to Adapter object.
  92. PVOID pContext; // Parameter to passed to CallBackFunc().
  93. RT_WORKITEM_CALL_BACK CallbackFunc; // Callback function of the workitem.
  94. u1Byte RefCount; // 0: driver is going to unload, 1: No such workitem scheduled, 2: one workitem is schedueled.
  95. PVOID pPlatformExt; // Pointer to platform-dependent extension.
  96. BOOLEAN bFree;
  97. char szID[36]; // An identity string of this workitem.
  98. }RT_WORK_ITEM, *PRT_WORK_ITEM;
  99. #endif
  100. #endif
  101. //
  102. // =========== Extern Variable ??? It should be forbidden.
  103. //
  104. //
  105. // =========== EXtern Function Prototype
  106. //
  107. u1Byte
  108. ODM_Read1Byte(
  109. IN PDM_ODM_T pDM_Odm,
  110. IN u4Byte RegAddr
  111. );
  112. u2Byte
  113. ODM_Read2Byte(
  114. IN PDM_ODM_T pDM_Odm,
  115. IN u4Byte RegAddr
  116. );
  117. u4Byte
  118. ODM_Read4Byte(
  119. IN PDM_ODM_T pDM_Odm,
  120. IN u4Byte RegAddr
  121. );
  122. VOID
  123. ODM_Write1Byte(
  124. IN PDM_ODM_T pDM_Odm,
  125. IN u4Byte RegAddr,
  126. IN u1Byte Data
  127. );
  128. VOID
  129. ODM_Write2Byte(
  130. IN PDM_ODM_T pDM_Odm,
  131. IN u4Byte RegAddr,
  132. IN u2Byte Data
  133. );
  134. VOID
  135. ODM_Write4Byte(
  136. IN PDM_ODM_T pDM_Odm,
  137. IN u4Byte RegAddr,
  138. IN u4Byte Data
  139. );
  140. VOID
  141. ODM_SetMACReg(
  142. IN PDM_ODM_T pDM_Odm,
  143. IN u4Byte RegAddr,
  144. IN u4Byte BitMask,
  145. IN u4Byte Data
  146. );
  147. u4Byte
  148. ODM_GetMACReg(
  149. IN PDM_ODM_T pDM_Odm,
  150. IN u4Byte RegAddr,
  151. IN u4Byte BitMask
  152. );
  153. VOID
  154. ODM_SetBBReg(
  155. IN PDM_ODM_T pDM_Odm,
  156. IN u4Byte RegAddr,
  157. IN u4Byte BitMask,
  158. IN u4Byte Data
  159. );
  160. u4Byte
  161. ODM_GetBBReg(
  162. IN PDM_ODM_T pDM_Odm,
  163. IN u4Byte RegAddr,
  164. IN u4Byte BitMask
  165. );
  166. VOID
  167. ODM_SetRFReg(
  168. IN PDM_ODM_T pDM_Odm,
  169. IN ODM_RF_RADIO_PATH_E eRFPath,
  170. IN u4Byte RegAddr,
  171. IN u4Byte BitMask,
  172. IN u4Byte Data
  173. );
  174. u4Byte
  175. ODM_GetRFReg(
  176. IN PDM_ODM_T pDM_Odm,
  177. IN ODM_RF_RADIO_PATH_E eRFPath,
  178. IN u4Byte RegAddr,
  179. IN u4Byte BitMask
  180. );
  181. //
  182. // Memory Relative Function.
  183. //
  184. VOID
  185. ODM_AllocateMemory(
  186. IN PDM_ODM_T pDM_Odm,
  187. OUT PVOID *pPtr,
  188. IN u4Byte length
  189. );
  190. VOID
  191. ODM_FreeMemory(
  192. IN PDM_ODM_T pDM_Odm,
  193. OUT PVOID pPtr,
  194. IN u4Byte length
  195. );
  196. VOID
  197. ODM_MoveMemory(
  198. IN PDM_ODM_T pDM_Odm,
  199. OUT PVOID pDest,
  200. IN PVOID pSrc,
  201. IN u4Byte Length
  202. );
  203. s4Byte ODM_CompareMemory(
  204. IN PDM_ODM_T pDM_Odm,
  205. IN PVOID pBuf1,
  206. IN PVOID pBuf2,
  207. IN u4Byte length
  208. );
  209. //
  210. // ODM MISC-spin lock relative API.
  211. //
  212. VOID
  213. ODM_AcquireSpinLock(
  214. IN PDM_ODM_T pDM_Odm,
  215. IN RT_SPINLOCK_TYPE type
  216. );
  217. VOID
  218. ODM_ReleaseSpinLock(
  219. IN PDM_ODM_T pDM_Odm,
  220. IN RT_SPINLOCK_TYPE type
  221. );
  222. //
  223. // ODM MISC-workitem relative API.
  224. //
  225. VOID
  226. ODM_InitializeWorkItem(
  227. IN PDM_ODM_T pDM_Odm,
  228. IN PRT_WORK_ITEM pRtWorkItem,
  229. IN RT_WORKITEM_CALL_BACK RtWorkItemCallback,
  230. IN PVOID pContext,
  231. IN const char* szID
  232. );
  233. VOID
  234. ODM_StartWorkItem(
  235. IN PRT_WORK_ITEM pRtWorkItem
  236. );
  237. VOID
  238. ODM_StopWorkItem(
  239. IN PRT_WORK_ITEM pRtWorkItem
  240. );
  241. VOID
  242. ODM_FreeWorkItem(
  243. IN PRT_WORK_ITEM pRtWorkItem
  244. );
  245. VOID
  246. ODM_ScheduleWorkItem(
  247. IN PRT_WORK_ITEM pRtWorkItem
  248. );
  249. VOID
  250. ODM_IsWorkItemScheduled(
  251. IN PRT_WORK_ITEM pRtWorkItem
  252. );
  253. //
  254. // ODM Timer relative API.
  255. //
  256. VOID
  257. ODM_StallExecution(
  258. IN u4Byte usDelay
  259. );
  260. VOID
  261. ODM_delay_ms(IN u4Byte ms);
  262. VOID
  263. ODM_delay_us(IN u4Byte us);
  264. VOID
  265. ODM_sleep_ms(IN u4Byte ms);
  266. VOID
  267. ODM_sleep_us(IN u4Byte us);
  268. VOID
  269. ODM_SetTimer(
  270. IN PDM_ODM_T pDM_Odm,
  271. IN PRT_TIMER pTimer,
  272. IN u4Byte msDelay
  273. );
  274. VOID
  275. ODM_InitializeTimer(
  276. IN PDM_ODM_T pDM_Odm,
  277. IN PRT_TIMER pTimer,
  278. IN RT_TIMER_CALL_BACK CallBackFunc,
  279. IN PVOID pContext,
  280. IN const char* szID
  281. );
  282. VOID
  283. ODM_CancelTimer(
  284. IN PDM_ODM_T pDM_Odm,
  285. IN PRT_TIMER pTimer
  286. );
  287. VOID
  288. ODM_ReleaseTimer(
  289. IN PDM_ODM_T pDM_Odm,
  290. IN PRT_TIMER pTimer
  291. );
  292. //
  293. // ODM FW relative API.
  294. //
  295. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  296. VOID
  297. ODM_FillH2CCmd(
  298. IN PADAPTER Adapter,
  299. IN u1Byte ElementID,
  300. IN u4Byte CmdLen,
  301. IN pu1Byte pCmdBuffer
  302. );
  303. #else
  304. u4Byte
  305. ODM_FillH2CCmd(
  306. IN pu1Byte pH2CBuffer,
  307. IN u4Byte H2CBufferLen,
  308. IN u4Byte CmdNum,
  309. IN pu4Byte pElementID,
  310. IN pu4Byte pCmdLen,
  311. IN pu1Byte* pCmbBuffer,
  312. IN pu1Byte CmdStartSeq
  313. );
  314. #endif
  315. #endif // __ODM_INTERFACE_H__