bcm-specs

[Specification

B PHY

/!\ This might be a state machine like the G PHY version below

  1. Back up PHYRegister 0x15

  2. Back up RadioRegister 0x52 and mask with 0xFFF0

  3. If the Radio ID for this radio is 0x2050
    1. Back up PHYRegisters 0xA, 0x2A, 0x35, 0x3, 0x1, 0x30

    2. Back up RadioRegisters 0x43, 0x7A

    3. Back up MMIO offset 0x3EC

    4. Back up RadioRegister 0x52 again and mask with 0xF0

    5. Write 0xFF to PHYRegister 0x30

    6. Write 0x3F3F to MMIO offset 0x3EC

    7. Write back the saved value of PHYRegister 0x35 masked with 0xFF7F

    8. Write back the saved value of RadioRegister 0x7A masked with 0xFFF0

  4. Write 0xB000 to PHYRegister 0x15

  5. If the Radio ID for this radio is 0x2050
    1. Write 0x203 to PHYRegister 0x2B

    2. Write 0x8A3 to PHYRegister 0x2A

  6. Otherwise
    1. Write 0x1402 to PHYRegister 0x2B

  7. Minimum of the first measurement is 0xFFFF (unsigned 16 bit value)
  8. Loop 4 times, from 0 to 3
    1. Write the first saved value of RadioRegister 0x52 bitwise OR'd with the number of times through this loop to RadioRegister 0x52

    2. Perform Reg15Loop (return value is ignored)

  9. Loop 10 times from 0 to 9
    1. Write the first saved value of RadioRegister 0x52 bitwise OR'd with the number of times through this loop to RadioRegister 0x52

    2. Perform Reg15Loop

    3. Divide the result by 10
    4. If this value is less than the minimum of the first measurement
      1. This is the new minimum, save it along with the position in the loop that this minimum occured at.
  10. Write the first saved value of RadioRegister 0x52 bitwise OR'd with the position in the loop the minimum value occured at to RadioRegister 0x52.

  11. Minimum of the second measurement is 0xFFFF (unsigned 16 bit value)
  12. Loop 5 times from -4 to 4, incrementing by 2's
    1. Loop 5 times from -4 to 4, incrementing by 2's
      1. If the current position in the inner loop is less than 0
        1. Find (0x100 * the position in outer loop) + the position in the inner loop + 0x100, this is the index value
      2. Otherwise
        1. Find (0x100 * the position in the outer loop) + the position in the inner loop, this is the index value
      3. Write the index value to PHYRegister 0x2F

      4. Perform Reg15Loop

      5. Divide the result by 10
      6. If this value is less than the minimum of the second measurement
        1. This is the new second minimum, save this value and the index value of this loop
  13. Increment the index value of the second minimum by 0x101
  14. Write the index value of the second minimum to PHYRegister 0x2F

  15. If the Radio ID for this radio is 0x2050
    1. Restore PHYRegisters 0xA, 0x2A, 0x35, 0x3, 0x1, 0x30

    2. Restore RadioRegisters 0x43, 0x7A

    3. MaskSet RadioRegister 0x52 with mask 0xF and set with the second saved value

    4. Restore MMIO offset 0x3EC

  16. Restore PHYRegister 0x15

  17. Perform a Synth PU Workaround

G PHYs

Measuring the LO is done from two different contexts, initialization and normal operation. When performed after initialization, only iterate over the LO Pairs that have been marked as used.

Setup

  1. If this board has HardwarePowerControl

    1. Back up PHYRegisters 0x80F, 0x801, 0x60, 0x14 and 0x478

    2. If the PHY revision is 6, 7 or 8
      1. Bitwise OR PHYRegister 0x478 with 0x100

      2. Bitwise OR PHYRegister 0x801 with 0x40

    3. Bitwise OR PHYRegister 0x60 with 0x40

    4. Bitwise OR PHYRegister 0x14 with 0x200

  2. If this is a BPHY with Radio Version 0x2050 and Radio Revision < 6

    1. Write 0x410 to PHYRegister 0x16

    2. Write 0x820 to PHYRegister 0x17

  3. If this isn't during initialization and this is a board with HardwarePowerControl

    1. Read in the Used LO Control Bitmap from SHM offset 0x89C in 16 bit chunks, but clear the top 8 bits of each 16 bit value read in

    2. Clear the Used LO Control Bitmap at SHM offset 0x89C by writing 0's

    3. If any bits are set in Used LO Control Bitmap that were just read in, save a copy of the Used LO Control Bitmap

    4. Loop from 0 to 0x40
      1. If the saved Used LO Control Bitmap has the bit corresponding to this loop position set, mark the LO Control array value corresponding to the position in this loop (see Loop To Attenuation for details) as used

  4. If PHYConnected is set

    1. Save PHYRegisters 0x814, 0x815, 0x811, 0x812, 0x802, 0x3E, 0x429

    2. Mask PHYRegister 0x429 with mask 0x7FFF

    3. Mask PHYRegister 0x802 with mask 0xFFFC

    4. Bitwise OR PHYRegister 0x814 with 3

    5. Mask PHYRegister 0x815 with mask 0xFFFC

    6. If this is a G PHY
      1. With PHY Revision >= 7 and BoardFlags indicate an External LNA

        1. Write 0x933 to PHYRegister 0x811

      2. Otherwise
        1. Write 0x133 to PHYRegister 0x811

    7. Otherwise
      1. Write 0 to PHYRegister 0x811

    8. Write 0 to PHYRegister 0x3E

  5. Save the 16 bit MMIO offset 0x3E2

  6. Save the 16 bit MMIO offset 0x3F4

  7. Save PHYRegisters 0x15, 0x2A, 0x35 and 0x60

  8. Save RadioRegisters 0x43, 0x7A

  9. If this isn't a 0x2050 Radio with Radio Revision 8
    1. Save RadioRegister 0x52 bitwise AND'd with 0xF0

  10. If this is a BPHY
    1. Save PHYRegisters 0x30, 0x6

    2. Write 0xFF to PHYRegister 0x30

    3. Write 0x3F3F to PHYRegister 0x6

  11. Otherwise
    1. Set bit 0x8000 in MMIO offset 0x3E2

  12. Bitwise AND MMIO offset 0x3F4 with 0xF000

  13. Write 0x7F to the LO Mask Register (PHYRegister 0x80F on GPHYs and 0x2E on BPHYs)

  14. Bitwise AND PHYRegister 0x35 with 0xFF7F

  15. Bitwise AND RadioRegister 0x7A with 0xFFF0

  16. Write 0x8A3 to PHYRegister 0x2A

  17. IF this is a GPHY or a BPHY with a 0x2050 Radio and Radio Revision 6 or greater
    1. Write 0x1003 to PHYRegister 0x2B

  18. Otherwise
    1. Write 0x802 to PHYRegister 0x2B

  19. If PHYConnected is set

    1. Perform a DummyTransmission

  20. Switch to channel 6
  21. Perform a dummy read on RadioRegister 0x51

  22. If this is a GPHY
    1. Write 0 to PHYRegister 0x2F

  23. If this is during initialization
    1. If this isn't a PHY Revision 2 or greater OR PHYConnected isn't set

      1. Set RadioRegister 0x43 below with 6

      2. The three values used when measuring the single subvalue below are 0x20, 0 and 0
    2. Otherwise
      1. Take the first saved Loopback Gain value, bitwise AND the signed 16 bit value with 0xFFFE

      2. If the 0xA - result * 2 < 0

        1. Set RadioRegister 0x43 below with 0

        2. Find the absolute value of 0xA - (result * 2), then divide by 6
        3. Cap the result to 0xF
        4. The three values used when measuring the single subvalue below are 0, 0 and the result
      3. Otherwise
        1. The three values used when measuring the single subvalue below are 0, 0 and 0
        2. Find 0xA - the result * 2
        3. If this is less than 0x24 (0x3C if this is a GPHY with PHY Revision 2 or greater and Radio Revision 8)
          1. Use 0xA - the result * 2
        4. Otherwise
          1. Use 0x24 (0x3C if this is a GPHY with PHY Revision 2 or greater and Radio Revision 8)
        5. If the result of the last operation is less than -3
          1. Add 6 to the result
        6. Otherwise
          1. Add 3 to the result
        7. If the result / 4 is greater than or equal to 0x9 (0xF if this is a GPHY with PHY Revision 2 or greater and Radio Revision 8)
          1. Set RadioRegister 0x43 below with 0x9 (0xF if this is a GPHY with PHY Revision 2 or greater and Radio Revision 8)

        8. Otherwise
          1. Set RadioRegister 0x43 below with the result / 4

    3. MaskSet RadioRegister 0x43 with mask 0xFFF0 and set with the value found above

    4. Set the Baseband Attenuation to 2 (see AttenuationControl)

    5. Mask the RadioRegister from the TXCTL Register and Value Table and mask with the value from the table

    6. If this is a GPHY with an 0x2050 Radio with Radio Revision 8
      1. Loop 2 times
        1. MaskSet RadioRegister 0x52 with mask 0xFF0F and set with 0x70 the first time and 0x40 the second (These are TXCTL1 Values)

        2. Loop over the TXCTL2 Values

          1. MaskSet RadioRegister 0x52 with mask 0xFFF0 and set with the current TXCTL2 Value

          2. Measure a single subvalue as shown below, using the control values specified above
          3. If the result is less than the previous minimum
            1. Save the current TXCTL1 Attenuation Value and TXCTL2 Attenuation Value
          4. If the saved TXCTL2 value is 0, break the loop
        1. Write the saved TXCTL2 attenuation value OR'd with the saved TXCTL1 attenuation value left shifted by 4 to RadioRegister 0x52

    7. Otherwise,
      1. Mask RadioRegister 0x52 with mask 0xFFF0

  24. If this is a GPHY with PHY Revision 3 or greater
    1. Write 0xC078 to PHYRegister 0x80F (the LO Control Register Mask)

  25. Otherwise
    1. Write 0x8078 to the appropriate LO Control Register Mask PHYRegister 0x2E for BPHYs or 0x80F for GPHYs

Measuring the LO Control Values

In the following, you'll always be measuring values in search of a minimum. One idea as to what it's measuring is a deviation value, so the spec is written accordingly, even if deviation doesn't make too much sense since it looks like the minimum can be negative.

  1. Start with a LO Control Pair of (0,0)
  2. Loop over the RF Attenuation List for this board

    1. If this is during initialization and the flag is not set for this RF Attenuation List value

      1. If this is the first iteration
        1. Set the LO Control Pair to (0,0)
      2. Otherwise,
        1. If both the current and previous RF Attenuation List values are odd

          1. Set the LO Control Pair to the saved LO Control Value at Row RF Attenuation List value corresponding to the loop position - 1 + the Maximum RF Attenuation List value if the flag is set for that value and Column 0

        2. Otherwise
          1. Set the LO Control Pair to the Saved LO Control Value located at Row RF Attenuation List value corresponding to the loop position

    2. MaskSet RadioRegister 0x43 with mask 0xFFF0 and set with the current RF Attenuation List value

    3. MaskSet the RadioRegister from the TXCTL Register and Value Table and mask with bitwise inverse of the Table Value, set with the Table Value if the flag is set for this RF Attenuation List value

    4. Loop over the Baseband Attenuation List for this board

      1. If this isn't being performed during initialization
        1. If the Used Attenuation Value that corresponds to the current RF Attenuation List and Baseband Attenuation List values isn't used

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

        2. Copy the LO Pair from the TX Power LO Control Array value associated with the current RF Attenuation List and Baseband Attenuation List values (if the flag is set adjust as needed) to the Cuurent LO Control Pair

      2. Otherwise
        1. Copy the LO Pair from the TX Power LO Control Array value associated with the current RF Attenuation List and Baseband Attenuation List values, ignoring the flag

      3. Multiply the RF Attenuation List value by 2, add to that the Baseband Attenuation List value divided by 2

      4. If the flag is set for this RF Attenuation List value

        1. Subract the Flag Value (found in the table below) from the previous result
      5. If the PHYConnected flag is set and the PHY Revision is 2 or more

        1. Add the first Loopback Gain value masked with 0xFFFE to the previous result

      6. Measure the LO Gain Values using the value found above

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

      8. Backup the current LO Control Pair
        1. Measure the deviation as explained below
        2. Save the Current LO Control Pair to the TX Power Lo Control Array as specified in LocalOscillator

        3. If this is a BPHY
          1. Increment each of the saved LO control Pair values by 1

Restoration

  1. Write the current LO Control Value to the LO Control PHYRegister (0x810 for G PHYs, 0x2F for B PHYs)

  2. If PHYConnected is set

    1. Write 0xE300 to PHY Register 0x15
    2. Write the fourth gain value (from the last time LO Gain Values was measured) shifted up by 8 ORed with 0xA0 to PHY Register 0x812

    3. Delay 5 uSecs
    4. Write the fourth gain value (from the last time LO Gain Values was measured) shifted up by 8 ORed with 0xA2 to PHY Register 0x812

    5. Delay 2 uSecs
    6. Write the fourth gain value (from the last time LO Gain Values was measured) shifted up by 8 ORed with 0xA3 to PHY Register 0x812

  3. Otherwise
    1. Bitwise AND the fourth gain value (from the last time LO Gain Values was measured) with 0xFFFF, then bitwise OR the result with 0xEFA0

    2. Write the result to PHYRegister 0x15

  4. If this is a board with HardwarePowerControl

    1. Initialize the GPHY DC Lookup Table

  5. Otherwise
    1. If this is during initialization
      1. Adjust the LO using Radio Attenuation 3, Baseband Attenuation 2 and TXCTL1 0

    2. Otherwise
      1. Adjust the LO using the saved attenuation values (see SetTXPower).

  6. If this is a GPHY
    1. If the PHY Revision is 3 or greater
      1. Write 0xC078 to PHYRegister 0x2E

    2. Otherwise
      1. Write 0x8078 to PHYRegister 0x2E

    3. If the PHY Revision is 2 or greater
      1. Write 0x202 to PHYRegister 0x2F

    4. Otherwise
      1. Write 0x101 to PHYRegister 0x2F

  7. Restore MMIO offset 0x3F4

  8. Restore PHYRegisters 0x15, 0x2A, 0x35, 0x60

  9. Restore RadioRegisters 0x43, 0x7A

  10. If this isn't a 0x2050 Radio with Radio Revision 8
    1. MaskSet RadioRegister 0x52 with mask 0xFF0F and set with the backed up value of RadioRegister 0x52

  11. Restore MMIO offset 0x3E2

  12. If this is a BPHY with an 0x2050 Radio and Radio Revision 5 or less
    1. Restore PHYRegisters 0x30, 0x6

  13. If PHYConnected

    1. RestorePHYRegisters 0x814, 0x815, 0x802, 0x811, 0x812, 0x3E, 0x429

  14. If this board has HardwarePowerControl

    1. Restore PHYRegister 0x80F, bitwise AND'd with 0xBFFF

    2. Restore PHYRegisters 0x801, 0x60, 0x14, 0x478

  15. Set the channel back to the current channel (with Synth PU Workaround)

Deviation Measuring State Machine

Again, we're using "deviation" here, even though we're not sure that this is what is actually being measured. What it does look like is that the state machine proceeds until it finds the smallest "deviation" for this set of RF Attenuation List and Baseband Attenuation List values.

A state diagram of the state machine's steps is available here: statemachine.pdf.

State Value Multipliers

Criteria

Value

During initialization and PHY Revision is 2 or greater and PHYConnected is set

3

Otherwise

1

Measuring a Single Deviation Value

Each transition of the state machine modifies the current control value pair depending on the target state of that transition. The table of control pair modifiers is given below. Note that under certain circumstances the value given here is multiplied by the State Value Multiplier given in the table above.

 1. +1 / +1
 2. +1 /  0
 3. +1 / -1
 4.  0 / -1
 5. -1 / -1
 6. -1 /  0
 7. -1 /  1
 8.  0 /  1

If the absolute value of either value in the control pair would cause it to be greater than 16, the transition may not be taken. Otherwise, a deviation value is measured for the all possible new control pairs (write the control pair to 0x810/0x2F again before measuring the deviation value), and the transition that generates the smallest new deviation is taken. This repeats up to 24 times or until no transition yields a smaller deviation than the current value.

The new control pair is returned.

Measuring the Deviation Value

  1. Start the Measured Subvalues Counter at 0
  2. If the PHY Revision is 2 or greater and the PHYConnected value is set and none of the entries in the TX Power LO Control Array are marked as used, perform the procedure below 4 times, otherwise, perform the procedure below only once

    1. Write the current LO Control Value to the LO Control PHYRegister (0x810 for G PHYs, 0x2F for B PHYs)

    2. Measure a single subvalue as shown below, using the first gain value, the third gain value and the fourth gain value (gain values are from the last time LO Gain Values was measured)

    3. If this is during initialization OR the subvalue measured is 0x258 or higher
      1. If the subvalue measured is 0x12C or higher and this is not during initialization
        1. Add 6 to the value used to measure the LO Gain Values

      2. Otherwise, if the subvalue measured is below 0x12C
        1. Add 0xC to the value used to measure the LO Gain Values

      3. Measure a single subvalue as shown below, using the first gain value, the third gain value and the fourth gain value (gain values are from the last time LO Gain Values was measured)

    4. While the Measured Subvalues Counter is less than 24
      1. Loop over the each possible value in this state
        1. Multiply the state values by the state value multiplier, then add the result to each of the values of the Last LO Pair
        2. If the value of either of the LO Control Pairs isn't equal to the previous value of either of the LO control pairs and the absolute value of each of the LO Pair values are 16 or below
          1. Write the LO Control Pair to the LO Control register
          2. Measure a single subvalue as shown below, using the first gain value, the third gain value and the fourth gain value (gain values are from the last time LO Gain Values was measured)

          3. If the single subvalue is lower than previous results, we've found a new minimum
            1. Save the single subvalue to compare against the next time through the loop
            2. Save the loop position this occured at, this is the next state
            3. Unless the PHY has revision 2 or greater and the PHYConnected is set and the single subvalue is 1500 or greater

              1. Backup this LO Pair as the Last LO Pair
              2. Break from the "possible state value loop"
      2. If the Current LO Control Pair is equal to the Last LO Control Pair
        1. We've found the minimum, and we're finished with measuring this deviation value (break from the measured subvalues while loop)
      3. Otherwise
        1. Copy the current LO control Pair to the last LO Control Pair
        2. Increment the Measured Subvalues Counter

Measuring Subvalues

There are three values passed in that comprise the control value. The value written to the PHYRegisters depends upon the state of PHYConnected.

When PHY Connected is Set

Find the Control Value

When PHYConnected is set, the control value is comprised of three values passed in:

  1. Left shift the first value passed in by 12
  2. Left shift the second value passed in by 8
  3. Bitwise OR the previous two values and the third value passed in
  4. Btiwsie OR 0x10 with the result
  5. If BoardFlags BFL_EXTLNA is set and the PHY Revision is 7 or greater

    1. Bitwise OR the result with 0x8000

Measure the Subvalue

  1. Write 0xE300 to PHYRegister 0x15

  2. Write the control value to PHYRegister 0x812

  3. Delay 10 uSec
  4. Write the control value ORed with 0x2 to PHYRegister 0x812

  5. Delay 10 uSec
  6. Write the control value ORed with 0x3 to PHYRegister 0x812

  7. Delay 10 uSec
  8. Write 0xF300 to PHYRegister 0x15

  9. Delay 21 uSec
  10. Return the value of PHYRegister 0x2D

When PHY Connected isn't Set

Measure the Subvalue

  1. Write the third value passed in ORed with 0xEFA0 to PHYRegister 0x15

  2. Delay 10 uSec
  3. Write the third value passed in ORed with 0xEFE0 to PHYRegister 0x15

  4. Delay 10 uSec
  5. Write the third value passed in ORed with 0xFFE0 to PHYRegister 0x15

  6. Delay 21 uSec
  7. Return the value of PHYRegister 0x2D

TXCTL Register and Value Table

G PHY

PHY Revision

Radio Revision

TXCTL Register

TXCTL Value

Flag Value

2 or greater

8

0x43

0x10

2

Otherwise

Any

0x52

0x30

5

B PHY

Radio Revision

TXCTL Register

TXCTL Value

Flag Value

5 or less

0x43

0x30

0

Otherwise

0x52

0x30

5


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