LP PHY TX IQLO Cal (struct lpphy_txgains *target_gains, int mode, int keep_tone)
- Create a 5 element array of u16 for override data
- Create an 11 element array of u16 for system coefficients and initialize to zero
- Create a 6 element array of u16 calibration commands and initialize to { 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 }
- Create a 6 element array of u16 recalibration commands and initialize to { 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223 }
- Create a 6 element array of u16 command data and initialize to { 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 }
- Create a table with table ID of 0, table width of 16
- Set the calibration to start at step 0
- If mode is zero
- Set start coefficients to system coefficients
- Set commands to calibration commands
- Set number of commands to size of the calibration commands array
- Else if mode is 1
- Set start coefficients to lpphy_txiqlocal_bestcoefs
- Set commands to recalibration commands
- Set number of commands to size of the recalibration commands array
- Else if mode is 2
- Set the table data pointer to the system coefficients
- Set the table length to 7 and the table offset to 80
- Set commands to recalibration commands
- Set number of commands to size of the recalibration commands array
- If mode is 2 OR 3
LP PHY Get Radio Loft with arguments ( &ei0, &eq0, &fi0, &fq0 )
Set system coefficients[7] = ((ei0 & 0xFF) << 8) | (eq0 & 0xFF)
- Set system coefficients[8] to 0
Set system coefficients[7] = ((fi0 & 0xFF) << 8) | (fq0 & 0xFF)
- Set system coefficients[10] to 0
- Set start coefficients to system coefficients
- If mode is 3
- Set commands to calibration commands
- Set number of commands to size of the calibration commands array
- Set the calibration to start at step 2
- Set the table data pointer to the start coefficients, the table length to 11, and the table offset to 64
Read Phy Register 0x4A4, mask with 0xE000 and save as old value
LP PHT Set TX Power Control with argument 0
If Phy Register 0x43B & 0x0040 is not zero
- Set old override = 1
- Otherwise
- Set old override = 0
- If old override is not zero
LP PHY Get TX gains with argument &old_gains (a struct lpphy_txgains variable)
- If (input) target_gains is NULL
- If the old override is zero
LP PHY Set TX Power by Index with private variable lpphy_tssi_index as argument
LP PHY Get TX Gain with &temp_gains as argument
Set target_gains = &temp_gains
- If the old override is zero
Calculate tmp as (target_gains->gm_gain << 8) | (target_gains->pga_gain << 4) | target_gains->pad_gain
- Use memset to clear the override array
- If current band is 5 GHx
- Set the band index to 1
- Set a 9-element gains array to {0x7ef, 7, 0xe, 0xe, 0, 0, 0, 0, 0}
- Otherwise
- Set the band index to 0
- Set a 9-element gains array to {0, 0, 0, 0, 0, 0, 0, 0, 0}
- Set calculated gains to *target_gains
- If tmp equals the 0th element of the gains array
- Set cal_gains.gm_gain = gains[1]
- Set cal_gains.pga_gain = gains[2]
- Set cal_gains.pad_gain = gains[3]
- Copy all 5 elements of the override array to gains[3 - 7]
LP PHY Set TX Gain with &cal_gains as argument
If PHY revision < 2
Set bit 0x8 in Phy Register 0x44C
Clear bit 0x8 in Phy Register 0x44D
Set bit 0x20 in Phy Register 0x44C
Clear bit 0x20 in Phy Register 0x44D
Read Phy Register 0x43D and save as tmp2
MaskSet Phy Register 0x43D with mask 0xFF00 and set with 0x0059
Read Radio Register 0x16 and save as tmp3
Clear bits 0xFF0C in Radio Register 0x16
Clear bits 0x0010 in Radio Register 0x12
Set bit 0x0001 in Phy Register 0x490
- Otherwise
Read Phy Register 0x43E and save as tmp2
- If boardtype is 0x0490
MaskSet Phy Register 0x43E with mask 0xFC00 and set with 0x00A5
- Otherwise
MaskSet Phy Register 0x43E with mask 0xFC00 and set with 0x00CA
Read Radio Register 0x121 and save as tmp3
Clear bits 0x000D in Radio Register 0x121
Clear bits 0x0080 in Radio Register 0x11F
Read Phy Register 0x4D0 and save as tmp4
Clear bit 0x8 in Phy Register 0x4D0
Read Phy Register 0x503 and save as tmp5
Set bit 0x8 in Phy Register 0x503
Clear bit 0x4 in Phy Register 0x503
Call LP PHY Set TRSW Override with arguments (0, 1)
- Set table data pointer to the Loft Gain Ladder Table below
- Set table length to 20 and table offset to 0
- Set table data pointer to the IR Gain Ladder Table
- Set table offset to 32
If phy_tone_freq is zero AND the PHY revision < 2
- Set table data pointer to a u16 variable
- Set table length to 1, ID to 0x0B, offset to 9. and width to 16
Loop starting from 1 until LP PHY TX IQLO Functional returns zero
If loop index > 20
- Error and goto cleanup
- If loop index % 3 is zero
- If the table data word ANDed with 1 is not zero
- Increment table data word
- Otherwise
- Decrement table data word
Write 0x0AA9 to Phy Register 0x453
If PHY TX Tone Frequency is zero
If PHY revision < 2
Call LP PHY Start TX Tone with arguments ( 2500, 100)
- Otherwise
Call LP PHY Start TX Tone with arguments ( 3750, 22)
Set bit 0x8000 in Phy Register 0x453
- Loop with index i from the calibration starting step through one less than the number of commands (inclusive)
The calibration type is (commands[i] & 0x0F00) >> 8
- The command number is the ith entry in the command_nums array
- If ncorr_override[cal_type] is not zero
The command number is ncorr_override[cal_type] << 8 | (command number & 0xFF)
Write command number to Phy Register 0x452
- If the calibration type is 3 or 4
- Set the table data pointer to a u16 called start, the table length to 1, and the table offset to 69
- Set the table pointer to a u16 containing zero
Write cal_cmds[i] to Phy Register 0x451
If LP PHY IQcal Wait is not zero
- Error as TX IQLO Cal failed to complete
- Goto cleanup
- Set the table data pointer to an 11 element array of u16
- Set the table length to 11, and the table offset to 96
- Set the table offset to 64
- If the calibration type is 3 or 4
- Set the table pointer to start, the length to 1, and the table offset to 69
Set the table data pointer to lpphy_txiqlocal_bestcoeffs, the length to 11, and the table offset to 96
Set the table data pointer to lpphy_txiqlocal_bestcoeffs[0], the length to 4, and the table offset to 80
Set the table data pointer to lpphy_txiqlocal_bestcoeffs[5], the length to 2, and the table offset to 85
cleanup:
- If keep_tone is zero
Call LP PHY Stop TX Tone
Write 0 to Phy Register 0x453
If PHY revision < 2
- If keep_tone is zero
Clear bits 0x28 in Phy Register 0x44C
Set bit 0x10 in Radio Register 0x12
Write tmp2 to Phy Register 0x43D
Write tmp3 to Radio Register 0x16
- If keep_tone is zero
- Otherwise
Set bit 0x8 in Phy Register 0x503
MaskSet Phy Register 0x43C with mask 0xFFC7 and set with rssi_muxsel_old << 3
Bit set 0x80 in Radio Register 0x11F
Write tmp2 to Phy Register 0x43E
Write tmp3 to Radio Register 0x121
Write tmp4 to Phy Register 0x4D0
Write tmp5 to Phy Register 0x503
Clear bit 0x4 in Phy Register 0x43B
- If the old override is not zero
Call LP PHY Set TX Gain with &old_gains as the argument
Call LP PHY Set TX Power Control with tx_pwr_ctrl_old as thge argument
Loft Gain Ladder Table
0x020 |
0x030 |
0x040 |
0x060 |
0x080 |
0x0B0 |
0x100 |
0x101 |
0x102 |
0x103 |
0x104 |
0x105 |
0x106 |
0x107 |
0x177 |
0x207 |
0x2D7 |
0x407 |
0x5B7 |
0x807 |
IR Gain Ladder Table
0x010 |
0x020 |
0x040 |
0x060 |
0x080 |
0x0B0 |
0x100 |
0x170 |
0x200 |
0x2D0 |
0x400 |
0x401 |
0x402 |
0x403 |
0x404 |
0x405 |
0x406 |
0x407 |
0x5B7 |
0x807 |