phydm_regconfig8821c.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 "../phydm_precomp.h"
  22. #if (RTL8821C_SUPPORT == 1)
  23. void
  24. odm_config_rf_reg_8821c(
  25. struct PHY_DM_STRUCT *p_dm_odm,
  26. u32 addr,
  27. u32 data,
  28. enum odm_rf_radio_path_e RF_PATH,
  29. u32 reg_addr
  30. )
  31. {
  32. if (addr == 0xffe) {
  33. #ifdef CONFIG_LONG_DELAY_ISSUE
  34. ODM_sleep_ms(50);
  35. #else
  36. ODM_delay_ms(50);
  37. #endif
  38. } else {
  39. odm_set_rf_reg(p_dm_odm, RF_PATH, reg_addr, RFREGOFFSETMASK, data);
  40. /* Add 1us delay between BB/RF register setting. */
  41. ODM_delay_us(1);
  42. }
  43. }
  44. void
  45. odm_config_rf_radio_a_8821c(
  46. struct PHY_DM_STRUCT *p_dm_odm,
  47. u32 addr,
  48. u32 data
  49. )
  50. {
  51. u32 content = 0x1000; /* RF_Content: radioa_txt */
  52. u32 maskfor_phy_set = (u32)(content & 0xE000);
  53. odm_config_rf_reg_8821c(p_dm_odm, addr, data, ODM_RF_PATH_A, addr | maskfor_phy_set);
  54. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> odm_config_rf_with_header_file: [RadioA] %08X %08X\n", addr, data));
  55. }
  56. void
  57. odm_config_mac_8821c(
  58. struct PHY_DM_STRUCT *p_dm_odm,
  59. u32 addr,
  60. u8 data
  61. )
  62. {
  63. odm_write_1byte(p_dm_odm, addr, data);
  64. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> odm_config_mac_with_header_file: [MAC_REG] %08X %08X\n", addr, data));
  65. }
  66. void
  67. odm_update_agc_big_jump_lmt_8821c(
  68. struct PHY_DM_STRUCT *p_dm_odm,
  69. u32 addr,
  70. u32 data
  71. )
  72. {
  73. struct _dynamic_initial_gain_threshold_ *p_dm_dig_table = &p_dm_odm->dm_dig_table;
  74. u8 rf_gain_idx = (u8)((data & 0xFF000000) >> 24);
  75. u8 bb_gain_idx = (u8)((data & 0x00ff0000) >> 16);
  76. u8 agc_table_idx = (u8)((data & 0x00000f00) >> 8);
  77. static boolean is_limit;
  78. if (addr != 0x81c)
  79. return;
  80. /*dbg_print("data = 0x%x, rf_gain_idx = 0x%x, bb_gain_idx = 0x%x, agc_table_idx = 0x%x\n", data, rf_gain_idx, bb_gain_idx, agc_table_idx);*/
  81. /*dbg_print("rf_gain_idx = 0x%x, p_dm_dig_table->rf_gain_idx = 0x%x\n", rf_gain_idx, p_dm_dig_table->rf_gain_idx);*/
  82. if (bb_gain_idx > 0x3c) {
  83. if ((rf_gain_idx == p_dm_dig_table->rf_gain_idx) && (is_limit == false)) {
  84. is_limit = true;
  85. p_dm_dig_table->big_jump_lmt[agc_table_idx] = bb_gain_idx - 2;
  86. ODM_RT_TRACE(p_dm_odm, ODM_COMP_DIG, ODM_DBG_TRACE, ("===> [AGC_TAB] big_jump_lmt [%d] = 0x%x\n", agc_table_idx, p_dm_dig_table->big_jump_lmt[agc_table_idx]));
  87. }
  88. } else
  89. is_limit = false;
  90. p_dm_dig_table->rf_gain_idx = rf_gain_idx;
  91. }
  92. void
  93. odm_config_bb_agc_8821c(
  94. struct PHY_DM_STRUCT *p_dm_odm,
  95. u32 addr,
  96. u32 bitmask,
  97. u32 data
  98. )
  99. {
  100. odm_update_agc_big_jump_lmt_8821c(p_dm_odm, addr, data);
  101. odm_set_bb_reg(p_dm_odm, addr, bitmask, data);
  102. /* Add 1us delay between BB/RF register setting. */
  103. ODM_delay_us(1);
  104. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> odm_config_bb_with_header_file: [AGC_TAB] %08X %08X\n", addr, data));
  105. }
  106. void
  107. odm_config_bb_phy_reg_pg_8821c(
  108. struct PHY_DM_STRUCT *p_dm_odm,
  109. u32 band,
  110. u32 rf_path,
  111. u32 tx_num,
  112. u32 addr,
  113. u32 bitmask,
  114. u32 data
  115. )
  116. {
  117. #if (DM_ODM_SUPPORT_TYPE & ODM_CE)
  118. phy_store_tx_power_by_rate(p_dm_odm->adapter, band, rf_path, tx_num, addr, bitmask, data);
  119. #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  120. PHY_StoreTxPowerByRate(p_dm_odm->adapter, band, rf_path, tx_num, addr, bitmask, data);
  121. #endif
  122. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> odm_config_bb_with_header_file: [PHY_REG] %08X %08X %08X\n", addr, bitmask, data));
  123. }
  124. void
  125. odm_config_bb_phy_8821c(
  126. struct PHY_DM_STRUCT *p_dm_odm,
  127. u32 addr,
  128. u32 bitmask,
  129. u32 data
  130. )
  131. {
  132. if (addr == 0xffe)
  133. #ifdef CONFIG_LONG_DELAY_ISSUE
  134. ODM_sleep_ms(50);
  135. #else
  136. ODM_delay_ms(50);
  137. #endif
  138. else
  139. odm_set_bb_reg(p_dm_odm, addr, bitmask, data);
  140. /* Add 1us delay between BB/RF register setting. */
  141. ODM_delay_us(1);
  142. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> odm_config_bb_with_header_file: [PHY_REG] %08X %08X\n", addr, data));
  143. }
  144. void
  145. odm_config_bb_txpwr_lmt_8821c(
  146. struct PHY_DM_STRUCT *p_dm_odm,
  147. u8 *regulation,
  148. u8 *band,
  149. u8 *bandwidth,
  150. u8 *rate_section,
  151. u8 *rf_path,
  152. u8 *channel,
  153. u8 *power_limit
  154. )
  155. {
  156. #if (DM_ODM_SUPPORT_TYPE & ODM_CE)
  157. phy_set_tx_power_limit(p_dm_odm, regulation, band,
  158. bandwidth, rate_section, rf_path, channel, power_limit);
  159. #elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  160. PHY_SetTxPowerLimit(p_dm_odm, regulation, band,
  161. bandwidth, rate_section, rf_path, channel, power_limit);
  162. #endif
  163. }
  164. #endif