37 static bool _rtl92c_phy_rf6052_config_parafile(
struct ieee80211_hw *
hw);
47 0xfffff3ff) | 0x0400);
59 "unknown bandwidth: %#X\n", bandwidth);
72 u32 tx_agc[2] = { 0, 0 }, tmpval = 0;
73 bool turbo_scanoff =
false;
90 tx_agc[idx1] = ppowerlevel[idx1] |
91 (ppowerlevel[idx1] << 8) |
92 (ppowerlevel[idx1] << 16) |
93 (ppowerlevel[idx1] << 24);
95 if (tx_agc[idx1] > 0x20 &&
102 if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
106 }
else if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
112 tx_agc[idx1] = ppowerlevel[idx1] |
113 (ppowerlevel[idx1] << 8) |
114 (ppowerlevel[idx1] << 16) |
115 (ppowerlevel[idx1] << 24);
132 ptr = (
u8 *) (&(tx_agc[idx1]));
133 for (idx2 = 0; idx2 < 4; idx2++) {
143 "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n",
148 tmpval = tmpval & 0xff00ffff;
151 "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n",
156 "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n",
161 "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n",
167 u32 *ofdmbase,
u32 *mcsbase)
172 u32 powerBase0, powerBase1;
173 u8 legacy_pwrdiff = 0, ht20_pwrdiff = 0;
176 for (i = 0; i < 2; i++) {
177 powerlevel[
i] = ppowerlevel[
i];
179 powerBase0 = powerlevel[
i] + legacy_pwrdiff;
180 powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) |
181 (powerBase0 << 8) | powerBase0;
182 *(ofdmbase +
i) = powerBase0;
184 " [OFDM power base index rf(%c) = 0x%x]\n",
185 i == 0 ?
'A' :
'B', *(ofdmbase + i));
187 for (i = 0; i < 2; i++) {
190 powerlevel[
i] += ht20_pwrdiff;
192 powerBase1 = powerlevel[
i];
193 powerBase1 = (powerBase1 << 24) |
194 (powerBase1 << 16) | (powerBase1 << 8) | powerBase1;
195 *(mcsbase +
i) = powerBase1;
197 " [MCS power base index rf(%c) = 0x%x]\n",
198 i == 0 ?
'A' :
'B', *(mcsbase + i));
202 static void _rtl92c_get_txpower_writeval_by_regulatory(
struct ieee80211_hw *hw,
211 u8 i, chnlgroup = 0, pwr_diff_limit[4];
212 u32 writeVal, customer_limit, rf;
214 for (rf = 0; rf < 2; rf++) {
219 [chnlgroup][index + (rf ? 8 : 0)]
220 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
222 "RTK better performance,writeVal(%c) = 0x%x\n",
223 rf == 0 ?
'A' :
'B', writeVal);
231 else if (channel >= 4 && channel <= 9)
233 else if (channel > 9)
244 ((index < 2) ? powerBase0[rf] :
247 "Realtek regulatory, 20MHz, writeVal(%c) = 0x%x\n",
248 rf == 0 ?
'A' :
'B', writeVal);
251 writeVal = ((index < 2) ? powerBase0[rf] :
254 "Better regulatory,writeVal(%c) = 0x%x\n",
255 rf == 0 ?
'A' :
'B', writeVal);
262 "customer's limit, 40MHzrf(%c) = 0x%x\n",
268 "customer's limit, 20MHz rf(%c) = 0x%x\n",
273 for (i = 0; i < 4; i++) {
276 [chnlgroup][index + (rf ? 8 : 0)]
277 & (0x7f << (i * 8))) >> (i * 8));
280 if (pwr_diff_limit[i] >
283 pwr_diff_limit[
i] = rtlefuse->
287 if (pwr_diff_limit[i] >
295 customer_limit = (pwr_diff_limit[3] << 24) |
296 (pwr_diff_limit[2] << 16) |
297 (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]);
299 "Customer's limit rf(%c) = 0x%x\n",
300 rf == 0 ?
'A' :
'B', customer_limit);
301 writeVal = customer_limit + ((index < 2) ?
302 powerBase0[rf] : powerBase1[rf]);
304 "Customer, writeVal rf(%c)= 0x%x\n",
305 rf == 0 ?
'A' :
'B', writeVal);
310 [index + (rf ? 8 : 0)] + ((index < 2) ?
311 powerBase0[rf] : powerBase1[rf]);
313 "RTK better performance, writeValrf(%c) = 0x%x\n",
314 rf == 0 ?
'A' :
'B', writeVal);
317 if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
319 writeVal = 0x14141414;
320 else if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
322 writeVal = 0x00000000;
324 writeVal = writeVal - 0x06060606;
325 else if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
328 *(p_outwriteval + rf) = writeVal;
332 static void _rtl92c_write_ofdm_power_reg(
struct ieee80211_hw *hw,
333 u8 index,
u32 *pValue)
337 u16 regoffset_a[6] = {
342 u16 regoffset_b[6] = {
347 u8 i, rf, pwr_val[4];
351 for (rf = 0; rf < 2; rf++) {
352 writeVal = pValue[rf];
353 for (i = 0; i < 4; i++) {
354 pwr_val[
i] = (
u8)((writeVal & (0x7f << (i * 8))) >>
359 writeVal = (pwr_val[3] << 24) | (pwr_val[2] << 16) |
360 (pwr_val[1] << 8) | pwr_val[0];
362 regoffset = regoffset_a[
index];
364 regoffset = regoffset_b[
index];
365 rtl_set_bbreg(hw, regoffset,
MASKDWORD, writeVal);
367 "Set 0x%x = %08x\n", regoffset, writeVal);
368 if (((get_rf_type(rtlphy) ==
RF_2T2R) &&
371 ((get_rf_type(rtlphy) !=
RF_2T2R) &&
374 writeVal = pwr_val[3];
381 for (i = 0; i < 3; i++) {
382 writeVal = (writeVal > 6) ? (writeVal - 6) : 0;
383 rtl_write_byte(rtlpriv, (
u32)(regoffset + i),
391 u8 *ppowerlevel,
u8 channel)
393 u32 writeVal[2], powerBase0[2], powerBase1[2];
396 rtl92c_phy_get_power_base(hw, ppowerlevel,
397 channel, &powerBase0[0], &powerBase1[0]);
398 for (index = 0; index < 6; index++) {
399 _rtl92c_get_txpower_writeval_by_regulatory(hw,
404 _rtl92c_write_ofdm_power_reg(hw, index, &writeVal[0]);
412 bool rtstatus =
true;
413 u8 b_reg_hwparafile = 1;
419 if (b_reg_hwparafile == 1)
420 rtstatus = _rtl92c_phy_rf6052_config_parafile(hw);
424 static bool _rtl92c_phy_rf6052_config_parafile(
struct ieee80211_hw *hw)
430 bool rtstatus =
true;
438 u4_regvalue = rtl_get_bbreg(hw, pphyreg->
rfintfs,
443 u4_regvalue = rtl_get_bbreg(hw, pphyreg->
rfintfs,
473 rtl_set_bbreg(hw, pphyreg->
rfintfs,
478 rtl_set_bbreg(hw, pphyreg->
rfintfs,
484 "Radio[%d] Fail!!", rfpath);
485 goto phy_rf_cfg_fail;