HalHWImg8723A_MAC.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. ******************************************************************************/
  15. #include "odm_precomp.h"
  16. static bool CheckCondition(const u32 Condition, const u32 Hex)
  17. {
  18. u32 _board = (Hex & 0x000000FF);
  19. u32 _interface = (Hex & 0x0000FF00) >> 8;
  20. u32 _platform = (Hex & 0x00FF0000) >> 16;
  21. u32 cond = Condition;
  22. if (Condition == 0xCDCDCDCD)
  23. return true;
  24. cond = Condition & 0x000000FF;
  25. if ((_board == cond) && cond != 0x00)
  26. return false;
  27. cond = Condition & 0x0000FF00;
  28. cond >>= 8;
  29. if ((_interface & cond) == 0 && cond != 0x07)
  30. return false;
  31. cond = Condition & 0x00FF0000;
  32. cond >>= 16;
  33. if ((_platform & cond) == 0 && cond != 0x0F)
  34. return false;
  35. return true;
  36. }
  37. /******************************************************************************
  38. * MAC_REG.TXT
  39. ******************************************************************************/
  40. static u32 Array_MAC_REG_8723A[] = {
  41. 0x420, 0x00000080,
  42. 0x423, 0x00000000,
  43. 0x430, 0x00000000,
  44. 0x431, 0x00000000,
  45. 0x432, 0x00000000,
  46. 0x433, 0x00000001,
  47. 0x434, 0x00000004,
  48. 0x435, 0x00000005,
  49. 0x436, 0x00000006,
  50. 0x437, 0x00000007,
  51. 0x438, 0x00000000,
  52. 0x439, 0x00000000,
  53. 0x43A, 0x00000000,
  54. 0x43B, 0x00000001,
  55. 0x43C, 0x00000004,
  56. 0x43D, 0x00000005,
  57. 0x43E, 0x00000006,
  58. 0x43F, 0x00000007,
  59. 0x440, 0x0000005D,
  60. 0x441, 0x00000001,
  61. 0x442, 0x00000000,
  62. 0x444, 0x00000015,
  63. 0x445, 0x000000F0,
  64. 0x446, 0x0000000F,
  65. 0x447, 0x00000000,
  66. 0x458, 0x00000041,
  67. 0x459, 0x000000A8,
  68. 0x45A, 0x00000072,
  69. 0x45B, 0x000000B9,
  70. 0x460, 0x00000066,
  71. 0x461, 0x00000066,
  72. 0x462, 0x00000008,
  73. 0x463, 0x00000003,
  74. 0x4C8, 0x000000FF,
  75. 0x4C9, 0x00000008,
  76. 0x4CC, 0x000000FF,
  77. 0x4CD, 0x000000FF,
  78. 0x4CE, 0x00000001,
  79. 0x500, 0x00000026,
  80. 0x501, 0x000000A2,
  81. 0x502, 0x0000002F,
  82. 0x503, 0x00000000,
  83. 0x504, 0x00000028,
  84. 0x505, 0x000000A3,
  85. 0x506, 0x0000005E,
  86. 0x507, 0x00000000,
  87. 0x508, 0x0000002B,
  88. 0x509, 0x000000A4,
  89. 0x50A, 0x0000005E,
  90. 0x50B, 0x00000000,
  91. 0x50C, 0x0000004F,
  92. 0x50D, 0x000000A4,
  93. 0x50E, 0x00000000,
  94. 0x50F, 0x00000000,
  95. 0x512, 0x0000001C,
  96. 0x514, 0x0000000A,
  97. 0x515, 0x00000010,
  98. 0x516, 0x0000000A,
  99. 0x517, 0x00000010,
  100. 0x51A, 0x00000016,
  101. 0x524, 0x0000000F,
  102. 0x525, 0x0000004F,
  103. 0x546, 0x00000040,
  104. 0x547, 0x00000000,
  105. 0x550, 0x00000010,
  106. 0x551, 0x00000010,
  107. 0x559, 0x00000002,
  108. 0x55A, 0x00000002,
  109. 0x55D, 0x000000FF,
  110. 0x605, 0x00000030,
  111. 0x608, 0x0000000E,
  112. 0x609, 0x0000002A,
  113. 0x652, 0x00000020,
  114. 0x63C, 0x0000000A,
  115. 0x63D, 0x0000000A,
  116. 0x63E, 0x0000000E,
  117. 0x63F, 0x0000000E,
  118. 0x66E, 0x00000005,
  119. 0x700, 0x00000021,
  120. 0x701, 0x00000043,
  121. 0x702, 0x00000065,
  122. 0x703, 0x00000087,
  123. 0x708, 0x00000021,
  124. 0x709, 0x00000043,
  125. 0x70A, 0x00000065,
  126. 0x70B, 0x00000087,
  127. };
  128. void ODM_ReadAndConfig_MAC_REG_8723A(struct dm_odm_t *pDM_Odm)
  129. {
  130. #define READ_NEXT_PAIR(v1, v2, i) \
  131. do { \
  132. i += 2; v1 = Array[i]; v2 = Array[i+1]; \
  133. } while (0)
  134. u32 hex = 0;
  135. u32 i = 0;
  136. u8 platform = 0x04;
  137. u8 board = pDM_Odm->BoardType;
  138. u32 ArrayLen = sizeof(Array_MAC_REG_8723A)/sizeof(u32);
  139. u32 *Array = Array_MAC_REG_8723A;
  140. hex += board;
  141. hex += ODM_ITRF_USB << 8;
  142. hex += platform << 16;
  143. hex += 0xFF000000;
  144. for (i = 0; i < ArrayLen; i += 2) {
  145. u32 v1 = Array[i];
  146. u32 v2 = Array[i+1];
  147. /* This (offset, data) pair meets the condition. */
  148. if (v1 < 0xCDCDCDCD) {
  149. odm_ConfigMAC_8723A(pDM_Odm, v1, (u8)v2);
  150. continue;
  151. } else {
  152. if (!CheckCondition(Array[i], hex)) {
  153. /* Discard the following (offset, data) pairs. */
  154. READ_NEXT_PAIR(v1, v2, i);
  155. while (v2 != 0xDEAD &&
  156. v2 != 0xCDEF &&
  157. v2 != 0xCDCD && i < ArrayLen - 2)
  158. READ_NEXT_PAIR(v1, v2, i);
  159. i -= 2; /* prevent from for-loop += 2 */
  160. } else {
  161. /* Configure matched pairs and skip to end of if-else. */
  162. READ_NEXT_PAIR(v1, v2, i);
  163. while (v2 != 0xDEAD &&
  164. v2 != 0xCDEF &&
  165. v2 != 0xCDCD && i < ArrayLen - 2) {
  166. odm_ConfigMAC_8723A(pDM_Odm, v1, (u8)v2);
  167. READ_NEXT_PAIR(v1, v2, i);
  168. }
  169. while (v2 != 0xDEAD && i < ArrayLen - 2)
  170. READ_NEXT_PAIR(v1, v2, i);
  171. }
  172. }
  173. }
  174. }