N PHY Periodic Calibration Run (u8 type)
- Set fullcal to TRUE
- Set restore to FALSE
If bit 0x10 in measure_hold is set
- return
- If type is zero
Set fullcal to (radio_chanspec not equal to nphy_txiqlocal_chanspec
- Else if type is 2
- Set fullcal to FALSE
If cal_type_override not zero
If cal_type_override is not 1
- Set fullcal to false
If mphase_cal_phase_id > 1
If nphy_txiqlocal_chanspec not equal to radio_chanspec
If mphase_cal_phase_id is 9
- Write 10000 to shared memory location (0x5c * 2)
- Suspend MAC
Call PHY Register Enter
If mphase_cal_phase_id is 0 or 1
Set nphy_cal_orig_pwr_idx[0] to (PHY Register 0x1ED >> 8) & 0x7F
Set nphy_cal_orig_pwr_idx[1] to (PHY Register 0x1EE >> 8) & 0x7F
If nphy_txpwrctrl is 0
Read the N PHY Table with ID 7, length 2, offset 0x110, width 16, and data at nphy_cal_orig_tx_gain
- Otherwise
Set nphy_cal_orig_tx_gain[0] and [1] to 0
Set target to the returned value from N PHY Get TX Gain
Set state to nphy_txpwrctrl
Call N PHY TX Power Control Enable with argument 0
If antsel is 2
Call N PHY Antenna Select Init with true as argument
Set mphase to (mphase_cal_phase_id != 0)
- If mphase is not true
If PHY revision >= 3
Call N PHY Precal TX Gain
Set nphy_cal_target_gain to the output of N PHY Get TX Gain
- Set restore to true
Set target to nphy_cal_target_gain
If the output of N PHY Cal TX IQ Lo with arguments target, fullcal and mphase is 0
If (ipa2g_on and this is a 2G channel) OR (ipa5g_on and this is a 5G channel)
Call PHY a4 with argument true
Call PHY Register Exit
- Enable MAC
- Write 10000 to shared memory location (0x5c * 2)
- Disable MAC
Call PHY Register Enter
If (cal_type_override == 1)
- Set tmp to 2
- Otherwise
- Set tmp to 0
If the output of (N PHY Cal RX IQ with arguments target, (first_cal_after_assoc OR tmp, and false) is zero
Call N PHY Save Cal
Set nphy_perical_last to now
- If type is 0
Call N PHY RSSI Calibrate
If first_cal_after_assoc OR cal_type_override equals 1
Set first_cal_after_assoc to false
If PHY Revision >= 3
- Otherwise
If mphase_cal_phase_id is 1
Set nphy_perical_last to now
Set nphy_txiqlocal_chanspec to radio_chanspec
If PHY Revisio0n >= 3
Set nphy_cal_target_gain to the output value of N PHY Get TX Gain
Increment mphase_cal_phase_id
Else if mphase_cal_phase_id is 2, 3, 4, 5, 6, or 7
If radar_percal_mask AND 0x10 is not zero
Set nphy_rxcal_active to true
If the output of N PHY Cal TX IQ LO with arguments nphy_cal_target_gain, fullcal, and true is not zero
- Break
If PHY Revision < 3 AND (mphase_cal_phase_id is 6
Add 2 to mphase_cal_phase_id
- Otherwise
Increment mphase_cal_phase_id
Else if mphase_cal_phase_id is 8
If radar_percal_mask & 0x2 is not zero
If (ipa2g_on and this is a 2G channel) OR (ipa5g_on and this is a 5G channel)
Call PHY a4 with argument true
Increment mphase_cal_phase_id
- Break
Else if mphase_cal_phase_id is 9
If radar_percal_mask & 0x1 is not zero
Set nphy_rxcal_active to true
If (cal_type_override == 1)
- Set tmp to 2
- Otherwise
- Set tmp to 0
If the output of (N PHY Cal RX IQ with arguments target, (first_cal_after_assoc OR tmp, and false) is zero
Call N PHY Save Cal
Increment mphase_cal_phase_id
Else if mphase_cal_phase_id is 10
If radar_percal_mask & 0x4 is not zero
Set nphy_rxcal_active to true
Call N PHY RSSI Calibrate
If PHY Revision >= 3
- Set restore to true
If first_cal_after_assoc
Increment mphase_cal_phase_id
- Else
Else if mphase_cal_phase_id is 11
If radar_percal_mask & 0x8 is not zero
Set nphy_rxcal_active to true
If first_cal_after_assoc
Set first_cal_after_assoc to false
- Otherwise
If PHY Revision >= 3
- If restore is true
- If state is true
Call N PHY TX Power Index with arguments 1, nphy_cal_orig_pwr_idx[0], false
Call N PHY TX Power Index with arguments 2, nphy_cal_orig_pwr_idx[1], false
Set nphy_txpwrindex[0].index to -1
Set nphy_txpwrindex[1].index to -1
- Otherwise
Call N PHY TX Power Index with arguments 1, nphy_txpwrindex[0].index_internal, false
Call N PHY TX Power Index with arguments 2, nphy_txpwrindex[1].index_internal, false
- If state is true
- If restore is true
Call N PHY TX Power Control Enable with argument state
Call PHY Register Exit
- Enable MAC