HalHWImg8812A_TestChip_MAC.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. #include "../odm_precomp.h"
  21. #if (RTL8812A_SUPPORT == 1)
  22. static BOOLEAN
  23. CheckCondition(
  24. const u4Byte Condition,
  25. const u4Byte Hex
  26. )
  27. {
  28. u4Byte _board = (Hex & 0x000000FF);
  29. u4Byte _interface = (Hex & 0x0000FF00) >> 8;
  30. u4Byte _platform = (Hex & 0x00FF0000) >> 16;
  31. u4Byte cond = Condition;
  32. if ( Condition == 0xCDCDCDCD )
  33. return TRUE;
  34. cond = Condition & 0x000000FF;
  35. if ( (_board != cond) && (cond != 0xFF) )
  36. return FALSE;
  37. cond = Condition & 0x0000FF00;
  38. cond = cond >> 8;
  39. if ( ((_interface & cond) == 0) && (cond != 0x07) )
  40. return FALSE;
  41. cond = Condition & 0x00FF0000;
  42. cond = cond >> 16;
  43. if ( ((_platform & cond) == 0) && (cond != 0x0F) )
  44. return FALSE;
  45. return TRUE;
  46. }
  47. /******************************************************************************
  48. * MAC_REG.TXT
  49. ******************************************************************************/
  50. u4Byte Array_TC_8812A_MAC_REG[] = {
  51. 0x010, 0x0000000C,
  52. 0x072, 0x00000000,
  53. 0x428, 0x0000000A,
  54. 0x429, 0x00000010,
  55. 0x430, 0x00000000,
  56. 0x431, 0x00000000,
  57. 0x432, 0x00000000,
  58. 0x433, 0x00000001,
  59. 0x434, 0x00000004,
  60. 0x435, 0x00000005,
  61. 0x436, 0x00000007,
  62. 0x437, 0x00000008,
  63. 0x43C, 0x00000004,
  64. 0x43D, 0x00000005,
  65. 0x43E, 0x00000007,
  66. 0x43F, 0x00000008,
  67. 0x440, 0x0000005D,
  68. 0x441, 0x00000001,
  69. 0x442, 0x00000000,
  70. 0x444, 0x00000010,
  71. 0x445, 0x00000000,
  72. 0x446, 0x00000000,
  73. 0x447, 0x00000000,
  74. 0x448, 0x00000000,
  75. 0x449, 0x000000F0,
  76. 0x44A, 0x0000000F,
  77. 0x44B, 0x0000003E,
  78. 0x44C, 0x00000010,
  79. 0x44D, 0x00000000,
  80. 0x44E, 0x00000000,
  81. 0x44F, 0x00000000,
  82. 0x450, 0x00000000,
  83. 0x451, 0x000000F0,
  84. 0x452, 0x0000000F,
  85. 0x453, 0x00000000,
  86. 0x45B, 0x00000080,
  87. 0x460, 0x00000066,
  88. 0x461, 0x00000066,
  89. 0x4C8, 0x000000FF,
  90. 0x4C9, 0x00000008,
  91. 0x4CC, 0x000000FF,
  92. 0x4CD, 0x000000FF,
  93. 0x4CE, 0x00000001,
  94. 0x500, 0x00000026,
  95. 0x501, 0x000000A2,
  96. 0x502, 0x0000002F,
  97. 0x503, 0x00000000,
  98. 0x504, 0x00000028,
  99. 0x505, 0x000000A3,
  100. 0x506, 0x0000005E,
  101. 0x507, 0x00000000,
  102. 0x508, 0x0000002B,
  103. 0x509, 0x000000A4,
  104. 0x50A, 0x0000005E,
  105. 0x50B, 0x00000000,
  106. 0x50C, 0x0000004F,
  107. 0x50D, 0x000000A4,
  108. 0x50E, 0x00000000,
  109. 0x50F, 0x00000000,
  110. 0x512, 0x0000001C,
  111. 0x514, 0x0000000A,
  112. 0x516, 0x0000000A,
  113. 0x525, 0x0000004F,
  114. 0x550, 0x00000010,
  115. 0x551, 0x00000010,
  116. 0x559, 0x00000002,
  117. 0x55C, 0x00000050,
  118. 0x55D, 0x000000FF,
  119. 0x604, 0x00000009,
  120. 0x605, 0x00000030,
  121. 0x607, 0x00000007,
  122. 0x608, 0x0000000E,
  123. 0x609, 0x0000002A,
  124. 0x620, 0x000000FF,
  125. 0x621, 0x000000FF,
  126. 0x622, 0x000000FF,
  127. 0x623, 0x000000FF,
  128. 0x624, 0x000000FF,
  129. 0x625, 0x000000FF,
  130. 0x626, 0x000000FF,
  131. 0x627, 0x000000FF,
  132. 0x638, 0x00000050,
  133. 0x63C, 0x0000000A,
  134. 0x63D, 0x0000000A,
  135. 0x63E, 0x0000000E,
  136. 0x63F, 0x0000000E,
  137. 0x640, 0x00000040,
  138. 0x642, 0x00000040,
  139. 0x643, 0x00000000,
  140. 0x66E, 0x00000005,
  141. 0x700, 0x00000021,
  142. 0x701, 0x00000043,
  143. 0x702, 0x00000065,
  144. 0x703, 0x00000087,
  145. 0x708, 0x00000021,
  146. 0x709, 0x00000043,
  147. 0x70A, 0x00000065,
  148. 0x70B, 0x00000087,
  149. 0x718, 0x00000040,
  150. };
  151. void
  152. ODM_ReadAndConfig_TC_8812A_MAC_REG(
  153. IN PDM_ODM_T pDM_Odm
  154. )
  155. {
  156. #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = Array[i]; v2 = Array[i+1]; } while(0)
  157. u4Byte hex = 0;
  158. u4Byte i = 0;
  159. u2Byte count = 0;
  160. pu4Byte ptr_array = NULL;
  161. u1Byte platform = pDM_Odm->SupportPlatform;
  162. u1Byte _interface = pDM_Odm->SupportInterface;
  163. u1Byte board = pDM_Odm->BoardType;
  164. u4Byte ArrayLen = sizeof(Array_TC_8812A_MAC_REG)/sizeof(u4Byte);
  165. pu4Byte Array = Array_TC_8812A_MAC_REG;
  166. hex += board;
  167. hex += _interface << 8;
  168. hex += platform << 16;
  169. hex += 0xFF000000;
  170. ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ReadAndConfig_TC_8812A_MAC_REG, hex = 0x%X\n", hex));
  171. for (i = 0; i < ArrayLen; i += 2 )
  172. {
  173. u4Byte v1 = Array[i];
  174. u4Byte v2 = Array[i+1];
  175. // This (offset, data) pair meets the condition.
  176. if ( v1 < 0xCDCDCDCD )
  177. {
  178. odm_ConfigMAC_8812A(pDM_Odm, v1, (u1Byte)v2);
  179. continue;
  180. }
  181. else
  182. { // This line is the start line of branch.
  183. if ( !CheckCondition(Array[i], hex) )
  184. { // Discard the following (offset, data) pairs.
  185. READ_NEXT_PAIR(v1, v2, i);
  186. while (v2 != 0xDEAD &&
  187. v2 != 0xCDEF &&
  188. v2 != 0xCDCD && i < ArrayLen -2)
  189. {
  190. READ_NEXT_PAIR(v1, v2, i);
  191. }
  192. i -= 2; // prevent from for-loop += 2
  193. }
  194. else // Configure matched pairs and skip to end of if-else.
  195. {
  196. READ_NEXT_PAIR(v1, v2, i);
  197. while (v2 != 0xDEAD &&
  198. v2 != 0xCDEF &&
  199. v2 != 0xCDCD && i < ArrayLen -2)
  200. {
  201. odm_ConfigMAC_8812A(pDM_Odm, v1, (u1Byte)v2);
  202. READ_NEXT_PAIR(v1, v2, i);
  203. }
  204. while (v2 != 0xDEAD && i < ArrayLen -2)
  205. {
  206. READ_NEXT_PAIR(v1, v2, i);
  207. }
  208. }
  209. }
  210. }
  211. }
  212. #endif // end of HWIMG_SUPPORT