HalHWImg8821A_TestChip_MAC.c 5.9 KB

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