48 [rfpath] & 0xfffff3ff) | 0x0400);
53 "20M RF 0x18 = 0x%x\n",
65 "40M RF 0x18 = 0x%x\n",
71 "unknown bandwidth: %#X\n", bandwidth);
83 u32 tx_agc[2] = {0, 0}, tmpval;
84 bool turbo_scanoff =
false;
95 tx_agc[idx1] = ppowerlevel[idx1] |
96 (ppowerlevel[idx1] << 8) |
97 (ppowerlevel[idx1] << 16) |
98 (ppowerlevel[idx1] << 24);
103 tx_agc[idx1] = ppowerlevel[idx1] |
104 (ppowerlevel[idx1] << 8) |
105 (ppowerlevel[idx1] << 16) |
106 (ppowerlevel[idx1] << 24);
119 ptr = (
u8 *) (&(tx_agc[idx1]));
120 for (idx2 = 0; idx2 < 4; idx2++) {
130 "CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n",
135 "CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n",
140 "CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n",
145 "CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n",
151 u32 *ofdmbase,
u32 *mcsbase)
156 u32 powerbase0, powerbase1;
157 u8 legacy_pwrdiff, ht20_pwrdiff;
160 for (i = 0; i < 2; i++) {
161 powerlevel[
i] = ppowerlevel[
i];
163 powerbase0 = powerlevel[
i] + legacy_pwrdiff;
164 powerbase0 = (powerbase0 << 24) | (powerbase0 << 16) |
165 (powerbase0 << 8) | powerbase0;
166 *(ofdmbase +
i) = powerbase0;
168 " [OFDM power base index rf(%c) = 0x%x]\n",
169 i == 0 ?
'A' :
'B', *(ofdmbase + i));
172 for (i = 0; i < 2; i++) {
175 powerlevel[
i] += ht20_pwrdiff;
177 powerbase1 = powerlevel[
i];
178 powerbase1 = (powerbase1 << 24) | (powerbase1 << 16) |
179 (powerbase1 << 8) | powerbase1;
180 *(mcsbase +
i) = powerbase1;
182 " [MCS power base index rf(%c) = 0x%x]\n",
183 i == 0 ?
'A' :
'B', *(mcsbase + i));
187 static u8 _rtl92d_phy_get_chnlgroup_bypg(
u8 chnlindex)
191 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
192 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58,
193 60, 62, 64, 100, 102, 104, 106, 108, 110, 112,
194 114, 116, 118, 120, 122, 124, 126, 128, 130, 132,
195 134, 136, 138, 140, 149, 151, 153, 155, 157, 159,
199 if (channel_info[chnlindex] <= 3)
201 else if (channel_info[chnlindex] <= 9)
203 else if (channel_info[chnlindex] <= 14)
205 else if (channel_info[chnlindex] <= 64)
207 else if (channel_info[chnlindex] <= 140)
214 static void _rtl92d_get_txpower_writeval_by_regulatory(
struct ieee80211_hw *hw,
223 u8 i, chnlgroup = 0, pwr_diff_limit[4];
224 u32 writeval = 0, customer_limit, rf;
226 for (rf = 0; rf < 2; rf++) {
232 (rf ? 8 : 0)] + ((index < 2) ?
236 "RTK better performance, writeval(%c) = 0x%x\n",
237 rf == 0 ?
'A' :
'B', writeval);
243 chnlgroup = _rtl92d_phy_get_chnlgroup_bypg(
252 (rf ? 8 : 0)] + ((index < 2) ?
256 "Realtek regulatory, 20MHz, writeval(%c) = 0x%x\n",
257 rf == 0 ?
'A' :
'B', writeval);
261 writeval = ((index < 2) ? powerbase0[rf] :
264 "Better regulatory, writeval(%c) = 0x%x\n",
265 rf == 0 ?
'A' :
'B', writeval);
271 "customer's limit, 40MHz rf(%c) = 0x%x\n",
277 "customer's limit, 20MHz rf(%c) = 0x%x\n",
282 for (i = 0; i < 4; i++) {
285 [chnlgroup][index + (rf ? 8 : 0)] &
286 (0x7f << (i * 8))) >> (i * 8));
289 if (pwr_diff_limit[i] >
296 if (pwr_diff_limit[i] >
304 customer_limit = (pwr_diff_limit[3] << 24) |
305 (pwr_diff_limit[2] << 16) |
306 (pwr_diff_limit[1] << 8) |
309 "Customer's limit rf(%c) = 0x%x\n",
310 rf == 0 ?
'A' :
'B', customer_limit);
311 writeval = customer_limit + ((index < 2) ?
312 powerbase0[rf] : powerbase1[rf]);
314 "Customer, writeval rf(%c)= 0x%x\n",
315 rf == 0 ?
'A' :
'B', writeval);
321 (rf ? 8 : 0)] + ((index < 2) ?
322 powerbase0[rf] : powerbase1[rf]);
324 "RTK better performance, writeval rf(%c) = 0x%x\n",
325 rf == 0 ?
'A' :
'B', writeval);
328 *(p_outwriteval + rf) = writeval;
332 static void _rtl92d_write_ofdm_power_reg(
struct ieee80211_hw *hw,
333 u8 index,
u32 *pvalue)
337 static u16 regoffset_a[6] = {
342 static 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 <<
355 (i * 8))) >> (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,
BMASKDWORD, 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++) {
383 writeval = (writeval > 8) ?
386 writeval = (writeval > 6) ?
388 rtl_write_byte(rtlpriv, (
u32) (regoffset + i),
396 u8 *ppowerlevel,
u8 channel)
398 u32 writeval[2], powerbase0[2], powerbase1[2];
401 _rtl92d_phy_get_power_base(hw, ppowerlevel, channel,
402 &powerbase0[0], &powerbase1[0]);
403 for (index = 0; index < 6; index++) {
404 _rtl92d_get_txpower_writeval_by_regulatory(hw,
405 channel, index, &powerbase0[0],
406 &powerbase1[0], &writeval[0]);
407 _rtl92d_write_ofdm_power_reg(hw, index, &writeval[0]);
425 u1btmp = rtl_read_byte(rtlpriv, mac_reg);
426 if (!(u1btmp & mac_on_bit)) {
456 u1btmp = rtl_read_byte(rtlpriv, mac_reg);
457 if (!(u1btmp & mac_on_bit)) {
470 bool rtstatus =
true;
475 bool mac1_initradioa_first =
false, mac0_initradiob_first =
false;
476 bool need_pwrdown_radioa =
false, need_pwrdown_radiob =
false;
477 bool true_bpath =
false;
496 mac0_initradiob_first =
true;
508 mac1_initradioa_first =
true;
522 if (mac1_initradioa_first) {
525 need_pwrdown_radioa =
true;
528 mac1_initradioa_first =
false;
533 }
else if (mac0_initradiob_first) {
539 mac0_initradiob_first =
false;
540 need_pwrdown_radiob =
true;
550 u4_regvalue = rtl_get_bbreg(hw, pphyreg->
rfintfs,
555 u4_regvalue = rtl_get_bbreg(hw, pphyreg->
rfintfs,
606 "Radio[%d] Fail!!", rfpath);
607 goto phy_rf_cfg_fail;
616 if (need_pwrdown_radioa)
618 else if (need_pwrdown_radiob)