bcm-v4

[Specification

Local Oscillator Computed I and Q Table

The LO Computed I and Q table is a table of the computed I and Q values (LO Control Values) associated with the attenuation settings of the device. The I and Q values are kept for each possible attenuation value and are indexed by RF Attenuation and Baseband Attenuation. If the PAD Mixer is enabled, the value is considered different from the attenuation setting without the PAD Mixer and are stored as such. Additionally, entries may be marked as used or unused to help speed up calibration when the table isn't empty.

Building the Table

There are specific branches in the sections below that depend upon whether the table is empty or not. On init and after certain events, the table is cleared and then rebuilt.

Start

In this phase, registers are backed up and the LO is put into a known frequency to prepare for calibration.

  1. If Hardware Power Control is enabled

    1. Backup PHY Registers 0x80F, 0x801, 0x60, 0x14, 0x478

    2. OR PHY Register 0x478 with 0x100

    3. OR PHY Register 0x801 with 0x40

    4. OR PHY Register 0x60 with 0x40

    5. OR PHY Register 0x14 with 0x200

  2. If this isn't a GPHY
    1. Return /!\ Note older versions had B PHY Code too...

  3. If the table isn't empty and Hardware Power Control is enabled

    1. Read in the Power Vector from SHM offset 0x310 in 16 bit pieces, but clear the top 8 bits of each 16 bit value (Note that this introduces 8 bits of 0 between 8 bits of data read)

    2. Clear the Power Vector at SHM offset 0x310 by writing 0's

    3. If any Power Vector bits are set

      1. Save a copy of the Power Vector

    4. Loop from 0 to 0x40
      1. If the saved Power Vector has the bit corresponding to this loop position set

        1. The RF Attenuation value corresponding to this position is found by dividing the list position by the length of the RF Attenuation List for this board and throwing away the remainder, this is the offset to use in the RF Attenuation List

        2. The Baseband Attenuation value corresponding to this position is found by dividing the list position by the length of the RF Attenuation Values for this board and only keeping the remainder, this is the offset to use in the Baseband Attenuation List

        3. Mark as used the I and Q table entry corresponding to the Baseband and RF attenuation values found above
  4. If the PHY Revision is 2 or greater
    1. Save PHY Registers 0x814, 0x815, 0x811, 0x812, 0x802, 0x3E, 0x429

    2. AND PHY Register 0x802 with 0xFFFC

    3. AND PHY Register 0x429 with 0x7FFF

    4. OR PHY Register 0x814 with 3

    5. AND PHY Register 0x815 with 0xFFFC

    6. If PHY Revision is 7 or greater and the Board Flags indicate an External LNA

      1. Write 0x933 to PHY Register 0x811

    7. Otherwise
      1. Write 0x133 to PHY Register 0x811

    8. Write 0 to PHY Register 0x3E

  5. Back up Core Registers 0x3F4, 0x3E2

  6. Back up Radio Registers 0x43, 0x7A

  7. Back up PHY Registers 0x15, 0x2A, 0x35, 0x60

  8. If TX Magnification isn't enabled

    1. Back up Radio Register 0x52

    2. AND the backed up value with 0xF0
  9. Back up the current channel
  10. OR Core Register 0x3E2 with 0x8000

  11. AND Core Register 0x3F4 with 0xF000

  12. Write 0x7F to PHY Register 0x80F

  13. Write the backed up value of PHY Register 0x35 AND'd with 0xFF7F to PHY Register 0x35

  14. Write the backed up value of Radio Register 0x7A AND'd with 0xFFF0 to Radio Register 0x7A

  15. Write 0x8A3 to PHY Register 0x2A

  16. Write 0x1003 to PHY Register 0x2B

  17. If the PHY Revision is 2 or greater
    1. Perform a CCK Dummy Transmission

  18. Set the channel to 6
  19. Perform a dummy read on Radio Register 0x51

  20. If this is a G PHY
    1. Write 0 to PHY Register 0x2F

  21. If the table is empty
    1. If Loopback Gain is disabled

      1. The Loopback Gain value is 0

      2. The TRSW_RX value is 2

      3. The PGA value is 0

      4. MaskSet the Power Control Radio Register (0x43) with mask 0xFFF0 and set with 6

    2. Otherwise, the values must be computed
      1. The TRSW_RX value is 0

      2. Take the saved Maximum Loopback Gain value and divide the result by 2, this is the Loopback Gain value (converted back to dB from hdB)

      3. If the Loopback Gain value in hdB is greater than 10

        1. Subtract 10 from the Loopback Gain value in hdB, then divide that by 6, this is the PGA Value

        2. If the PGA Value is 0x10 or greater

          1. Use 0xF as the PGA Value instead

        3. MaskSet the Power Control Radio Register (0x43) with mask 0xFFF0 and set with 0

      4. Otherwise
        1. The PGA value is 0

        2. If the PHY Revision is 2 or greater with a 0x2050 radio with revision 8
          1. The Loopback Gain Comparison value is 0xF
        3. Otherwise
          1. The Loopback Gain Comparison value is 0x9
        4. If the Loopback Gain in hdB is less than the Loopback Gain Comparison value multiplied by 4
          1. The Power Control value starts with the Loopback Gain Comparison value multiplied by 4
        5. Otherwise
          1. The Power Control value starts with the Loopback Gain value in dB
        6. If the Loopback Gain value in hdB is less than 0
          1. Add 6 to the Power Control value
        7. Otherwise
          1. Add 3 to the Power Control value
        8. Divide the Power Control value by 4
        9. If the Power Control value is less than the Loopback Gain Comparison value
          1. MaskSet the Power Control Radio Register (0x43) with mask 0xFFF0 and set with the Power Control value

        10. Otherwise
          1. MaskSet the Power Control Radio Register (0x43) with mask 0xFFF0 and set with the Loopback Gain Comparison value

    3. Set the Baseband Attenuation to 2
    4. AND the TXCTL Radio Register from the TXCTL Register and Value Table with bitwise inverse of the value from the table

    5. If TX Magnification is enabled

      1. Loop over the TX Magnification Values

        1. MaskSet Radio Register 0x52 with mask 0xFF0F and set with the current TX Magnification Value left shifted by 4

        2. Loop over the TX Bias List

          1. MaskSet Radio Register 0x52 with mask 0xFFF0 and set with the current TX Bias List value

          2. Measure the Feedthrough using the TRSW_RX value and PGA value from above and an LNA value of 0

          3. If the result is less than the previous minimum (or it's the first time through the loop)
            1. Save the current TX Bias value and TX Magnification value
          4. If the saved TX Bias value is 0, break the loop
        1. Left shift the saved TX Magnification value by 4
        2. OR that value with the saved TX Bias value
        3. Write the result to Radio Register 0x52

    6. Otherwise,
      1. AND Radio Register 0x52 with 0xFFF0 (the TX Bias is 0)

  22. If the PHY Revision is 3 or greater
    1. Write 0xC078 to the LO Control PHY Register (0x80F on G PHYs, 0x2E on B PHYs)

  23. Otherwise
    1. Write 0x8078 to the LO Control PHY Register (0x80F on G PHYs, 0x2E on B PHYs)

LO Calibration

In this phase, different states are tried to find the state with the lowest LO leakage

  1. Start with a LO Control Value with I = 0 and Q = 0

  2. Loop over the RF Attenuation List for this board

    1. If the table was empty and the PAD Mixer flag is not enabled for this RF Attenuation List value

      1. If this is the first iteration
        1. Set the LO Control Value to I = 0 and Q = 0

      2. Otherwise,
        1. If both the current and previous RF Attenuation List values are odd

          1. Set the LO Control Value to the computed I and Q table value corresponding to the last RF Attenuation List value and a Baseband Attenuation value of 0

        2. Otherwise
          1. Set the LO Control Value to the computed I and Q table value corresponding to the current RF Attenuation List value and a Baseband Attenuation value of 0

    1. MaskSet Radio Register 0x43 with mask 0xFFF0 and set with the current RF Attenuation List value

    2. MaskSet the Radio Register from the TXCTL Register and Value Table and mask with bitwise inverse of the Table Value and set with the Table Value if the PAD Mixer is enabled for this RF Attenuation List value

    3. Loop over the Baseband Attenuation List: for this board

      1. If the table is not empty
        1. If the I and Q value that corresponds to the current RF Attenuation List and Baseband Attenuation List values isn't marked as used

          1. Skip this Baseband Attenuation List Value and move to the next one

        2. Copy the I and Q value associated with the current RF Attenuation List and Baseband Attenuation List values to the Curent LO Control Pair

      2. Otherwise
        1. Copy the I and Q value associated with the current RF Attenuation List and Baseband Attenuation List values as if the PAD Mixer wasn't enabled

      3. Multiply the RF Attenuation List value by 2 and add to that the Baseband Attenuation List value divided by 2, this is the Maximum RX Gain

      4. If the PAD Mixer is enabled for this RF Attenuation List value

        1. Subtract the PAD Mixer Gain (found in the TXCTL Register and Value Table) from the Maximum RX Gain

      5. If Loopback Gain is enabled
        1. Add the Maximum Loopback Gain value (in hdB) to the Maximum RX Gain
      6. Measure the Gains using the Maximum RX Gain found above (if the Loopback gain is enabled, the use of TRSW_RX is requested)

      7. Set the Baseband Attenuation to the current Baseband Attenuation List value

      8. Backup the current LO Control Value

      9. Test the states using the Local Oscillator State Machine

      10. If this is a BPHY
        1. Increment the I and Q values of the the current LO Control Value by 1

      11. Save the LO Control Value into the I and Q value table associated with the current Baseband and RF attenuation values

Finish

In this phase, registers are restored and the LO is configured for normal operation

  1. Write the LO Control Value with the lowest Feedthrough to the LO Control PHY Register (0x80F on G PHYs, 0x2E on B PHYs)

  2. If the PHY Revision is 2 or greater
    1. Write 0xE300 to PHY Register 0x15

    2. Write the PGA value from the last time the Gain Values were measured, shifted up by 8 ORed with 0xA0 to PHY Register 0x812

    3. Delay 5 uSecs
    4. Write the PGA value from the last time Gain Values were measured, shifted up by 8 ORed with 0xA2 to PHY Register 0x812

    5. Delay 2 uSecs
    6. Write the PGA value from the last time Gain Values were measured, shifted up by 8 ORed with 0xA3 to PHY Register 0x812

  3. Otherwise
    1. Bitwise OR the PGA value from the last time Gain Values were measured then with 0xEFA0 and write the result to PHY Register 0x15

  4. If this is a board with Hardware Power Control
    1. Initialize the GPHY DC Lookup Table
  5. Otherwise
    1. If the table was empty
      1. Adjust the Local Oscillator using Radio Attenuation 3, Baseband Attenuation 2 and no TX Control flags set

    2. Otherwise
      1. Adjust the Local Oscillator using the saved attenuation values

  6. If the PHY Revision is 3 or greater
    1. Write 0xC078 to PHY Register 0x2E

  7. Otherwise
    1. Write 0x8078 to PHY Register 0x2E

  8. If the PHY Revision is 2 or greater
    1. Write 0x202 to PHY Register 0x2F

  9. Otherwise
    1. Write 0x101 to PHY Register 0x2F

  10. Restore Core Register 0x3F4

  11. Restore PHY Registers 0x15, 0x2A, 0x35, 0x60

  12. Restore Radio Registers 0x43, 0x7A

  13. If TX Magnification isn't enabled

    1. MaskSet Radio Register 0x52 with mask 0xFF0F and set with the backed up value of Radio Register 0x52

  14. Restore Core Register 0x3E2

  15. If the PHY Revision is 2 or greater
    1. Restore PHY Registers 0x814, 0x815, 0x802, 0x811, 0x812, 0x3E, 0x429

  16. If this board has Hardware Power Control
    1. Restore PHY Register 0x80F, bitwise AND'd with 0xBFFF

    2. Restore PHY Registers 0x801, 0x60, 0x14, 0x478

  17. Set the channel back to the current channel (with the SynthPU Workaround)


Exported/Archived from the wiki to HTML on 2016-10-27