halhwimg8821c_mac.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  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. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. /*Image2HeaderVersion: R3 1.0*/
  26. #include "mp_precomp.h"
  27. #include "../phydm_precomp.h"
  28. #if (RTL8821C_SUPPORT == 1)
  29. static boolean
  30. check_positive(
  31. struct dm_struct *dm,
  32. const u32 condition1,
  33. const u32 condition2,
  34. const u32 condition3,
  35. const u32 condition4
  36. )
  37. {
  38. u32 cond1 = condition1, cond2 = condition2, cond3 = condition3, cond4 = condition4;
  39. u8 cut_version_for_para = (dm->cut_version == ODM_CUT_A) ? 15 : dm->cut_version;
  40. u8 pkg_type_for_para = (dm->package_type == 0) ? 15 : dm->package_type;
  41. u32 driver1 = cut_version_for_para << 24 |
  42. (dm->support_interface & 0xF0) << 16 |
  43. dm->support_platform << 16 |
  44. pkg_type_for_para << 12 |
  45. (dm->support_interface & 0x0F) << 8 |
  46. dm->rfe_type;
  47. u32 driver2 = (dm->type_glna & 0xFF) << 0 |
  48. (dm->type_gpa & 0xFF) << 8 |
  49. (dm->type_alna & 0xFF) << 16 |
  50. (dm->type_apa & 0xFF) << 24;
  51. u32 driver3 = 0;
  52. u32 driver4 = (dm->type_glna & 0xFF00) >> 8 |
  53. (dm->type_gpa & 0xFF00) |
  54. (dm->type_alna & 0xFF00) << 8 |
  55. (dm->type_apa & 0xFF00) << 16;
  56. PHYDM_DBG(dm, ODM_COMP_INIT,
  57. "===> %s (cond1, cond2, cond3, cond4) = (0x%X 0x%X 0x%X 0x%X)\n",
  58. __func__, cond1, cond2, cond3, cond4);
  59. PHYDM_DBG(dm, ODM_COMP_INIT,
  60. "===> %s (driver1, driver2, driver3, driver4) = (0x%X 0x%X 0x%X 0x%X)\n",
  61. __func__, driver1, driver2, driver3, driver4);
  62. PHYDM_DBG(dm, ODM_COMP_INIT,
  63. " (Platform, Interface) = (0x%X, 0x%X)\n",
  64. dm->support_platform, dm->support_interface);
  65. PHYDM_DBG(dm, ODM_COMP_INIT, " (RFE, Package) = (0x%X, 0x%X)\n",
  66. dm->rfe_type, dm->package_type);
  67. /*============== value Defined Check ===============*/
  68. /*cut version [27:24] need to do value check*/
  69. if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
  70. return false;
  71. /*pkg type [15:12] need to do value check*/
  72. if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
  73. return false;
  74. /*interface [11:8] need to do value check*/
  75. if (((cond1 & 0x00000F00) != 0) && ((cond1 & 0x00000F00) != (driver1 & 0x00000F00)))
  76. return false;
  77. /*=============== Bit Defined Check ================*/
  78. /* We don't care [31:28] */
  79. cond1 &= 0x000000FF;
  80. driver1 &= 0x000000FF;
  81. if (cond1 == driver1)
  82. return true;
  83. else
  84. return false;
  85. }
  86. static boolean
  87. check_negative(
  88. struct dm_struct *dm,
  89. const u32 condition1,
  90. const u32 condition2
  91. )
  92. {
  93. return true;
  94. }
  95. /******************************************************************************
  96. * mac_reg.TXT
  97. ******************************************************************************/
  98. u32 array_mp_8821c_mac_reg[] = {
  99. 0x010, 0x00000043,
  100. 0x025, 0x0000001D,
  101. 0x026, 0x000000CE,
  102. 0x04F, 0x00000001,
  103. 0x029, 0x000000F9,
  104. 0x420, 0x00000080,
  105. 0x421, 0x0000000F,
  106. 0x428, 0x0000000A,
  107. 0x429, 0x00000010,
  108. 0x430, 0x00000000,
  109. 0x431, 0x00000000,
  110. 0x432, 0x00000000,
  111. 0x433, 0x00000001,
  112. 0x434, 0x00000004,
  113. 0x435, 0x00000005,
  114. 0x436, 0x00000007,
  115. 0x437, 0x00000008,
  116. 0x43C, 0x00000004,
  117. 0x43D, 0x00000005,
  118. 0x43E, 0x00000007,
  119. 0x43F, 0x00000008,
  120. 0x440, 0x0000005D,
  121. 0x441, 0x00000001,
  122. 0x442, 0x00000000,
  123. 0x444, 0x00000010,
  124. 0x445, 0x000000F0,
  125. 0x446, 0x00000001,
  126. 0x447, 0x000000FE,
  127. 0x448, 0x00000000,
  128. 0x449, 0x00000000,
  129. 0x44A, 0x00000000,
  130. 0x44B, 0x00000040,
  131. 0x44C, 0x00000010,
  132. 0x44D, 0x000000F0,
  133. 0x44E, 0x0000003F,
  134. 0x44F, 0x00000000,
  135. 0x450, 0x00000000,
  136. 0x451, 0x00000000,
  137. 0x452, 0x00000000,
  138. 0x453, 0x00000040,
  139. 0x455, 0x00000070,
  140. 0x45E, 0x00000004,
  141. 0x49C, 0x00000010,
  142. 0x49D, 0x000000F0,
  143. 0x49E, 0x00000000,
  144. 0x49F, 0x00000006,
  145. 0x4A0, 0x000000E0,
  146. 0x4A1, 0x00000003,
  147. 0x4A2, 0x00000000,
  148. 0x4A3, 0x00000040,
  149. 0x4A4, 0x00000015,
  150. 0x4A5, 0x000000F0,
  151. 0x4A6, 0x00000000,
  152. 0x4A7, 0x00000006,
  153. 0x4A8, 0x000000E0,
  154. 0x4A9, 0x00000000,
  155. 0x4AA, 0x00000000,
  156. 0x4AB, 0x00000000,
  157. 0x7DA, 0x00000008,
  158. 0x1448, 0x00000006,
  159. 0x144A, 0x00000006,
  160. 0x144C, 0x00000006,
  161. 0x144E, 0x00000006,
  162. 0x4C8, 0x000000FF,
  163. 0x4C9, 0x00000008,
  164. 0x4CC, 0x000000FF,
  165. 0x4CD, 0x000000FF,
  166. 0x4CE, 0x00000001,
  167. 0x4CF, 0x00000008,
  168. 0x500, 0x00000026,
  169. 0x501, 0x000000A2,
  170. 0x502, 0x0000002F,
  171. 0x503, 0x00000000,
  172. 0x504, 0x00000028,
  173. 0x505, 0x000000A3,
  174. 0x506, 0x0000005E,
  175. 0x507, 0x00000000,
  176. 0x508, 0x0000002B,
  177. 0x509, 0x000000A4,
  178. 0x50A, 0x0000005E,
  179. 0x50B, 0x00000000,
  180. 0x50C, 0x0000004F,
  181. 0x50D, 0x000000A4,
  182. 0x50E, 0x00000000,
  183. 0x50F, 0x00000000,
  184. 0x512, 0x0000001C,
  185. 0x514, 0x0000000A,
  186. 0x516, 0x0000000A,
  187. 0x521, 0x0000002F,
  188. 0x525, 0x0000004F,
  189. 0x551, 0x00000010,
  190. 0x559, 0x00000002,
  191. 0x55C, 0x00000050,
  192. 0x55D, 0x000000FF,
  193. 0x577, 0x0000000B,
  194. 0x578, 0x00000014,
  195. 0x579, 0x00000014,
  196. 0x57A, 0x00000014,
  197. 0x5BE, 0x00000064,
  198. 0x605, 0x00000030,
  199. 0x608, 0x0000000E,
  200. 0x609, 0x00000022,
  201. 0x60C, 0x00000018,
  202. 0x6A0, 0x000000FF,
  203. 0x6A1, 0x000000FF,
  204. 0x6A2, 0x000000FF,
  205. 0x6A3, 0x000000FF,
  206. 0x6A4, 0x000000FF,
  207. 0x6A5, 0x000000FF,
  208. 0x6DE, 0x00000084,
  209. 0x620, 0x000000FF,
  210. 0x621, 0x000000FF,
  211. 0x622, 0x000000FF,
  212. 0x623, 0x000000FF,
  213. 0x624, 0x000000FF,
  214. 0x625, 0x000000FF,
  215. 0x626, 0x000000FF,
  216. 0x627, 0x000000FF,
  217. 0x638, 0x00000050,
  218. 0x63C, 0x0000000A,
  219. 0x63D, 0x0000000A,
  220. 0x63E, 0x0000000E,
  221. 0x63F, 0x0000000E,
  222. 0x640, 0x00000040,
  223. 0x642, 0x00000040,
  224. 0x643, 0x00000000,
  225. 0x652, 0x000000C8,
  226. 0x66E, 0x00000005,
  227. 0x700, 0x00000021,
  228. 0x701, 0x00000043,
  229. 0x702, 0x00000065,
  230. 0x703, 0x00000087,
  231. 0x708, 0x00000021,
  232. 0x709, 0x00000043,
  233. 0x70A, 0x00000065,
  234. 0x70B, 0x00000087,
  235. 0x718, 0x00000040,
  236. 0x7D4, 0x00000098,
  237. };
  238. void
  239. odm_read_and_config_mp_8821c_mac_reg(struct dm_struct *dm)
  240. {
  241. u32 i = 0;
  242. u8 c_cond;
  243. boolean is_matched = true, is_skipped = false;
  244. u32 array_len = sizeof(array_mp_8821c_mac_reg) / sizeof(u32);
  245. u32 *array = array_mp_8821c_mac_reg;
  246. u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
  247. PHYDM_DBG(dm, ODM_COMP_INIT, "===> %s\n", __func__);
  248. while ((i + 1) < array_len) {
  249. v1 = array[i];
  250. v2 = array[i + 1];
  251. if (v1 & (BIT(31) | BIT(30))) {/*positive & negative condition*/
  252. if (v1 & BIT(31)) {/* positive condition*/
  253. c_cond = (u8)((v1 & (BIT(29) | BIT(28))) >> 28);
  254. if (c_cond == COND_ENDIF) {/*end*/
  255. is_matched = true;
  256. is_skipped = false;
  257. PHYDM_DBG(dm, ODM_COMP_INIT, "ENDIF\n");
  258. } else if (c_cond == COND_ELSE) { /*else*/
  259. is_matched = is_skipped ? false : true;
  260. PHYDM_DBG(dm, ODM_COMP_INIT, "ELSE\n");
  261. } else {/*if , else if*/
  262. pre_v1 = v1;
  263. pre_v2 = v2;
  264. PHYDM_DBG(dm, ODM_COMP_INIT, "IF or ELSE IF\n");
  265. }
  266. } else if (v1 & BIT(30)) { /*negative condition*/
  267. if (is_skipped == false) {
  268. if (check_positive(dm, pre_v1, pre_v2, v1, v2)) {
  269. is_matched = true;
  270. is_skipped = true;
  271. } else {
  272. is_matched = false;
  273. is_skipped = false;
  274. }
  275. } else
  276. is_matched = false;
  277. }
  278. } else {
  279. if (is_matched)
  280. odm_config_mac_8821c(dm, v1, (u8)v2);
  281. }
  282. i = i + 2;
  283. }
  284. }
  285. u32
  286. odm_get_version_mp_8821c_mac_reg(void)
  287. {
  288. return 49;
  289. }
  290. #endif /* end of HWIMG_SUPPORT*/