N PHY RSSI Calibrate Rev 3

  1. Establish a 2-element u16 array clip_state
  2. Establish a 2-element u1s array clip_off and preset with 0xFFFF in both elements
  3. Create an 8 x 4 s32 array results and initialize to 0
  4. Create a 4-element s32 array results_min and initialize to 0
  5. Create a 4-element s32 array poll_result and initialize to zero
  6. Call N PHY Classifier with arguments 0, 0 and save output as class

  7. Call N PHY Classifier with arguments 7, 4

  8. Call N PHY Clip Detection with 0, clip_state as arguments

  9. Call N PHY Clip Detection with 1, clip_off as arguments

  10. Save PHY Registers 0x91, 0x92, 0x8F, 0xA5, 0xA6, 0xA7, 0xE7, 0xEC
  11. If PHY Revision >= 7

    1. Save PHY Registers 0x342, 0x343, 0x346, 0x347
  12. Save PHY Registers 0xE5, 0xE6, 0x78, 0xF9, 0xFB
  13. If PHY Revision >= 7

    1. Save PHY Registers 0x340, 0x341, 0x344, 0x345
  14. Save PHY Registers 0x7A, and 0x7D
  15. Call N PHY RF Control Intc Override with arguments 0, 0, 7

  16. Call N PHY RF Control Intc Override with arguments 1, 1, 7

  17. If PHY Revision >= 7

    1. Call N PHY RF Control Override One to Many with 0, 0, 0, 0 as arguments

    2. Call N PHY RF Control Override One to Many with 1, 1, 0, 0 as arguments

    3. Call N PHY RF Control Override Rev 7 with 0x80, 1, 0, 0, 0 as arguments

    4. Call N PHY RF Control Override Rev 7 with 0x40, 1, 0, 0, 0 as arguments

  18. Otherwise
    1. Call N PHY RF Control Override with arguments 1, 0, 0, 0

    2. Call N PHY RF Control Override with arguments 2, 1, 0, 0

    3. Call N PHY RF Control Override with arguments 0x80, 1, 0, 0

  19. Call N PHY RF Control Override with arguments 0x40, 1, 0, 0

  20. If the current band is 5G
    1. If PHY Revision >= 7

      1. Call N PHY RF Control Override Rev 7 with arguments 0x20, 0, 0, 0, 0

      2. Call N PHY RF Control Override Rev 7 with arguments 0x10, 1, 0, 0, 0

    2. Otherwise
      1. Call N PHY RF Control Override with arguments 0x20, 0, 0, 0

      2. Call N PHY RF Control Override with arguments 0x10, 1, 0, 0

  21. Otherwise
    1. If PHY Revision >= 7

      1. Call N PHY RF Control Override Rev 7 with arguments 0x10, 0, 0, 0, 0

      2. Call N PHY RF Control Override Rev 7 with arguments 0x20, 1, 0, 0, 0

    2. Otherwise
      1. Call N PHY RF Control Override with arguments 0x10, 0, 0, 0

      2. Call N PHY RF Control Override with arguments 0x20, 1, 0, 0

  22. Save the output of N PHY RX Core Get State

  23. Set max to 8
  24. Loop 2 times with index i (thru cores?)
    1. If the saved core state & (1 << i) is zero

      1. Continue
    2. Call N PHY Scale RSSI Offset with 0, 0, i+1, 0, 2 as arguments

    3. Call N PHY Scale RSSI Offset with 0, 0, i+1, 1, 2 as arguments

    4. Loop 8 times with index j
      1. If PHY Revision >= 7

        1. Set tmp to (i == 0) ? 0xB4 : 0x139
        2. Maskset Radio Register tmp with mask 0xF8 and set with j
      2. Otherwise
        1. Set tmp to (i == 0) ? 0x602B : 0x702B
        2. MaskSet Radio Register tmp with mask 0xE3 and set with j << 2

      3. Call N PHY Poll RSSI with 2, &results[j][0], 8 as arguments

    5. Loop 4 times with index j
      1. If j / 2 equals i and j % 2 equals 0
        1. Set mind to 0x100000
        2. Set minpoll to 249
        3. Set mink to 0
        4. Loop 8 times with index k
          1. Set current to results[k][j] * results[k][j] + results[k][j + 1] * results[k][j]
          2. If current < mind

            1. Set mind to current
            2. Set mink to k
          3. If results[k][j] < minpoll

            1. Set minpoll to results[k][j]
        5. Set final to mink
          1. Set results_min[j] to minpoll
    6. If PHY Revision >= 7

      1. Set tmp to (i == 0) ? 0xB4 : 0x139
      2. Maskset Radio Register tmp with mask 0xF8 and set with final
    7. Otherwise
      1. Set tmp to (i == 0) ? 0x602B : 0x702B
      2. MaskSet Radio Register tmp with mask 0xE3 and set with final << 2

    8. Loop 4 times with index j
      1. If i equals j / 2
        1. Set offset[j] to -results[final][j]
        2. If offset[j] < 0

          1. Set offset[j] to -((abs(offset[j]) + 4) / 8)
        3. Otherwise
          1. Set offset[j] to (offset[j] + 4) / 8
        4. If results_min[j] equals 248
          1. Set offset[j] to -32
        5. Call N PHY Scale Offset RSSI with arguments 0, offset[j], (j/2==0) ? 1:2, (j%2==0) ? 0:1, 2 as arguments

  25. Loop 2 times with index i
    1. If the saved core state & (1 << i) is zero

      1. Continue
    2. Loop 2 times with index j
      1. Call N PHY Scale Offset RSSI with arguments 0, 0, i+1, 0, j

      2. Call N PHY Scale Offset RSSI with arguments 0, 0, i+1, 1, j

      3. Call N PHY Poll RSSI with j, poll_result, 8 as arguments

      4. Loop 4 times with index k
        1. If i equals k / 2
          1. Set offset[k] to 232 - poll_result[k]
          2. If offset[k] < 0

            1. Set offset[k] to -((abs(offset[k] + 4) / 8)
          3. Otherwise
            1. Set offset[k] to (offset[k] + 4) / 8
          4. Call N PHY Scale Offset RSSI with 0, offset[2 * i], i + 1, k % 2, type as arguments

  26. Restore PHY Registers 0x91 and 0x92
  27. Call N PHY Force RF Seq with argument 2

  28. MaskSet PHY Register 0xE7 with mask 0xFFFE and set with 0x0001

  29. MaskSet PHY Register 0x78 with mask 0xFFFE and set with 0x0001

  30. MaskSet PHY Register 0xE7 with mask 0xFFFE and set with 0

  31. MaskSet PHY Register 0xEC with mask 0xFFFE and set with 1

  32. MaskSet PHY Register 0x78 with mask 0xFFFD and set with 0x0002

  33. MaskSet PHY Register 0xE7 with mask 0xFFFE and set with 0

  34. Restore saved values for PHY Registers 0x8F, 0xA5, 0xA6, 0xA7, 0xE7, 0xEC
  35. If PHY Revision >= 7

    1. Restore saved values for PHY Registers 0x342, 0x343, 0x346, 0x347
  36. Restore saved values for PHY Registers 0xE5, 0xE6, 0x78, 0xF9, 0xFB
  37. If PHY Revision >= 7

    1. Restore saved values for PHY Registers 0x340, 0x341, 0x344, 0x345
  38. Restore saved values for PHY Registers 0x7A, 0x7D
  39. If the band is 2 GHz
    1. If PHY Revision >= 7

      1. Save Radio Register 0xB4 to rssical_cache.rssical_radio_regs_2G[0]

      2. Save Radio Register 0x139 to rssical_cache.rssical_radio_regs_2G[1]

    2. Otherwise
      1. Save Radio Register 0x602B to rssical_cache.rssical_radio_regs_2G[0]

      2. Save Radio Register 0x702B to rssical_cache.rssical_radio_regs_2G[1]

    3. Save PHY Register 0x1A6 to rssical_cache.rssical_phyregs_2G[0]

    4. Save PHY Register 0x1AC to rssical_cache.rssical_phyregs_2G[1]

    5. Save PHY Register 0x1B2 to rssical_cache.rssical_phyregs_2G[2]

    6. Save PHY Register 0x1B8 to rssical_cache.rssical_phyregs_2G[3]

    7. Save PHY Register 0x1A4 to rssical_cache.rssical_phyregs_2G[4]

    8. Save PHY Register 0x1AA to rssical_cache.rssical_phyregs_2G[5]

    9. Save PHY Register 0x1B0 to rssical_cache.rssical_phyregs_2G[6]

    10. Save PHY Register 0x1B6 to rssical_cache.rssical_phyregs_2G[7]

    11. Save PHY Register 0x1A5 to rssical_cache.rssical_phyregs_2G[8]

    12. Save PHY Register 0x1AB to rssical_cache.rssical_phyregs_2G[9]

    13. Save PHY Register 0x1B1 to rssical_cache.rssical_phyregs_2G[10]

    14. Save PHY Register 0x1B7 to rssical_cache.rssical_phyregs_2G[11]

    15. Set nphy_rssical_chanspec_2G to the current chanspec

  40. Otherwise
    1. If PHY Revision >= 7

      1. Save Radio Register 0xB4 to rssical_cache.rssical_radio_regs_5G[0]

      2. Save Radio Register 0x139 to rssical_cache.rssical_radio_regs_5G[1]

    2. Otherwise
      1. Save Radio Register 0x602B to rssical_cache.rssical_radio_regs_5G[0]

      2. Save Radio Register 0x702B to rssical_cache.rssical_radio_regs_5G[1]

    3. Save PHY Register 0x1A6 to rssical_cache.rssical_phyregs_5G[0]

    4. Save PHY Register 0x1AC to rssical_cache.rssical_phyregs_5G[1]

    5. Save PHY Register 0x1B2 to rssical_cache.rssical_phyregs_5G[2]

    6. Save PHY Register 0x1B8 to rssical_cache.rssical_phyregs_5G[3]

    7. Save PHY Register 0x1A4 to rssical_cache.rssical_phyregs_5G[4]

    8. Save PHY Register 0x1AA to rssical_cache.rssical_phyregs_5G[5]

    9. Save PHY Register 0x1B0 to rssical_cache.rssical_phyregs_5G[6]

    10. Save PHY Register 0x1B6 to rssical_cache.rssical_phyregs_5G[7]

    11. Save PHY Register 0x1A5 to rssical_cache.rssical_phyregs_5G[8]

    12. Save PHY Register 0x1AB to rssical_cache.rssical_phyregs_5G[9]

    13. Save PHY Register 0x1B1 to rssical_cache.rssical_phyregs_5G[10]

    14. Save PHY Register 0x1B7 to rssical_cache.rssical_phyregs_5G[11]

    15. Set nphy_rssical_chanspec_5G to the current chanspec

  41. Call N PHY Classifier with arguments 7, class

  42. Call N PHY Clip Detection with 1, clip_state as arguments

802.11/PHY/N/RSSICalRev3 (last edited 2013-03-18 20:31:14 by lwfinger)