37 static bool _rtl92ce_phy_rf6052_config_parafile(
struct ieee80211_hw *
hw);
47 0xfffff3ff) | 0x0400);
59 "unknown bandwidth: %#X\n", bandwidth);
71 u32 tx_agc[2] = {0, 0}, tmpval;
72 bool turbo_scanoff =
false;
85 tx_agc[idx1] = ppowerlevel[idx1] |
86 (ppowerlevel[idx1] << 8) |
87 (ppowerlevel[idx1] << 16) |
88 (ppowerlevel[idx1] << 24);
93 tx_agc[idx1] = ppowerlevel[idx1] |
94 (ppowerlevel[idx1] << 8) |
95 (ppowerlevel[idx1] << 16) |
96 (ppowerlevel[idx1] << 24);
114 ptr = (
u8 *) (&(tx_agc[idx1]));
115 for (idx2 = 0; idx2 < 4; idx2++) {
126 "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n",
131 tmpval = tmpval & 0xff00ffff;
136 "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n",
143 "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n",
150 "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n",
156 u32 *ofdmbase,
u32 *mcsbase)
161 u32 powerBase0, powerBase1;
162 u8 legacy_pwrdiff, ht20_pwrdiff;
165 for (i = 0; i < 2; i++) {
166 powerlevel[
i] = ppowerlevel[
i];
168 powerBase0 = powerlevel[
i] + legacy_pwrdiff;
170 powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) |
171 (powerBase0 << 8) | powerBase0;
172 *(ofdmbase +
i) = powerBase0;
174 " [OFDM power base index rf(%c) = 0x%x]\n",
175 i == 0 ?
'A' :
'B', *(ofdmbase + i));
178 for (i = 0; i < 2; i++) {
181 powerlevel[
i] += ht20_pwrdiff;
183 powerBase1 = powerlevel[
i];
184 powerBase1 = (powerBase1 << 24) |
185 (powerBase1 << 16) | (powerBase1 << 8) | powerBase1;
187 *(mcsbase +
i) = powerBase1;
190 " [MCS power base index rf(%c) = 0x%x]\n",
191 i == 0 ?
'A' :
'B', *(mcsbase + i));
195 static void _rtl92c_get_txpower_writeval_by_regulatory(
struct ieee80211_hw *hw,
204 u8 i, chnlgroup = 0, pwr_diff_limit[4];
205 u32 writeVal, customer_limit, rf;
207 for (rf = 0; rf < 2; rf++) {
215 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
218 "RTK better performance, writeVal(%c) = 0x%x\n",
219 rf == 0 ?
'A' :
'B', writeVal);
223 writeVal = ((index < 2) ? powerBase0[rf] :
227 "Realtek regulatory, 40MHz, writeVal(%c) = 0x%x\n",
228 rf == 0 ?
'A' :
'B', writeVal);
235 else if (channel >= 4 && channel <= 9)
237 else if (channel > 9)
245 [index + (rf ? 8 : 0)] + ((index < 2) ?
250 "Realtek regulatory, 20MHz, writeVal(%c) = 0x%x\n",
251 rf == 0 ?
'A' :
'B', writeVal);
256 ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
259 "Better regulatory, writeVal(%c) = 0x%x\n",
260 rf == 0 ?
'A' :
'B', writeVal);
267 "customer's limit, 40MHz rf(%c) = 0x%x\n",
273 "customer's limit, 20MHz rf(%c) = 0x%x\n",
278 for (i = 0; i < 4; i++) {
282 (rf ? 8 : 0)] & (0x7f << (i * 8))) >>
287 if (pwr_diff_limit[i] >
294 if (pwr_diff_limit[i] >
303 customer_limit = (pwr_diff_limit[3] << 24) |
304 (pwr_diff_limit[2] << 16) |
305 (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]);
308 "Customer's limit rf(%c) = 0x%x\n",
309 rf == 0 ?
'A' :
'B', customer_limit);
311 writeVal = customer_limit +
312 ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
315 "Customer, writeVal rf(%c)= 0x%x\n",
316 rf == 0 ?
'A' :
'B', writeVal);
322 [index + (rf ? 8 : 0)]
323 + ((index < 2) ? powerBase0[rf] : powerBase1[rf]);
326 "RTK better performance, writeVal rf(%c) = 0x%x\n",
327 rf == 0 ?
'A' :
'B', writeVal);
332 writeVal = writeVal - 0x06060606;
333 else if (rtlpriv->
dm.dynamic_txhighpower_lvl ==
335 writeVal = writeVal - 0x0c0c0c0c;
336 *(p_outwriteval + rf) = writeVal;
340 static void _rtl92c_write_ofdm_power_reg(
struct ieee80211_hw *hw,
341 u8 index,
u32 *pValue)
346 u16 regoffset_a[6] = {
351 u16 regoffset_b[6] = {
356 u8 i, rf, pwr_val[4];
360 for (rf = 0; rf < 2; rf++) {
361 writeVal = pValue[rf];
362 for (i = 0; i < 4; i++) {
363 pwr_val[
i] = (
u8) ((writeVal & (0x7f <<
364 (i * 8))) >> (i * 8));
369 writeVal = (pwr_val[3] << 24) | (pwr_val[2] << 16) |
370 (pwr_val[1] << 8) | pwr_val[0];
373 regoffset = regoffset_a[
index];
375 regoffset = regoffset_b[
index];
376 rtl_set_bbreg(hw, regoffset,
MASKDWORD, writeVal);
379 "Set 0x%x = %08x\n", regoffset, writeVal);
381 if (((get_rf_type(rtlphy) ==
RF_2T2R) &&
384 ((get_rf_type(rtlphy) !=
RF_2T2R) &&
388 writeVal = pwr_val[3];
396 for (i = 0; i < 3; i++) {
397 writeVal = (writeVal > 6) ? (writeVal - 6) : 0;
398 rtl_write_byte(rtlpriv, (
u32) (regoffset + i),
406 u8 *ppowerlevel,
u8 channel)
408 u32 writeVal[2], powerBase0[2], powerBase1[2];
411 rtl92c_phy_get_power_base(hw, ppowerlevel,
412 channel, &powerBase0[0], &powerBase1[0]);
414 for (index = 0; index < 6; index++) {
415 _rtl92c_get_txpower_writeval_by_regulatory(hw,
421 _rtl92c_write_ofdm_power_reg(hw, index, &writeVal[0]);
435 return _rtl92ce_phy_rf6052_config_parafile(hw);
439 static bool _rtl92ce_phy_rf6052_config_parafile(
struct ieee80211_hw *hw)
445 bool rtstatus =
true;
455 u4_regvalue = rtl_get_bbreg(hw, pphyreg->
rfintfs,
460 u4_regvalue = rtl_get_bbreg(hw, pphyreg->
rfintfs,
496 rtl_set_bbreg(hw, pphyreg->
rfintfs,
501 rtl_set_bbreg(hw, pphyreg->
rfintfs,
508 "Radio[%d] Fail!!\n", rfpath);