N PHY TX Power Control Setup
- Create 2 element s16 arrays a1, b0, and b1
- Create 2 element u8 array idle
- Create 2 element s8 array target
- Create 64 element u32 array regval
- If 802.11 core revision is 11 or 12
Set bit 1 << 21 in MAC control register
- Do dummy read of MAC control register
- Delay 1 usec
if phyhang_avoid is not zero
Call N PHY Stay In Carrier Search with argument 1 (enable)
- Set bit 1 in PHY Register 0x122
If PHY Revision >= 3
Clear bit 1 << 15 in PHY Register 0x1E7
- Otherwise
Set bit 1 << 15 in PHY Register 0x1E7
- If 802.11 core revision is 11 or 12
Clear bit 1 << 21 in MAC control register
If SPROM Revision < 4
Set idle[0] to nphy_pwrctrl_info[0].idle_tssi_2g
Set idle[1] to nphy_pwrctrl_info[1].idle_tssi_2g
- Set both elements of target to 52
- Set both elements of a1 to -424
- Set both elements of b0 to 5612
- Set both elements of b1 to -1393
- Otherwise
Call N PHY Get Channel Frequency Range with argument 0 and save result in chan_range
- If chan_range is 0
Set idle[0] to nphy_pwrctrl_info[0].idle_tssi_2g
Set idle[1] to nphy_pwrctrl_info[1].idle_tssi_2g
Set target[0] to nphy_pwrctrl_info[0].max_pwr_2g
Set target[1] to nphy_pwrctrl_info[1].max_pwr_2g
Set a1[0] to nphy_pwrctrl_info[0].pwrdet_2g_a1
Set a1[1] to nphy_pwrctrl_info[1].pwrdet_2g_a1
Set b0[0] to nphy_pwrctrl_info[0].pwrdet_2g_b0
Set b0[1] to nphy_pwrctrl_info[1].pwrdet_2g_b0
Set b1[1] to nphy_pwrctrl_info[0].pwrdet_2g_b1
Set b1[1] to nphy_pwrctrl_info[1].pwrdet_2g_b1
- Else if chan_range is 1
Set idle[0] to nphy_pwrctrl_info[0].idle_tssi_5g
Set idle[1] to nphy_pwrctrl_info[1].idle_tssi_5g
Set target[0] to nphy_pwrctrl_info[0].max_pwr_5gl
Set target[1] to nphy_pwrctrl_info[1].max_pwr_5gl
Set a1[0] to nphy_pwrctrl_info[0].pwrdet_5gl_a1
Set a1[1] to nphy_pwrctrl_info[1].pwrdet_5gl_a1
Set b0[0] to nphy_pwrctrl_info[0].pwrdet_5gl_b0
Set b0[1] to nphy_pwrctrl_info[1].pwrdet_5gl_b0
Set b1[1] to nphy_pwrctrl_info[0].pwrdet_5gl_b1
Set b1[1] to nphy_pwrctrl_info[1].pwrdet_5gl_b1
- Else if chan_range is 2
Set idle[0] to nphy_pwrctrl_info[0].idle_tssi_5g
Set idle[1] to nphy_pwrctrl_info[1].idle_tssi_5g
Set target[0] to nphy_pwrctrl_info[0].max_pwr_5gm
Set target[1] to nphy_pwrctrl_info[1].max_pwr_5gm
Set a1[0] to nphy_pwrctrl_info[0].pwrdet_5gm_a1
Set a1[1] to nphy_pwrctrl_info[1].pwrdet_5gm_a1
Set b0[0] to nphy_pwrctrl_info[0].pwrdet_5gm_b0
Set b0[1] to nphy_pwrctrl_info[1].pwrdet_5gm_b0
Set b1[1] to nphy_pwrctrl_info[0].pwrdet_5gm_b1
Set b1[1] to nphy_pwrctrl_info[1].pwrdet_5gm_b1
- Else if chan_range is 3
Set idle[0] to nphy_pwrctrl_info[0].idle_tssi_5g
Set idle[1] to nphy_pwrctrl_info[1].idle_tssi_5g
Set target[0] to nphy_pwrctrl_info[0].max_pwr_5gh
Set target[1] to nphy_pwrctrl_info[1].max_pwr_5gh
Set a1[0] to nphy_pwrctrl_info[0].pwrdet_5gh_a1
Set a1[1] to nphy_pwrctrl_info[1].pwrdet_5gh_a1
Set b0[0] to nphy_pwrctrl_info[0].pwrdet_5gh_b0
Set b0[1] to nphy_pwrctrl_info[1].pwrdet_5gh_b0
Set b1[1] to nphy_pwrctrl_info[0].pwrdet_5gh_b1
Set b1[1] to nphy_pwrctrl_info[1].pwrdet_5gh_b1
- Otherwise
Set idle[0] to nphy_pwrctrl_info[0].idle_tssi_2g
Set idle[1] to nphy_pwrctrl_info[1].idle_tssi_2g
- Set both elements of target to 52 1, Set both elements of a1 to -424
- Set both elements of b0 to 5612
- Set both elements of b1 to -1393
Set target[0] to tx_power_max
Set target[1] to tx_power_max (Yes, they just overwrote the values set above!)
If PHY Revision >= 3
- If SPROM FEM 2G TSSI POS
Set bit 0x1 << 14) in PHY Register 0x1E9
If PHY Revision >= 7
- Loop for core equal 0, 1
If (nphy_ipa2g_on and band is 2 GHz) or (nphy_ipa5g_on and band is 5 GHz)
- If this is a 2G channel
- Write 0xE to Radio Register (core == 0) ? 0x179 : 0x199
- Otherwise
- Write 0xC to Radio Register (core == 0) ? 0x179 : 0x199
- If this is a 2G channel
- Loop for core equal 0, 1
- Otherwise
If (nphy_ipa2g_on and band is 2 GHz) or (nphy_ipa5g_on and band is 5 GHz)
- If this is a 5G channel
- Set tmp to 0xC
- Otherwise
- Set tmp to 0xE
- Write tmp to Radio Register 0x202D
- Write tmp to Radio Register 0x302D
- If this is a 5G channel
- Otherwise
- Write 0x11 to Radio Register 0x202D
- Write 0x11 to Radio Register 0x302D
- If SPROM FEM 2G TSSI POS
- If 802.11 core revision is 11 or 12
Set bit 1 << 21 in MAC control register
- Do dummy read of MAC control register
- Delay 1 usec
If PHY Revision >= 7
- Maskset PHY Register 0x1E7 with mask 0xFF80 and set with 0x19
- Otherwise
- Maskset PHY Register 0x1E7 with mask 0xFF80 and set with 0x40
If PHY Revision >= 7
- Maskset PHY Register 0x222 with mask 0xFF00 and set with 0x19
Else if PHY Revision > 1
- Maskset PHY Register 0x222 with mask 0xFF00 and set with 0x40
- If 802.11 core revision is 11 or 12
Clear bit 1 << 21 in MAC control register
- Write 0x3F0 to PHY Register 0x1E8
Write (1 << 15 | idle[1] << 8 | idle[0]) to PHY Register 0x1E9
Write (target[1] << 8 | target[0]) to PHY Register 0x1EA
- Loop for id values of 0 and 1
- Loop for index from 0 through 63 (inclusive)
- Set num to 8 * (16 * b0[id] + b1[id] * index)
- Set den to 32768 + a1[id] * index
- Set pwr to the maximum of (4 * num + den/2) / den and -8
If PHY Revision < 3
If index <= (31 - idle[id] +1)
- Set pwr to maximum of pwr and target[id] + 1
- Set regval[index] to pwr
- Write N PHY table with ID (id + 26), length 64, offset 0, width 32, and data regval
- Loop for index from 0 through 63 (inclusive)
Write N PHY table with ID 26, length 84 offset 64, width 8 and data from adj_pwr_tbl_nphy
Write N PHY table with ID 27, length 84 offset 64, width 8 and data from adj_pwr_tbl_nphy
if phyhang_avoid is not zero
Call N PHY Stay In Carrier Search with argument 0 (disable)