bcm-v4

[Specification

int N PHY ACI Scan IQ Based

  1. Copy nphy_aci.detect_repeat_ctr to repeat_ctr

  2. Copy nphy_aci.detect_num_samples to nsamps

  3. Set count_thresh to nsamps / 5
  4. Set num_adc_ranges to 3
  5. Set u32 array adc_pwrs to {nphy_aci.adcpwr_enter_thresh, 1400, 9000, 12000}

  6. Set s8 array valid_w2s[] to {23, 19, 10}
  7. Set u32 adc_pwrs_rev3[] to {nphy_aci.adcpwr_enter_thresh, 7000, 13000, 15000}

  8. Set s8 valid_w2s_rev3[] to {15, 10, 5}
  9. Establish a 2-element u8 array named saved_pwr_index
  10. Set pwr to 0
  11. Set u16 array clip_off[] to {0xFFFF, 0xFFFF}
  12. Copy pubpi.radio_chanspec to orig_chanspec

  13. Set orig_channel to orig_chanspec & 0xFF

  14. If PHY revision >= 3

    1. Set adc_code_thresh to square root of nphy_aci.adcpwr_enter_thresh / 2

    2. Call N PHY Classifier with 0, 0 as arguments and save result as classifier_state

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

    4. Read PHY Register 0x1ED, mask with 0x7F00, shift the result right by 8 and save as saved_pwr_index[0]
    5. Read PHY Register 0x1EE, mask with 0x7F00, shift the result right by 8 and save as saved_pwr_index[1]
    6. Save [[802.11/PHY/Registers|PHY Registers] 0xCA, 0xC8, and 0xC9
    7. If the bandwidth is 40 MHz
      1. Set chan_delta to 6 and chan_skip to 5
    8. Otherwise
      1. Set chan_delta to 5 and chan_skip to 4
    9. Set start to orig_channel - chan_delta
    10. If start < 1

      1. Set start to 1
    11. Set stop to orig_channel + chan_delta
    12. If stop > 13

      1. Set stop to 13
    13. Loop from start to end (inclusive) with chan as loop index
      1. If chan < (orig_channel - chan_skip) OR chan > (orig_channel + chan_skip)

        1. If chan <= 14

          1. Set tmp to chan | 0x2B00
        2. Otherwise
          1. Set tmp to chan | 0x1B00
        3. Call PHY Set Chanspec with tmp as argument

        4. Call N PHY Classifier with 7, 4 as arguments

        5. Call N PHY Clip Det with 1, clip_off as arguments

        6. Call N PHY RF Ctrl Override with 0x1000, 0x213F, 3, 0 as arguments

        7. Write 0xFFFF to PHY Registers 0xC8 and 0xC9

        8. Call N PHY RSSI Sel with arguments 5, 1

        9. Call N PHY Force Seq with argument 2

        10. Set pwr_ch to 0
        11. Set w2_ch to 32
        12. Loop 2 times with core as the index
          1. Write (6 + core) to PHY Register 0xCA
          2. Loop from repeat_ctr times with ctr as index
            1. Set avg_adcpwr to 0
            2. Set avgw2 to 0
            3. Set count to 0
            4. Loop nsamps times with samp as the index
              1. If core is 0
                1. Read PHY Register 0x1C9 and save as gpio

              2. Otherwise
                1. Read PHY Register 0x1CA and save as gpio

              3. Bitwise mask gpio with 0x3FF, left shift by 6, cast the result as s16, right shift by 8 and save as adc_code
              4. Right shift gpio by 10, mask with 0x3F, left shift by 2, cast as s8, right shift by 2 and save as w2 (These items are sign extended.)
              5. If abs(adc_code) > adc_code_thresh

                1. Increment count
                2. Add adc_code * adc_code to avg_adcpwr
                3. Add w2 to avgw2
            5. If count > count_thresh

            6. Divide avg_adcpwr by count
            7. If avg_adcpwr > pwr_ch

              1. Divide avgw2 by count
              2. Set adcpwr_val to 1
              3. Loop num_adc_ranges times with i as index
                1. If avg_adcpwr >= adc_pwrs_rev3[i] AND avg_adcpwr < adc_pwrs_rev3[i + 1]

                  1. If avgw2 < valid_w2s_rev3[i]

                    1. Set adcpwr_val to 0
                  2. Break
              4. If adcpwr_val is 1
                1. Set pwr_ch to avg_adcpwr
                2. Set w2_ch to avgw2
          3. Delay 10 usec
        13. If pwr < pwr_ch

          1. Set pwr to pwr_ch
    14. Restore PHY Registers 0xCA, 0xC8, 0xC9

    15. Call N PHY RSSI Sel with 0, 0 as arguments

    16. Call N PHY Force RF Seq with 2 as the argument

    17. Call N PHY RF Ctrl Override 0x1000, 0, 3, 1 as arguments

    18. Call N PHY Force RF Seq with 2 as the argument

    19. Call N PHY Clip Detection 1, clip_state as arguments

    20. Call N PHY Classifier with 7, classifier_state as arguments

    21. Call N PHY Force RF Seq with 2 as the argument

    22. Call PHY Set Chanspec with argument orig_chanspec

    23. Set nphy_txpwr_idx[0] and [1] from saved_pwr_idx[0] and [1]

    24. Call N PHY TX Power Ctrl Enable with tx_pwr_ctrl_state as argument

    25. If pwr > adc_pwrs_rev3[1]

      1. Return 3
    26. Return 0
  15. Otherwise
    1. If aci_state & 2 is not zero

      1. Set adc_pwrs_rev3[0] to nphy_aci.adcpwr_exit_thresh

    2. Call N PHY Classifier with arguments (0, 0) and save in classifier_state

    3. Call N PHY Clip Detection with arguments (0, clip_state)

    4. Save PHY Registers 0xCA, 0xC8, 0xC9, 0x91 and 0x92

    5. Save Radio Registers 0x66, 0x95, 0x71, and 0xA0

    6. Read Radio Register 0x2B, add 20 and save in rccal_val

    7. If 0x1F < rccal_val

      1. Set rccal_val to 0x1F
    8. Bitwise OR rccal_val with 0x20
    9. If the bandwidth is 40 MHz
      1. Set chan_delta to 6
      2. Set chan_skip to 5
    10. Otherwise
      1. Set chan_delta to 5
      2. Set chan_skip to 4
    11. Set start to orig_channel - chan_delta
    12. If start < 1

      1. Set start to 1
    13. Set end to orig_channel + chan_delta
    14. If end > 13

      1. Set end to 13
    15. Loop from start to end (inclusive) with chan as index
      1. If chan < (orig_channel - chan_skip) OR chan > (orig_channel + chan_skip)

        1. If channel <= 14

          1. Set tmp to channel | 0x2B00
        2. Otherwise
          1. Set tmp to channel | 0x1B00
        3. Call PHY Set Chanspec with tmp as argument

        4. Call N PHY Classifier with arguments 7, 4

        5. Call N PHY Clip Detection with arguments 1, clip_off

        6. Call N PHY RF Ctrl Override with 0x400, 0x62C, 3, 0 as arguments

        7. Write 0x120 to PHY Registers 0x91 and 0x92

        8. Clear bit 0x2 in Radio Register 0x66

        9. Clear bit 0x2 in Radio Register 0x95

        10. Write rccal_val to Radio Registers 0x71 and 0xA0
        11. Call N PHY RSSI Sel with 5, 1 as arguments

        12. Write 0xFFFF to PHY Registers 0xC8 and 0xC9
        13. Call N PHY RF Seq with 2 as the argument

        14. Set pwr_ch to 0
        15. Set w2_ch to 32
        16. Loop 2 times with core as index
          1. Write core + 6 to PHY Register 0xCA

          2. Loop repeat_ctr times with ctr as index
            1. Set avg_adcpwr, avgw2, and count to 0
            2. Loop nsamps times with samp as index
              1. If core is 0
                1. Read PHY Register 0x1C9 and save in gpio

              2. Otherwise
                1. Read PHY Register 0x1CA and save in gpio

              3. Mask gpio with 0x3FF, left shift by 6, cast to s16, right shift by 8, and save as adc_code
              4. Right shift gpio by 10, mask with 0x3F, left shift by 2, cast to s8, right shift by 2, and save as w2
              5. If abs(adc_code) > adc_code_thresh

                1. Increment count
                2. Add adc_code * adc_code to avg_adcpwr
                3. Add w2 to avgw2
            3. If count > count_thresh

              1. Divide avg_adcpwr by count
              2. If avg_adcpwr > pwr_ch

                1. Divide avgw2 by count
                2. Set adcpwr_val to 1
                3. Loop num_adc_ranges times with i as index
                  1. If avg_adcpwr >= adc_pwrs[i] AND avg_adcpwr < adc_pwrs[i + 1]

                    1. If avgw2 < valid_w2s[i]

                      1. Set adcpwr_val to 0
                    2. Break
                4. If adcpwr_val is not zero
                  1. Set pwr_ch to avg_adcpwr
                  2. Set w2_ch to avgw2
            4. Delay 10 usec
          3. If pwr > pwr_ch

            1. Set pwr to pwr_ch
    16. Restore PHY Registers 0xCA, 0xC8, and 0xC9

    17. Call N PHY RSSI Sel with 0, 0 as arguments

    18. Restore Radio Registers 0x71, 0xA0, 0x66, and 0x95

    19. Restore PHY Registers 0x0x91 and 0x92

    20. Call N PHY RF Ctrl Override with 0x0400, 0, 3, 1 as arguments

    21. Call N PHY Force RF Seq with argument 2

    22. Call N PHY Clip Detection 1, clip_state as arguments

    23. Call N PHY Classifier with 7, classifier_state as arguments

    24. Call N PHY RF Seq with 2 as the argument

    25. Call PHY Set Chanspec with argument orig_chanspec

    26. If pwr > adc_pwrs[2]

      1. Return 3
    27. Else if pwr > adc_pwrs[1]

      1. Return 2
    28. Else if pwr > adc_pwrs[0]

      1. Return 1
  16. Return 0

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