N PHY TX Power Fix
- Establish a 2-element u8 array named txpi
- Establish a u32 pointer named gaintbl
If phyhang_avoid
Call N PHY Stay in Carrier Search with argument 1
If the SPROM Revision < 4
- Set txpi[0] and txpi[1] to 72
- Otherwise
Call 802.11/PHY/N/GetChanFreqRange with argument 0, save return in tmp
- If tmp is zero
Set txpi[i] to nphy_txpid2g[i] for i = 0, 1
- Else if tmp is 1
Set txpi[i] to nphy_txpid5gl[i] for i = 0, 1
- Else if tmp is 2
Set txpi[i] to nphy_txpid5g[i] for i = 0, 1
- Else if tmp is 3
Set txpi[i] to nphy_txpid5gh[i] for i = 0, 1
- Otherwise
- Set txpi[i] to 91 for i = 0, 1
If PHY Revision >= 7
- Set txpi[i] to 30 for i = 0,1
Else if PHY Revision >= 3
- Set txpi[i] to 40 for i = 0, 1
If PHY Revision < 7
If txpi[0] < 40 PR txpi[0] > 100 OR If txpi[1] < 40 PR txpi[1] > 100
- Set txpi[i] to 91 for i = 0, 1
Set nphy_txpwrindex[i].index_internal = txpi[i] for i = 0, 1
Set nphy_txpwrindex[i].index_internal_save = txpi[i] for i = 0, 1
- Loop 2 times with index i
If PHY Revision >= 3
If ((nphy_ipa2g_on and band is 2 GHz) or (nphy_ipa5g_on and band is 5 GHz))
Set gaintbl to the output of N PHY Get IPA Gain Table
- Set txgain to gaintbl[txpi[i]]
- Otherwise
- If the band if 5 GHz
- If PHY Revision is 3
- Set txgain to nphy_txpwrctrl_5GHz_txgain_rev3[txpi[i]]
- Else if PHY Revision is 4
- If SPROM FEM 5G extpa_gain is 3
- Set txgain to nphy_tpc_5GHz_txgain_HiPwrEPA[txpi[i]]
- Otherwise
- Set txgain to nphy_txpwrctrl_5GHz_txgain_rev4[txpi[i]]
- If SPROM FEM 5G extpa_gain is 3
- Otherwise
- Set txgain to nphy_txpwrctrl_5GHz_txgain_rev5[txpi[i]]
- If PHY Revision is 3
- Otherwise
If PHY Revision >= 5 AND SPROM FEM 5G extpa_gain is 3
- Set txgain to nphy_tpc_5GHz_txgain_HiPwrEPA[txpi[i]]
- Otherwise
- Set txgain to nphy_txpwrctrl_5GHz_txgain_rev3[txpi[i]]
- If the band if 5 GHz
- Otherwise
- Set txgain to nphy_txpwrctrl_txgain[txpi[i]]
If PHY Revision >= 3
Set radio_gain to (txgain >> 16) & ((1 << 17) - 1)
- Otherwise
Set radio_gain to (txgain >> 16) & ((1 << 13) - 1)
If If PHY Revision >= 7
Set dac_gain to (txgain >> 8) & ((1 << 3) - 1)
- Otherwise
Set dac_gain to (txgain >> 8) & ((1 << 6) - 1)
Set bbmult to txgain & ((1 << 8) - 1)
If PHY Revision >= 3
- If i is 0
- Set bit 0x0100 in PHY register 0x8F
- Otherwise
- Set bit 0x0100 in PHY register 0xA5
- If i is 0
- Otherwise
- Set bit 0x4000 in PHY Register 0xA5
- If i is 0
- Write dac_gain to PHY Register 0xAA
- Otherwise
- Write dac_gain to PHY Register 0xAB
- Write an N PHY Table with ID 5, length 1, offset (0x110 + i), width 16, and data from rad_gain
- Read an N PHY Table with ID 15, length 1, offset 0x57, width 16, and data m1m2
- If i is 0
Maskset mlm2 with mask 0x00FF and set with bbmult << 8
- Otherwise
- Maskset mlm2 with mask 0xFF00 and set with bbmult
- Write an N PHY Table with ID 15, length 1, offset 0x57, width 16, and data m1m2
If ((nphy_ipa2g_on and band is 2 GHz) or (nphy_ipa5g_on and band is 5 GHz))
- Read an N PHY Table with ID (26 + i), length 1, offset 576 + txpi[i], width 32, and data tmp32
- If i is 0
Maskset PHY Register 0x297 with mask 0xE00F and set with (tmp32 << 4)
- Set bit 4 in PHY Register 0x297
- Otherwise
Maskset PHY Register 0x29B with mask 0xE00F and set with (tmp32 << 4)
- Set bit 4 in PHY Register 0x29B
- Mask PHY Register 0xBF with mask 0xFFE0
If phyhang_avoid
Call N PHY Stay in Carrier Search with argument 0