bcm-v4

[Specification

LP PHY TX IQLO Cal (struct lpphy_txgains *target_gains, int mode, int keep_tone)

  1. Create a 5 element array of u16 for override data
  2. Create an 11 element array of u16 for system coefficients and initialize to zero
  3. Create a 6 element array of u16 calibration commands and initialize to { 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234 }
  4. Create a 6 element array of u16 recalibration commands and initialize to { 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223 }
  5. Create a 6 element array of u16 command data and initialize to { 0x7a97, 0x7a97, 0x7a97, 0x7a87, 0x7a87, 0x7b97 }
  6. Create a table with table ID of 0, table width of 16
  7. Set the calibration to start at step 0
  8. If mode is zero
    1. Set start coefficients to system coefficients
    2. Set commands to calibration commands
    3. Set number of commands to size of the calibration commands array
  9. Else if mode is 1
    1. Set start coefficients to lpphy_txiqlocal_bestcoefs
    2. Set commands to recalibration commands
    3. Set number of commands to size of the recalibration commands array
  10. Else if mode is 2
    1. Set the table data pointer to the system coefficients
    2. Set the table length to 7 and the table offset to 80
    3. Read the LP table

    4. Set commands to recalibration commands
    5. Set number of commands to size of the recalibration commands array
  11. If mode is 2 OR 3
    1. LP PHY Get Radio Loft with arguments ( &ei0, &eq0, &fi0, &fq0 )

    2. Set system coefficients[7] = ((ei0 & 0xFF) << 8) | (eq0 & 0xFF)

    3. Set system coefficients[8] to 0
    4. Set system coefficients[7] = ((fi0 & 0xFF) << 8) | (fq0 & 0xFF)

    5. Set system coefficients[10] to 0
    6. Set start coefficients to system coefficients
    7. If mode is 3
      1. Set commands to calibration commands
      2. Set number of commands to size of the calibration commands array
      3. Set the calibration to start at step 2
  12. Set the table data pointer to the start coefficients, the table length to 11, and the table offset to 64
  13. Write the LP table

  14. Read Phy Register 0x4A4, mask with 0xE000 and save as old value

  15. LP PHT Set TX Power Control with argument 0

  16. If Phy Register 0x43B & 0x0040 is not zero

    1. Set old override = 1
  17. Otherwise
    1. Set old override = 0
  18. If old override is not zero
    1. LP PHY Get TX gains with argument &old_gains (a struct lpphy_txgains variable)

  19. If (input) target_gains is NULL
    1. If the old override is zero
      1. LP PHY Set TX Power by Index with private variable lpphy_tssi_index as argument

    2. LP PHY Get TX Gain with &temp_gains as argument

    3. Set target_gains = &temp_gains

  20. Calculate tmp as (target_gains->gm_gain << 8) | (target_gains->pga_gain << 4) | target_gains->pad_gain

  21. Use memset to clear the override array
  22. If current band is 5 GHx
    1. Set the band index to 1
    2. Set a 9-element gains array to {0x7ef, 7, 0xe, 0xe, 0, 0, 0, 0, 0}
  23. Otherwise
    1. Set the band index to 0
    2. Set a 9-element gains array to {0, 0, 0, 0, 0, 0, 0, 0, 0}
  24. Set calculated gains to *target_gains
  25. If tmp equals the 0th element of the gains array
    1. Set cal_gains.gm_gain = gains[1]
    2. Set cal_gains.pga_gain = gains[2]
    3. Set cal_gains.pad_gain = gains[3]
    4. Copy all 5 elements of the override array to gains[3 - 7]
  26. LP PHY Set TX Gain with &cal_gains as argument

  27. If PHY revision < 2

    1. Set bit 0x8 in Phy Register 0x44C

    2. Clear bit 0x8 in Phy Register 0x44D

    3. Set bit 0x20 in Phy Register 0x44C

    4. Clear bit 0x20 in Phy Register 0x44D

    5. Read Phy Register 0x43D and save as tmp2

    6. MaskSet Phy Register 0x43D with mask 0xFF00 and set with 0x0059

    7. Read Radio Register 0x16 and save as tmp3

    8. Clear bits 0xFF0C in Radio Register 0x16

    9. Clear bits 0x0010 in Radio Register 0x12

    10. Set bit 0x0001 in Phy Register 0x490

  28. Otherwise
    1. Read Phy Register 0x43E and save as tmp2

    2. If boardtype is 0x0490
      1. MaskSet Phy Register 0x43E with mask 0xFC00 and set with 0x00A5

    3. Otherwise
      1. MaskSet Phy Register 0x43E with mask 0xFC00 and set with 0x00CA

    4. Read Radio Register 0x121 and save as tmp3

    5. Clear bits 0x000D in Radio Register 0x121

    6. Clear bits 0x0080 in Radio Register 0x11F

    7. Read Phy Register 0x4D0 and save as tmp4

    8. Clear bit 0x8 in Phy Register 0x4D0

    9. Read Phy Register 0x503 and save as tmp5

    10. Set bit 0x8 in Phy Register 0x503

    11. Clear bit 0x4 in Phy Register 0x503

  29. Call LP PHY Set TRSW Override with arguments (0, 1)

  30. Set table data pointer to the Loft Gain Ladder Table below
  31. Set table length to 20 and table offset to 0
  32. Write LP table

  33. Set table data pointer to the IR Gain Ladder Table
  34. Set table offset to 32
  35. Write LP table

  36. If phy_tone_freq is zero AND the PHY revision < 2

    1. Set table data pointer to a u16 variable
    2. Set table length to 1, ID to 0x0B, offset to 9. and width to 16
    3. Loop starting from 1 until LP PHY TX IQLO Functional returns zero

      1. If loop index > 20

        1. Error and goto cleanup
      2. LP PHY Stop TX Tone

      3. If loop index % 3 is zero
        1. Read LP Table

        2. If the table data word ANDed with 1 is not zero
          1. Increment table data word
        3. Otherwise
          1. Decrement table data word
        4. Write LP Table

    4. Write 0x0AA9 to Phy Register 0x453

    5. If PHY TX Tone Frequency is zero

      1. If PHY revision < 2

        1. Call LP PHY Start TX Tone with arguments ( 2500, 100)

      2. Otherwise
        1. Call LP PHY Start TX Tone with arguments ( 3750, 22)

      3. Set bit 0x8000 in Phy Register 0x453

      4. Loop with index i from the calibration starting step through one less than the number of commands (inclusive)
        1. The calibration type is (commands[i] & 0x0F00) >> 8

        2. The command number is the ith entry in the command_nums array
        3. If ncorr_override[cal_type] is not zero
          1. The command number is ncorr_override[cal_type] << 8 | (command number & 0xFF)

        4. Write command number to Phy Register 0x452

        5. If the calibration type is 3 or 4
          1. Set the table data pointer to a u16 called start, the table length to 1, and the table offset to 69
          2. Read an LP table

          3. Set the table pointer to a u16 containing zero
          4. Write an LP table

        6. Write cal_cmds[i] to Phy Register 0x451

        7. If LP PHY IQcal Wait is not zero

          1. Error as TX IQLO Cal failed to complete
          2. Goto cleanup
        8. Set the table data pointer to an 11 element array of u16
        9. Set the table length to 11, and the table offset to 96
        10. Read an LP table

        11. Set the table offset to 64
        12. Write an LP table

        13. If the calibration type is 3 or 4
          1. Set the table pointer to start, the length to 1, and the table offset to 69
          2. Write an LP table

  37. Set the table data pointer to lpphy_txiqlocal_bestcoeffs, the length to 11, and the table offset to 96

  38. Read an LP table

  39. Set the table data pointer to lpphy_txiqlocal_bestcoeffs[0], the length to 4, and the table offset to 80

  40. Write an LP table

  41. Set the table data pointer to lpphy_txiqlocal_bestcoeffs[5], the length to 2, and the table offset to 85

cleanup:

  1. If keep_tone is zero
    1. Call LP PHY Stop TX Tone

  2. Write 0 to Phy Register 0x453

  3. If PHY revision < 2

    1. If keep_tone is zero
      1. Clear bits 0x28 in Phy Register 0x44C

    2. Set bit 0x10 in Radio Register 0x12

    3. Write tmp2 to Phy Register 0x43D

    4. Write tmp3 to Radio Register 0x16

  4. Otherwise
    1. Set bit 0x8 in Phy Register 0x503

    2. MaskSet Phy Register 0x43C with mask 0xFFC7 and set with rssi_muxsel_old << 3

    3. Bit set 0x80 in Radio Register 0x11F

    4. Write tmp2 to Phy Register 0x43E

    5. Write tmp3 to Radio Register 0x121

    6. Write tmp4 to Phy Register 0x4D0

    7. Write tmp5 to Phy Register 0x503

  5. Call LP PHY Clear TRSW Override

  6. Clear bit 0x4 in Phy Register 0x43B

  7. If the old override is not zero
    1. Call LP PHY Set TX Gain with &old_gains as the argument

  8. 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


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