diff --git a/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c b/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c index f93b7af26877..6b47a5990d3b 100644 --- a/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c +++ b/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c @@ -1,6946 +1,6942 @@ /* Broadcom B43 wireless driver IEEE 802.11n PHY data tables Copyright (c) 2008 Michael Buesch Copyright (c) 2010 Rafał Miłecki This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. */ #include __FBSDID("$FreeBSD$"); /* * The Broadcom Wireless LAN controller driver. */ #include "opt_wlan.h" #include "opt_bwn.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "bhnd_nvram_map.h" struct bwn_nphy_txgains { uint16_t tx_lpf[2]; uint16_t txgm[2]; uint16_t pga[2]; uint16_t pad[2]; uint16_t ipa[2]; }; struct bwn_nphy_iqcal_params { uint16_t tx_lpf; uint16_t txgm; uint16_t pga; uint16_t pad; uint16_t ipa; uint16_t cal_gain; uint16_t ncorr[5]; }; struct bwn_nphy_iq_est { int32_t iq0_prod; uint32_t i0_pwr; uint32_t q0_pwr; int32_t iq1_prod; uint32_t i1_pwr; uint32_t q1_pwr; }; enum bwn_nphy_rf_sequence { BWN_RFSEQ_RX2TX, BWN_RFSEQ_TX2RX, BWN_RFSEQ_RESET2RX, BWN_RFSEQ_UPDATE_GAINH, BWN_RFSEQ_UPDATE_GAINL, BWN_RFSEQ_UPDATE_GAINU, }; enum n_rf_ctl_over_cmd { N_RF_CTL_OVER_CMD_RXRF_PU = 0, N_RF_CTL_OVER_CMD_RX_PU = 1, N_RF_CTL_OVER_CMD_TX_PU = 2, N_RF_CTL_OVER_CMD_RX_GAIN = 3, N_RF_CTL_OVER_CMD_TX_GAIN = 4, }; enum n_intc_override { N_INTC_OVERRIDE_OFF = 0, N_INTC_OVERRIDE_TRSW = 1, N_INTC_OVERRIDE_PA = 2, N_INTC_OVERRIDE_EXT_LNA_PU = 3, N_INTC_OVERRIDE_EXT_LNA_GAIN = 4, }; enum n_rssi_type { N_RSSI_W1 = 0, N_RSSI_W2, N_RSSI_NB, N_RSSI_IQ, N_RSSI_TSSI_2G, N_RSSI_TSSI_5G, N_RSSI_TBD, }; enum n_rail_type { N_RAIL_I = 0, N_RAIL_Q = 1, }; static inline bool bwn_nphy_ipa(struct bwn_mac *mac) { bwn_band_t band = bwn_current_band(mac); return ((mac->mac_phy.phy_n->ipa2g_on && band == BWN_BAND_2G) || (mac->mac_phy.phy_n->ipa5g_on && band == BWN_BAND_5G)); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreGetState */ static uint8_t bwn_nphy_get_rx_core_state(struct bwn_mac *mac) { return (BWN_PHY_READ(mac, BWN_NPHY_RFSEQCA) & BWN_NPHY_RFSEQCA_RXEN) >> BWN_NPHY_RFSEQCA_RXEN_SHIFT; } /************************************************** * RF (just without bwn_nphy_rf_ctl_intc_override) **************************************************/ /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ForceRFSeq */ static void bwn_nphy_force_rf_sequence(struct bwn_mac *mac, enum bwn_nphy_rf_sequence seq) { static const uint16_t trigger[] = { [BWN_RFSEQ_RX2TX] = BWN_NPHY_RFSEQTR_RX2TX, [BWN_RFSEQ_TX2RX] = BWN_NPHY_RFSEQTR_TX2RX, [BWN_RFSEQ_RESET2RX] = BWN_NPHY_RFSEQTR_RST2RX, [BWN_RFSEQ_UPDATE_GAINH] = BWN_NPHY_RFSEQTR_UPGH, [BWN_RFSEQ_UPDATE_GAINL] = BWN_NPHY_RFSEQTR_UPGL, [BWN_RFSEQ_UPDATE_GAINU] = BWN_NPHY_RFSEQTR_UPGU, }; int i; uint16_t seq_mode = BWN_PHY_READ(mac, BWN_NPHY_RFSEQMODE); if (seq >= nitems(trigger)) { BWN_WARNPRINTF(mac->mac_sc, "%s: seq %d > max", __func__, seq); } BWN_PHY_SET(mac, BWN_NPHY_RFSEQMODE, BWN_NPHY_RFSEQMODE_CAOVER | BWN_NPHY_RFSEQMODE_TROVER); BWN_PHY_SET(mac, BWN_NPHY_RFSEQTR, trigger[seq]); for (i = 0; i < 200; i++) { if (!(BWN_PHY_READ(mac, BWN_NPHY_RFSEQST) & trigger[seq])) goto ok; DELAY(1000); } BWN_ERRPRINTF(mac->mac_sc, "RF sequence status timeout\n"); ok: BWN_PHY_WRITE(mac, BWN_NPHY_RFSEQMODE, seq_mode); } static void bwn_nphy_rf_ctl_override_rev19(struct bwn_mac *mac, uint16_t field, uint16_t value, uint8_t core, bool off, uint8_t override_id) { /* TODO */ } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverrideRev7 */ static void bwn_nphy_rf_ctl_override_rev7(struct bwn_mac *mac, uint16_t field, uint16_t value, uint8_t core, bool off, uint8_t override) { struct bwn_phy *phy = &mac->mac_phy; const struct bwn_nphy_rf_control_override_rev7 *e; uint16_t en_addrs[3][2] = { { 0x0E7, 0x0EC }, { 0x342, 0x343 }, { 0x346, 0x347 } }; uint16_t en_addr; uint16_t en_mask = field; uint16_t val_addr; uint8_t i; if (phy->rev >= 19 || phy->rev < 3) { BWN_WARNPRINTF(mac->mac_sc, "%s: phy rev %d out of range\n", __func__, phy->rev); return; } /* Remember: we can get NULL! */ e = bwn_nphy_get_rf_ctl_over_rev7(mac, field, override); for (i = 0; i < 2; i++) { if (override >= nitems(en_addrs)) { BWN_ERRPRINTF(mac->mac_sc, "Invalid override value %d\n", override); return; } en_addr = en_addrs[override][i]; if (e) val_addr = (i == 0) ? e->val_addr_core0 : e->val_addr_core1; if (off) { BWN_PHY_MASK(mac, en_addr, ~en_mask); if (e) /* Do it safer, better than wl */ BWN_PHY_MASK(mac, val_addr, ~e->val_mask); } else { if (!core || (core & (1 << i))) { BWN_PHY_SET(mac, en_addr, en_mask); if (e) BWN_PHY_SETMASK(mac, val_addr, ~e->val_mask, (value << e->val_shift)); } } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverideOneToMany */ static void bwn_nphy_rf_ctl_override_one_to_many(struct bwn_mac *mac, enum n_rf_ctl_over_cmd cmd, uint16_t value, uint8_t core, bool off) { struct bwn_phy *phy = &mac->mac_phy; uint16_t tmp; if (phy->rev < 7) { BWN_ERRPRINTF(mac->mac_sc, "%s: phy rev %d out of range\n", __func__, phy->rev); } switch (cmd) { case N_RF_CTL_OVER_CMD_RXRF_PU: bwn_nphy_rf_ctl_override_rev7(mac, 0x20, value, core, off, 1); bwn_nphy_rf_ctl_override_rev7(mac, 0x10, value, core, off, 1); bwn_nphy_rf_ctl_override_rev7(mac, 0x08, value, core, off, 1); break; case N_RF_CTL_OVER_CMD_RX_PU: bwn_nphy_rf_ctl_override_rev7(mac, 0x4, value, core, off, 1); bwn_nphy_rf_ctl_override_rev7(mac, 0x2, value, core, off, 1); bwn_nphy_rf_ctl_override_rev7(mac, 0x1, value, core, off, 1); bwn_nphy_rf_ctl_override_rev7(mac, 0x2, value, core, off, 2); bwn_nphy_rf_ctl_override_rev7(mac, 0x0800, 0, core, off, 1); break; case N_RF_CTL_OVER_CMD_TX_PU: bwn_nphy_rf_ctl_override_rev7(mac, 0x4, value, core, off, 0); bwn_nphy_rf_ctl_override_rev7(mac, 0x2, value, core, off, 1); bwn_nphy_rf_ctl_override_rev7(mac, 0x1, value, core, off, 2); bwn_nphy_rf_ctl_override_rev7(mac, 0x0800, 1, core, off, 1); break; case N_RF_CTL_OVER_CMD_RX_GAIN: tmp = value & 0xFF; bwn_nphy_rf_ctl_override_rev7(mac, 0x0800, tmp, core, off, 0); tmp = value >> 8; bwn_nphy_rf_ctl_override_rev7(mac, 0x6000, tmp, core, off, 0); break; case N_RF_CTL_OVER_CMD_TX_GAIN: tmp = value & 0x7FFF; bwn_nphy_rf_ctl_override_rev7(mac, 0x1000, tmp, core, off, 0); tmp = value >> 14; bwn_nphy_rf_ctl_override_rev7(mac, 0x4000, tmp, core, off, 0); break; } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlOverride */ static void bwn_nphy_rf_ctl_override(struct bwn_mac *mac, uint16_t field, uint16_t value, uint8_t core, bool off) { int i; uint8_t index = fls(field); uint8_t addr, en_addr, val_addr; /* we expect only one bit set */ if (field & (~(1 << (index - 1)))) { BWN_ERRPRINTF(mac->mac_sc, "%s: field 0x%04x has >1 bit set\n", __func__, field); } if (mac->mac_phy.rev >= 3) { const struct bwn_nphy_rf_control_override_rev3 *rf_ctrl; for (i = 0; i < 2; i++) { if (index == 0 || index == 16) { BWN_ERRPRINTF(mac->mac_sc, "Unsupported RF Ctrl Override call\n"); return; } rf_ctrl = &tbl_rf_control_override_rev3[index - 1]; en_addr = BWN_PHY_N((i == 0) ? rf_ctrl->en_addr0 : rf_ctrl->en_addr1); val_addr = BWN_PHY_N((i == 0) ? rf_ctrl->val_addr0 : rf_ctrl->val_addr1); if (off) { BWN_PHY_MASK(mac, en_addr, ~(field)); BWN_PHY_MASK(mac, val_addr, ~(rf_ctrl->val_mask)); } else { if (core == 0 || ((1 << i) & core)) { BWN_PHY_SET(mac, en_addr, field); BWN_PHY_SETMASK(mac, val_addr, ~(rf_ctrl->val_mask), (value << rf_ctrl->val_shift)); } } } } else { const struct bwn_nphy_rf_control_override_rev2 *rf_ctrl; if (off) { BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_OVER, ~(field)); value = 0; } else { BWN_PHY_SET(mac, BWN_NPHY_RFCTL_OVER, field); } for (i = 0; i < 2; i++) { if (index <= 1 || index == 16) { BWN_ERRPRINTF(mac->mac_sc, "Unsupported RF Ctrl Override call\n"); return; } if (index == 2 || index == 10 || (index >= 13 && index <= 15)) { core = 1; } rf_ctrl = &tbl_rf_control_override_rev2[index - 2]; addr = BWN_PHY_N((i == 0) ? rf_ctrl->addr0 : rf_ctrl->addr1); if ((1 << i) & core) BWN_PHY_SETMASK(mac, addr, ~(rf_ctrl->bmask), (value << rf_ctrl->shift)); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_OVER, 0x1); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_START); DELAY(1); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_OVER, 0xFFFE); } } } static void bwn_nphy_rf_ctl_intc_override_rev7(struct bwn_mac *mac, enum n_intc_override intc_override, uint16_t value, uint8_t core_sel) { uint16_t reg, tmp, tmp2, val; int core; /* TODO: What about rev19+? Revs 3+ and 7+ are a bit similar */ for (core = 0; core < 2; core++) { if ((core_sel == 1 && core != 0) || (core_sel == 2 && core != 1)) continue; reg = (core == 0) ? BWN_NPHY_RFCTL_INTC1 : BWN_NPHY_RFCTL_INTC2; switch (intc_override) { case N_INTC_OVERRIDE_OFF: BWN_PHY_WRITE(mac, reg, 0); BWN_PHY_MASK(mac, 0x2ff, ~0x2000); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); break; case N_INTC_OVERRIDE_TRSW: BWN_PHY_SETMASK(mac, reg, ~0xC0, value << 6); BWN_PHY_SET(mac, reg, 0x400); BWN_PHY_MASK(mac, 0x2ff, ~0xC000 & 0xFFFF); BWN_PHY_SET(mac, 0x2ff, 0x2000); BWN_PHY_SET(mac, 0x2ff, 0x0001); break; case N_INTC_OVERRIDE_PA: tmp = 0x0030; if (bwn_current_band(mac) == BWN_BAND_5G) val = value << 5; else val = value << 4; BWN_PHY_SETMASK(mac, reg, ~tmp, val); BWN_PHY_SET(mac, reg, 0x1000); break; case N_INTC_OVERRIDE_EXT_LNA_PU: if (bwn_current_band(mac) == BWN_BAND_5G) { tmp = 0x0001; tmp2 = 0x0004; val = value; } else { tmp = 0x0004; tmp2 = 0x0001; val = value << 2; } BWN_PHY_SETMASK(mac, reg, ~tmp, val); BWN_PHY_MASK(mac, reg, ~tmp2); break; case N_INTC_OVERRIDE_EXT_LNA_GAIN: if (bwn_current_band(mac) == BWN_BAND_5G) { tmp = 0x0002; tmp2 = 0x0008; val = value << 1; } else { tmp = 0x0008; tmp2 = 0x0002; val = value << 3; } BWN_PHY_SETMASK(mac, reg, ~tmp, val); BWN_PHY_MASK(mac, reg, ~tmp2); break; } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RFCtrlIntcOverride */ static void bwn_nphy_rf_ctl_intc_override(struct bwn_mac *mac, enum n_intc_override intc_override, uint16_t value, uint8_t core) { uint8_t i, j; uint16_t reg, tmp, val; if (mac->mac_phy.rev >= 7) { bwn_nphy_rf_ctl_intc_override_rev7(mac, intc_override, value, core); return; } if (mac->mac_phy.rev < 3) { BWN_ERRPRINTF(mac->mac_sc, "%s: phy rev %d out of range\n", __func__, mac->mac_phy.rev); } for (i = 0; i < 2; i++) { if ((core == 1 && i == 1) || (core == 2 && !i)) continue; reg = (i == 0) ? BWN_NPHY_RFCTL_INTC1 : BWN_NPHY_RFCTL_INTC2; BWN_PHY_SET(mac, reg, 0x400); switch (intc_override) { case N_INTC_OVERRIDE_OFF: BWN_PHY_WRITE(mac, reg, 0); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); break; case N_INTC_OVERRIDE_TRSW: if (!i) { BWN_PHY_SETMASK(mac, BWN_NPHY_RFCTL_INTC1, 0xFC3F, (value << 6)); BWN_PHY_SETMASK(mac, BWN_NPHY_TXF_40CO_B1S1, 0xFFFE, 1); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_START); for (j = 0; j < 100; j++) { if (!(BWN_PHY_READ(mac, BWN_NPHY_RFCTL_CMD) & BWN_NPHY_RFCTL_CMD_START)) { j = 0; break; } DELAY(10); } if (j) BWN_ERRPRINTF(mac->mac_sc, "intc override timeout\n"); BWN_PHY_MASK(mac, BWN_NPHY_TXF_40CO_B1S1, 0xFFFE); } else { BWN_PHY_SETMASK(mac, BWN_NPHY_RFCTL_INTC2, 0xFC3F, (value << 6)); BWN_PHY_SETMASK(mac, BWN_NPHY_RFCTL_OVER, 0xFFFE, 1); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_RXTX); for (j = 0; j < 100; j++) { if (!(BWN_PHY_READ(mac, BWN_NPHY_RFCTL_CMD) & BWN_NPHY_RFCTL_CMD_RXTX)) { j = 0; break; } DELAY(10); } if (j) BWN_ERRPRINTF(mac->mac_sc, "intc override timeout\n"); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_OVER, 0xFFFE); } break; case N_INTC_OVERRIDE_PA: if (bwn_current_band(mac) == BWN_BAND_5G) { tmp = 0x0020; val = value << 5; } else { tmp = 0x0010; val = value << 4; } BWN_PHY_SETMASK(mac, reg, ~tmp, val); break; case N_INTC_OVERRIDE_EXT_LNA_PU: if (bwn_current_band(mac) == BWN_BAND_5G) { tmp = 0x0001; val = value; } else { tmp = 0x0004; val = value << 2; } BWN_PHY_SETMASK(mac, reg, ~tmp, val); break; case N_INTC_OVERRIDE_EXT_LNA_GAIN: if (bwn_current_band(mac) == BWN_BAND_5G) { tmp = 0x0002; val = value << 1; } else { tmp = 0x0008; val = value << 3; } BWN_PHY_SETMASK(mac, reg, ~tmp, val); break; } } } /************************************************** * Various PHY ops **************************************************/ /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */ static void bwn_nphy_write_clip_detection(struct bwn_mac *mac, const uint16_t *clip_st) { BWN_PHY_WRITE(mac, BWN_NPHY_C1_CLIP1THRES, clip_st[0]); BWN_PHY_WRITE(mac, BWN_NPHY_C2_CLIP1THRES, clip_st[1]); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/clip-detection */ static void bwn_nphy_read_clip_detection(struct bwn_mac *mac, uint16_t *clip_st) { clip_st[0] = BWN_PHY_READ(mac, BWN_NPHY_C1_CLIP1THRES); clip_st[1] = BWN_PHY_READ(mac, BWN_NPHY_C2_CLIP1THRES); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/classifier */ static uint16_t bwn_nphy_classifier(struct bwn_mac *mac, uint16_t mask, uint16_t val) { struct bwn_softc *sc = mac->mac_sc; uint16_t tmp; if (bhnd_get_hwrev(sc->sc_dev) == 16) bwn_mac_suspend(mac); tmp = BWN_PHY_READ(mac, BWN_NPHY_CLASSCTL); tmp &= (BWN_NPHY_CLASSCTL_CCKEN | BWN_NPHY_CLASSCTL_OFDMEN | BWN_NPHY_CLASSCTL_WAITEDEN); tmp &= ~mask; tmp |= (val & mask); BWN_PHY_SETMASK(mac, BWN_NPHY_CLASSCTL, 0xFFF8, tmp); if (bhnd_get_hwrev(sc->sc_dev) == 16) bwn_mac_enable(mac); return tmp; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CCA */ static void bwn_nphy_reset_cca(struct bwn_mac *mac) { uint16_t bbcfg; bwn_phy_force_clock(mac, 1); bbcfg = BWN_PHY_READ(mac, BWN_NPHY_BBCFG); BWN_PHY_WRITE(mac, BWN_NPHY_BBCFG, bbcfg | BWN_NPHY_BBCFG_RSTCCA); DELAY(1); BWN_PHY_WRITE(mac, BWN_NPHY_BBCFG, bbcfg & ~BWN_NPHY_BBCFG_RSTCCA); bwn_phy_force_clock(mac, 0); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/carriersearch */ static void bwn_nphy_stay_in_carrier_search(struct bwn_mac *mac, bool enable) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = phy->phy_n; if (enable) { static const uint16_t clip[] = { 0xFFFF, 0xFFFF }; if (nphy->deaf_count++ == 0) { nphy->classifier_state = bwn_nphy_classifier(mac, 0, 0); bwn_nphy_classifier(mac, 0x7, BWN_NPHY_CLASSCTL_WAITEDEN); bwn_nphy_read_clip_detection(mac, nphy->clip_state); bwn_nphy_write_clip_detection(mac, clip); } bwn_nphy_reset_cca(mac); } else { if (--nphy->deaf_count == 0) { bwn_nphy_classifier(mac, 0x7, nphy->classifier_state); bwn_nphy_write_clip_detection(mac, nphy->clip_state); } } } /* http://bcm-v4.sipsolutions.net/PHY/N/Read_Lpf_Bw_Ctl */ static uint16_t bwn_nphy_read_lpf_ctl(struct bwn_mac *mac, uint16_t offset) { if (!offset) offset = bwn_is_40mhz(mac) ? 0x159 : 0x154; return bwn_ntab_read(mac, BWN_NTAB16(7, offset)) & 0x7; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/AdjustLnaGainTbl */ static void bwn_nphy_adjust_lna_gain_table(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t i; int16_t tmp; uint16_t data[4]; int16_t gain[2]; uint16_t minmax[2]; static const uint16_t lna_gain[4] = { -2, 10, 19, 25 }; if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); if (nphy->gain_boost) { if (bwn_current_band(mac) == BWN_BAND_2G) { gain[0] = 6; gain[1] = 6; } else { tmp = 40370 - 315 * bwn_get_chan(mac); gain[0] = ((tmp >> 13) + ((tmp >> 12) & 1)); tmp = 23242 - 224 * bwn_get_chan(mac); gain[1] = ((tmp >> 13) + ((tmp >> 12) & 1)); } } else { gain[0] = 0; gain[1] = 0; } for (i = 0; i < 2; i++) { if (nphy->elna_gain_config) { data[0] = 19 + gain[i]; data[1] = 25 + gain[i]; data[2] = 25 + gain[i]; data[3] = 25 + gain[i]; } else { data[0] = lna_gain[0] + gain[i]; data[1] = lna_gain[1] + gain[i]; data[2] = lna_gain[2] + gain[i]; data[3] = lna_gain[3] + gain[i]; } bwn_ntab_write_bulk(mac, BWN_NTAB16(i, 8), 4, data); minmax[i] = 23 + gain[i]; } BWN_PHY_SETMASK(mac, BWN_NPHY_C1_MINMAX_GAIN, ~BWN_NPHY_C1_MINGAIN, minmax[0] << BWN_NPHY_C1_MINGAIN_SHIFT); BWN_PHY_SETMASK(mac, BWN_NPHY_C2_MINMAX_GAIN, ~BWN_NPHY_C2_MINGAIN, minmax[1] << BWN_NPHY_C2_MINGAIN_SHIFT); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRfSeq */ static void bwn_nphy_set_rf_sequence(struct bwn_mac *mac, uint8_t cmd, uint8_t *events, uint8_t *delays, uint8_t length) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t i; uint8_t end = (mac->mac_phy.rev >= 3) ? 0x1F : 0x0F; uint16_t offset1 = cmd << 4; uint16_t offset2 = offset1 + 0x80; if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, true); bwn_ntab_write_bulk(mac, BWN_NTAB8(7, offset1), length, events); bwn_ntab_write_bulk(mac, BWN_NTAB8(7, offset2), length, delays); for (i = length; i < 16; i++) { bwn_ntab_write(mac, BWN_NTAB8(7, offset1 + i), end); bwn_ntab_write(mac, BWN_NTAB8(7, offset2 + i), 1); } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, false); } /************************************************** * Radio 0x2057 **************************************************/ static void bwn_radio_2057_chantab_upload(struct bwn_mac *mac, const struct bwn_nphy_chantabent_rev7 *e_r7, const struct bwn_nphy_chantabent_rev7_2g *e_r7_2g) { if (e_r7_2g) { BWN_RF_WRITE(mac, R2057_VCOCAL_COUNTVAL0, e_r7_2g->radio_vcocal_countval0); BWN_RF_WRITE(mac, R2057_VCOCAL_COUNTVAL1, e_r7_2g->radio_vcocal_countval1); BWN_RF_WRITE(mac, R2057_RFPLL_REFMASTER_SPAREXTALSIZE, e_r7_2g->radio_rfpll_refmaster_sparextalsize); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_R1, e_r7_2g->radio_rfpll_loopfilter_r1); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C2, e_r7_2g->radio_rfpll_loopfilter_c2); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C1, e_r7_2g->radio_rfpll_loopfilter_c1); BWN_RF_WRITE(mac, R2057_CP_KPD_IDAC, e_r7_2g->radio_cp_kpd_idac); BWN_RF_WRITE(mac, R2057_RFPLL_MMD0, e_r7_2g->radio_rfpll_mmd0); BWN_RF_WRITE(mac, R2057_RFPLL_MMD1, e_r7_2g->radio_rfpll_mmd1); BWN_RF_WRITE(mac, R2057_VCOBUF_TUNE, e_r7_2g->radio_vcobuf_tune); BWN_RF_WRITE(mac, R2057_LOGEN_MX2G_TUNE, e_r7_2g->radio_logen_mx2g_tune); BWN_RF_WRITE(mac, R2057_LOGEN_INDBUF2G_TUNE, e_r7_2g->radio_logen_indbuf2g_tune); BWN_RF_WRITE(mac, R2057_TXMIX2G_TUNE_BOOST_PU_CORE0, e_r7_2g->radio_txmix2g_tune_boost_pu_core0); BWN_RF_WRITE(mac, R2057_PAD2G_TUNE_PUS_CORE0, e_r7_2g->radio_pad2g_tune_pus_core0); BWN_RF_WRITE(mac, R2057_LNA2G_TUNE_CORE0, e_r7_2g->radio_lna2g_tune_core0); BWN_RF_WRITE(mac, R2057_TXMIX2G_TUNE_BOOST_PU_CORE1, e_r7_2g->radio_txmix2g_tune_boost_pu_core1); BWN_RF_WRITE(mac, R2057_PAD2G_TUNE_PUS_CORE1, e_r7_2g->radio_pad2g_tune_pus_core1); BWN_RF_WRITE(mac, R2057_LNA2G_TUNE_CORE1, e_r7_2g->radio_lna2g_tune_core1); } else { BWN_RF_WRITE(mac, R2057_VCOCAL_COUNTVAL0, e_r7->radio_vcocal_countval0); BWN_RF_WRITE(mac, R2057_VCOCAL_COUNTVAL1, e_r7->radio_vcocal_countval1); BWN_RF_WRITE(mac, R2057_RFPLL_REFMASTER_SPAREXTALSIZE, e_r7->radio_rfpll_refmaster_sparextalsize); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_R1, e_r7->radio_rfpll_loopfilter_r1); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C2, e_r7->radio_rfpll_loopfilter_c2); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C1, e_r7->radio_rfpll_loopfilter_c1); BWN_RF_WRITE(mac, R2057_CP_KPD_IDAC, e_r7->radio_cp_kpd_idac); BWN_RF_WRITE(mac, R2057_RFPLL_MMD0, e_r7->radio_rfpll_mmd0); BWN_RF_WRITE(mac, R2057_RFPLL_MMD1, e_r7->radio_rfpll_mmd1); BWN_RF_WRITE(mac, R2057_VCOBUF_TUNE, e_r7->radio_vcobuf_tune); BWN_RF_WRITE(mac, R2057_LOGEN_MX2G_TUNE, e_r7->radio_logen_mx2g_tune); BWN_RF_WRITE(mac, R2057_LOGEN_MX5G_TUNE, e_r7->radio_logen_mx5g_tune); BWN_RF_WRITE(mac, R2057_LOGEN_INDBUF2G_TUNE, e_r7->radio_logen_indbuf2g_tune); BWN_RF_WRITE(mac, R2057_LOGEN_INDBUF5G_TUNE, e_r7->radio_logen_indbuf5g_tune); BWN_RF_WRITE(mac, R2057_TXMIX2G_TUNE_BOOST_PU_CORE0, e_r7->radio_txmix2g_tune_boost_pu_core0); BWN_RF_WRITE(mac, R2057_PAD2G_TUNE_PUS_CORE0, e_r7->radio_pad2g_tune_pus_core0); BWN_RF_WRITE(mac, R2057_PGA_BOOST_TUNE_CORE0, e_r7->radio_pga_boost_tune_core0); BWN_RF_WRITE(mac, R2057_TXMIX5G_BOOST_TUNE_CORE0, e_r7->radio_txmix5g_boost_tune_core0); BWN_RF_WRITE(mac, R2057_PAD5G_TUNE_MISC_PUS_CORE0, e_r7->radio_pad5g_tune_misc_pus_core0); BWN_RF_WRITE(mac, R2057_LNA2G_TUNE_CORE0, e_r7->radio_lna2g_tune_core0); BWN_RF_WRITE(mac, R2057_LNA5G_TUNE_CORE0, e_r7->radio_lna5g_tune_core0); BWN_RF_WRITE(mac, R2057_TXMIX2G_TUNE_BOOST_PU_CORE1, e_r7->radio_txmix2g_tune_boost_pu_core1); BWN_RF_WRITE(mac, R2057_PAD2G_TUNE_PUS_CORE1, e_r7->radio_pad2g_tune_pus_core1); BWN_RF_WRITE(mac, R2057_PGA_BOOST_TUNE_CORE1, e_r7->radio_pga_boost_tune_core1); BWN_RF_WRITE(mac, R2057_TXMIX5G_BOOST_TUNE_CORE1, e_r7->radio_txmix5g_boost_tune_core1); BWN_RF_WRITE(mac, R2057_PAD5G_TUNE_MISC_PUS_CORE1, e_r7->radio_pad5g_tune_misc_pus_core1); BWN_RF_WRITE(mac, R2057_LNA2G_TUNE_CORE1, e_r7->radio_lna2g_tune_core1); BWN_RF_WRITE(mac, R2057_LNA5G_TUNE_CORE1, e_r7->radio_lna5g_tune_core1); } } static void bwn_radio_2057_setup(struct bwn_mac *mac, const struct bwn_nphy_chantabent_rev7 *tabent_r7, const struct bwn_nphy_chantabent_rev7_2g *tabent_r7_2g) { struct bwn_phy *phy = &mac->mac_phy; bwn_radio_2057_chantab_upload(mac, tabent_r7, tabent_r7_2g); switch (phy->rf_rev) { case 0 ... 4: case 6: if (bwn_current_band(mac) == BWN_BAND_2G) { BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_R1, 0x3f); BWN_RF_WRITE(mac, R2057_CP_KPD_IDAC, 0x3f); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C1, 0x8); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C2, 0x8); } else { BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_R1, 0x1f); BWN_RF_WRITE(mac, R2057_CP_KPD_IDAC, 0x3f); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C1, 0x8); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C2, 0x8); } break; case 9: /* e.g. PHY rev 16 */ BWN_RF_WRITE(mac, R2057_LOGEN_PTAT_RESETS, 0x20); BWN_RF_WRITE(mac, R2057_VCOBUF_IDACS, 0x18); if (bwn_current_band(mac) == BWN_BAND_5G) { BWN_RF_WRITE(mac, R2057_LOGEN_PTAT_RESETS, 0x38); BWN_RF_WRITE(mac, R2057_VCOBUF_IDACS, 0x0f); if (bwn_is_40mhz(mac)) { /* TODO */ } else { BWN_RF_WRITE(mac, R2057_PAD_BIAS_FILTER_BWS_CORE0, 0x3c); BWN_RF_WRITE(mac, R2057_PAD_BIAS_FILTER_BWS_CORE1, 0x3c); } } break; case 14: /* 2 GHz only */ BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_R1, 0x1b); BWN_RF_WRITE(mac, R2057_CP_KPD_IDAC, 0x3f); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C1, 0x1f); BWN_RF_WRITE(mac, R2057_RFPLL_LOOPFILTER_C2, 0x1f); break; } if (bwn_current_band(mac) == BWN_BAND_2G) { uint16_t txmix2g_tune_boost_pu = 0; uint16_t pad2g_tune_pus = 0; if (bwn_nphy_ipa(mac)) { switch (phy->rf_rev) { case 9: txmix2g_tune_boost_pu = 0x0041; /* TODO */ break; case 14: txmix2g_tune_boost_pu = 0x21; pad2g_tune_pus = 0x23; break; } } if (txmix2g_tune_boost_pu) BWN_RF_WRITE(mac, R2057_TXMIX2G_TUNE_BOOST_PU_CORE0, txmix2g_tune_boost_pu); if (pad2g_tune_pus) BWN_RF_WRITE(mac, R2057_PAD2G_TUNE_PUS_CORE0, pad2g_tune_pus); if (txmix2g_tune_boost_pu) BWN_RF_WRITE(mac, R2057_TXMIX2G_TUNE_BOOST_PU_CORE1, txmix2g_tune_boost_pu); if (pad2g_tune_pus) BWN_RF_WRITE(mac, R2057_PAD2G_TUNE_PUS_CORE1, pad2g_tune_pus); } /* 50..100 */ DELAY(100); /* VCO calibration */ BWN_RF_MASK(mac, R2057_RFPLL_MISC_EN, ~0x01); BWN_RF_MASK(mac, R2057_RFPLL_MISC_CAL_RESETN, ~0x04); BWN_RF_SET(mac, R2057_RFPLL_MISC_CAL_RESETN, 0x4); BWN_RF_SET(mac, R2057_RFPLL_MISC_EN, 0x01); /* 300..600 */ DELAY(600); } /* Calibrate resistors in LPF of PLL? * http://bcm-v4.sipsolutions.net/PHY/radio205x_rcal */ static uint8_t bwn_radio_2057_rcal(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; uint16_t saved_regs_phy[12]; uint16_t saved_regs_phy_rf[6]; uint16_t saved_regs_radio[2] = { }; static const uint16_t phy_to_store[] = { BWN_NPHY_RFCTL_RSSIO1, BWN_NPHY_RFCTL_RSSIO2, BWN_NPHY_RFCTL_LUT_TRSW_LO1, BWN_NPHY_RFCTL_LUT_TRSW_LO2, BWN_NPHY_RFCTL_RXG1, BWN_NPHY_RFCTL_RXG2, BWN_NPHY_RFCTL_TXG1, BWN_NPHY_RFCTL_TXG2, BWN_NPHY_REV7_RF_CTL_MISC_REG3, BWN_NPHY_REV7_RF_CTL_MISC_REG4, BWN_NPHY_REV7_RF_CTL_MISC_REG5, BWN_NPHY_REV7_RF_CTL_MISC_REG6, }; static const uint16_t phy_to_store_rf[] = { BWN_NPHY_REV3_RFCTL_OVER0, BWN_NPHY_REV3_RFCTL_OVER1, BWN_NPHY_REV7_RF_CTL_OVER3, BWN_NPHY_REV7_RF_CTL_OVER4, BWN_NPHY_REV7_RF_CTL_OVER5, BWN_NPHY_REV7_RF_CTL_OVER6, }; uint16_t tmp; int i; /* Save */ for (i = 0; i < nitems(phy_to_store); i++) saved_regs_phy[i] = BWN_PHY_READ(mac, phy_to_store[i]); for (i = 0; i < nitems(phy_to_store_rf); i++) saved_regs_phy_rf[i] = BWN_PHY_READ(mac, phy_to_store_rf[i]); /* Set */ for (i = 0; i < nitems(phy_to_store); i++) BWN_PHY_WRITE(mac, phy_to_store[i], 0); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_RFCTL_OVER0, 0x07ff); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_RFCTL_OVER1, 0x07ff); BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER3, 0x07ff); BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER4, 0x07ff); BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER5, 0x007f); BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER6, 0x007f); switch (phy->rf_rev) { case 5: BWN_PHY_MASK(mac, BWN_NPHY_REV7_RF_CTL_OVER3, ~0x2); DELAY(10); BWN_RF_SET(mac, R2057_IQTEST_SEL_PU, 0x1); BWN_RF_SETMASK(mac, R2057v7_IQTEST_SEL_PU2, ~0x2, 0x1); break; case 9: BWN_PHY_SET(mac, BWN_NPHY_REV7_RF_CTL_OVER3, 0x2); BWN_PHY_SET(mac, BWN_NPHY_REV7_RF_CTL_MISC_REG3, 0x2); saved_regs_radio[0] = BWN_RF_READ(mac, R2057_IQTEST_SEL_PU); BWN_RF_WRITE(mac, R2057_IQTEST_SEL_PU, 0x11); break; case 14: saved_regs_radio[0] = BWN_RF_READ(mac, R2057_IQTEST_SEL_PU); saved_regs_radio[1] = BWN_RF_READ(mac, R2057v7_IQTEST_SEL_PU2); BWN_PHY_SET(mac, BWN_NPHY_REV7_RF_CTL_MISC_REG3, 0x2); BWN_PHY_SET(mac, BWN_NPHY_REV7_RF_CTL_OVER3, 0x2); BWN_RF_WRITE(mac, R2057v7_IQTEST_SEL_PU2, 0x2); BWN_RF_WRITE(mac, R2057_IQTEST_SEL_PU, 0x1); break; } /* Enable */ BWN_RF_SET(mac, R2057_RCAL_CONFIG, 0x1); DELAY(10); /* Start */ BWN_RF_SET(mac, R2057_RCAL_CONFIG, 0x2); /* 100..200 */ DELAY(200); /* Stop */ BWN_RF_MASK(mac, R2057_RCAL_CONFIG, ~0x2); /* Wait and check for result */ if (!bwn_radio_wait_value(mac, R2057_RCAL_STATUS, 1, 1, 100, 1000000)) { BWN_ERRPRINTF(mac->mac_sc, "Radio 0x2057 rcal timeout\n"); return 0; } tmp = BWN_RF_READ(mac, R2057_RCAL_STATUS) & 0x3E; /* Disable */ BWN_RF_MASK(mac, R2057_RCAL_CONFIG, ~0x1); /* Restore */ for (i = 0; i < nitems(phy_to_store_rf); i++) BWN_PHY_WRITE(mac, phy_to_store_rf[i], saved_regs_phy_rf[i]); for (i = 0; i < nitems(phy_to_store); i++) BWN_PHY_WRITE(mac, phy_to_store[i], saved_regs_phy[i]); switch (phy->rf_rev) { case 0 ... 4: case 6: BWN_RF_SETMASK(mac, R2057_TEMPSENSE_CONFIG, ~0x3C, tmp); BWN_RF_SETMASK(mac, R2057_BANDGAP_RCAL_TRIM, ~0xF0, tmp << 2); break; case 5: BWN_RF_MASK(mac, R2057_IPA2G_CASCONV_CORE0, ~0x1); BWN_RF_MASK(mac, R2057v7_IQTEST_SEL_PU2, ~0x2); break; case 9: BWN_RF_WRITE(mac, R2057_IQTEST_SEL_PU, saved_regs_radio[0]); break; case 14: BWN_RF_WRITE(mac, R2057_IQTEST_SEL_PU, saved_regs_radio[0]); BWN_RF_WRITE(mac, R2057v7_IQTEST_SEL_PU2, saved_regs_radio[1]); break; } return tmp & 0x3e; } /* Calibrate the internal RC oscillator? * http://bcm-v4.sipsolutions.net/PHY/radio2057_rccal */ static uint16_t bwn_radio_2057_rccal(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; bool special = (phy->rf_rev == 3 || phy->rf_rev == 4 || phy->rf_rev == 6); uint16_t tmp; /* Setup cal */ if (special) { BWN_RF_WRITE(mac, R2057_RCCAL_MASTER, 0x61); BWN_RF_WRITE(mac, R2057_RCCAL_TRC0, 0xC0); } else { BWN_RF_WRITE(mac, R2057v7_RCCAL_MASTER, 0x61); BWN_RF_WRITE(mac, R2057_RCCAL_TRC0, 0xE9); } BWN_RF_WRITE(mac, R2057_RCCAL_X1, 0x6E); /* Start, wait, stop */ BWN_RF_WRITE(mac, R2057_RCCAL_START_R1_Q1_P1, 0x55); if (!bwn_radio_wait_value(mac, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500, 5000000)) BWN_DBGPRINTF(mac, "Radio 0x2057 rccal timeout\n"); /* 35..70 */ DELAY(70); BWN_RF_WRITE(mac, R2057_RCCAL_START_R1_Q1_P1, 0x15); /* 70..140 */ DELAY(140); /* Setup cal */ if (special) { BWN_RF_WRITE(mac, R2057_RCCAL_MASTER, 0x69); BWN_RF_WRITE(mac, R2057_RCCAL_TRC0, 0xB0); } else { BWN_RF_WRITE(mac, R2057v7_RCCAL_MASTER, 0x69); BWN_RF_WRITE(mac, R2057_RCCAL_TRC0, 0xD5); } BWN_RF_WRITE(mac, R2057_RCCAL_X1, 0x6E); /* Start, wait, stop */ /* 35..70 */ DELAY(70); BWN_RF_WRITE(mac, R2057_RCCAL_START_R1_Q1_P1, 0x55); /* 70..140 */ DELAY(140); if (!bwn_radio_wait_value(mac, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500, 5000000)) BWN_DBGPRINTF(mac, "Radio 0x2057 rccal timeout\n"); /* 35..70 */ DELAY(70); BWN_RF_WRITE(mac, R2057_RCCAL_START_R1_Q1_P1, 0x15); /* 70..140 */ DELAY(140); /* Setup cal */ if (special) { BWN_RF_WRITE(mac, R2057_RCCAL_MASTER, 0x73); BWN_RF_WRITE(mac, R2057_RCCAL_X1, 0x28); BWN_RF_WRITE(mac, R2057_RCCAL_TRC0, 0xB0); } else { BWN_RF_WRITE(mac, R2057v7_RCCAL_MASTER, 0x73); BWN_RF_WRITE(mac, R2057_RCCAL_X1, 0x6E); BWN_RF_WRITE(mac, R2057_RCCAL_TRC0, 0x99); } /* Start, wait, stop */ /* 35..70 */ DELAY(70); BWN_RF_WRITE(mac, R2057_RCCAL_START_R1_Q1_P1, 0x55); /* 70..140 */ DELAY(140); if (!bwn_radio_wait_value(mac, R2057_RCCAL_DONE_OSCCAP, 2, 2, 500, 5000000)) { BWN_ERRPRINTF(mac->mac_sc, "Radio 0x2057 rcal timeout\n"); return 0; } tmp = BWN_RF_READ(mac, R2057_RCCAL_DONE_OSCCAP); /* 35..70 */ DELAY(70); BWN_RF_WRITE(mac, R2057_RCCAL_START_R1_Q1_P1, 0x15); /* 70..140 */ DELAY(140); if (special) BWN_RF_MASK(mac, R2057_RCCAL_MASTER, ~0x1); else BWN_RF_MASK(mac, R2057v7_RCCAL_MASTER, ~0x1); return tmp; } static void bwn_radio_2057_init_pre(struct bwn_mac *mac) { BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_CHIP0PU); /* Maybe wl meant to reset and set (order?) RFCTL_CMD_OEPORFORCE? */ BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_OEPORFORCE); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_OEPORFORCE); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_CHIP0PU); } static void bwn_radio_2057_init_post(struct bwn_mac *mac) { BWN_RF_SET(mac, R2057_XTALPUOVR_PINCTRL, 0x1); if (0) /* FIXME: Is this BCM43217 specific? */ BWN_RF_SET(mac, R2057_XTALPUOVR_PINCTRL, 0x2); BWN_RF_SET(mac, R2057_RFPLL_MISC_CAL_RESETN, 0x78); BWN_RF_SET(mac, R2057_XTAL_CONFIG2, 0x80); DELAY(2000); BWN_RF_MASK(mac, R2057_RFPLL_MISC_CAL_RESETN, ~0x78); BWN_RF_MASK(mac, R2057_XTAL_CONFIG2, ~0x80); if (mac->mac_phy.phy_do_full_init) { bwn_radio_2057_rcal(mac); bwn_radio_2057_rccal(mac); } BWN_RF_MASK(mac, R2057_RFPLL_MASTER, ~0x8); } /* http://bcm-v4.sipsolutions.net/802.11/Radio/2057/Init */ static void bwn_radio_2057_init(struct bwn_mac *mac) { bwn_radio_2057_init_pre(mac); r2057_upload_inittabs(mac); bwn_radio_2057_init_post(mac); } /************************************************** * Radio 0x2056 **************************************************/ static void bwn_chantab_radio_2056_upload(struct bwn_mac *mac, const struct bwn_nphy_channeltab_entry_rev3 *e) { BWN_RF_WRITE(mac, B2056_SYN_PLL_VCOCAL1, e->radio_syn_pll_vcocal1); BWN_RF_WRITE(mac, B2056_SYN_PLL_VCOCAL2, e->radio_syn_pll_vcocal2); BWN_RF_WRITE(mac, B2056_SYN_PLL_REFDIV, e->radio_syn_pll_refdiv); BWN_RF_WRITE(mac, B2056_SYN_PLL_MMD2, e->radio_syn_pll_mmd2); BWN_RF_WRITE(mac, B2056_SYN_PLL_MMD1, e->radio_syn_pll_mmd1); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER1, e->radio_syn_pll_loopfilter1); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER2, e->radio_syn_pll_loopfilter2); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER3, e->radio_syn_pll_loopfilter3); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER4, e->radio_syn_pll_loopfilter4); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER5, e->radio_syn_pll_loopfilter5); BWN_RF_WRITE(mac, B2056_SYN_RESERVED_ADDR27, e->radio_syn_reserved_addr27); BWN_RF_WRITE(mac, B2056_SYN_RESERVED_ADDR28, e->radio_syn_reserved_addr28); BWN_RF_WRITE(mac, B2056_SYN_RESERVED_ADDR29, e->radio_syn_reserved_addr29); BWN_RF_WRITE(mac, B2056_SYN_LOGEN_VCOBUF1, e->radio_syn_logen_vcobuf1); BWN_RF_WRITE(mac, B2056_SYN_LOGEN_MIXER2, e->radio_syn_logen_mixer2); BWN_RF_WRITE(mac, B2056_SYN_LOGEN_BUF3, e->radio_syn_logen_buf3); BWN_RF_WRITE(mac, B2056_SYN_LOGEN_BUF4, e->radio_syn_logen_buf4); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_LNAA_TUNE, e->radio_rx0_lnaa_tune); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_LNAG_TUNE, e->radio_rx0_lnag_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_INTPAA_BOOST_TUNE, e->radio_tx0_intpaa_boost_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_INTPAG_BOOST_TUNE, e->radio_tx0_intpag_boost_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_PADA_BOOST_TUNE, e->radio_tx0_pada_boost_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_PADG_BOOST_TUNE, e->radio_tx0_padg_boost_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_PGAA_BOOST_TUNE, e->radio_tx0_pgaa_boost_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_PGAG_BOOST_TUNE, e->radio_tx0_pgag_boost_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_MIXA_BOOST_TUNE, e->radio_tx0_mixa_boost_tune); BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_MIXG_BOOST_TUNE, e->radio_tx0_mixg_boost_tune); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_LNAA_TUNE, e->radio_rx1_lnaa_tune); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_LNAG_TUNE, e->radio_rx1_lnag_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_INTPAA_BOOST_TUNE, e->radio_tx1_intpaa_boost_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_INTPAG_BOOST_TUNE, e->radio_tx1_intpag_boost_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_PADA_BOOST_TUNE, e->radio_tx1_pada_boost_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_PADG_BOOST_TUNE, e->radio_tx1_padg_boost_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_PGAA_BOOST_TUNE, e->radio_tx1_pgaa_boost_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_PGAG_BOOST_TUNE, e->radio_tx1_pgag_boost_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_MIXA_BOOST_TUNE, e->radio_tx1_mixa_boost_tune); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_MIXG_BOOST_TUNE, e->radio_tx1_mixg_boost_tune); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2056Setup */ static void bwn_radio_2056_setup(struct bwn_mac *mac, const struct bwn_nphy_channeltab_entry_rev3 *e) { struct bwn_softc *sc = mac->mac_sc; bwn_band_t band = bwn_current_band(mac); uint16_t offset; uint8_t i; uint16_t bias, cbias; uint16_t pag_boost, padg_boost, pgag_boost, mixg_boost; uint16_t paa_boost, pada_boost, pgaa_boost, mixa_boost; bool is_pkg_fab_smic; DPRINTF(mac->mac_sc, BWN_DEBUG_RF, "%s: called\n", __func__); if (mac->mac_phy.rev < 3) { BWN_ERRPRINTF(mac->mac_sc, "%s: phy rev %d out of range\n", __func__, mac->mac_phy.rev); } is_pkg_fab_smic = ((sc->sc_cid.chip_id == BHND_CHIPID_BCM43224 || sc->sc_cid.chip_id == BHND_CHIPID_BCM43225 || sc->sc_cid.chip_id == BHND_CHIPID_BCM43421) && sc->sc_cid.chip_pkg == BHND_PKGID_BCM43224_FAB_SMIC); bwn_chantab_radio_2056_upload(mac, e); b2056_upload_syn_pll_cp2(mac, band == BWN_BAND_5G); if (sc->sc_board_info.board_flags2 & BHND_BFL2_GPLL_WAR && bwn_current_band(mac) == BWN_BAND_2G) { BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER1, 0x1F); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER2, 0x1F); if (sc->sc_cid.chip_id == BHND_CHIPID_BCM4716 || sc->sc_cid.chip_id == BHND_CHIPID_BCM47162) { BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER4, 0x14); BWN_RF_WRITE(mac, B2056_SYN_PLL_CP2, 0); } else { BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER4, 0x0B); BWN_RF_WRITE(mac, B2056_SYN_PLL_CP2, 0x14); } } if (sc->sc_board_info.board_flags2 & BHND_BFL2_GPLL_WAR && bwn_current_band(mac) == BWN_BAND_2G) { BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER1, 0x1f); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER2, 0x1f); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER4, 0x0b); BWN_RF_WRITE(mac, B2056_SYN_PLL_CP2, 0x20); } if (sc->sc_board_info.board_flags2 & BHND_BFL2_APLL_WAR && bwn_current_band(mac) == BWN_BAND_5G) { BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER1, 0x1F); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER2, 0x1F); BWN_RF_WRITE(mac, B2056_SYN_PLL_LOOPFILTER4, 0x05); BWN_RF_WRITE(mac, B2056_SYN_PLL_CP2, 0x0C); } if (mac->mac_phy.phy_n->ipa2g_on && band == BWN_BAND_2G) { for (i = 0; i < 2; i++) { offset = i ? B2056_TX1 : B2056_TX0; if (mac->mac_phy.rev >= 5) { BWN_RF_WRITE(mac, offset | B2056_TX_PADG_IDAC, 0xcc); if (sc->sc_cid.chip_id == BHND_CHIPID_BCM4716 || sc->sc_cid.chip_id == BHND_CHIPID_BCM47162) { bias = 0x40; cbias = 0x45; pag_boost = 0x5; pgag_boost = 0x33; mixg_boost = 0x55; } else { bias = 0x25; cbias = 0x20; if (is_pkg_fab_smic) { bias = 0x2a; cbias = 0x38; } pag_boost = 0x4; pgag_boost = 0x03; mixg_boost = 0x65; } padg_boost = 0x77; BWN_RF_WRITE(mac, offset | B2056_TX_INTPAG_IMAIN_STAT, bias); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAG_IAUX_STAT, bias); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAG_CASCBIAS, cbias); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAG_BOOST_TUNE, pag_boost); BWN_RF_WRITE(mac, offset | B2056_TX_PGAG_BOOST_TUNE, pgag_boost); BWN_RF_WRITE(mac, offset | B2056_TX_PADG_BOOST_TUNE, padg_boost); BWN_RF_WRITE(mac, offset | B2056_TX_MIXG_BOOST_TUNE, mixg_boost); } else { bias = bwn_is_40mhz(mac) ? 0x40 : 0x20; BWN_RF_WRITE(mac, offset | B2056_TX_INTPAG_IMAIN_STAT, bias); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAG_IAUX_STAT, bias); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAG_CASCBIAS, 0x30); } BWN_RF_WRITE(mac, offset | B2056_TX_PA_SPARE1, 0xee); } } else if (mac->mac_phy.phy_n->ipa5g_on && band == BWN_BAND_5G) { uint16_t freq = bwn_get_centre_freq(mac); /* XXX 5g low/med/high? */ if (freq < 5100) { paa_boost = 0xA; pada_boost = 0x77; pgaa_boost = 0xF; mixa_boost = 0xF; } else if (freq < 5340) { paa_boost = 0x8; pada_boost = 0x77; pgaa_boost = 0xFB; mixa_boost = 0xF; } else if (freq < 5650) { paa_boost = 0x0; pada_boost = 0x77; pgaa_boost = 0xB; mixa_boost = 0xF; } else { paa_boost = 0x0; pada_boost = 0x77; if (freq != 5825) pgaa_boost = -(freq - 18) / 36 + 168; else pgaa_boost = 6; mixa_boost = 0xF; } cbias = is_pkg_fab_smic ? 0x35 : 0x30; for (i = 0; i < 2; i++) { offset = i ? B2056_TX1 : B2056_TX0; BWN_RF_WRITE(mac, offset | B2056_TX_INTPAA_BOOST_TUNE, paa_boost); BWN_RF_WRITE(mac, offset | B2056_TX_PADA_BOOST_TUNE, pada_boost); BWN_RF_WRITE(mac, offset | B2056_TX_PGAA_BOOST_TUNE, pgaa_boost); BWN_RF_WRITE(mac, offset | B2056_TX_MIXA_BOOST_TUNE, mixa_boost); BWN_RF_WRITE(mac, offset | B2056_TX_TXSPARE1, 0x30); BWN_RF_WRITE(mac, offset | B2056_TX_PA_SPARE2, 0xee); BWN_RF_WRITE(mac, offset | B2056_TX_PADA_CASCBIAS, 0x03); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAA_IAUX_STAT, 0x30); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAA_IMAIN_STAT, 0x30); BWN_RF_WRITE(mac, offset | B2056_TX_INTPAA_CASCBIAS, cbias); } } DELAY(50); /* VCO calibration */ BWN_RF_WRITE(mac, B2056_SYN_PLL_VCOCAL12, 0x00); BWN_RF_WRITE(mac, B2056_TX_INTPAA_PA_MISC, 0x38); BWN_RF_WRITE(mac, B2056_TX_INTPAA_PA_MISC, 0x18); BWN_RF_WRITE(mac, B2056_TX_INTPAA_PA_MISC, 0x38); BWN_RF_WRITE(mac, B2056_TX_INTPAA_PA_MISC, 0x39); DELAY(300); } static uint8_t bwn_radio_2056_rcal(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; uint16_t mast2, tmp; if (phy->rev != 3) return 0; DPRINTF(mac->mac_sc, BWN_DEBUG_RF, "%s: called\n", __func__); mast2 = BWN_RF_READ(mac, B2056_SYN_PLL_MAST2); BWN_RF_WRITE(mac, B2056_SYN_PLL_MAST2, mast2 | 0x7); DELAY(10); BWN_RF_WRITE(mac, B2056_SYN_RCAL_MASTER, 0x01); DELAY(10); BWN_RF_WRITE(mac, B2056_SYN_RCAL_MASTER, 0x09); if (!bwn_radio_wait_value(mac, B2056_SYN_RCAL_CODE_OUT, 0x80, 0x80, 100, 1000000)) { BWN_ERRPRINTF(mac->mac_sc, "Radio recalibration timeout\n"); return 0; } BWN_RF_WRITE(mac, B2056_SYN_RCAL_MASTER, 0x01); tmp = BWN_RF_READ(mac, B2056_SYN_RCAL_CODE_OUT); BWN_RF_WRITE(mac, B2056_SYN_RCAL_MASTER, 0x00); BWN_RF_WRITE(mac, B2056_SYN_PLL_MAST2, mast2); return tmp & 0x1f; } static void bwn_radio_init2056_pre(struct bwn_mac *mac) { DPRINTF(mac->mac_sc, BWN_DEBUG_RF, "%s: called\n", __func__); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_CHIP0PU); /* Maybe wl meant to reset and set (order?) RFCTL_CMD_OEPORFORCE? */ BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_OEPORFORCE); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_OEPORFORCE); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_CHIP0PU); } static void bwn_radio_init2056_post(struct bwn_mac *mac) { DPRINTF(mac->mac_sc, BWN_DEBUG_RF, "%s: called\n", __func__); BWN_RF_SET(mac, B2056_SYN_COM_CTRL, 0xB); BWN_RF_SET(mac, B2056_SYN_COM_PU, 0x2); BWN_RF_SET(mac, B2056_SYN_COM_RESET, 0x2); DELAY(1000); BWN_RF_MASK(mac, B2056_SYN_COM_RESET, ~0x2); BWN_RF_MASK(mac, B2056_SYN_PLL_MAST2, ~0xFC); BWN_RF_MASK(mac, B2056_SYN_RCCAL_CTRL0, ~0x1); if (mac->mac_phy.phy_do_full_init) bwn_radio_2056_rcal(mac); } /* * Initialize a Broadcom 2056 N-radio * http://bcm-v4.sipsolutions.net/802.11/Radio/2056/Init */ static void bwn_radio_init2056(struct bwn_mac *mac) { DPRINTF(mac->mac_sc, BWN_DEBUG_RF, "%s: called\n", __func__); bwn_radio_init2056_pre(mac); b2056_upload_inittabs(mac, 0, 0); bwn_radio_init2056_post(mac); } /************************************************** * Radio 0x2055 **************************************************/ static void bwn_chantab_radio_upload(struct bwn_mac *mac, const struct bwn_nphy_channeltab_entry_rev2 *e) { BWN_RF_WRITE(mac, B2055_PLL_REF, e->radio_pll_ref); BWN_RF_WRITE(mac, B2055_RF_PLLMOD0, e->radio_rf_pllmod0); BWN_RF_WRITE(mac, B2055_RF_PLLMOD1, e->radio_rf_pllmod1); BWN_RF_WRITE(mac, B2055_VCO_CAPTAIL, e->radio_vco_captail); BWN_READ_4(mac, BWN_MACCTL); /* flush writes */ BWN_RF_WRITE(mac, B2055_VCO_CAL1, e->radio_vco_cal1); BWN_RF_WRITE(mac, B2055_VCO_CAL2, e->radio_vco_cal2); BWN_RF_WRITE(mac, B2055_PLL_LFC1, e->radio_pll_lfc1); BWN_RF_WRITE(mac, B2055_PLL_LFR1, e->radio_pll_lfr1); BWN_READ_4(mac, BWN_MACCTL); /* flush writes */ BWN_RF_WRITE(mac, B2055_PLL_LFC2, e->radio_pll_lfc2); BWN_RF_WRITE(mac, B2055_LGBUF_CENBUF, e->radio_lgbuf_cenbuf); BWN_RF_WRITE(mac, B2055_LGEN_TUNE1, e->radio_lgen_tune1); BWN_RF_WRITE(mac, B2055_LGEN_TUNE2, e->radio_lgen_tune2); BWN_READ_4(mac, BWN_MACCTL); /* flush writes */ BWN_RF_WRITE(mac, B2055_C1_LGBUF_ATUNE, e->radio_c1_lgbuf_atune); BWN_RF_WRITE(mac, B2055_C1_LGBUF_GTUNE, e->radio_c1_lgbuf_gtune); BWN_RF_WRITE(mac, B2055_C1_RX_RFR1, e->radio_c1_rx_rfr1); BWN_RF_WRITE(mac, B2055_C1_TX_PGAPADTN, e->radio_c1_tx_pgapadtn); BWN_READ_4(mac, BWN_MACCTL); /* flush writes */ BWN_RF_WRITE(mac, B2055_C1_TX_MXBGTRIM, e->radio_c1_tx_mxbgtrim); BWN_RF_WRITE(mac, B2055_C2_LGBUF_ATUNE, e->radio_c2_lgbuf_atune); BWN_RF_WRITE(mac, B2055_C2_LGBUF_GTUNE, e->radio_c2_lgbuf_gtune); BWN_RF_WRITE(mac, B2055_C2_RX_RFR1, e->radio_c2_rx_rfr1); BWN_READ_4(mac, BWN_MACCTL); /* flush writes */ BWN_RF_WRITE(mac, B2055_C2_TX_PGAPADTN, e->radio_c2_tx_pgapadtn); BWN_RF_WRITE(mac, B2055_C2_TX_MXBGTRIM, e->radio_c2_tx_mxbgtrim); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/Radio/2055Setup */ static void bwn_radio_2055_setup(struct bwn_mac *mac, const struct bwn_nphy_channeltab_entry_rev2 *e) { if (mac->mac_phy.rev >= 3) { BWN_ERRPRINTF(mac->mac_sc, "%s: phy rev %d out of range\n", __func__, mac->mac_phy.rev); } DPRINTF(mac->mac_sc, BWN_DEBUG_RF, "%s: called\n", __func__); bwn_chantab_radio_upload(mac, e); DELAY(50); BWN_RF_WRITE(mac, B2055_VCO_CAL10, 0x05); BWN_RF_WRITE(mac, B2055_VCO_CAL10, 0x45); BWN_READ_4(mac, BWN_MACCTL); /* flush writes */ BWN_RF_WRITE(mac, B2055_VCO_CAL10, 0x65); DELAY(300); } static void bwn_radio_init2055_pre(struct bwn_mac *mac) { BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_PORFORCE); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_CHIP0PU | BWN_NPHY_RFCTL_CMD_OEPORFORCE); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_PORFORCE); } static void bwn_radio_init2055_post(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; bool workaround = false; if (bhnd_get_hwrev(sc->sc_dev) < 4) workaround = (sc->sc_board_info.board_vendor != PCI_VENDOR_BROADCOM) && (sc->sc_board_info.board_type == BHND_BOARD_BCM4321CB2) && (sc->sc_board_info.board_rev >= 0x41); else workaround = !(sc->sc_board_info.board_flags2 & BHND_BFL2_RXBB_INT_REG_DIS); BWN_RF_MASK(mac, B2055_MASTER1, 0xFFF3); if (workaround) { BWN_RF_MASK(mac, B2055_C1_RX_BB_REG, 0x7F); BWN_RF_MASK(mac, B2055_C2_RX_BB_REG, 0x7F); } BWN_RF_SETMASK(mac, B2055_RRCCAL_NOPTSEL, 0xFFC0, 0x2C); BWN_RF_WRITE(mac, B2055_CAL_MISC, 0x3C); BWN_RF_MASK(mac, B2055_CAL_MISC, 0xFFBE); BWN_RF_SET(mac, B2055_CAL_LPOCTL, 0x80); BWN_RF_SET(mac, B2055_CAL_MISC, 0x1); DELAY(1000); BWN_RF_SET(mac, B2055_CAL_MISC, 0x40); if (!bwn_radio_wait_value(mac, B2055_CAL_COUT2, 0x80, 0x80, 10, 2000)) BWN_ERRPRINTF(mac->mac_sc, "radio post init timeout\n"); BWN_RF_MASK(mac, B2055_CAL_LPOCTL, 0xFF7F); bwn_switch_channel(mac, bwn_get_chan(mac)); BWN_RF_WRITE(mac, B2055_C1_RX_BB_LPF, 0x9); BWN_RF_WRITE(mac, B2055_C2_RX_BB_LPF, 0x9); BWN_RF_WRITE(mac, B2055_C1_RX_BB_MIDACHP, 0x83); BWN_RF_WRITE(mac, B2055_C2_RX_BB_MIDACHP, 0x83); BWN_RF_SETMASK(mac, B2055_C1_LNA_GAINBST, 0xFFF8, 0x6); BWN_RF_SETMASK(mac, B2055_C2_LNA_GAINBST, 0xFFF8, 0x6); if (!nphy->gain_boost) { BWN_RF_SET(mac, B2055_C1_RX_RFSPC1, 0x2); BWN_RF_SET(mac, B2055_C2_RX_RFSPC1, 0x2); } else { BWN_RF_MASK(mac, B2055_C1_RX_RFSPC1, 0xFFFD); BWN_RF_MASK(mac, B2055_C2_RX_RFSPC1, 0xFFFD); } DELAY(2); } /* * Initialize a Broadcom 2055 N-radio * http://bcm-v4.sipsolutions.net/802.11/Radio/2055/Init */ static void bwn_radio_init2055(struct bwn_mac *mac) { bwn_radio_init2055_pre(mac); if (mac->mac_status < BWN_MAC_STATUS_INITED) { /* Follow wl, not specs. Do not force uploading all regs */ b2055_upload_inittab(mac, 0, 0); } else { bool ghz5 = bwn_current_band(mac) == BWN_BAND_5G; b2055_upload_inittab(mac, ghz5, 0); } bwn_radio_init2055_post(mac); } /************************************************** * Samples **************************************************/ /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/LoadSampleTable */ static int bwn_nphy_load_samples(struct bwn_mac *mac, struct bwn_c32 *samples, uint16_t len) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t i; uint32_t *data; data = malloc(len * sizeof(uint32_t), M_DEVBUF, M_NOWAIT | M_ZERO); if (!data) { BWN_ERRPRINTF(mac->mac_sc, "allocation for samples loading failed\n"); return -ENOMEM; } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); for (i = 0; i < len; i++) { data[i] = (samples[i].i & 0x3FF << 10); data[i] |= samples[i].q & 0x3FF; } bwn_ntab_write_bulk(mac, BWN_NTAB32(17, 0), len, data); free(data, M_DEVBUF); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); return 0; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GenLoadSamples */ static uint16_t bwn_nphy_gen_load_samples(struct bwn_mac *mac, uint32_t freq, uint16_t max, bool test) { int i; uint16_t bw, len, rot, angle; struct bwn_c32 *samples; bw = bwn_is_40mhz(mac) ? 40 : 20; len = bw << 3; if (test) { if (BWN_PHY_READ(mac, BWN_NPHY_BBCFG) & BWN_NPHY_BBCFG_RSTRX) bw = 82; else bw = 80; if (bwn_is_40mhz(mac)) bw <<= 1; len = bw << 1; } samples = malloc(len * sizeof(struct bwn_c32), M_DEVBUF, M_NOWAIT | M_ZERO); if (!samples) { BWN_ERRPRINTF(mac->mac_sc, "allocation for samples generation failed\n"); return 0; } rot = (((freq * 36) / bw) << 16) / 100; angle = 0; for (i = 0; i < len; i++) { samples[i] = bwn_cordic(angle); angle += rot; samples[i].q = CORDIC_CONVERT(samples[i].q * max); samples[i].i = CORDIC_CONVERT(samples[i].i * max); } i = bwn_nphy_load_samples(mac, samples, len); free(samples, M_DEVBUF); return (i < 0) ? 0 : len; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RunSamples */ static void bwn_nphy_run_samples(struct bwn_mac *mac, uint16_t samps, uint16_t loops, uint16_t wait, bool iqmode, bool dac_test, bool modify_bbmult) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; int i; uint16_t seq_mode; uint32_t tmp; bwn_nphy_stay_in_carrier_search(mac, true); if (phy->rev >= 7) { bool lpf_bw3, lpf_bw4; lpf_bw3 = BWN_PHY_READ(mac, BWN_NPHY_REV7_RF_CTL_OVER3) & 0x80; lpf_bw4 = BWN_PHY_READ(mac, BWN_NPHY_REV7_RF_CTL_OVER4) & 0x80; if (lpf_bw3 || lpf_bw4) { /* TODO */ } else { uint16_t value = bwn_nphy_read_lpf_ctl(mac, 0); if (phy->rev >= 19) bwn_nphy_rf_ctl_override_rev19(mac, 0x80, value, 0, false, 1); else bwn_nphy_rf_ctl_override_rev7(mac, 0x80, value, 0, false, 1); nphy->lpf_bw_overrode_for_sample_play = true; } } if ((nphy->bb_mult_save & 0x80000000) == 0) { tmp = bwn_ntab_read(mac, BWN_NTAB16(15, 87)); nphy->bb_mult_save = (tmp & 0xFFFF) | 0x80000000; } if (modify_bbmult) { tmp = !bwn_is_40mhz(mac) ? 0x6464 : 0x4747; bwn_ntab_write(mac, BWN_NTAB16(15, 87), tmp); } BWN_PHY_WRITE(mac, BWN_NPHY_SAMP_DEPCNT, (samps - 1)); if (loops != 0xFFFF) BWN_PHY_WRITE(mac, BWN_NPHY_SAMP_LOOPCNT, (loops - 1)); else BWN_PHY_WRITE(mac, BWN_NPHY_SAMP_LOOPCNT, loops); BWN_PHY_WRITE(mac, BWN_NPHY_SAMP_WAITCNT, wait); seq_mode = BWN_PHY_READ(mac, BWN_NPHY_RFSEQMODE); BWN_PHY_SET(mac, BWN_NPHY_RFSEQMODE, BWN_NPHY_RFSEQMODE_CAOVER); if (iqmode) { BWN_PHY_MASK(mac, BWN_NPHY_IQLOCAL_CMDGCTL, 0x7FFF); BWN_PHY_SET(mac, BWN_NPHY_IQLOCAL_CMDGCTL, 0x8000); } else { tmp = dac_test ? 5 : 1; BWN_PHY_WRITE(mac, BWN_NPHY_SAMP_CMD, tmp); } for (i = 0; i < 100; i++) { if (!(BWN_PHY_READ(mac, BWN_NPHY_RFSEQST) & 1)) { i = 0; break; } DELAY(10); } if (i) BWN_ERRPRINTF(mac->mac_sc, "run samples timeout\n"); BWN_PHY_WRITE(mac, BWN_NPHY_RFSEQMODE, seq_mode); bwn_nphy_stay_in_carrier_search(mac, false); } /************************************************** * RSSI **************************************************/ /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ScaleOffsetRssi */ static void bwn_nphy_scale_offset_rssi(struct bwn_mac *mac, uint16_t scale, int8_t offset, uint8_t core, enum n_rail_type rail, enum n_rssi_type rssi_type) { uint16_t tmp; bool core1or5 = (core == 1) || (core == 5); bool core2or5 = (core == 2) || (core == 5); offset = bwn_clamp_val(offset, -32, 31); tmp = ((scale & 0x3F) << 8) | (offset & 0x3F); switch (rssi_type) { case N_RSSI_NB: if (core1or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_RSSI_Z, tmp); if (core1or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_RSSI_Z, tmp); if (core2or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_RSSI_Z, tmp); if (core2or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_RSSI_Z, tmp); break; case N_RSSI_W1: if (core1or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_RSSI_X, tmp); if (core1or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_RSSI_X, tmp); if (core2or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_RSSI_X, tmp); if (core2or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_RSSI_X, tmp); break; case N_RSSI_W2: if (core1or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_RSSI_Y, tmp); if (core1or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_RSSI_Y, tmp); if (core2or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_RSSI_Y, tmp); if (core2or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_RSSI_Y, tmp); break; case N_RSSI_TBD: if (core1or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_TBD, tmp); if (core1or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_TBD, tmp); if (core2or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_TBD, tmp); if (core2or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_TBD, tmp); break; case N_RSSI_IQ: if (core1or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_PWRDET, tmp); if (core1or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_PWRDET, tmp); if (core2or5 && rail == N_RAIL_I) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_PWRDET, tmp); if (core2or5 && rail == N_RAIL_Q) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_PWRDET, tmp); break; case N_RSSI_TSSI_2G: if (core1or5) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_TSSI, tmp); if (core2or5) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_TSSI, tmp); break; case N_RSSI_TSSI_5G: if (core1or5) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_TSSI, tmp); if (core2or5) BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_TSSI, tmp); break; } } static void bwn_nphy_rssi_select_rev19(struct bwn_mac *mac, uint8_t code, enum n_rssi_type rssi_type) { /* TODO */ } static void bwn_nphy_rev3_rssi_select(struct bwn_mac *mac, uint8_t code, enum n_rssi_type rssi_type) { uint8_t i; uint16_t reg, val; if (code == 0) { BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER1, 0xFDFF); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER, 0xFDFF); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C1, 0xFCFF); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C2, 0xFCFF); BWN_PHY_MASK(mac, BWN_NPHY_TXF_40CO_B1S0, 0xFFDF); BWN_PHY_MASK(mac, BWN_NPHY_TXF_40CO_B32S1, 0xFFDF); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP1, 0xFFC3); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP2, 0xFFC3); } else { for (i = 0; i < 2; i++) { if ((code == 1 && i == 1) || (code == 2 && !i)) continue; reg = (i == 0) ? BWN_NPHY_AFECTL_OVER1 : BWN_NPHY_AFECTL_OVER; BWN_PHY_SETMASK(mac, reg, 0xFDFF, 0x0200); if (rssi_type == N_RSSI_W1 || rssi_type == N_RSSI_W2 || rssi_type == N_RSSI_NB) { reg = (i == 0) ? BWN_NPHY_AFECTL_C1 : BWN_NPHY_AFECTL_C2; BWN_PHY_SETMASK(mac, reg, 0xFCFF, 0); reg = (i == 0) ? BWN_NPHY_RFCTL_LUT_TRSW_UP1 : BWN_NPHY_RFCTL_LUT_TRSW_UP2; BWN_PHY_SETMASK(mac, reg, 0xFFC3, 0); if (rssi_type == N_RSSI_W1) val = (bwn_current_band(mac) == BWN_BAND_5G) ? 4 : 8; else if (rssi_type == N_RSSI_W2) val = 16; else val = 32; BWN_PHY_SET(mac, reg, val); reg = (i == 0) ? BWN_NPHY_TXF_40CO_B1S0 : BWN_NPHY_TXF_40CO_B32S1; BWN_PHY_SET(mac, reg, 0x0020); } else { if (rssi_type == N_RSSI_TBD) val = 0x0100; else if (rssi_type == N_RSSI_IQ) val = 0x0200; else val = 0x0300; reg = (i == 0) ? BWN_NPHY_AFECTL_C1 : BWN_NPHY_AFECTL_C2; BWN_PHY_SETMASK(mac, reg, 0xFCFF, val); BWN_PHY_SETMASK(mac, reg, 0xF3FF, val << 2); if (rssi_type != N_RSSI_IQ && rssi_type != N_RSSI_TBD) { bwn_band_t band = bwn_current_band(mac); if (mac->mac_phy.rev < 7) { if (bwn_nphy_ipa(mac)) val = (band == BWN_BAND_5G) ? 0xC : 0xE; else val = 0x11; reg = (i == 0) ? B2056_TX0 : B2056_TX1; reg |= B2056_TX_TX_SSI_MUX; BWN_RF_WRITE(mac, reg, val); } reg = (i == 0) ? BWN_NPHY_AFECTL_OVER1 : BWN_NPHY_AFECTL_OVER; BWN_PHY_SET(mac, reg, 0x0200); } } } } } static void bwn_nphy_rev2_rssi_select(struct bwn_mac *mac, uint8_t code, enum n_rssi_type rssi_type) { uint16_t val; bool rssi_w1_w2_nb = false; switch (rssi_type) { case N_RSSI_W1: case N_RSSI_W2: case N_RSSI_NB: val = 0; rssi_w1_w2_nb = true; break; case N_RSSI_TBD: val = 1; break; case N_RSSI_IQ: val = 2; break; default: val = 3; } val = (val << 12) | (val << 14); BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C1, 0x0FFF, val); BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C2, 0x0FFF, val); if (rssi_w1_w2_nb) { BWN_PHY_SETMASK(mac, BWN_NPHY_RFCTL_RSSIO1, 0xFFCF, (rssi_type + 1) << 4); BWN_PHY_SETMASK(mac, BWN_NPHY_RFCTL_RSSIO2, 0xFFCF, (rssi_type + 1) << 4); } if (code == 0) { BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER, ~0x3000); if (rssi_w1_w2_nb) { BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, ~(BWN_NPHY_RFCTL_CMD_RXEN | BWN_NPHY_RFCTL_CMD_CORESEL)); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_OVER, ~(0x1 << 12 | 0x1 << 5 | 0x1 << 1 | 0x1)); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_START); DELAY(20); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_OVER, ~0x1); } } else { BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x3000); if (rssi_w1_w2_nb) { BWN_PHY_SETMASK(mac, BWN_NPHY_RFCTL_CMD, ~(BWN_NPHY_RFCTL_CMD_RXEN | BWN_NPHY_RFCTL_CMD_CORESEL), (BWN_NPHY_RFCTL_CMD_RXEN | code << BWN_NPHY_RFCTL_CMD_CORESEL_SHIFT)); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_OVER, (0x1 << 12 | 0x1 << 5 | 0x1 << 1 | 0x1)); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_START); DELAY(20); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_OVER, ~0x1); } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSISel */ static void bwn_nphy_rssi_select(struct bwn_mac *mac, uint8_t code, enum n_rssi_type type) { if (mac->mac_phy.rev >= 19) bwn_nphy_rssi_select_rev19(mac, code, type); else if (mac->mac_phy.rev >= 3) bwn_nphy_rev3_rssi_select(mac, code, type); else bwn_nphy_rev2_rssi_select(mac, code, type); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetRssi2055Vcm */ static void bwn_nphy_set_rssi_2055_vcm(struct bwn_mac *mac, enum n_rssi_type rssi_type, uint8_t *buf) { int i; for (i = 0; i < 2; i++) { if (rssi_type == N_RSSI_NB) { if (i == 0) { BWN_RF_SETMASK(mac, B2055_C1_B0NB_RSSIVCM, 0xFC, buf[0]); BWN_RF_SETMASK(mac, B2055_C1_RX_BB_RSSICTL5, 0xFC, buf[1]); } else { BWN_RF_SETMASK(mac, B2055_C2_B0NB_RSSIVCM, 0xFC, buf[2 * i]); BWN_RF_SETMASK(mac, B2055_C2_RX_BB_RSSICTL5, 0xFC, buf[2 * i + 1]); } } else { if (i == 0) BWN_RF_SETMASK(mac, B2055_C1_RX_BB_RSSICTL5, 0xF3, buf[0] << 2); else BWN_RF_SETMASK(mac, B2055_C2_RX_BB_RSSICTL5, 0xF3, buf[2 * i + 1] << 2); } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/PollRssi */ static int bwn_nphy_poll_rssi(struct bwn_mac *mac, enum n_rssi_type rssi_type, int32_t *buf, uint8_t nsamp) { int i; int out; uint16_t save_regs_phy[9]; uint16_t s[2]; /* TODO: rev7+ is treated like rev3+, what about rev19+? */ if (mac->mac_phy.rev >= 3) { save_regs_phy[0] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C1); save_regs_phy[1] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C2); save_regs_phy[2] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP1); save_regs_phy[3] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP2); save_regs_phy[4] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER1); save_regs_phy[5] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER); save_regs_phy[6] = BWN_PHY_READ(mac, BWN_NPHY_TXF_40CO_B1S0); save_regs_phy[7] = BWN_PHY_READ(mac, BWN_NPHY_TXF_40CO_B32S1); save_regs_phy[8] = 0; } else { save_regs_phy[0] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C1); save_regs_phy[1] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C2); save_regs_phy[2] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER); save_regs_phy[3] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_CMD); save_regs_phy[4] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_OVER); save_regs_phy[5] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_RSSIO1); save_regs_phy[6] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_RSSIO2); save_regs_phy[7] = 0; save_regs_phy[8] = 0; } bwn_nphy_rssi_select(mac, 5, rssi_type); if (mac->mac_phy.rev < 2) { save_regs_phy[8] = BWN_PHY_READ(mac, BWN_NPHY_GPIO_SEL); BWN_PHY_WRITE(mac, BWN_NPHY_GPIO_SEL, 5); } for (i = 0; i < 4; i++) buf[i] = 0; for (i = 0; i < nsamp; i++) { if (mac->mac_phy.rev < 2) { s[0] = BWN_PHY_READ(mac, BWN_NPHY_GPIO_LOOUT); s[1] = BWN_PHY_READ(mac, BWN_NPHY_GPIO_HIOUT); } else { s[0] = BWN_PHY_READ(mac, BWN_NPHY_RSSI1); s[1] = BWN_PHY_READ(mac, BWN_NPHY_RSSI2); } buf[0] += ((int8_t)((s[0] & 0x3F) << 2)) >> 2; buf[1] += ((int8_t)(((s[0] >> 8) & 0x3F) << 2)) >> 2; buf[2] += ((int8_t)((s[1] & 0x3F) << 2)) >> 2; buf[3] += ((int8_t)(((s[1] >> 8) & 0x3F) << 2)) >> 2; } out = (buf[0] & 0xFF) << 24 | (buf[1] & 0xFF) << 16 | (buf[2] & 0xFF) << 8 | (buf[3] & 0xFF); if (mac->mac_phy.rev < 2) BWN_PHY_WRITE(mac, BWN_NPHY_GPIO_SEL, save_regs_phy[8]); if (mac->mac_phy.rev >= 3) { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C1, save_regs_phy[0]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C2, save_regs_phy[1]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP1, save_regs_phy[2]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP2, save_regs_phy[3]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER1, save_regs_phy[4]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, save_regs_phy[5]); BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B1S0, save_regs_phy[6]); BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B32S1, save_regs_phy[7]); } else { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C1, save_regs_phy[0]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C2, save_regs_phy[1]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, save_regs_phy[2]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_CMD, save_regs_phy[3]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_OVER, save_regs_phy[4]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_RSSIO1, save_regs_phy[5]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_RSSIO2, save_regs_phy[6]); } return out; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICalRev3 */ static void bwn_nphy_rev3_rssi_cal(struct bwn_mac *mac) { //struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t saved_regs_phy_rfctl[2]; uint16_t saved_regs_phy[22]; uint16_t regs_to_store_rev3[] = { BWN_NPHY_AFECTL_OVER1, BWN_NPHY_AFECTL_OVER, BWN_NPHY_AFECTL_C1, BWN_NPHY_AFECTL_C2, BWN_NPHY_TXF_40CO_B1S1, BWN_NPHY_RFCTL_OVER, BWN_NPHY_TXF_40CO_B1S0, BWN_NPHY_TXF_40CO_B32S1, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_LUT_TRSW_UP1, BWN_NPHY_RFCTL_LUT_TRSW_UP2, BWN_NPHY_RFCTL_RSSIO1, BWN_NPHY_RFCTL_RSSIO2 }; uint16_t regs_to_store_rev7[] = { BWN_NPHY_AFECTL_OVER1, BWN_NPHY_AFECTL_OVER, BWN_NPHY_AFECTL_C1, BWN_NPHY_AFECTL_C2, BWN_NPHY_TXF_40CO_B1S1, BWN_NPHY_RFCTL_OVER, BWN_NPHY_REV7_RF_CTL_OVER3, BWN_NPHY_REV7_RF_CTL_OVER4, BWN_NPHY_REV7_RF_CTL_OVER5, BWN_NPHY_REV7_RF_CTL_OVER6, 0x2ff, BWN_NPHY_TXF_40CO_B1S0, BWN_NPHY_TXF_40CO_B32S1, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_LUT_TRSW_UP1, BWN_NPHY_RFCTL_LUT_TRSW_UP2, BWN_NPHY_REV7_RF_CTL_MISC_REG3, BWN_NPHY_REV7_RF_CTL_MISC_REG4, BWN_NPHY_REV7_RF_CTL_MISC_REG5, BWN_NPHY_REV7_RF_CTL_MISC_REG6, BWN_NPHY_RFCTL_RSSIO1, BWN_NPHY_RFCTL_RSSIO2 }; uint16_t *regs_to_store; int regs_amount; uint16_t class; uint16_t clip_state[2]; uint16_t clip_off[2] = { 0xFFFF, 0xFFFF }; uint8_t vcm_final = 0; int32_t offset[4]; int32_t results[8][4] = { }; int32_t results_min[4] = { }; int32_t poll_results[4] = { }; uint16_t *rssical_radio_regs = NULL; uint16_t *rssical_phy_regs = NULL; uint16_t r; /* routing */ uint8_t rx_core_state; int core, i, j, vcm; if (mac->mac_phy.rev >= 7) { regs_to_store = regs_to_store_rev7; regs_amount = nitems(regs_to_store_rev7); } else { regs_to_store = regs_to_store_rev3; regs_amount = nitems(regs_to_store_rev3); } KASSERT((regs_amount <= nitems(saved_regs_phy)), ("%s: reg_amount (%d) too large\n", __func__, regs_amount)); class = bwn_nphy_classifier(mac, 0, 0); bwn_nphy_classifier(mac, 7, 4); bwn_nphy_read_clip_detection(mac, clip_state); bwn_nphy_write_clip_detection(mac, clip_off); saved_regs_phy_rfctl[0] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC1); saved_regs_phy_rfctl[1] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC2); for (i = 0; i < regs_amount; i++) saved_regs_phy[i] = BWN_PHY_READ(mac, regs_to_store[i]); bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_OFF, 0, 7); bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_TRSW, 1, 7); if (mac->mac_phy.rev >= 7) { bwn_nphy_rf_ctl_override_one_to_many(mac, N_RF_CTL_OVER_CMD_RXRF_PU, 0, 0, false); bwn_nphy_rf_ctl_override_one_to_many(mac, N_RF_CTL_OVER_CMD_RX_PU, 1, 0, false); bwn_nphy_rf_ctl_override_rev7(mac, 0x80, 1, 0, false, 0); bwn_nphy_rf_ctl_override_rev7(mac, 0x40, 1, 0, false, 0); if (bwn_current_band(mac) == BWN_BAND_5G) { bwn_nphy_rf_ctl_override_rev7(mac, 0x20, 0, 0, false, 0); bwn_nphy_rf_ctl_override_rev7(mac, 0x10, 1, 0, false, 0); } else { bwn_nphy_rf_ctl_override_rev7(mac, 0x10, 0, 0, false, 0); bwn_nphy_rf_ctl_override_rev7(mac, 0x20, 1, 0, false, 0); } } else { bwn_nphy_rf_ctl_override(mac, 0x1, 0, 0, false); bwn_nphy_rf_ctl_override(mac, 0x2, 1, 0, false); bwn_nphy_rf_ctl_override(mac, 0x80, 1, 0, false); bwn_nphy_rf_ctl_override(mac, 0x40, 1, 0, false); if (bwn_current_band(mac) == BWN_BAND_5G) { bwn_nphy_rf_ctl_override(mac, 0x20, 0, 0, false); bwn_nphy_rf_ctl_override(mac, 0x10, 1, 0, false); } else { bwn_nphy_rf_ctl_override(mac, 0x10, 0, 0, false); bwn_nphy_rf_ctl_override(mac, 0x20, 1, 0, false); } } rx_core_state = bwn_nphy_get_rx_core_state(mac); for (core = 0; core < 2; core++) { if (!(rx_core_state & (1 << core))) continue; r = core ? B2056_RX1 : B2056_RX0; bwn_nphy_scale_offset_rssi(mac, 0, 0, core + 1, N_RAIL_I, N_RSSI_NB); bwn_nphy_scale_offset_rssi(mac, 0, 0, core + 1, N_RAIL_Q, N_RSSI_NB); /* Grab RSSI results for every possible VCM */ for (vcm = 0; vcm < 8; vcm++) { if (mac->mac_phy.rev >= 7) BWN_RF_SETMASK(mac, core ? R2057_NB_MASTER_CORE1 : R2057_NB_MASTER_CORE0, ~R2057_VCM_MASK, vcm); else BWN_RF_SETMASK(mac, r | B2056_RX_RSSI_MISC, 0xE3, vcm << 2); bwn_nphy_poll_rssi(mac, N_RSSI_NB, results[vcm], 8); } /* Find out which VCM got the best results */ for (i = 0; i < 4; i += 2) { int32_t currd; int32_t mind = 0x100000; int32_t minpoll = 249; uint8_t minvcm = 0; if (2 * core != i) continue; for (vcm = 0; vcm < 8; vcm++) { currd = results[vcm][i] * results[vcm][i] + results[vcm][i + 1] * results[vcm][i]; if (currd < mind) { mind = currd; minvcm = vcm; } if (results[vcm][i] < minpoll) minpoll = results[vcm][i]; } vcm_final = minvcm; results_min[i] = minpoll; } /* Select the best VCM */ if (mac->mac_phy.rev >= 7) BWN_RF_SETMASK(mac, core ? R2057_NB_MASTER_CORE1 : R2057_NB_MASTER_CORE0, ~R2057_VCM_MASK, vcm); else BWN_RF_SETMASK(mac, r | B2056_RX_RSSI_MISC, 0xE3, vcm_final << 2); for (i = 0; i < 4; i++) { if (core != i / 2) continue; offset[i] = -results[vcm_final][i]; if (offset[i] < 0) offset[i] = -((abs(offset[i]) + 4) / 8); else offset[i] = (offset[i] + 4) / 8; if (results_min[i] == 248) offset[i] = -32; bwn_nphy_scale_offset_rssi(mac, 0, offset[i], (i / 2 == 0) ? 1 : 2, (i % 2 == 0) ? N_RAIL_I : N_RAIL_Q, N_RSSI_NB); } } for (core = 0; core < 2; core++) { if (!(rx_core_state & (1 << core))) continue; for (i = 0; i < 2; i++) { bwn_nphy_scale_offset_rssi(mac, 0, 0, core + 1, N_RAIL_I, i); bwn_nphy_scale_offset_rssi(mac, 0, 0, core + 1, N_RAIL_Q, i); bwn_nphy_poll_rssi(mac, i, poll_results, 8); for (j = 0; j < 4; j++) { if (j / 2 == core) { offset[j] = 232 - poll_results[j]; if (offset[j] < 0) offset[j] = -(abs(offset[j] + 4) / 8); else offset[j] = (offset[j] + 4) / 8; bwn_nphy_scale_offset_rssi(mac, 0, offset[2 * core], core + 1, j % 2, i); } } } } BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, saved_regs_phy_rfctl[0]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, saved_regs_phy_rfctl[1]); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); BWN_PHY_SET(mac, BWN_NPHY_TXF_40CO_B1S1, 0x1); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_START); BWN_PHY_MASK(mac, BWN_NPHY_TXF_40CO_B1S1, ~0x1); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_OVER, 0x1); BWN_PHY_SET(mac, BWN_NPHY_RFCTL_CMD, BWN_NPHY_RFCTL_CMD_RXTX); BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_OVER, ~0x1); for (i = 0; i < regs_amount; i++) BWN_PHY_WRITE(mac, regs_to_store[i], saved_regs_phy[i]); /* Store for future configuration */ if (bwn_current_band(mac) == BWN_BAND_2G) { rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G; rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G; } else { rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G; rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G; } if (mac->mac_phy.rev >= 7) { rssical_radio_regs[0] = BWN_RF_READ(mac, R2057_NB_MASTER_CORE0); rssical_radio_regs[1] = BWN_RF_READ(mac, R2057_NB_MASTER_CORE1); } else { rssical_radio_regs[0] = BWN_RF_READ(mac, B2056_RX0 | B2056_RX_RSSI_MISC); rssical_radio_regs[1] = BWN_RF_READ(mac, B2056_RX1 | B2056_RX_RSSI_MISC); } rssical_phy_regs[0] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_0I_RSSI_Z); rssical_phy_regs[1] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_0Q_RSSI_Z); rssical_phy_regs[2] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_1I_RSSI_Z); rssical_phy_regs[3] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_1Q_RSSI_Z); rssical_phy_regs[4] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_0I_RSSI_X); rssical_phy_regs[5] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_0Q_RSSI_X); rssical_phy_regs[6] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_1I_RSSI_X); rssical_phy_regs[7] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_1Q_RSSI_X); rssical_phy_regs[8] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_0I_RSSI_Y); rssical_phy_regs[9] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_0Q_RSSI_Y); rssical_phy_regs[10] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_1I_RSSI_Y); rssical_phy_regs[11] = BWN_PHY_READ(mac, BWN_NPHY_RSSIMC_1Q_RSSI_Y); /* Remember for which channel we store configuration */ if (bwn_current_band(mac) == BWN_BAND_2G) nphy->rssical_chanspec_2G.center_freq = bwn_get_centre_freq(mac); else nphy->rssical_chanspec_5G.center_freq = bwn_get_centre_freq(mac); /* End of calibration, restore configuration */ bwn_nphy_classifier(mac, 7, class); bwn_nphy_write_clip_detection(mac, clip_state); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */ static void bwn_nphy_rev2_rssi_cal(struct bwn_mac *mac, enum n_rssi_type type) { int i, j, vcm; uint8_t state[4]; uint8_t code, val; uint16_t class, override; uint8_t regs_save_radio[2]; uint16_t regs_save_phy[2]; int32_t offset[4]; uint8_t core; uint8_t rail; uint16_t clip_state[2]; uint16_t clip_off[2] = { 0xFFFF, 0xFFFF }; int32_t results_min[4] = { }; uint8_t vcm_final[4] = { }; int32_t results[4][4] = { }; int32_t miniq[4][2] = { }; if (type == N_RSSI_NB) { code = 0; val = 6; } else if (type == N_RSSI_W1 || type == N_RSSI_W2) { code = 25; val = 4; } else { BWN_ERRPRINTF(mac->mac_sc, "%s: RSSI type %d invalid\n", __func__, type); return; } class = bwn_nphy_classifier(mac, 0, 0); bwn_nphy_classifier(mac, 7, 4); bwn_nphy_read_clip_detection(mac, clip_state); bwn_nphy_write_clip_detection(mac, clip_off); if (bwn_current_band(mac) == BWN_BAND_5G) override = 0x140; else override = 0x110; regs_save_phy[0] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC1); regs_save_radio[0] = BWN_RF_READ(mac, B2055_C1_PD_RXTX); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, override); BWN_RF_WRITE(mac, B2055_C1_PD_RXTX, val); regs_save_phy[1] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC2); regs_save_radio[1] = BWN_RF_READ(mac, B2055_C2_PD_RXTX); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, override); BWN_RF_WRITE(mac, B2055_C2_PD_RXTX, val); state[0] = BWN_RF_READ(mac, B2055_C1_PD_RSSIMISC) & 0x07; state[1] = BWN_RF_READ(mac, B2055_C2_PD_RSSIMISC) & 0x07; BWN_RF_MASK(mac, B2055_C1_PD_RSSIMISC, 0xF8); BWN_RF_MASK(mac, B2055_C2_PD_RSSIMISC, 0xF8); state[2] = BWN_RF_READ(mac, B2055_C1_SP_RSSI) & 0x07; state[3] = BWN_RF_READ(mac, B2055_C2_SP_RSSI) & 0x07; bwn_nphy_rssi_select(mac, 5, type); bwn_nphy_scale_offset_rssi(mac, 0, 0, 5, N_RAIL_I, type); bwn_nphy_scale_offset_rssi(mac, 0, 0, 5, N_RAIL_Q, type); for (vcm = 0; vcm < 4; vcm++) { uint8_t tmp[4]; for (j = 0; j < 4; j++) tmp[j] = vcm; if (type != N_RSSI_W2) bwn_nphy_set_rssi_2055_vcm(mac, type, tmp); bwn_nphy_poll_rssi(mac, type, results[vcm], 8); if (type == N_RSSI_W1 || type == N_RSSI_W2) for (j = 0; j < 2; j++) miniq[vcm][j] = min(results[vcm][2 * j], results[vcm][2 * j + 1]); } for (i = 0; i < 4; i++) { int32_t mind = 0x100000; uint8_t minvcm = 0; int32_t minpoll = 249; int32_t currd; for (vcm = 0; vcm < 4; vcm++) { if (type == N_RSSI_NB) currd = abs(results[vcm][i] - code * 8); else currd = abs(miniq[vcm][i / 2] - code * 8); if (currd < mind) { mind = currd; minvcm = vcm; } if (results[vcm][i] < minpoll) minpoll = results[vcm][i]; } results_min[i] = minpoll; vcm_final[i] = minvcm; } if (type != N_RSSI_W2) bwn_nphy_set_rssi_2055_vcm(mac, type, vcm_final); for (i = 0; i < 4; i++) { offset[i] = (code * 8) - results[vcm_final[i]][i]; if (offset[i] < 0) offset[i] = -((abs(offset[i]) + 4) / 8); else offset[i] = (offset[i] + 4) / 8; if (results_min[i] == 248) offset[i] = code - 32; core = (i / 2) ? 2 : 1; rail = (i % 2) ? N_RAIL_Q : N_RAIL_I; bwn_nphy_scale_offset_rssi(mac, 0, offset[i], core, rail, type); } BWN_RF_SETMASK(mac, B2055_C1_PD_RSSIMISC, 0xF8, state[0]); BWN_RF_SETMASK(mac, B2055_C2_PD_RSSIMISC, 0xF8, state[1]); switch (state[2]) { case 1: bwn_nphy_rssi_select(mac, 1, N_RSSI_NB); break; case 4: bwn_nphy_rssi_select(mac, 1, N_RSSI_W1); break; case 2: bwn_nphy_rssi_select(mac, 1, N_RSSI_W2); break; default: bwn_nphy_rssi_select(mac, 1, N_RSSI_W2); break; } switch (state[3]) { case 1: bwn_nphy_rssi_select(mac, 2, N_RSSI_NB); break; case 4: bwn_nphy_rssi_select(mac, 2, N_RSSI_W1); break; default: bwn_nphy_rssi_select(mac, 2, N_RSSI_W2); break; } bwn_nphy_rssi_select(mac, 0, type); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, regs_save_phy[0]); BWN_RF_WRITE(mac, B2055_C1_PD_RXTX, regs_save_radio[0]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, regs_save_phy[1]); BWN_RF_WRITE(mac, B2055_C2_PD_RXTX, regs_save_radio[1]); bwn_nphy_classifier(mac, 7, class); bwn_nphy_write_clip_detection(mac, clip_state); /* Specs don't say about reset here, but it makes wl and b43 dumps identical, it really seems wl performs this */ bwn_nphy_reset_cca(mac); } /* * RSSI Calibration * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RSSICal */ static void bwn_nphy_rssi_cal(struct bwn_mac *mac) { if (mac->mac_phy.rev >= 19) { /* TODO */ } else if (mac->mac_phy.rev >= 3) { bwn_nphy_rev3_rssi_cal(mac); } else { bwn_nphy_rev2_rssi_cal(mac, N_RSSI_NB); bwn_nphy_rev2_rssi_cal(mac, N_RSSI_W1); bwn_nphy_rev2_rssi_cal(mac, N_RSSI_W2); } } /************************************************** * Workarounds **************************************************/ static void bwn_nphy_gain_ctl_workarounds_rev19(struct bwn_mac *mac) { /* TODO */ } static void bwn_nphy_gain_ctl_workarounds_rev7(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; switch (phy->rev) { /* TODO */ } } static void bwn_nphy_gain_ctl_workarounds_rev3(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; bool ghz5; bool ext_lna; uint16_t rssi_gain; struct bwn_nphy_gain_ctl_workaround_entry *e; uint8_t lpf_gain[6] = { 0x00, 0x06, 0x0C, 0x12, 0x12, 0x12 }; uint8_t lpf_bits[6] = { 0, 1, 2, 3, 3, 3 }; /* Prepare values */ ghz5 = BWN_PHY_READ(mac, BWN_NPHY_BANDCTL) & BWN_NPHY_BANDCTL_5GHZ; ext_lna = ghz5 ? sc->sc_board_info.board_flags & BHND_BFL_EXTLNA_5GHZ : sc->sc_board_info.board_flags & BHND_BFL_EXTLNA; e = bwn_nphy_get_gain_ctl_workaround_ent(mac, ghz5, ext_lna); if (ghz5 && mac->mac_phy.rev >= 5) rssi_gain = 0x90; else rssi_gain = 0x50; BWN_PHY_SET(mac, BWN_NPHY_RXCTL, 0x0040); /* Set Clip 2 detect */ BWN_PHY_SET(mac, BWN_NPHY_C1_CGAINI, BWN_NPHY_C1_CGAINI_CL2DETECT); BWN_PHY_SET(mac, BWN_NPHY_C2_CGAINI, BWN_NPHY_C2_CGAINI_CL2DETECT); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_BIASPOLE_LNAG1_IDAC, 0x17); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_BIASPOLE_LNAG1_IDAC, 0x17); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_LNAG2_IDAC, 0xF0); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_LNAG2_IDAC, 0xF0); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_RSSI_POLE, 0x00); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_RSSI_POLE, 0x00); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_RSSI_GAIN, rssi_gain); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_RSSI_GAIN, rssi_gain); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_BIASPOLE_LNAA1_IDAC, 0x17); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_BIASPOLE_LNAA1_IDAC, 0x17); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_LNAA2_IDAC, 0xFF); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_LNAA2_IDAC, 0xFF); bwn_ntab_write_bulk(mac, BWN_NTAB8(0, 8), 4, e->lna1_gain); bwn_ntab_write_bulk(mac, BWN_NTAB8(1, 8), 4, e->lna1_gain); bwn_ntab_write_bulk(mac, BWN_NTAB8(0, 16), 4, e->lna2_gain); bwn_ntab_write_bulk(mac, BWN_NTAB8(1, 16), 4, e->lna2_gain); bwn_ntab_write_bulk(mac, BWN_NTAB8(0, 32), 10, e->gain_db); bwn_ntab_write_bulk(mac, BWN_NTAB8(1, 32), 10, e->gain_db); bwn_ntab_write_bulk(mac, BWN_NTAB8(2, 32), 10, e->gain_bits); bwn_ntab_write_bulk(mac, BWN_NTAB8(3, 32), 10, e->gain_bits); bwn_ntab_write_bulk(mac, BWN_NTAB8(0, 0x40), 6, lpf_gain); bwn_ntab_write_bulk(mac, BWN_NTAB8(1, 0x40), 6, lpf_gain); bwn_ntab_write_bulk(mac, BWN_NTAB8(2, 0x40), 6, lpf_bits); bwn_ntab_write_bulk(mac, BWN_NTAB8(3, 0x40), 6, lpf_bits); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C1_INITGAIN_A, e->init_gain); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C2_INITGAIN_A, e->init_gain); bwn_ntab_write_bulk(mac, BWN_NTAB16(7, 0x106), 2, e->rfseq_init); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C1_CLIP_HIGAIN_A, e->cliphi_gain); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C2_CLIP_HIGAIN_A, e->cliphi_gain); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C1_CLIP_MEDGAIN_A, e->clipmd_gain); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C2_CLIP_MEDGAIN_A, e->clipmd_gain); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C1_CLIP_LOGAIN_A, e->cliplo_gain); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C2_CLIP_LOGAIN_A, e->cliplo_gain); BWN_PHY_SETMASK(mac, BWN_NPHY_CRSMINPOWER0, 0xFF00, e->crsmin); BWN_PHY_SETMASK(mac, BWN_NPHY_CRSMINPOWERL0, 0xFF00, e->crsminl); BWN_PHY_SETMASK(mac, BWN_NPHY_CRSMINPOWERU0, 0xFF00, e->crsminu); BWN_PHY_WRITE(mac, BWN_NPHY_C1_NBCLIPTHRES, e->nbclip); BWN_PHY_WRITE(mac, BWN_NPHY_C2_NBCLIPTHRES, e->nbclip); BWN_PHY_SETMASK(mac, BWN_NPHY_C1_CLIPWBTHRES, ~BWN_NPHY_C1_CLIPWBTHRES_CLIP2, e->wlclip); BWN_PHY_SETMASK(mac, BWN_NPHY_C2_CLIPWBTHRES, ~BWN_NPHY_C2_CLIPWBTHRES_CLIP2, e->wlclip); BWN_PHY_WRITE(mac, BWN_NPHY_CCK_SHIFTB_REF, 0x809C); } static void bwn_nphy_gain_ctl_workarounds_rev1_2(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t i, j; uint8_t code; uint16_t tmp; uint8_t rfseq_events[3] = { 6, 8, 7 }; uint8_t rfseq_delays[3] = { 10, 30, 1 }; /* Set Clip 2 detect */ BWN_PHY_SET(mac, BWN_NPHY_C1_CGAINI, BWN_NPHY_C1_CGAINI_CL2DETECT); BWN_PHY_SET(mac, BWN_NPHY_C2_CGAINI, BWN_NPHY_C2_CGAINI_CL2DETECT); /* Set narrowband clip threshold */ BWN_PHY_WRITE(mac, BWN_NPHY_C1_NBCLIPTHRES, 0x84); BWN_PHY_WRITE(mac, BWN_NPHY_C2_NBCLIPTHRES, 0x84); if (!bwn_is_40mhz(mac)) { /* Set dwell lengths */ BWN_PHY_WRITE(mac, BWN_NPHY_CLIP1_NBDWELL_LEN, 0x002B); BWN_PHY_WRITE(mac, BWN_NPHY_CLIP2_NBDWELL_LEN, 0x002B); BWN_PHY_WRITE(mac, BWN_NPHY_W1CLIP1_DWELL_LEN, 0x0009); BWN_PHY_WRITE(mac, BWN_NPHY_W1CLIP2_DWELL_LEN, 0x0009); } /* Set wideband clip 2 threshold */ BWN_PHY_SETMASK(mac, BWN_NPHY_C1_CLIPWBTHRES, ~BWN_NPHY_C1_CLIPWBTHRES_CLIP2, 21); BWN_PHY_SETMASK(mac, BWN_NPHY_C2_CLIPWBTHRES, ~BWN_NPHY_C2_CLIPWBTHRES_CLIP2, 21); if (!bwn_is_40mhz(mac)) { BWN_PHY_SETMASK(mac, BWN_NPHY_C1_CGAINI, ~BWN_NPHY_C1_CGAINI_GAINBKOFF, 0x1); BWN_PHY_SETMASK(mac, BWN_NPHY_C2_CGAINI, ~BWN_NPHY_C2_CGAINI_GAINBKOFF, 0x1); BWN_PHY_SETMASK(mac, BWN_NPHY_C1_CCK_CGAINI, ~BWN_NPHY_C1_CCK_CGAINI_GAINBKOFF, 0x1); BWN_PHY_SETMASK(mac, BWN_NPHY_C2_CCK_CGAINI, ~BWN_NPHY_C2_CCK_CGAINI_GAINBKOFF, 0x1); } BWN_PHY_WRITE(mac, BWN_NPHY_CCK_SHIFTB_REF, 0x809C); if (nphy->gain_boost) { if (bwn_current_band(mac) == BWN_BAND_2G && bwn_is_40mhz(mac)) code = 4; else code = 5; } else { code = bwn_is_40mhz(mac) ? 6 : 7; } /* Set HPVGA2 index */ BWN_PHY_SETMASK(mac, BWN_NPHY_C1_INITGAIN, ~BWN_NPHY_C1_INITGAIN_HPVGA2, code << BWN_NPHY_C1_INITGAIN_HPVGA2_SHIFT); BWN_PHY_SETMASK(mac, BWN_NPHY_C2_INITGAIN, ~BWN_NPHY_C2_INITGAIN_HPVGA2, code << BWN_NPHY_C2_INITGAIN_HPVGA2_SHIFT); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, 0x1D06); /* specs say about 2 loops, but wl does 4 */ for (i = 0; i < 4; i++) BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, (code << 8 | 0x7C)); bwn_nphy_adjust_lna_gain_table(mac); if (nphy->elna_gain_config) { BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, 0x0808); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x0); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x1); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x1); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x1); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, 0x0C08); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x0); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x1); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x1); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0x1); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, 0x1D06); /* specs say about 2 loops, but wl does 4 */ for (i = 0; i < 4; i++) BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, (code << 8 | 0x74)); } if (mac->mac_phy.rev == 2) { for (i = 0; i < 4; i++) { BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, (0x0400 * i) + 0x0020); for (j = 0; j < 21; j++) { tmp = j * (i < 2 ? 3 : 1); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, tmp); } } } bwn_nphy_set_rf_sequence(mac, 5, rfseq_events, rfseq_delays, 3); BWN_PHY_SETMASK(mac, BWN_NPHY_OVER_DGAIN1, ~BWN_NPHY_OVER_DGAIN_CCKDGECV & 0xFFFF, 0x5A << BWN_NPHY_OVER_DGAIN_CCKDGECV_SHIFT); if (bwn_current_band(mac) == BWN_BAND_2G) BWN_PHY_SETMASK(mac, BWN_PHY_N(0xC5D), 0xFF80, 4); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/WorkaroundsGainCtrl */ static void bwn_nphy_gain_ctl_workarounds(struct bwn_mac *mac) { if (mac->mac_phy.rev >= 19) bwn_nphy_gain_ctl_workarounds_rev19(mac); else if (mac->mac_phy.rev >= 7) bwn_nphy_gain_ctl_workarounds_rev7(mac); else if (mac->mac_phy.rev >= 3) bwn_nphy_gain_ctl_workarounds_rev3(mac); else bwn_nphy_gain_ctl_workarounds_rev1_2(mac); } static int bwn_nphy_workarounds_rev7plus(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; /* TX to RX */ uint8_t tx2rx_events[7] = { 4, 3, 5, 2, 1, 8, 31, }; uint8_t tx2rx_delays[7] = { 8, 4, 4, 4, 4, 6, 1, }; /* RX to TX */ uint8_t rx2tx_events_ipa[9] = { 0x0, 0x1, 0x2, 0x8, 0x5, 0x6, 0xF, 0x3, 0x1F }; uint8_t rx2tx_delays_ipa[9] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; static const uint16_t ntab7_15e_16e[] = { 0, 0x10f, 0x10f }; uint8_t ntab7_138_146[] = { 0x11, 0x11 }; uint8_t ntab7_133[] = { 0x77, 0x11, 0x11 }; uint16_t lpf_ofdm_20mhz[2], lpf_ofdm_40mhz[2], lpf_11b[2]; uint16_t bcap_val; int16_t bcap_val_11b[2], bcap_val_11n_20[2], bcap_val_11n_40[2]; uint16_t scap_val; int16_t scap_val_11b[2], scap_val_11n_20[2], scap_val_11n_40[2]; bool rccal_ovrd = false; uint16_t bias, conv, filt; uint32_t noise_tbl[2]; uint32_t tmp32; uint8_t core; BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A0, 0x0125); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A1, 0x01b3); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A2, 0x0105); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B0, 0x016e); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B1, 0x00cd); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B2, 0x0020); if (phy->rev == 7) { BWN_PHY_SET(mac, BWN_NPHY_FINERX2_CGC, 0x10); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN0, 0xFF80, 0x0020); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN0, 0x80FF, 0x2700); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN1, 0xFF80, 0x002E); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN1, 0x80FF, 0x3300); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN2, 0xFF80, 0x0037); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN2, 0x80FF, 0x3A00); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN3, 0xFF80, 0x003C); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN3, 0x80FF, 0x3E00); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN4, 0xFF80, 0x003E); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN4, 0x80FF, 0x3F00); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN5, 0xFF80, 0x0040); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN5, 0x80FF, 0x4000); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN6, 0xFF80, 0x0040); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN6, 0x80FF, 0x4000); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN7, 0xFF80, 0x0040); BWN_PHY_SETMASK(mac, BWN_NPHY_FREQGAIN7, 0x80FF, 0x4000); } if (phy->rev >= 16) { BWN_PHY_WRITE(mac, BWN_NPHY_FORCEFRONT0, 0x7ff); BWN_PHY_WRITE(mac, BWN_NPHY_FORCEFRONT1, 0x7ff); } else if (phy->rev <= 8) { BWN_PHY_WRITE(mac, BWN_NPHY_FORCEFRONT0, 0x1B0); BWN_PHY_WRITE(mac, BWN_NPHY_FORCEFRONT1, 0x1B0); } if (phy->rev >= 16) BWN_PHY_SETMASK(mac, BWN_NPHY_TXTAILCNT, ~0xFF, 0xa0); else if (phy->rev >= 8) BWN_PHY_SETMASK(mac, BWN_NPHY_TXTAILCNT, ~0xFF, 0x72); bwn_ntab_write(mac, BWN_NTAB16(8, 0x00), 2); bwn_ntab_write(mac, BWN_NTAB16(8, 0x10), 2); tmp32 = bwn_ntab_read(mac, BWN_NTAB32(30, 0)); tmp32 &= 0xffffff; bwn_ntab_write(mac, BWN_NTAB32(30, 0), tmp32); bwn_ntab_write_bulk(mac, BWN_NTAB16(7, 0x15d), 3, ntab7_15e_16e); bwn_ntab_write_bulk(mac, BWN_NTAB16(7, 0x16d), 3, ntab7_15e_16e); bwn_nphy_set_rf_sequence(mac, 1, tx2rx_events, tx2rx_delays, nitems(tx2rx_events)); if (bwn_nphy_ipa(mac)) bwn_nphy_set_rf_sequence(mac, 0, rx2tx_events_ipa, rx2tx_delays_ipa, nitems(rx2tx_events_ipa)); BWN_PHY_SETMASK(mac, BWN_NPHY_EPS_OVERRIDEI_0, 0x3FFF, 0x4000); BWN_PHY_SETMASK(mac, BWN_NPHY_EPS_OVERRIDEI_1, 0x3FFF, 0x4000); for (core = 0; core < 2; core++) { lpf_ofdm_20mhz[core] = bwn_nphy_read_lpf_ctl(mac, 0x154 + core * 0x10); lpf_ofdm_40mhz[core] = bwn_nphy_read_lpf_ctl(mac, 0x159 + core * 0x10); lpf_11b[core] = bwn_nphy_read_lpf_ctl(mac, 0x152 + core * 0x10); } bcap_val = BWN_RF_READ(mac, R2057_RCCAL_BCAP_VAL); scap_val = BWN_RF_READ(mac, R2057_RCCAL_SCAP_VAL); if (bwn_nphy_ipa(mac)) { bool ghz2 = bwn_current_band(mac) == BWN_BAND_2G; switch (phy->rf_rev) { case 5: /* Check radio version (to be 0) by PHY rev for now */ if (phy->rev == 8 && bwn_is_40mhz(mac)) { for (core = 0; core < 2; core++) { scap_val_11b[core] = scap_val; bcap_val_11b[core] = bcap_val; scap_val_11n_20[core] = scap_val; bcap_val_11n_20[core] = bcap_val; scap_val_11n_40[core] = 0xc; bcap_val_11n_40[core] = 0xc; } rccal_ovrd = true; } if (phy->rev == 9) { /* TODO: Radio version 1 (e.g. BCM5357B0) */ } break; case 7: case 8: for (core = 0; core < 2; core++) { scap_val_11b[core] = scap_val; bcap_val_11b[core] = bcap_val; lpf_ofdm_20mhz[core] = 4; lpf_11b[core] = 1; if (bwn_current_band(mac) == BWN_BAND_2G) { scap_val_11n_20[core] = 0xc; bcap_val_11n_20[core] = 0xc; scap_val_11n_40[core] = 0xa; bcap_val_11n_40[core] = 0xa; } else { scap_val_11n_20[core] = 0x14; bcap_val_11n_20[core] = 0x14; scap_val_11n_40[core] = 0xf; bcap_val_11n_40[core] = 0xf; } } rccal_ovrd = true; break; case 9: for (core = 0; core < 2; core++) { bcap_val_11b[core] = bcap_val; scap_val_11b[core] = scap_val; lpf_11b[core] = 1; if (ghz2) { bcap_val_11n_20[core] = bcap_val + 13; scap_val_11n_20[core] = scap_val + 15; } else { bcap_val_11n_20[core] = bcap_val + 14; scap_val_11n_20[core] = scap_val + 15; } lpf_ofdm_20mhz[core] = 4; if (ghz2) { bcap_val_11n_40[core] = bcap_val - 7; scap_val_11n_40[core] = scap_val - 5; } else { bcap_val_11n_40[core] = bcap_val + 2; scap_val_11n_40[core] = scap_val + 4; } lpf_ofdm_40mhz[core] = 4; } rccal_ovrd = true; break; case 14: for (core = 0; core < 2; core++) { bcap_val_11b[core] = bcap_val; scap_val_11b[core] = scap_val; lpf_11b[core] = 1; } bcap_val_11n_20[0] = bcap_val + 20; scap_val_11n_20[0] = scap_val + 20; lpf_ofdm_20mhz[0] = 3; bcap_val_11n_20[1] = bcap_val + 16; scap_val_11n_20[1] = scap_val + 16; lpf_ofdm_20mhz[1] = 3; bcap_val_11n_40[0] = bcap_val + 20; scap_val_11n_40[0] = scap_val + 20; lpf_ofdm_40mhz[0] = 4; bcap_val_11n_40[1] = bcap_val + 10; scap_val_11n_40[1] = scap_val + 10; lpf_ofdm_40mhz[1] = 4; rccal_ovrd = true; break; } } else { if (phy->rf_rev == 5) { for (core = 0; core < 2; core++) { lpf_ofdm_20mhz[core] = 1; lpf_ofdm_40mhz[core] = 3; scap_val_11b[core] = scap_val; bcap_val_11b[core] = bcap_val; scap_val_11n_20[core] = 0x11; scap_val_11n_40[core] = 0x11; bcap_val_11n_20[core] = 0x13; bcap_val_11n_40[core] = 0x13; } rccal_ovrd = true; } } if (rccal_ovrd) { uint16_t rx2tx_lut_20_11b[2], rx2tx_lut_20_11n[2], rx2tx_lut_40_11n[2]; uint8_t rx2tx_lut_extra = 1; for (core = 0; core < 2; core++) { bcap_val_11b[core] = bwn_clamp_val(bcap_val_11b[core], 0, 0x1f); scap_val_11b[core] = bwn_clamp_val(scap_val_11b[core], 0, 0x1f); bcap_val_11n_20[core] = bwn_clamp_val(bcap_val_11n_20[core], 0, 0x1f); scap_val_11n_20[core] = bwn_clamp_val(scap_val_11n_20[core], 0, 0x1f); bcap_val_11n_40[core] = bwn_clamp_val(bcap_val_11n_40[core], 0, 0x1f); scap_val_11n_40[core] = bwn_clamp_val(scap_val_11n_40[core], 0, 0x1f); rx2tx_lut_20_11b[core] = (rx2tx_lut_extra << 13) | (bcap_val_11b[core] << 8) | (scap_val_11b[core] << 3) | lpf_11b[core]; rx2tx_lut_20_11n[core] = (rx2tx_lut_extra << 13) | (bcap_val_11n_20[core] << 8) | (scap_val_11n_20[core] << 3) | lpf_ofdm_20mhz[core]; rx2tx_lut_40_11n[core] = (rx2tx_lut_extra << 13) | (bcap_val_11n_40[core] << 8) | (scap_val_11n_40[core] << 3) | lpf_ofdm_40mhz[core]; } for (core = 0; core < 2; core++) { bwn_ntab_write(mac, BWN_NTAB16(7, 0x152 + core * 16), rx2tx_lut_20_11b[core]); bwn_ntab_write(mac, BWN_NTAB16(7, 0x153 + core * 16), rx2tx_lut_20_11n[core]); bwn_ntab_write(mac, BWN_NTAB16(7, 0x154 + core * 16), rx2tx_lut_20_11n[core]); bwn_ntab_write(mac, BWN_NTAB16(7, 0x155 + core * 16), rx2tx_lut_40_11n[core]); bwn_ntab_write(mac, BWN_NTAB16(7, 0x156 + core * 16), rx2tx_lut_40_11n[core]); bwn_ntab_write(mac, BWN_NTAB16(7, 0x157 + core * 16), rx2tx_lut_40_11n[core]); bwn_ntab_write(mac, BWN_NTAB16(7, 0x158 + core * 16), rx2tx_lut_40_11n[core]); bwn_ntab_write(mac, BWN_NTAB16(7, 0x159 + core * 16), rx2tx_lut_40_11n[core]); } } BWN_PHY_WRITE(mac, 0x32F, 0x3); if (phy->rf_rev == 4 || phy->rf_rev == 6) bwn_nphy_rf_ctl_override_rev7(mac, 4, 1, 3, false, 0); if (phy->rf_rev == 3 || phy->rf_rev == 4 || phy->rf_rev == 6) { if (sc->sc_board_info.board_srom_rev && sc->sc_board_info.board_flags2 & BHND_BFL2_IPALVLSHIFT_3P3) { BWN_RF_WRITE(mac, 0x5, 0x05); BWN_RF_WRITE(mac, 0x6, 0x30); BWN_RF_WRITE(mac, 0x7, 0x00); BWN_RF_SET(mac, 0x4f, 0x1); BWN_RF_SET(mac, 0xd4, 0x1); bias = 0x1f; conv = 0x6f; filt = 0xaa; } else { bias = 0x2b; conv = 0x7f; filt = 0xee; } if (bwn_current_band(mac) == BWN_BAND_2G) { for (core = 0; core < 2; core++) { if (core == 0) { BWN_RF_WRITE(mac, 0x5F, bias); BWN_RF_WRITE(mac, 0x64, conv); BWN_RF_WRITE(mac, 0x66, filt); } else { BWN_RF_WRITE(mac, 0xE8, bias); BWN_RF_WRITE(mac, 0xE9, conv); BWN_RF_WRITE(mac, 0xEB, filt); } } } } if (bwn_nphy_ipa(mac)) { if (bwn_current_band(mac) == BWN_BAND_2G) { if (phy->rf_rev == 3 || phy->rf_rev == 4 || phy->rf_rev == 6) { for (core = 0; core < 2; core++) { if (core == 0) BWN_RF_WRITE(mac, 0x51, 0x7f); else BWN_RF_WRITE(mac, 0xd6, 0x7f); } } switch (phy->rf_rev) { case 3: for (core = 0; core < 2; core++) { if (core == 0) { BWN_RF_WRITE(mac, 0x64, 0x13); BWN_RF_WRITE(mac, 0x5F, 0x1F); BWN_RF_WRITE(mac, 0x66, 0xEE); BWN_RF_WRITE(mac, 0x59, 0x8A); BWN_RF_WRITE(mac, 0x80, 0x3E); } else { BWN_RF_WRITE(mac, 0x69, 0x13); BWN_RF_WRITE(mac, 0xE8, 0x1F); BWN_RF_WRITE(mac, 0xEB, 0xEE); BWN_RF_WRITE(mac, 0xDE, 0x8A); BWN_RF_WRITE(mac, 0x105, 0x3E); } } break; case 7: case 8: if (!bwn_is_40mhz(mac)) { BWN_RF_WRITE(mac, 0x5F, 0x14); BWN_RF_WRITE(mac, 0xE8, 0x12); } else { BWN_RF_WRITE(mac, 0x5F, 0x16); BWN_RF_WRITE(mac, 0xE8, 0x16); } break; case 14: for (core = 0; core < 2; core++) { int o = core ? 0x85 : 0; BWN_RF_WRITE(mac, o + R2057_IPA2G_CASCONV_CORE0, 0x13); BWN_RF_WRITE(mac, o + R2057_TXMIX2G_TUNE_BOOST_PU_CORE0, 0x21); BWN_RF_WRITE(mac, o + R2057_IPA2G_BIAS_FILTER_CORE0, 0xff); BWN_RF_WRITE(mac, o + R2057_PAD2G_IDACS_CORE0, 0x88); BWN_RF_WRITE(mac, o + R2057_PAD2G_TUNE_PUS_CORE0, 0x23); BWN_RF_WRITE(mac, o + R2057_IPA2G_IMAIN_CORE0, 0x16); BWN_RF_WRITE(mac, o + R2057_PAD_BIAS_FILTER_BWS_CORE0, 0x3e); BWN_RF_WRITE(mac, o + R2057_BACKUP1_CORE0, 0x10); } break; } } else { uint16_t freq = bwn_get_centre_freq(mac); if ((freq >= 5180 && freq <= 5230) || (freq >= 5745 && freq <= 5805)) { BWN_RF_WRITE(mac, 0x7D, 0xFF); BWN_RF_WRITE(mac, 0xFE, 0xFF); } } } else { if (phy->rf_rev != 5) { for (core = 0; core < 2; core++) { if (core == 0) { BWN_RF_WRITE(mac, 0x5c, 0x61); BWN_RF_WRITE(mac, 0x51, 0x70); } else { BWN_RF_WRITE(mac, 0xe1, 0x61); BWN_RF_WRITE(mac, 0xd6, 0x70); } } } } if (phy->rf_rev == 4) { bwn_ntab_write(mac, BWN_NTAB16(8, 0x05), 0x20); bwn_ntab_write(mac, BWN_NTAB16(8, 0x15), 0x20); for (core = 0; core < 2; core++) { if (core == 0) { BWN_RF_WRITE(mac, 0x1a1, 0x00); BWN_RF_WRITE(mac, 0x1a2, 0x3f); BWN_RF_WRITE(mac, 0x1a6, 0x3f); } else { BWN_RF_WRITE(mac, 0x1a7, 0x00); BWN_RF_WRITE(mac, 0x1ab, 0x3f); BWN_RF_WRITE(mac, 0x1ac, 0x3f); } } } else { BWN_PHY_SET(mac, BWN_NPHY_AFECTL_C1, 0x4); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER1, 0x4); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_C2, 0x4); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x4); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C1, ~0x1); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER1, 0x1); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C2, ~0x1); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x1); bwn_ntab_write(mac, BWN_NTAB16(8, 0x05), 0); bwn_ntab_write(mac, BWN_NTAB16(8, 0x15), 0); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C1, ~0x4); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER1, ~0x4); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C2, ~0x4); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER, ~0x4); } BWN_PHY_WRITE(mac, BWN_NPHY_ENDROP_TLEN, 0x2); bwn_ntab_write(mac, BWN_NTAB32(16, 0x100), 20); bwn_ntab_write_bulk(mac, BWN_NTAB8(7, 0x138), 2, ntab7_138_146); bwn_ntab_write(mac, BWN_NTAB16(7, 0x141), 0x77); bwn_ntab_write_bulk(mac, BWN_NTAB8(7, 0x133), 3, ntab7_133); bwn_ntab_write_bulk(mac, BWN_NTAB8(7, 0x146), 2, ntab7_138_146); bwn_ntab_write(mac, BWN_NTAB16(7, 0x123), 0x77); bwn_ntab_write(mac, BWN_NTAB16(7, 0x12A), 0x77); bwn_ntab_read_bulk(mac, BWN_NTAB32(16, 0x02), 1, noise_tbl); noise_tbl[1] = bwn_is_40mhz(mac) ? 0x14D : 0x18D; bwn_ntab_write_bulk(mac, BWN_NTAB32(16, 0x02), 2, noise_tbl); bwn_ntab_read_bulk(mac, BWN_NTAB32(16, 0x7E), 1, noise_tbl); noise_tbl[1] = bwn_is_40mhz(mac) ? 0x14D : 0x18D; bwn_ntab_write_bulk(mac, BWN_NTAB32(16, 0x7E), 2, noise_tbl); bwn_nphy_gain_ctl_workarounds(mac); /* TODO bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x08), 4, aux_adc_vmid_rev7_core0); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x18), 4, aux_adc_vmid_rev7_core1); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x0C), 4, aux_adc_gain_rev7); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x1C), 4, aux_adc_gain_rev7); */ return (0); } static int bwn_nphy_workarounds_rev3plus(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; /* TX to RX */ uint8_t tx2rx_events[7] = { 0x4, 0x3, 0x5, 0x2, 0x1, 0x8, 0x1F }; uint8_t tx2rx_delays[7] = { 8, 4, 4, 4, 4, 6, 1 }; /* RX to TX */ uint8_t rx2tx_events_ipa[9] = { 0x0, 0x1, 0x2, 0x8, 0x5, 0x6, 0xF, 0x3, 0x1F }; uint8_t rx2tx_delays_ipa[9] = { 8, 6, 6, 4, 4, 16, 43, 1, 1 }; uint8_t rx2tx_events[9] = { 0x0, 0x1, 0x2, 0x8, 0x5, 0x6, 0x3, 0x4, 0x1F }; uint8_t rx2tx_delays[9] = { 8, 6, 6, 4, 4, 18, 42, 1, 1 }; uint16_t vmids[5][4] = { { 0xa2, 0xb4, 0xb4, 0x89, }, /* 0 */ { 0xb4, 0xb4, 0xb4, 0x24, }, /* 1 */ { 0xa2, 0xb4, 0xb4, 0x74, }, /* 2 */ { 0xa2, 0xb4, 0xb4, 0x270, }, /* 3 */ { 0xa2, 0xb4, 0xb4, 0x00, }, /* 4 and 5 */ }; uint16_t gains[5][4] = { { 0x02, 0x02, 0x02, 0x00, }, /* 0 */ { 0x02, 0x02, 0x02, 0x02, }, /* 1 */ { 0x02, 0x02, 0x02, 0x04, }, /* 2 */ { 0x02, 0x02, 0x02, 0x00, }, /* 3 */ { 0x02, 0x02, 0x02, 0x00, }, /* 4 and 5 */ }; uint16_t *vmid, *gain; const char *pdet_range_var; uint8_t pdet_range; uint16_t tmp16; uint32_t tmp32; int error; BWN_PHY_WRITE(mac, BWN_NPHY_FORCEFRONT0, 0x1f8); BWN_PHY_WRITE(mac, BWN_NPHY_FORCEFRONT1, 0x1f8); tmp32 = bwn_ntab_read(mac, BWN_NTAB32(30, 0)); tmp32 &= 0xffffff; bwn_ntab_write(mac, BWN_NTAB32(30, 0), tmp32); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A0, 0x0125); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A1, 0x01B3); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A2, 0x0105); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B0, 0x016E); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B1, 0x00CD); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B2, 0x0020); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C1_CLIP_LOGAIN_B, 0x000C); BWN_PHY_WRITE(mac, BWN_NPHY_REV3_C2_CLIP_LOGAIN_B, 0x000C); /* TX to RX */ bwn_nphy_set_rf_sequence(mac, 1, tx2rx_events, tx2rx_delays, nitems(tx2rx_events)); /* RX to TX */ if (bwn_nphy_ipa(mac)) bwn_nphy_set_rf_sequence(mac, 0, rx2tx_events_ipa, rx2tx_delays_ipa, nitems(rx2tx_events_ipa)); if (nphy->hw_phyrxchain != 3 && nphy->hw_phyrxchain != nphy->hw_phytxchain) { if (bwn_nphy_ipa(mac)) { rx2tx_delays[5] = 59; rx2tx_delays[6] = 1; rx2tx_events[7] = 0x1F; } bwn_nphy_set_rf_sequence(mac, 0, rx2tx_events, rx2tx_delays, nitems(rx2tx_events)); } tmp16 = (bwn_current_band(mac) == BWN_BAND_2G) ? 0x2 : 0x9C40; BWN_PHY_WRITE(mac, BWN_NPHY_ENDROP_TLEN, tmp16); BWN_PHY_SETMASK(mac, BWN_NPHY_SGILTRNOFFSET, 0xF0FF, 0x0700); if (!bwn_is_40mhz(mac)) { bwn_ntab_write(mac, BWN_NTAB32(16, 3), 0x18D); bwn_ntab_write(mac, BWN_NTAB32(16, 127), 0x18D); } else { bwn_ntab_write(mac, BWN_NTAB32(16, 3), 0x14D); bwn_ntab_write(mac, BWN_NTAB32(16, 127), 0x14D); } bwn_nphy_gain_ctl_workarounds(mac); bwn_ntab_write(mac, BWN_NTAB16(8, 0), 2); bwn_ntab_write(mac, BWN_NTAB16(8, 16), 2); if (bwn_current_band(mac) == BWN_BAND_2G) pdet_range_var = BHND_NVAR_PDETRANGE2G; else pdet_range_var = BHND_NVAR_PDETRANGE5G; error = bhnd_nvram_getvar_uint8(sc->sc_dev, pdet_range_var, &pdet_range); if (error) { BWN_ERRPRINTF(mac->mac_sc, "Error reading PDet range %s from " "NVRAM: %d\n", pdet_range_var, error); return (error); } /* uint16_t min() */ vmid = vmids[min(pdet_range, 4)]; gain = gains[min(pdet_range, 4)]; switch (pdet_range) { case 3: if (!(mac->mac_phy.rev >= 4 && bwn_current_band(mac) == BWN_BAND_2G)) break; /* FALL THROUGH */ case 0: case 1: bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x08), 4, vmid); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x18), 4, vmid); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x0c), 4, gain); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x1c), 4, gain); break; case 2: if (mac->mac_phy.rev >= 6) { if (bwn_current_band(mac) == BWN_BAND_2G) vmid[3] = 0x94; else vmid[3] = 0x8e; gain[3] = 3; } else if (mac->mac_phy.rev == 5) { vmid[3] = 0x84; gain[3] = 2; } bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x08), 4, vmid); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x18), 4, vmid); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x0c), 4, gain); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x1c), 4, gain); break; case 4: case 5: if (bwn_current_band(mac) != BWN_BAND_2G) { if (pdet_range == 4) { vmid[3] = 0x8e; tmp16 = 0x96; gain[3] = 0x2; } else { vmid[3] = 0x89; tmp16 = 0x89; gain[3] = 0; } } else { if (pdet_range == 4) { vmid[3] = 0x89; tmp16 = 0x8b; gain[3] = 0x2; } else { vmid[3] = 0x74; tmp16 = 0x70; gain[3] = 0; } } bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x08), 4, vmid); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x0c), 4, gain); vmid[3] = tmp16; bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x18), 4, vmid); bwn_ntab_write_bulk(mac, BWN_NTAB16(8, 0x1c), 4, gain); break; } BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_MIXA_MAST_BIAS, 0x00); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_MIXA_MAST_BIAS, 0x00); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_MIXA_BIAS_MAIN, 0x06); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_MIXA_BIAS_MAIN, 0x06); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_MIXA_BIAS_AUX, 0x07); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_MIXA_BIAS_AUX, 0x07); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_MIXA_LOB_BIAS, 0x88); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_MIXA_LOB_BIAS, 0x88); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_MIXA_CMFB_IDAC, 0x00); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_MIXA_CMFB_IDAC, 0x00); BWN_RF_WRITE(mac, B2056_RX0 | B2056_RX_MIXG_CMFB_IDAC, 0x00); BWN_RF_WRITE(mac, B2056_RX1 | B2056_RX_MIXG_CMFB_IDAC, 0x00); /* N PHY WAR TX Chain Update with hw_phytxchain as argument */ if ((sc->sc_board_info.board_flags2 & BHND_BFL2_APLL_WAR && bwn_current_band(mac) == BWN_BAND_5G) || (sc->sc_board_info.board_flags2 & BHND_BFL2_GPLL_WAR2 && bwn_current_band(mac) == BWN_BAND_2G)) tmp32 = 0x00088888; else tmp32 = 0x88888888; bwn_ntab_write(mac, BWN_NTAB32(30, 1), tmp32); bwn_ntab_write(mac, BWN_NTAB32(30, 2), tmp32); bwn_ntab_write(mac, BWN_NTAB32(30, 3), tmp32); if (mac->mac_phy.rev == 4 && bwn_current_band(mac) == BWN_BAND_5G) { BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_GMBB_IDAC, 0x70); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_GMBB_IDAC, 0x70); } /* Dropped probably-always-true condition */ BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS40ASSERTTHRESH0, 0x03eb); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS40ASSERTTHRESH1, 0x03eb); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS40DEASSERTTHRESH0, 0x0341); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS40DEASSERTTHRESH1, 0x0341); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20LASSERTTHRESH0, 0x042b); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20LASSERTTHRESH1, 0x042b); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20LDEASSERTTHRESH0, 0x0381); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20LDEASSERTTHRESH1, 0x0381); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20UASSERTTHRESH0, 0x042b); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20UASSERTTHRESH1, 0x042b); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20UDEASSERTTHRESH0, 0x0381); BWN_PHY_WRITE(mac, BWN_NPHY_ED_CRS20UDEASSERTTHRESH1, 0x0381); if (mac->mac_phy.rev >= 6 && sc->sc_board_info.board_flags2 & BHND_BFL2_SINGLEANT_CCK) ; /* TODO: 0x0080000000000000 HF */ return (0); } static int bwn_nphy_workarounds_rev1_2(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = phy->phy_n; uint8_t events1[7] = { 0x0, 0x1, 0x2, 0x8, 0x4, 0x5, 0x3 }; uint8_t delays1[7] = { 0x8, 0x6, 0x6, 0x2, 0x4, 0x3C, 0x1 }; uint8_t events2[7] = { 0x0, 0x3, 0x5, 0x4, 0x2, 0x1, 0x8 }; uint8_t delays2[7] = { 0x8, 0x6, 0x2, 0x4, 0x4, 0x6, 0x1 }; if (sc->sc_board_info.board_flags2 & BHND_BFL2_SKWRKFEM_BRD || sc->sc_board_info.board_type == BHND_BOARD_BCM943224M93) { delays1[0] = 0x1; delays1[5] = 0x14; } if (bwn_current_band(mac) == BWN_BAND_5G && nphy->band5g_pwrgain) { BWN_RF_MASK(mac, B2055_C1_TX_RF_SPARE, ~0x8); BWN_RF_MASK(mac, B2055_C2_TX_RF_SPARE, ~0x8); } else { BWN_RF_SET(mac, B2055_C1_TX_RF_SPARE, 0x8); BWN_RF_SET(mac, B2055_C2_TX_RF_SPARE, 0x8); } bwn_ntab_write(mac, BWN_NTAB16(8, 0x00), 0x000A); bwn_ntab_write(mac, BWN_NTAB16(8, 0x10), 0x000A); if (mac->mac_phy.rev < 3) { bwn_ntab_write(mac, BWN_NTAB16(8, 0x02), 0xCDAA); bwn_ntab_write(mac, BWN_NTAB16(8, 0x12), 0xCDAA); } if (mac->mac_phy.rev < 2) { bwn_ntab_write(mac, BWN_NTAB16(8, 0x08), 0x0000); bwn_ntab_write(mac, BWN_NTAB16(8, 0x18), 0x0000); bwn_ntab_write(mac, BWN_NTAB16(8, 0x07), 0x7AAB); bwn_ntab_write(mac, BWN_NTAB16(8, 0x17), 0x7AAB); bwn_ntab_write(mac, BWN_NTAB16(8, 0x06), 0x0800); bwn_ntab_write(mac, BWN_NTAB16(8, 0x16), 0x0800); } BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP1, 0x301); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_LO2, 0x2D8); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP2, 0x301); bwn_nphy_set_rf_sequence(mac, 0, events1, delays1, 7); bwn_nphy_set_rf_sequence(mac, 1, events2, delays2, 7); bwn_nphy_gain_ctl_workarounds(mac); if (mac->mac_phy.rev < 2) { if (BWN_PHY_READ(mac, BWN_NPHY_RXCTL) & 0x2) bwn_hf_write(mac, bwn_hf_read(mac) | BWN_HF_MLADVW); } else if (mac->mac_phy.rev == 2) { BWN_PHY_WRITE(mac, BWN_NPHY_CRSCHECK2, 0); BWN_PHY_WRITE(mac, BWN_NPHY_CRSCHECK3, 0); } if (mac->mac_phy.rev < 2) BWN_PHY_MASK(mac, BWN_NPHY_SCRAM_SIGCTL, ~BWN_NPHY_SCRAM_SIGCTL_SCM); /* Set phase track alpha and beta */ BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A0, 0x125); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A1, 0x1B3); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_A2, 0x105); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B0, 0x16E); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B1, 0xCD); BWN_PHY_WRITE(mac, BWN_NPHY_PHASETR_B2, 0x20); if (mac->mac_phy.rev < 3) { BWN_PHY_MASK(mac, BWN_NPHY_PIL_DW1, ~BWN_NPHY_PIL_DW_64QAM & 0xFFFF); BWN_PHY_WRITE(mac, BWN_NPHY_TXF_20CO_S2B1, 0xB5); BWN_PHY_WRITE(mac, BWN_NPHY_TXF_20CO_S2B2, 0xA4); BWN_PHY_WRITE(mac, BWN_NPHY_TXF_20CO_S2B3, 0x00); } if (mac->mac_phy.rev == 2) BWN_PHY_SET(mac, BWN_NPHY_FINERX2_CGC, BWN_NPHY_FINERX2_CGC_DECGC); return (0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */ static int bwn_nphy_workarounds(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = phy->phy_n; int error; if (bwn_current_band(mac) == BWN_BAND_5G) bwn_nphy_classifier(mac, 1, 0); else bwn_nphy_classifier(mac, 1, 1); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); BWN_PHY_SET(mac, BWN_NPHY_IQFLIP, BWN_NPHY_IQFLIP_ADC1 | BWN_NPHY_IQFLIP_ADC2); /* TODO: rev19+ */ if (mac->mac_phy.rev >= 7) error = bwn_nphy_workarounds_rev7plus(mac); else if (mac->mac_phy.rev >= 3) error = bwn_nphy_workarounds_rev3plus(mac); else error = bwn_nphy_workarounds_rev1_2(mac); if (error) return (error); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); return (0); } /************************************************** * Tx/Rx common **************************************************/ /* * Transmits a known value for LO calibration * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TXTone */ static int bwn_nphy_tx_tone(struct bwn_mac *mac, uint32_t freq, uint16_t max_val, bool iqmode, bool dac_test, bool modify_bbmult) { uint16_t samp = bwn_nphy_gen_load_samples(mac, freq, max_val, dac_test); if (samp == 0) return -1; bwn_nphy_run_samples(mac, samp, 0xFFFF, 0, iqmode, dac_test, modify_bbmult); return 0; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */ static void bwn_nphy_update_txrx_chain(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; bool override = false; uint16_t chain = 0x33; if (nphy->txrx_chain == 0) { chain = 0x11; override = true; } else if (nphy->txrx_chain == 1) { chain = 0x22; override = true; } BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~(BWN_NPHY_RFSEQCA_TXEN | BWN_NPHY_RFSEQCA_RXEN), chain); if (override) BWN_PHY_SET(mac, BWN_NPHY_RFSEQMODE, BWN_NPHY_RFSEQMODE_CAOVER); else BWN_PHY_MASK(mac, BWN_NPHY_RFSEQMODE, ~BWN_NPHY_RFSEQMODE_CAOVER); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */ static void bwn_nphy_stop_playback(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t tmp; if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); tmp = BWN_PHY_READ(mac, BWN_NPHY_SAMP_STAT); if (tmp & 0x1) BWN_PHY_SET(mac, BWN_NPHY_SAMP_CMD, BWN_NPHY_SAMP_CMD_STOP); else if (tmp & 0x2) BWN_PHY_MASK(mac, BWN_NPHY_IQLOCAL_CMDGCTL, 0x7FFF); BWN_PHY_MASK(mac, BWN_NPHY_SAMP_CMD, ~0x0004); if (nphy->bb_mult_save & 0x80000000) { tmp = nphy->bb_mult_save & 0xFFFF; bwn_ntab_write(mac, BWN_NTAB16(15, 87), tmp); nphy->bb_mult_save = 0; } if (phy->rev >= 7 && nphy->lpf_bw_overrode_for_sample_play) { if (phy->rev >= 19) bwn_nphy_rf_ctl_override_rev19(mac, 0x80, 0, 0, true, 1); else bwn_nphy_rf_ctl_override_rev7(mac, 0x80, 0, 0, true, 1); nphy->lpf_bw_overrode_for_sample_play = false; } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IqCalGainParams */ static void bwn_nphy_iq_cal_gain_params(struct bwn_mac *mac, uint16_t core, struct bwn_nphy_txgains target, struct bwn_nphy_iqcal_params *params) { struct bwn_phy *phy = &mac->mac_phy; int i, j, indx; uint16_t gain; if (mac->mac_phy.rev >= 3) { params->tx_lpf = target.tx_lpf[core]; /* Rev 7+ */ params->txgm = target.txgm[core]; params->pga = target.pga[core]; params->pad = target.pad[core]; params->ipa = target.ipa[core]; if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { params->cal_gain = (params->txgm << 12) | (params->pga << 8) | (params->pad << 3) | (params->ipa) | (params->tx_lpf << 15); } else { params->cal_gain = (params->txgm << 12) | (params->pga << 8) | (params->pad << 4) | (params->ipa); } for (j = 0; j < 5; j++) params->ncorr[j] = 0x79; } else { gain = (target.pad[core]) | (target.pga[core] << 4) | (target.txgm[core] << 8); indx = (bwn_current_band(mac) == BWN_BAND_5G) ? 1 : 0; for (i = 0; i < 9; i++) if (tbl_iqcal_gainparams[indx][i][0] == gain) break; i = min(i, 8); params->txgm = tbl_iqcal_gainparams[indx][i][1]; params->pga = tbl_iqcal_gainparams[indx][i][2]; params->pad = tbl_iqcal_gainparams[indx][i][3]; params->cal_gain = (params->txgm << 7) | (params->pga << 4) | (params->pad << 2); for (j = 0; j < 4; j++) params->ncorr[j] = tbl_iqcal_gainparams[indx][i][4 + j]; } } /************************************************** * Tx and Rx **************************************************/ /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlEnable */ static void bwn_nphy_tx_power_ctrl(struct bwn_mac *mac, bool enable) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t i; uint16_t bmask, val, tmp; bwn_band_t band = bwn_current_band(mac); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); nphy->txpwrctrl = enable; if (!enable) { if (mac->mac_phy.rev >= 3 && (BWN_PHY_READ(mac, BWN_NPHY_TXPCTL_CMD) & (BWN_NPHY_TXPCTL_CMD_COEFF | BWN_NPHY_TXPCTL_CMD_HWPCTLEN | BWN_NPHY_TXPCTL_CMD_PCTLEN))) { /* We disable enabled TX pwr ctl, save it's state */ nphy->tx_pwr_idx[0] = BWN_PHY_READ(mac, BWN_NPHY_C1_TXPCTL_STAT) & 0x7f; nphy->tx_pwr_idx[1] = BWN_PHY_READ(mac, BWN_NPHY_C2_TXPCTL_STAT) & 0x7f; } BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, 0x6840); for (i = 0; i < 84; i++) BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, 0x6C40); for (i = 0; i < 84; i++) BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, 0); tmp = BWN_NPHY_TXPCTL_CMD_COEFF | BWN_NPHY_TXPCTL_CMD_HWPCTLEN; if (mac->mac_phy.rev >= 3) tmp |= BWN_NPHY_TXPCTL_CMD_PCTLEN; BWN_PHY_MASK(mac, BWN_NPHY_TXPCTL_CMD, ~tmp); if (mac->mac_phy.rev >= 3) { BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER1, 0x0100); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x0100); } else { BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x4000); } if (mac->mac_phy.rev == 2) BWN_PHY_SETMASK(mac, BWN_NPHY_BPHY_CTL3, ~BWN_NPHY_BPHY_CTL3_SCALE, 0x53); else if (mac->mac_phy.rev < 2) BWN_PHY_SETMASK(mac, BWN_NPHY_BPHY_CTL3, ~BWN_NPHY_BPHY_CTL3_SCALE, 0x5A); if (mac->mac_phy.rev < 2 && bwn_is_40mhz(mac)) bwn_hf_write(mac, bwn_hf_read(mac) | BWN_HF_TSSI_RESET_PSM_WORKAROUN); } else { bwn_ntab_write_bulk(mac, BWN_NTAB16(26, 64), 84, nphy->adj_pwr_tbl); bwn_ntab_write_bulk(mac, BWN_NTAB16(27, 64), 84, nphy->adj_pwr_tbl); bmask = BWN_NPHY_TXPCTL_CMD_COEFF | BWN_NPHY_TXPCTL_CMD_HWPCTLEN; /* wl does useless check for "enable" param here */ val = BWN_NPHY_TXPCTL_CMD_COEFF | BWN_NPHY_TXPCTL_CMD_HWPCTLEN; if (mac->mac_phy.rev >= 3) { bmask |= BWN_NPHY_TXPCTL_CMD_PCTLEN; if (val) val |= BWN_NPHY_TXPCTL_CMD_PCTLEN; } BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_CMD, ~(bmask), val); if (band == BWN_BAND_5G) { if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_CMD, ~BWN_NPHY_TXPCTL_CMD_INIT, 0x32); BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_INIT, ~BWN_NPHY_TXPCTL_INIT_PIDXI1, 0x32); } else { BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_CMD, ~BWN_NPHY_TXPCTL_CMD_INIT, 0x64); if (phy->rev > 1) BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_INIT, ~BWN_NPHY_TXPCTL_INIT_PIDXI1, 0x64); } } if (mac->mac_phy.rev >= 3) { if (nphy->tx_pwr_idx[0] != 128 && nphy->tx_pwr_idx[1] != 128) { /* Recover TX pwr ctl state */ BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_CMD, ~BWN_NPHY_TXPCTL_CMD_INIT, nphy->tx_pwr_idx[0]); if (mac->mac_phy.rev > 1) BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_INIT, ~0xff, nphy->tx_pwr_idx[1]); } } if (phy->rev >= 7) { /* TODO */ } if (mac->mac_phy.rev >= 3) { BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER1, ~0x100); BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER, ~0x100); } else { BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_OVER, ~0x4000); } if (mac->mac_phy.rev == 2) BWN_PHY_SETMASK(mac, BWN_NPHY_BPHY_CTL3, ~0xFF, 0x3b); else if (mac->mac_phy.rev < 2) BWN_PHY_SETMASK(mac, BWN_NPHY_BPHY_CTL3, ~0xFF, 0x40); if (mac->mac_phy.rev < 2 && bwn_is_40mhz(mac)) bwn_hf_write(mac, bwn_hf_read(mac) & ~BWN_HF_TSSI_RESET_PSM_WORKAROUN); if (bwn_nphy_ipa(mac)) { BWN_PHY_MASK(mac, BWN_NPHY_PAPD_EN0, ~0x4); BWN_PHY_MASK(mac, BWN_NPHY_PAPD_EN1, ~0x4); } } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrFix */ static int bwn_nphy_tx_power_fix(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t txpi[2], bbmult, i; uint16_t tmp, radio_gain, dac_gain; uint16_t freq = bwn_get_centre_freq(mac); uint32_t txgain; /* uint32_t gaintbl; rev3+ */ if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); /* TODO: rev19+ */ if (mac->mac_phy.rev >= 7) { txpi[0] = txpi[1] = 30; } else if (mac->mac_phy.rev >= 3) { txpi[0] = 40; txpi[1] = 40; } else if (sc->sc_board_info.board_srom_rev < 4) { txpi[0] = 72; txpi[1] = 72; } else if (sc->sc_board_info.board_srom_rev > 7) { txpi[0] = 0; txpi[1] = 0; } else { #define BWN_NPHY_GET_TXPI(_name, _result) \ do { \ int error; \ error = bhnd_nvram_getvar_uint8(sc->sc_dev, (_name), \ (_result)); \ if (error) { \ device_printf(sc->sc_dev, "NVRAM variable %s " \ "unreadable: %d\n", (_name), error); \ return (error); \ } \ } while(0) if (bwn_current_band(mac) == BWN_BAND_2G) { BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID2GA0, &txpi[0]); BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID2GA1, &txpi[1]); } else if (freq >= 4900 && freq < 5100) { BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID5GLA0, &txpi[0]); BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID5GLA1, &txpi[1]); } else if (freq >= 5100 && freq < 5500) { BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID5GA0, &txpi[0]); BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID5GA1, &txpi[1]); } else if (freq >= 5500) { BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID5GHA0, &txpi[0]); BWN_NPHY_GET_TXPI(BHND_NVAR_TXPID5GHA1, &txpi[1]); } else { txpi[0] = 91; txpi[1] = 91; } #undef BWN_NPHY_GET_TXPI } if (mac->mac_phy.rev < 7 && (txpi[0] < 40 || txpi[0] > 100 || txpi[1] < 40 || txpi[1] > 100)) txpi[0] = txpi[1] = 91; /* for (i = 0; i < 2; i++) { nphy->txpwrindex[i].index_internal = txpi[i]; nphy->txpwrindex[i].index_internal_save = txpi[i]; } */ for (i = 0; i < 2; i++) { const uint32_t *table = bwn_nphy_get_tx_gain_table(mac); if (!table) break; txgain = *(table + txpi[i]); if (mac->mac_phy.rev >= 3) radio_gain = (txgain >> 16) & 0x1FFFF; else radio_gain = (txgain >> 16) & 0x1FFF; if (mac->mac_phy.rev >= 7) dac_gain = (txgain >> 8) & 0x7; else dac_gain = (txgain >> 8) & 0x3F; bbmult = txgain & 0xFF; if (mac->mac_phy.rev >= 3) { if (i == 0) BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER1, 0x0100); else BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x0100); } else { BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x4000); } if (i == 0) BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_DACGAIN1, dac_gain); else BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_DACGAIN2, dac_gain); bwn_ntab_write(mac, BWN_NTAB16(0x7, 0x110 + i), radio_gain); tmp = bwn_ntab_read(mac, BWN_NTAB16(0xF, 0x57)); if (i == 0) tmp = (tmp & 0x00FF) | (bbmult << 8); else tmp = (tmp & 0xFF00) | bbmult; bwn_ntab_write(mac, BWN_NTAB16(0xF, 0x57), tmp); if (bwn_nphy_ipa(mac)) { uint32_t tmp32; uint16_t reg = (i == 0) ? BWN_NPHY_PAPD_EN0 : BWN_NPHY_PAPD_EN1; tmp32 = bwn_ntab_read(mac, BWN_NTAB32(26 + i, 576 + txpi[i])); BWN_PHY_SETMASK(mac, reg, 0xE00F, (uint32_t) tmp32 << 4); BWN_PHY_SET(mac, reg, 0x4); } } BWN_PHY_MASK(mac, BWN_NPHY_BPHY_CTL2, ~BWN_NPHY_BPHY_CTL2_LUT); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); return (0); } static void bwn_nphy_ipa_internal_tssi_setup(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; uint8_t core; uint16_t r; /* routing */ if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { for (core = 0; core < 2; core++) { r = core ? 0x190 : 0x170; if (bwn_current_band(mac) == BWN_BAND_2G) { BWN_RF_WRITE(mac, r + 0x5, 0x5); BWN_RF_WRITE(mac, r + 0x9, 0xE); if (phy->rev != 5) BWN_RF_WRITE(mac, r + 0xA, 0); if (phy->rev != 7) BWN_RF_WRITE(mac, r + 0xB, 1); else BWN_RF_WRITE(mac, r + 0xB, 0x31); } else { BWN_RF_WRITE(mac, r + 0x5, 0x9); BWN_RF_WRITE(mac, r + 0x9, 0xC); BWN_RF_WRITE(mac, r + 0xB, 0x0); if (phy->rev != 5) BWN_RF_WRITE(mac, r + 0xA, 1); else BWN_RF_WRITE(mac, r + 0xA, 0x31); } BWN_RF_WRITE(mac, r + 0x6, 0); BWN_RF_WRITE(mac, r + 0x7, 0); BWN_RF_WRITE(mac, r + 0x8, 3); BWN_RF_WRITE(mac, r + 0xC, 0); } } else { if (bwn_current_band(mac) == BWN_BAND_2G) BWN_RF_WRITE(mac, B2056_SYN_RESERVED_ADDR31, 0x128); else BWN_RF_WRITE(mac, B2056_SYN_RESERVED_ADDR31, 0x80); BWN_RF_WRITE(mac, B2056_SYN_RESERVED_ADDR30, 0); BWN_RF_WRITE(mac, B2056_SYN_GPIO_MASTER1, 0x29); for (core = 0; core < 2; core++) { r = core ? B2056_TX1 : B2056_TX0; BWN_RF_WRITE(mac, r | B2056_TX_IQCAL_VCM_HG, 0); BWN_RF_WRITE(mac, r | B2056_TX_IQCAL_IDAC, 0); BWN_RF_WRITE(mac, r | B2056_TX_TSSI_VCM, 3); BWN_RF_WRITE(mac, r | B2056_TX_TX_AMP_DET, 0); BWN_RF_WRITE(mac, r | B2056_TX_TSSI_MISC1, 8); BWN_RF_WRITE(mac, r | B2056_TX_TSSI_MISC2, 0); BWN_RF_WRITE(mac, r | B2056_TX_TSSI_MISC3, 0); if (bwn_current_band(mac) == BWN_BAND_2G) { BWN_RF_WRITE(mac, r | B2056_TX_TX_SSI_MASTER, 0x5); if (phy->rev != 5) BWN_RF_WRITE(mac, r | B2056_TX_TSSIA, 0x00); if (phy->rev >= 5) BWN_RF_WRITE(mac, r | B2056_TX_TSSIG, 0x31); else BWN_RF_WRITE(mac, r | B2056_TX_TSSIG, 0x11); BWN_RF_WRITE(mac, r | B2056_TX_TX_SSI_MUX, 0xE); } else { BWN_RF_WRITE(mac, r | B2056_TX_TX_SSI_MASTER, 0x9); BWN_RF_WRITE(mac, r | B2056_TX_TSSIA, 0x31); BWN_RF_WRITE(mac, r | B2056_TX_TSSIG, 0x0); BWN_RF_WRITE(mac, r | B2056_TX_TX_SSI_MUX, 0xC); } } } } /* * Stop radio and transmit known signal. Then check received signal strength to * get TSSI (Transmit Signal Strength Indicator). * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlIdleTssi */ static void bwn_nphy_tx_power_ctl_idle_tssi(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint32_t tmp; int32_t rssi[4] = { }; if (bwn_is_chan_passive(mac)) return; if (bwn_nphy_ipa(mac)) bwn_nphy_ipa_internal_tssi_setup(mac); if (phy->rev >= 19) bwn_nphy_rf_ctl_override_rev19(mac, 0x1000, 0, 3, false, 0); else if (phy->rev >= 7) bwn_nphy_rf_ctl_override_rev7(mac, 0x1000, 0, 3, false, 0); else if (phy->rev >= 3) bwn_nphy_rf_ctl_override(mac, 0x2000, 0, 3, false); bwn_nphy_stop_playback(mac); bwn_nphy_tx_tone(mac, 4000, 0, false, false, false); DELAY(20); tmp = bwn_nphy_poll_rssi(mac, N_RSSI_TSSI_2G, rssi, 1); bwn_nphy_stop_playback(mac); bwn_nphy_rssi_select(mac, 0, N_RSSI_W1); if (phy->rev >= 19) bwn_nphy_rf_ctl_override_rev19(mac, 0x1000, 0, 3, true, 0); else if (phy->rev >= 7) bwn_nphy_rf_ctl_override_rev7(mac, 0x1000, 0, 3, true, 0); else if (phy->rev >= 3) bwn_nphy_rf_ctl_override(mac, 0x2000, 0, 3, true); if (phy->rev >= 19) { /* TODO */ return; } else if (phy->rev >= 3) { nphy->pwr_ctl_info[0].idle_tssi_5g = (tmp >> 24) & 0xFF; nphy->pwr_ctl_info[1].idle_tssi_5g = (tmp >> 8) & 0xFF; } else { nphy->pwr_ctl_info[0].idle_tssi_5g = (tmp >> 16) & 0xFF; nphy->pwr_ctl_info[1].idle_tssi_5g = tmp & 0xFF; } nphy->pwr_ctl_info[0].idle_tssi_2g = (tmp >> 24) & 0xFF; nphy->pwr_ctl_info[1].idle_tssi_2g = (tmp >> 8) & 0xFF; } /* http://bcm-v4.sipsolutions.net/PHY/N/TxPwrLimitToTbl */ static void bwn_nphy_tx_prepare_adjusted_power_table(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t idx, delta; uint8_t i, stf_mode; /* Array adj_pwr_tbl corresponds to the hardware table. It consists of * 21 groups, each containing 4 entries. * * First group has entries for CCK modulation. * The rest of groups has 1 entry per modulation (SISO, CDD, STBC, SDM). * * Group 0 is for CCK * Groups 1..4 use BPSK (group per coding rate) * Groups 5..8 use QPSK (group per coding rate) * Groups 9..12 use 16-QAM (group per coding rate) * Groups 13..16 use 64-QAM (group per coding rate) * Groups 17..20 are unknown */ for (i = 0; i < 4; i++) nphy->adj_pwr_tbl[i] = nphy->tx_power_offset[i]; for (stf_mode = 0; stf_mode < 4; stf_mode++) { delta = 0; switch (stf_mode) { case 0: if (bwn_is_40mhz(mac) && mac->mac_phy.rev >= 5) { idx = 68; } else { delta = 1; idx = bwn_is_40mhz(mac) ? 52 : 4; } break; case 1: idx = bwn_is_40mhz(mac) ? 76 : 28; break; case 2: idx = bwn_is_40mhz(mac) ? 84 : 36; break; case 3: idx = bwn_is_40mhz(mac) ? 92 : 44; break; } for (i = 0; i < 20; i++) { nphy->adj_pwr_tbl[4 + 4 * i + stf_mode] = nphy->tx_power_offset[idx]; if (i == 0) idx += delta; if (i == 14) idx += 1 - delta; if (i == 3 || i == 4 || i == 7 || i == 8 || i == 11 || i == 13) idx += 1; } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlSetup */ static void bwn_nphy_tx_power_ctl_setup(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; struct bwn_phy_n_core_pwr_info core_pwr_info[4]; int n; int16_t a1[2], b0[2], b1[2]; uint8_t idle[2]; uint8_t ppr_max; int8_t target[2]; int32_t num, den, pwr; uint32_t regval[64]; uint16_t freq = bwn_get_centre_freq(mac); uint16_t tmp; uint16_t r; /* routing */ uint8_t i, c; for (n = 0; n < 4; n++) { bzero(&core_pwr_info[n], sizeof(core_pwr_info[n])); if (bwn_nphy_get_core_power_info(mac, n, &core_pwr_info[n]) != 0) { BWN_ERRPRINTF(mac->mac_sc, "%s: failed to get core_pwr_info for core %d\n", __func__, n); } } if (bhnd_get_hwrev(sc->sc_dev) == 11 || bhnd_get_hwrev(sc->sc_dev) == 12) { BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~0, 0x200000); BWN_READ_4(mac, BWN_MACCTL); DELAY(1); } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, true); BWN_PHY_SET(mac, BWN_NPHY_TSSIMODE, BWN_NPHY_TSSIMODE_EN); if (mac->mac_phy.rev >= 3) BWN_PHY_MASK(mac, BWN_NPHY_TXPCTL_CMD, ~BWN_NPHY_TXPCTL_CMD_PCTLEN & 0xFFFF); else BWN_PHY_SET(mac, BWN_NPHY_TXPCTL_CMD, BWN_NPHY_TXPCTL_CMD_PCTLEN); if (bhnd_get_hwrev(sc->sc_dev) == 11 || bhnd_get_hwrev(sc->sc_dev) == 12) BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~0x200000, 0); /* * XXX TODO: see if those bandsbelow map to 5g-lo, 5g-mid, 5g-hi in * any way. */ if (sc->sc_board_info.board_srom_rev < 4) { idle[0] = nphy->pwr_ctl_info[0].idle_tssi_2g; idle[1] = nphy->pwr_ctl_info[1].idle_tssi_2g; target[0] = target[1] = 52; a1[0] = a1[1] = -424; b0[0] = b0[1] = 5612; b1[0] = b1[1] = -1393; } else { if (bwn_current_band(mac) == BWN_BAND_2G) { for (c = 0; c < 2; c++) { idle[c] = nphy->pwr_ctl_info[c].idle_tssi_2g; target[c] = core_pwr_info[c].maxpwr_2g; a1[c] = core_pwr_info[c].pa_2g[0]; b0[c] = core_pwr_info[c].pa_2g[1]; b1[c] = core_pwr_info[c].pa_2g[2]; } } else if (freq >= 4900 && freq < 5100) { for (c = 0; c < 2; c++) { idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g; target[c] = core_pwr_info[c].maxpwr_5gl; a1[c] = core_pwr_info[c].pa_5gl[0]; b0[c] = core_pwr_info[c].pa_5gl[1]; b1[c] = core_pwr_info[c].pa_5gl[2]; } } else if (freq >= 5100 && freq < 5500) { for (c = 0; c < 2; c++) { idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g; target[c] = core_pwr_info[c].maxpwr_5g; a1[c] = core_pwr_info[c].pa_5g[0]; b0[c] = core_pwr_info[c].pa_5g[1]; b1[c] = core_pwr_info[c].pa_5g[2]; } } else if (freq >= 5500) { for (c = 0; c < 2; c++) { idle[c] = nphy->pwr_ctl_info[c].idle_tssi_5g; target[c] = core_pwr_info[c].maxpwr_5gh; a1[c] = core_pwr_info[c].pa_5gh[0]; b0[c] = core_pwr_info[c].pa_5gh[1]; b1[c] = core_pwr_info[c].pa_5gh[2]; } } else { idle[0] = nphy->pwr_ctl_info[0].idle_tssi_5g; idle[1] = nphy->pwr_ctl_info[1].idle_tssi_5g; target[0] = target[1] = 52; a1[0] = a1[1] = -424; b0[0] = b0[1] = 5612; b1[0] = b1[1] = -1393; } } ppr_max = bwn_ppr_get_max(mac, &nphy->tx_pwr_max_ppr); if (ppr_max) { target[0] = ppr_max; target[1] = ppr_max; } if (mac->mac_phy.rev >= 3) { if (nphy->tsspos_2g) BWN_PHY_SET(mac, BWN_NPHY_TXPCTL_ITSSI, 0x4000); if (mac->mac_phy.rev >= 7) { for (c = 0; c < 2; c++) { r = c ? 0x190 : 0x170; if (bwn_nphy_ipa(mac)) BWN_RF_WRITE(mac, r + 0x9, (bwn_current_band(mac) == BWN_BAND_2G) ? 0xE : 0xC); } } else { if (bwn_nphy_ipa(mac)) { tmp = (bwn_current_band(mac) == BWN_BAND_5G) ? 0xC : 0xE; BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_TX_SSI_MUX, tmp); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_TX_SSI_MUX, tmp); } else { BWN_RF_WRITE(mac, B2056_TX0 | B2056_TX_TX_SSI_MUX, 0x11); BWN_RF_WRITE(mac, B2056_TX1 | B2056_TX_TX_SSI_MUX, 0x11); } } } if (bhnd_get_hwrev(sc->sc_dev) == 11 || bhnd_get_hwrev(sc->sc_dev) == 12) { BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~0, 0x200000); BWN_READ_4(mac, BWN_MACCTL); DELAY(1); } if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_CMD, ~BWN_NPHY_TXPCTL_CMD_INIT, 0x19); BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_INIT, ~BWN_NPHY_TXPCTL_INIT_PIDXI1, 0x19); } else { BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_CMD, ~BWN_NPHY_TXPCTL_CMD_INIT, 0x40); if (mac->mac_phy.rev > 1) BWN_PHY_SETMASK(mac, BWN_NPHY_TXPCTL_INIT, ~BWN_NPHY_TXPCTL_INIT_PIDXI1, 0x40); } if (bhnd_get_hwrev(sc->sc_dev) == 11 || bhnd_get_hwrev(sc->sc_dev) == 12) BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~0x200000, 0); BWN_PHY_WRITE(mac, BWN_NPHY_TXPCTL_N, 0xF0 << BWN_NPHY_TXPCTL_N_TSSID_SHIFT | 3 << BWN_NPHY_TXPCTL_N_NPTIL2_SHIFT); BWN_PHY_WRITE(mac, BWN_NPHY_TXPCTL_ITSSI, idle[0] << BWN_NPHY_TXPCTL_ITSSI_0_SHIFT | idle[1] << BWN_NPHY_TXPCTL_ITSSI_1_SHIFT | BWN_NPHY_TXPCTL_ITSSI_BINF); BWN_PHY_WRITE(mac, BWN_NPHY_TXPCTL_TPWR, target[0] << BWN_NPHY_TXPCTL_TPWR_0_SHIFT | target[1] << BWN_NPHY_TXPCTL_TPWR_1_SHIFT); for (c = 0; c < 2; c++) { for (i = 0; i < 64; i++) { num = 8 * (16 * b0[c] + b1[c] * i); den = 32768 + a1[c] * i; pwr = max((4 * num + den / 2) / den, -8); if (mac->mac_phy.rev < 3 && (i <= (31 - idle[c] + 1))) pwr = max(pwr, target[c] + 1); regval[i] = pwr; } bwn_ntab_write_bulk(mac, BWN_NTAB32(26 + c, 0), 64, regval); } bwn_nphy_tx_prepare_adjusted_power_table(mac); bwn_ntab_write_bulk(mac, BWN_NTAB16(26, 64), 84, nphy->adj_pwr_tbl); bwn_ntab_write_bulk(mac, BWN_NTAB16(27, 64), 84, nphy->adj_pwr_tbl); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, false); } static void bwn_nphy_tx_gain_table_upload(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; const uint32_t *table = NULL; uint32_t rfpwr_offset; uint8_t pga_gain, pad_gain; int i; const int16_t *rf_pwr_offset_table = NULL; table = bwn_nphy_get_tx_gain_table(mac); if (!table) return; bwn_ntab_write_bulk(mac, BWN_NTAB32(26, 192), 128, table); bwn_ntab_write_bulk(mac, BWN_NTAB32(27, 192), 128, table); if (phy->rev < 3) return; #if 0 nphy->gmval = (table[0] >> 16) & 0x7000; #endif if (phy->rev >= 19) { return; } else if (phy->rev >= 7) { rf_pwr_offset_table = bwn_ntab_get_rf_pwr_offset_table(mac); if (!rf_pwr_offset_table) return; /* TODO: Enable this once we have gains configured */ return; } for (i = 0; i < 128; i++) { if (phy->rev >= 19) { /* TODO */ return; } else if (phy->rev >= 7) { pga_gain = (table[i] >> 24) & 0xf; pad_gain = (table[i] >> 19) & 0x1f; if (bwn_current_band(mac) == BWN_BAND_2G) rfpwr_offset = rf_pwr_offset_table[pad_gain]; else rfpwr_offset = rf_pwr_offset_table[pga_gain]; } else { pga_gain = (table[i] >> 24) & 0xF; if (bwn_current_band(mac) == BWN_BAND_2G) rfpwr_offset = bwn_ntab_papd_pga_gain_delta_ipa_2g[pga_gain]; else rfpwr_offset = 0; /* FIXME */ } bwn_ntab_write(mac, BWN_NTAB32(26, 576 + i), rfpwr_offset); bwn_ntab_write(mac, BWN_NTAB32(27, 576 + i), rfpwr_offset); } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/PA%20override */ static void bwn_nphy_pa_override(struct bwn_mac *mac, bool enable) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; bwn_band_t band; uint16_t tmp; if (!enable) { nphy->rfctrl_intc1_save = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC1); nphy->rfctrl_intc2_save = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC2); band = bwn_current_band(mac); if (mac->mac_phy.rev >= 7) { tmp = 0x1480; } else if (mac->mac_phy.rev >= 3) { if (band == BWN_BAND_5G) tmp = 0x600; else tmp = 0x480; } else { if (band == BWN_BAND_5G) tmp = 0x180; else tmp = 0x120; } BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, tmp); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, tmp); } else { BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, nphy->rfctrl_intc1_save); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, nphy->rfctrl_intc2_save); } } /* * TX low-pass filter bandwidth setup * http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxLpFbw */ static void bwn_nphy_tx_lpf_bw(struct bwn_mac *mac) { uint16_t tmp; if (mac->mac_phy.rev < 3 || mac->mac_phy.rev >= 7) return; if (bwn_nphy_ipa(mac)) tmp = bwn_is_40mhz(mac) ? 5 : 4; else tmp = bwn_is_40mhz(mac) ? 3 : 1; BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B32S2, (tmp << 9) | (tmp << 6) | (tmp << 3) | tmp); if (bwn_nphy_ipa(mac)) { tmp = bwn_is_40mhz(mac) ? 4 : 1; BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B1S2, (tmp << 9) | (tmp << 6) | (tmp << 3) | tmp); } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */ static void bwn_nphy_rx_iq_est(struct bwn_mac *mac, struct bwn_nphy_iq_est *est, uint16_t samps, uint8_t time, bool wait) { int i; uint16_t tmp; BWN_PHY_WRITE(mac, BWN_NPHY_IQEST_SAMCNT, samps); BWN_PHY_SETMASK(mac, BWN_NPHY_IQEST_WT, ~BWN_NPHY_IQEST_WT_VAL, time); if (wait) BWN_PHY_SET(mac, BWN_NPHY_IQEST_CMD, BWN_NPHY_IQEST_CMD_MODE); else BWN_PHY_MASK(mac, BWN_NPHY_IQEST_CMD, ~BWN_NPHY_IQEST_CMD_MODE); BWN_PHY_SET(mac, BWN_NPHY_IQEST_CMD, BWN_NPHY_IQEST_CMD_START); for (i = 1000; i; i--) { tmp = BWN_PHY_READ(mac, BWN_NPHY_IQEST_CMD); if (!(tmp & BWN_NPHY_IQEST_CMD_START)) { est->i0_pwr = (BWN_PHY_READ(mac, BWN_NPHY_IQEST_IPACC_HI0) << 16) | BWN_PHY_READ(mac, BWN_NPHY_IQEST_IPACC_LO0); est->q0_pwr = (BWN_PHY_READ(mac, BWN_NPHY_IQEST_QPACC_HI0) << 16) | BWN_PHY_READ(mac, BWN_NPHY_IQEST_QPACC_LO0); est->iq0_prod = (BWN_PHY_READ(mac, BWN_NPHY_IQEST_IQACC_HI0) << 16) | BWN_PHY_READ(mac, BWN_NPHY_IQEST_IQACC_LO0); est->i1_pwr = (BWN_PHY_READ(mac, BWN_NPHY_IQEST_IPACC_HI1) << 16) | BWN_PHY_READ(mac, BWN_NPHY_IQEST_IPACC_LO1); est->q1_pwr = (BWN_PHY_READ(mac, BWN_NPHY_IQEST_QPACC_HI1) << 16) | BWN_PHY_READ(mac, BWN_NPHY_IQEST_QPACC_LO1); est->iq1_prod = (BWN_PHY_READ(mac, BWN_NPHY_IQEST_IQACC_HI1) << 16) | BWN_PHY_READ(mac, BWN_NPHY_IQEST_IQACC_LO1); return; } DELAY(10); } memset(est, 0, sizeof(*est)); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqCoeffs */ static void bwn_nphy_rx_iq_coeffs(struct bwn_mac *mac, bool write, struct bwn_phy_n_iq_comp *pcomp) { if (write) { BWN_PHY_WRITE(mac, BWN_NPHY_C1_RXIQ_COMPA0, pcomp->a0); BWN_PHY_WRITE(mac, BWN_NPHY_C1_RXIQ_COMPB0, pcomp->b0); BWN_PHY_WRITE(mac, BWN_NPHY_C2_RXIQ_COMPA1, pcomp->a1); BWN_PHY_WRITE(mac, BWN_NPHY_C2_RXIQ_COMPB1, pcomp->b1); } else { pcomp->a0 = BWN_PHY_READ(mac, BWN_NPHY_C1_RXIQ_COMPA0); pcomp->b0 = BWN_PHY_READ(mac, BWN_NPHY_C1_RXIQ_COMPB0); pcomp->a1 = BWN_PHY_READ(mac, BWN_NPHY_C2_RXIQ_COMPA1); pcomp->b1 = BWN_PHY_READ(mac, BWN_NPHY_C2_RXIQ_COMPB1); } } #if 0 /* Ready but not used anywhere */ /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhyCleanup */ static void bwn_nphy_rx_cal_phy_cleanup(struct bwn_mac *mac, uint8_t core) { uint16_t *regs = mac->mac_phy.phy_n->tx_rx_cal_phy_saveregs; BWN_PHY_WRITE(mac, BWN_NPHY_RFSEQCA, regs[0]); if (core == 0) { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C1, regs[1]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER1, regs[2]); } else { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C2, regs[1]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, regs[2]); } BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, regs[3]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, regs[4]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_RSSIO1, regs[5]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_RSSIO2, regs[6]); BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B1S1, regs[7]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_OVER, regs[8]); BWN_PHY_WRITE(mac, BWN_NPHY_PAPD_EN0, regs[9]); BWN_PHY_WRITE(mac, BWN_NPHY_PAPD_EN1, regs[10]); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhySetup */ static void bwn_nphy_rx_cal_phy_setup(struct bwn_mac *mac, uint8_t core) { uint8_t rxval, txval; uint16_t *regs = mac->mac_phy.phy_n->tx_rx_cal_phy_saveregs; regs[0] = BWN_PHY_READ(mac, BWN_NPHY_RFSEQCA); if (core == 0) { regs[1] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C1); regs[2] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER1); } else { regs[1] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C2); regs[2] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER); } regs[3] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC1); regs[4] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC2); regs[5] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_RSSIO1); regs[6] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_RSSIO2); regs[7] = BWN_PHY_READ(mac, BWN_NPHY_TXF_40CO_B1S1); regs[8] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_OVER); regs[9] = BWN_PHY_READ(mac, BWN_NPHY_PAPD_EN0); regs[10] = BWN_PHY_READ(mac, BWN_NPHY_PAPD_EN1); BWN_PHY_MASK(mac, BWN_NPHY_PAPD_EN0, ~0x0001); BWN_PHY_MASK(mac, BWN_NPHY_PAPD_EN1, ~0x0001); BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~BWN_NPHY_RFSEQCA_RXDIS & 0xFFFF, ((1 - core) << BWN_NPHY_RFSEQCA_RXDIS_SHIFT)); BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~BWN_NPHY_RFSEQCA_TXEN, ((1 - core) << BWN_NPHY_RFSEQCA_TXEN_SHIFT)); BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~BWN_NPHY_RFSEQCA_RXEN, (core << BWN_NPHY_RFSEQCA_RXEN_SHIFT)); BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~BWN_NPHY_RFSEQCA_TXDIS, (core << BWN_NPHY_RFSEQCA_TXDIS_SHIFT)); if (core == 0) { BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C1, ~0x0007); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER1, 0x0007); } else { BWN_PHY_MASK(mac, BWN_NPHY_AFECTL_C2, ~0x0007); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x0007); } bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_PA, 0, 3); bwn_nphy_rf_ctl_override(mac, 8, 0, 3, false); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RX2TX); if (core == 0) { rxval = 1; txval = 8; } else { rxval = 4; txval = 2; } bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_TRSW, rxval, core + 1); bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_TRSW, txval, 2 - core); } #endif /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalcRxIqComp */ static void bwn_nphy_calc_rx_iq_comp(struct bwn_mac *mac, uint8_t mask) { int i; int32_t iq; uint32_t ii; uint32_t qq; int iq_nbits, qq_nbits; int arsh, brsh; uint16_t tmp, a, b; struct bwn_nphy_iq_est est; struct bwn_phy_n_iq_comp old; struct bwn_phy_n_iq_comp new = { }; bool error = false; if (mask == 0) return; bwn_nphy_rx_iq_coeffs(mac, false, &old); bwn_nphy_rx_iq_coeffs(mac, true, &new); bwn_nphy_rx_iq_est(mac, &est, 0x4000, 32, false); new = old; for (i = 0; i < 2; i++) { if (i == 0 && (mask & 1)) { iq = est.iq0_prod; ii = est.i0_pwr; qq = est.q0_pwr; } else if (i == 1 && (mask & 2)) { iq = est.iq1_prod; ii = est.i1_pwr; qq = est.q1_pwr; } else { continue; } if (ii + qq < 2) { error = true; break; } iq_nbits = fls(abs(iq)); qq_nbits = fls(qq); arsh = iq_nbits - 20; if (arsh >= 0) { a = -((iq << (30 - iq_nbits)) + (ii >> (1 + arsh))); tmp = ii >> arsh; } else { a = -((iq << (30 - iq_nbits)) + (ii << (-1 - arsh))); tmp = ii << -arsh; } if (tmp == 0) { error = true; break; } a /= tmp; brsh = qq_nbits - 11; if (brsh >= 0) { b = (qq << (31 - qq_nbits)); tmp = ii >> brsh; } else { b = (qq << (31 - qq_nbits)); tmp = ii << -brsh; } if (tmp == 0) { error = true; break; } b = bwn_sqrt(mac, b / tmp - a * a) - (1 << 10); if (i == 0 && (mask & 0x1)) { if (mac->mac_phy.rev >= 3) { new.a0 = a & 0x3FF; new.b0 = b & 0x3FF; } else { new.a0 = b & 0x3FF; new.b0 = a & 0x3FF; } } else if (i == 1 && (mask & 0x2)) { if (mac->mac_phy.rev >= 3) { new.a1 = a & 0x3FF; new.b1 = b & 0x3FF; } else { new.a1 = b & 0x3FF; new.b1 = a & 0x3FF; } } } if (error) new = old; bwn_nphy_rx_iq_coeffs(mac, true, &new); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxIqWar */ static void bwn_nphy_tx_iq_workaround(struct bwn_mac *mac) { uint16_t array[4]; bwn_ntab_read_bulk(mac, BWN_NTAB16(0xF, 0x50), 4, array); bwn_shm_write_2(mac, BWN_SHARED, BWN_SHM_SH_NPHY_TXIQW0, array[0]); bwn_shm_write_2(mac, BWN_SHARED, BWN_SHM_SH_NPHY_TXIQW1, array[1]); bwn_shm_write_2(mac, BWN_SHARED, BWN_SHM_SH_NPHY_TXIQW2, array[2]); bwn_shm_write_2(mac, BWN_SHARED, BWN_SHM_SH_NPHY_TXIQW3, array[3]); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SpurWar */ static void bwn_nphy_spur_workaround(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t channel = bwn_get_chan(mac); int tone[2] = { 57, 58 }; uint32_t noise[2] = { 0x3FF, 0x3FF }; if (mac->mac_phy.rev < 3) { BWN_ERRPRINTF(mac->mac_sc, "%s: phy rev %d out of range\n", __func__, mac->mac_phy.rev); } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); if (nphy->gband_spurwar_en) { /* TODO: N PHY Adjust Analog Pfbw (7) */ if (channel == 11 && bwn_is_40mhz(mac)) ; /* TODO: N PHY Adjust Min Noise Var(2, tone, noise)*/ else ; /* TODO: N PHY Adjust Min Noise Var(0, NULL, NULL)*/ /* TODO: N PHY Adjust CRS Min Power (0x1E) */ } if (nphy->aband_spurwar_en) { if (channel == 54) { tone[0] = 0x20; noise[0] = 0x25F; } else if (channel == 38 || channel == 102 || channel == 118) { if (0 /* FIXME */) { tone[0] = 0x20; noise[0] = 0x21F; } else { tone[0] = 0; noise[0] = 0; } } else if (channel == 134) { tone[0] = 0x20; noise[0] = 0x21F; } else if (channel == 151) { tone[0] = 0x10; noise[0] = 0x23F; } else if (channel == 153 || channel == 161) { tone[0] = 0x30; noise[0] = 0x23F; } else { tone[0] = 0; noise[0] = 0; } if (!tone[0] && !noise[0]) ; /* TODO: N PHY Adjust Min Noise Var(1, tone, noise)*/ else ; /* TODO: N PHY Adjust Min Noise Var(0, NULL, NULL)*/ } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */ static void bwn_nphy_tx_pwr_ctrl_coef_setup(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; int i, j; uint32_t tmp; uint32_t cur_real, cur_imag, real_part, imag_part; uint16_t buffer[7]; if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, true); bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 80), 7, buffer); for (i = 0; i < 2; i++) { tmp = ((buffer[i * 2] & 0x3FF) << 10) | (buffer[i * 2 + 1] & 0x3FF); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, (((i + 26) << 10) | 320)); for (j = 0; j < 128; j++) { BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATAHI, ((tmp >> 16) & 0xFFFF)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, (tmp & 0xFFFF)); } } for (i = 0; i < 2; i++) { tmp = buffer[5 + i]; real_part = (tmp >> 8) & 0xFF; imag_part = (tmp & 0xFF); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, (((i + 26) << 10) | 448)); if (mac->mac_phy.rev >= 3) { cur_real = real_part; cur_imag = imag_part; tmp = ((cur_real & 0xFF) << 8) | (cur_imag & 0xFF); } for (j = 0; j < 128; j++) { if (mac->mac_phy.rev < 3) { cur_real = (real_part * loscale[j] + 128) >> 8; cur_imag = (imag_part * loscale[j] + 128) >> 8; tmp = ((cur_real & 0xFF) << 8) | (cur_imag & 0xFF); } BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATAHI, ((tmp >> 16) & 0xFFFF)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, (tmp & 0xFFFF)); } } if (mac->mac_phy.rev >= 3) { bwn_shm_write_2(mac, BWN_SHARED, BWN_SHM_SH_NPHY_TXPWR_INDX0, 0xFFFF); bwn_shm_write_2(mac, BWN_SHARED, BWN_SHM_SH_NPHY_TXPWR_INDX1, 0xFFFF); } if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, false); } /* * Restore RSSI Calibration * http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreRssiCal */ static void bwn_nphy_restore_rssi_cal(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t *rssical_radio_regs = NULL; uint16_t *rssical_phy_regs = NULL; if (bwn_current_band(mac) == BWN_BAND_2G) { if (!nphy->rssical_chanspec_2G.center_freq) return; rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_2G; rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_2G; } else { if (!nphy->rssical_chanspec_5G.center_freq) return; rssical_radio_regs = nphy->rssical_cache.rssical_radio_regs_5G; rssical_phy_regs = nphy->rssical_cache.rssical_phy_regs_5G; } if (mac->mac_phy.rev >= 19) { /* TODO */ } else if (mac->mac_phy.rev >= 7) { BWN_RF_SETMASK(mac, R2057_NB_MASTER_CORE0, ~R2057_VCM_MASK, rssical_radio_regs[0]); BWN_RF_SETMASK(mac, R2057_NB_MASTER_CORE1, ~R2057_VCM_MASK, rssical_radio_regs[1]); } else { BWN_RF_SETMASK(mac, B2056_RX0 | B2056_RX_RSSI_MISC, 0xE3, rssical_radio_regs[0]); BWN_RF_SETMASK(mac, B2056_RX1 | B2056_RX_RSSI_MISC, 0xE3, rssical_radio_regs[1]); } BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_RSSI_Z, rssical_phy_regs[0]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_RSSI_Z, rssical_phy_regs[1]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_RSSI_Z, rssical_phy_regs[2]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_RSSI_Z, rssical_phy_regs[3]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_RSSI_X, rssical_phy_regs[4]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_RSSI_X, rssical_phy_regs[5]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_RSSI_X, rssical_phy_regs[6]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_RSSI_X, rssical_phy_regs[7]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0I_RSSI_Y, rssical_phy_regs[8]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_0Q_RSSI_Y, rssical_phy_regs[9]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1I_RSSI_Y, rssical_phy_regs[10]); BWN_PHY_WRITE(mac, BWN_NPHY_RSSIMC_1Q_RSSI_Y, rssical_phy_regs[11]); } static void bwn_nphy_tx_cal_radio_setup_rev19(struct bwn_mac *mac) { /* TODO */ } static void bwn_nphy_tx_cal_radio_setup_rev7(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t *save = nphy->tx_rx_cal_radio_saveregs; int core, off; uint16_t r, tmp; for (core = 0; core < 2; core++) { r = core ? 0x20 : 0; off = core * 11; save[off + 0] = BWN_RF_READ(mac, r + R2057_TX0_TX_SSI_MASTER); save[off + 1] = BWN_RF_READ(mac, r + R2057_TX0_IQCAL_VCM_HG); save[off + 2] = BWN_RF_READ(mac, r + R2057_TX0_IQCAL_IDAC); save[off + 3] = BWN_RF_READ(mac, r + R2057_TX0_TSSI_VCM); save[off + 4] = 0; save[off + 5] = BWN_RF_READ(mac, r + R2057_TX0_TX_SSI_MUX); if (phy->rf_rev != 5) save[off + 6] = BWN_RF_READ(mac, r + R2057_TX0_TSSIA); save[off + 7] = BWN_RF_READ(mac, r + R2057_TX0_TSSIG); save[off + 8] = BWN_RF_READ(mac, r + R2057_TX0_TSSI_MISC1); if (bwn_current_band(mac) == BWN_BAND_5G) { BWN_RF_WRITE(mac, r + R2057_TX0_TX_SSI_MASTER, 0xA); BWN_RF_WRITE(mac, r + R2057_TX0_IQCAL_VCM_HG, 0x43); BWN_RF_WRITE(mac, r + R2057_TX0_IQCAL_IDAC, 0x55); BWN_RF_WRITE(mac, r + R2057_TX0_TSSI_VCM, 0); BWN_RF_WRITE(mac, r + R2057_TX0_TSSIG, 0); if (nphy->use_int_tx_iq_lo_cal) { BWN_RF_WRITE(mac, r + R2057_TX0_TX_SSI_MUX, 0x4); tmp = true ? 0x31 : 0x21; /* TODO */ BWN_RF_WRITE(mac, r + R2057_TX0_TSSIA, tmp); } BWN_RF_WRITE(mac, r + R2057_TX0_TSSI_MISC1, 0x00); } else { BWN_RF_WRITE(mac, r + R2057_TX0_TX_SSI_MASTER, 0x6); BWN_RF_WRITE(mac, r + R2057_TX0_IQCAL_VCM_HG, 0x43); BWN_RF_WRITE(mac, r + R2057_TX0_IQCAL_IDAC, 0x55); BWN_RF_WRITE(mac, r + R2057_TX0_TSSI_VCM, 0); if (phy->rf_rev != 5) BWN_RF_WRITE(mac, r + R2057_TX0_TSSIA, 0); if (nphy->use_int_tx_iq_lo_cal) { BWN_RF_WRITE(mac, r + R2057_TX0_TX_SSI_MUX, 0x6); tmp = true ? 0x31 : 0x21; /* TODO */ BWN_RF_WRITE(mac, r + R2057_TX0_TSSIG, tmp); } BWN_RF_WRITE(mac, r + R2057_TX0_TSSI_MISC1, 0); } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalRadioSetup */ static void bwn_nphy_tx_cal_radio_setup(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t *save = nphy->tx_rx_cal_radio_saveregs; uint16_t tmp; uint8_t offset, i; if (phy->rev >= 19) { bwn_nphy_tx_cal_radio_setup_rev19(mac); } else if (phy->rev >= 7) { bwn_nphy_tx_cal_radio_setup_rev7(mac); } else if (phy->rev >= 3) { for (i = 0; i < 2; i++) { tmp = (i == 0) ? 0x2000 : 0x3000; offset = i * 11; save[offset + 0] = BWN_RF_READ(mac, B2055_CAL_RVARCTL); save[offset + 1] = BWN_RF_READ(mac, B2055_CAL_LPOCTL); save[offset + 2] = BWN_RF_READ(mac, B2055_CAL_TS); save[offset + 3] = BWN_RF_READ(mac, B2055_CAL_RCCALRTS); save[offset + 4] = BWN_RF_READ(mac, B2055_CAL_RCALRTS); save[offset + 5] = BWN_RF_READ(mac, B2055_PADDRV); save[offset + 6] = BWN_RF_READ(mac, B2055_XOCTL1); save[offset + 7] = BWN_RF_READ(mac, B2055_XOCTL2); save[offset + 8] = BWN_RF_READ(mac, B2055_XOREGUL); save[offset + 9] = BWN_RF_READ(mac, B2055_XOMISC); save[offset + 10] = BWN_RF_READ(mac, B2055_PLL_LFC1); if (bwn_current_band(mac) == BWN_BAND_5G) { BWN_RF_WRITE(mac, tmp | B2055_CAL_RVARCTL, 0x0A); BWN_RF_WRITE(mac, tmp | B2055_CAL_LPOCTL, 0x40); BWN_RF_WRITE(mac, tmp | B2055_CAL_TS, 0x55); BWN_RF_WRITE(mac, tmp | B2055_CAL_RCCALRTS, 0); BWN_RF_WRITE(mac, tmp | B2055_CAL_RCALRTS, 0); if (nphy->ipa5g_on) { BWN_RF_WRITE(mac, tmp | B2055_PADDRV, 4); BWN_RF_WRITE(mac, tmp | B2055_XOCTL1, 1); } else { BWN_RF_WRITE(mac, tmp | B2055_PADDRV, 0); BWN_RF_WRITE(mac, tmp | B2055_XOCTL1, 0x2F); } BWN_RF_WRITE(mac, tmp | B2055_XOCTL2, 0); } else { BWN_RF_WRITE(mac, tmp | B2055_CAL_RVARCTL, 0x06); BWN_RF_WRITE(mac, tmp | B2055_CAL_LPOCTL, 0x40); BWN_RF_WRITE(mac, tmp | B2055_CAL_TS, 0x55); BWN_RF_WRITE(mac, tmp | B2055_CAL_RCCALRTS, 0); BWN_RF_WRITE(mac, tmp | B2055_CAL_RCALRTS, 0); BWN_RF_WRITE(mac, tmp | B2055_XOCTL1, 0); if (nphy->ipa2g_on) { BWN_RF_WRITE(mac, tmp | B2055_PADDRV, 6); BWN_RF_WRITE(mac, tmp | B2055_XOCTL2, (mac->mac_phy.rev < 5) ? 0x11 : 0x01); } else { BWN_RF_WRITE(mac, tmp | B2055_PADDRV, 0); BWN_RF_WRITE(mac, tmp | B2055_XOCTL2, 0); } } BWN_RF_WRITE(mac, tmp | B2055_XOREGUL, 0); BWN_RF_WRITE(mac, tmp | B2055_XOMISC, 0); BWN_RF_WRITE(mac, tmp | B2055_PLL_LFC1, 0); } } else { save[0] = BWN_RF_READ(mac, B2055_C1_TX_RF_IQCAL1); BWN_RF_WRITE(mac, B2055_C1_TX_RF_IQCAL1, 0x29); save[1] = BWN_RF_READ(mac, B2055_C1_TX_RF_IQCAL2); BWN_RF_WRITE(mac, B2055_C1_TX_RF_IQCAL2, 0x54); save[2] = BWN_RF_READ(mac, B2055_C2_TX_RF_IQCAL1); BWN_RF_WRITE(mac, B2055_C2_TX_RF_IQCAL1, 0x29); save[3] = BWN_RF_READ(mac, B2055_C2_TX_RF_IQCAL2); BWN_RF_WRITE(mac, B2055_C2_TX_RF_IQCAL2, 0x54); save[3] = BWN_RF_READ(mac, B2055_C1_PWRDET_RXTX); save[4] = BWN_RF_READ(mac, B2055_C2_PWRDET_RXTX); if (!(BWN_PHY_READ(mac, BWN_NPHY_BANDCTL) & BWN_NPHY_BANDCTL_5GHZ)) { BWN_RF_WRITE(mac, B2055_C1_PWRDET_RXTX, 0x04); BWN_RF_WRITE(mac, B2055_C2_PWRDET_RXTX, 0x04); } else { BWN_RF_WRITE(mac, B2055_C1_PWRDET_RXTX, 0x20); BWN_RF_WRITE(mac, B2055_C2_PWRDET_RXTX, 0x20); } if (mac->mac_phy.rev < 2) { BWN_RF_SET(mac, B2055_C1_TX_BB_MXGM, 0x20); BWN_RF_SET(mac, B2055_C2_TX_BB_MXGM, 0x20); } else { BWN_RF_MASK(mac, B2055_C1_TX_BB_MXGM, ~0x20); BWN_RF_MASK(mac, B2055_C2_TX_BB_MXGM, ~0x20); } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/UpdateTxCalLadder */ static void bwn_nphy_update_tx_cal_ladder(struct bwn_mac *mac, uint16_t core) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; int i; uint16_t scale, entry; uint16_t tmp = nphy->txcal_bbmult; if (core == 0) tmp >>= 8; tmp &= 0xff; for (i = 0; i < 18; i++) { scale = (ladder_lo[i].percent * tmp) / 100; entry = ((scale & 0xFF) << 8) | ladder_lo[i].g_env; bwn_ntab_write(mac, BWN_NTAB16(15, i), entry); scale = (ladder_iq[i].percent * tmp) / 100; entry = ((scale & 0xFF) << 8) | ladder_iq[i].g_env; bwn_ntab_write(mac, BWN_NTAB16(15, i + 32), entry); } } static void bwn_nphy_pa_set_tx_dig_filter(struct bwn_mac *mac, uint16_t offset, const int16_t *filter) { int i; offset = BWN_PHY_N(offset); for (i = 0; i < 15; i++, offset++) BWN_PHY_WRITE(mac, offset, filter[i]); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ExtPaSetTxDigiFilts */ static void bwn_nphy_ext_pa_set_tx_dig_filters(struct bwn_mac *mac) { bwn_nphy_pa_set_tx_dig_filter(mac, 0x2C5, tbl_tx_filter_coef_rev4[2]); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/IpaSetTxDigiFilts */ static void bwn_nphy_int_pa_set_tx_dig_filters(struct bwn_mac *mac) { /* BWN_NPHY_TXF_20CO_S0A1, BWN_NPHY_TXF_40CO_S0A1, unknown */ static const uint16_t offset[] = { 0x186, 0x195, 0x2C5 }; static const int16_t dig_filter_phy_rev16[] = { -375, 136, -407, 208, -1527, 956, 93, 186, 93, 230, -44, 230, 201, -191, 201, }; int i; for (i = 0; i < 3; i++) bwn_nphy_pa_set_tx_dig_filter(mac, offset[i], tbl_tx_filter_coef_rev4[i]); /* Verified with BCM43227 and BCM43228 */ if (mac->mac_phy.rev == 16) bwn_nphy_pa_set_tx_dig_filter(mac, 0x186, dig_filter_phy_rev16); /* Verified with BCM43131 and BCM43217 */ if (mac->mac_phy.rev == 17) { bwn_nphy_pa_set_tx_dig_filter(mac, 0x186, dig_filter_phy_rev16); bwn_nphy_pa_set_tx_dig_filter(mac, 0x195, tbl_tx_filter_coef_rev4[1]); } if (bwn_is_40mhz(mac)) { bwn_nphy_pa_set_tx_dig_filter(mac, 0x186, tbl_tx_filter_coef_rev4[3]); } else { if (bwn_current_band(mac) == BWN_BAND_5G) bwn_nphy_pa_set_tx_dig_filter(mac, 0x186, tbl_tx_filter_coef_rev4[5]); if (bwn_get_chan(mac) == 14) bwn_nphy_pa_set_tx_dig_filter(mac, 0x186, tbl_tx_filter_coef_rev4[6]); } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetTxGain */ static struct bwn_nphy_txgains bwn_nphy_get_tx_gains(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t curr_gain[2]; struct bwn_nphy_txgains target; const uint32_t *table = NULL; if (!nphy->txpwrctrl) { int i; if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, true); bwn_ntab_read_bulk(mac, BWN_NTAB16(7, 0x110), 2, curr_gain); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, false); for (i = 0; i < 2; ++i) { if (mac->mac_phy.rev >= 7) { target.ipa[i] = curr_gain[i] & 0x0007; target.pad[i] = (curr_gain[i] & 0x00F8) >> 3; target.pga[i] = (curr_gain[i] & 0x0F00) >> 8; target.txgm[i] = (curr_gain[i] & 0x7000) >> 12; target.tx_lpf[i] = (curr_gain[i] & 0x8000) >> 15; } else if (mac->mac_phy.rev >= 3) { target.ipa[i] = curr_gain[i] & 0x000F; target.pad[i] = (curr_gain[i] & 0x00F0) >> 4; target.pga[i] = (curr_gain[i] & 0x0F00) >> 8; target.txgm[i] = (curr_gain[i] & 0x7000) >> 12; } else { target.ipa[i] = curr_gain[i] & 0x0003; target.pad[i] = (curr_gain[i] & 0x000C) >> 2; target.pga[i] = (curr_gain[i] & 0x0070) >> 4; target.txgm[i] = (curr_gain[i] & 0x0380) >> 7; } } } else { int i; uint16_t index[2]; index[0] = (BWN_PHY_READ(mac, BWN_NPHY_C1_TXPCTL_STAT) & BWN_NPHY_TXPCTL_STAT_BIDX) >> BWN_NPHY_TXPCTL_STAT_BIDX_SHIFT; index[1] = (BWN_PHY_READ(mac, BWN_NPHY_C2_TXPCTL_STAT) & BWN_NPHY_TXPCTL_STAT_BIDX) >> BWN_NPHY_TXPCTL_STAT_BIDX_SHIFT; for (i = 0; i < 2; ++i) { table = bwn_nphy_get_tx_gain_table(mac); if (!table) break; if (mac->mac_phy.rev >= 7) { target.ipa[i] = (table[index[i]] >> 16) & 0x7; target.pad[i] = (table[index[i]] >> 19) & 0x1F; target.pga[i] = (table[index[i]] >> 24) & 0xF; target.txgm[i] = (table[index[i]] >> 28) & 0x7; target.tx_lpf[i] = (table[index[i]] >> 31) & 0x1; } else if (mac->mac_phy.rev >= 3) { target.ipa[i] = (table[index[i]] >> 16) & 0xF; target.pad[i] = (table[index[i]] >> 20) & 0xF; target.pga[i] = (table[index[i]] >> 24) & 0xF; target.txgm[i] = (table[index[i]] >> 28) & 0xF; } else { target.ipa[i] = (table[index[i]] >> 16) & 0x3; target.pad[i] = (table[index[i]] >> 18) & 0x3; target.pga[i] = (table[index[i]] >> 20) & 0x7; target.txgm[i] = (table[index[i]] >> 23) & 0x7; } } } return target; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhyCleanup */ static void bwn_nphy_tx_cal_phy_cleanup(struct bwn_mac *mac) { uint16_t *regs = mac->mac_phy.phy_n->tx_rx_cal_phy_saveregs; if (mac->mac_phy.rev >= 3) { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C1, regs[0]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C2, regs[1]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER1, regs[2]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, regs[3]); BWN_PHY_WRITE(mac, BWN_NPHY_BBCFG, regs[4]); bwn_ntab_write(mac, BWN_NTAB16(8, 3), regs[5]); bwn_ntab_write(mac, BWN_NTAB16(8, 19), regs[6]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, regs[7]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, regs[8]); BWN_PHY_WRITE(mac, BWN_NPHY_PAPD_EN0, regs[9]); BWN_PHY_WRITE(mac, BWN_NPHY_PAPD_EN1, regs[10]); bwn_nphy_reset_cca(mac); } else { BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C1, 0x0FFF, regs[0]); BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C2, 0x0FFF, regs[1]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, regs[2]); bwn_ntab_write(mac, BWN_NTAB16(8, 2), regs[3]); bwn_ntab_write(mac, BWN_NTAB16(8, 18), regs[4]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, regs[5]); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, regs[6]); } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhySetup */ static void bwn_nphy_tx_cal_phy_setup(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t *regs = mac->mac_phy.phy_n->tx_rx_cal_phy_saveregs; uint16_t tmp; regs[0] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C1); regs[1] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_C2); if (mac->mac_phy.rev >= 3) { BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C1, 0xF0FF, 0x0A00); BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C2, 0xF0FF, 0x0A00); tmp = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER1); regs[2] = tmp; BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER1, tmp | 0x0600); tmp = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER); regs[3] = tmp; BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, tmp | 0x0600); regs[4] = BWN_PHY_READ(mac, BWN_NPHY_BBCFG); BWN_PHY_MASK(mac, BWN_NPHY_BBCFG, ~BWN_NPHY_BBCFG_RSTRX & 0xFFFF); tmp = bwn_ntab_read(mac, BWN_NTAB16(8, 3)); regs[5] = tmp; bwn_ntab_write(mac, BWN_NTAB16(8, 3), 0); tmp = bwn_ntab_read(mac, BWN_NTAB16(8, 19)); regs[6] = tmp; bwn_ntab_write(mac, BWN_NTAB16(8, 19), 0); regs[7] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC1); regs[8] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC2); if (!nphy->use_int_tx_iq_lo_cal) bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_PA, 1, 3); else bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_PA, 0, 3); bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_TRSW, 2, 1); bwn_nphy_rf_ctl_intc_override(mac, N_INTC_OVERRIDE_TRSW, 8, 2); regs[9] = BWN_PHY_READ(mac, BWN_NPHY_PAPD_EN0); regs[10] = BWN_PHY_READ(mac, BWN_NPHY_PAPD_EN1); BWN_PHY_MASK(mac, BWN_NPHY_PAPD_EN0, ~0x0001); BWN_PHY_MASK(mac, BWN_NPHY_PAPD_EN1, ~0x0001); tmp = bwn_nphy_read_lpf_ctl(mac, 0); if (phy->rev >= 19) bwn_nphy_rf_ctl_override_rev19(mac, 0x80, tmp, 0, false, 1); else if (phy->rev >= 7) bwn_nphy_rf_ctl_override_rev7(mac, 0x80, tmp, 0, false, 1); if (nphy->use_int_tx_iq_lo_cal && true /* FIXME */) { if (phy->rev >= 19) { bwn_nphy_rf_ctl_override_rev19(mac, 0x8, 0, 0x3, false, 0); } else if (phy->rev >= 8) { bwn_nphy_rf_ctl_override_rev7(mac, 0x8, 0, 0x3, false, 0); } else if (phy->rev == 7) { BWN_RF_SETMASK(mac, R2057_OVR_REG0, 1 << 4, 1 << 4); if (bwn_current_band(mac) == BWN_BAND_2G) { BWN_RF_SETMASK(mac, R2057_PAD2G_TUNE_PUS_CORE0, ~1, 0); BWN_RF_SETMASK(mac, R2057_PAD2G_TUNE_PUS_CORE1, ~1, 0); } else { BWN_RF_SETMASK(mac, R2057_IPA5G_CASCOFFV_PU_CORE0, ~1, 0); BWN_RF_SETMASK(mac, R2057_IPA5G_CASCOFFV_PU_CORE1, ~1, 0); } } } } else { BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C1, 0x0FFF, 0xA000); BWN_PHY_SETMASK(mac, BWN_NPHY_AFECTL_C2, 0x0FFF, 0xA000); tmp = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER); regs[2] = tmp; BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, tmp | 0x3000); tmp = bwn_ntab_read(mac, BWN_NTAB16(8, 2)); regs[3] = tmp; tmp |= 0x2000; bwn_ntab_write(mac, BWN_NTAB16(8, 2), tmp); tmp = bwn_ntab_read(mac, BWN_NTAB16(8, 18)); regs[4] = tmp; tmp |= 0x2000; bwn_ntab_write(mac, BWN_NTAB16(8, 18), tmp); regs[5] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC1); regs[6] = BWN_PHY_READ(mac, BWN_NPHY_RFCTL_INTC2); if (bwn_current_band(mac) == BWN_BAND_5G) tmp = 0x0180; else tmp = 0x0120; BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, tmp); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, tmp); } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SaveCal */ static void bwn_nphy_save_cal(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; struct bwn_phy_n_iq_comp *rxcal_coeffs = NULL; uint16_t *txcal_radio_regs = NULL; struct bwn_chanspec *iqcal_chanspec; uint16_t *table = NULL; if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 1); if (bwn_current_band(mac) == BWN_BAND_2G) { rxcal_coeffs = &nphy->cal_cache.rxcal_coeffs_2G; txcal_radio_regs = nphy->cal_cache.txcal_radio_regs_2G; iqcal_chanspec = &nphy->iqcal_chanspec_2G; table = nphy->cal_cache.txcal_coeffs_2G; } else { rxcal_coeffs = &nphy->cal_cache.rxcal_coeffs_5G; txcal_radio_regs = nphy->cal_cache.txcal_radio_regs_5G; iqcal_chanspec = &nphy->iqcal_chanspec_5G; table = nphy->cal_cache.txcal_coeffs_5G; } bwn_nphy_rx_iq_coeffs(mac, false, rxcal_coeffs); /* TODO use some definitions */ if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { txcal_radio_regs[0] = BWN_RF_READ(mac, R2057_TX0_LOFT_FINE_I); txcal_radio_regs[1] = BWN_RF_READ(mac, R2057_TX0_LOFT_FINE_Q); txcal_radio_regs[4] = BWN_RF_READ(mac, R2057_TX0_LOFT_COARSE_I); txcal_radio_regs[5] = BWN_RF_READ(mac, R2057_TX0_LOFT_COARSE_Q); txcal_radio_regs[2] = BWN_RF_READ(mac, R2057_TX1_LOFT_FINE_I); txcal_radio_regs[3] = BWN_RF_READ(mac, R2057_TX1_LOFT_FINE_Q); txcal_radio_regs[6] = BWN_RF_READ(mac, R2057_TX1_LOFT_COARSE_I); txcal_radio_regs[7] = BWN_RF_READ(mac, R2057_TX1_LOFT_COARSE_Q); } else if (phy->rev >= 3) { txcal_radio_regs[0] = BWN_RF_READ(mac, 0x2021); txcal_radio_regs[1] = BWN_RF_READ(mac, 0x2022); txcal_radio_regs[2] = BWN_RF_READ(mac, 0x3021); txcal_radio_regs[3] = BWN_RF_READ(mac, 0x3022); txcal_radio_regs[4] = BWN_RF_READ(mac, 0x2023); txcal_radio_regs[5] = BWN_RF_READ(mac, 0x2024); txcal_radio_regs[6] = BWN_RF_READ(mac, 0x3023); txcal_radio_regs[7] = BWN_RF_READ(mac, 0x3024); } else { txcal_radio_regs[0] = BWN_RF_READ(mac, 0x8B); txcal_radio_regs[1] = BWN_RF_READ(mac, 0xBA); txcal_radio_regs[2] = BWN_RF_READ(mac, 0x8D); txcal_radio_regs[3] = BWN_RF_READ(mac, 0xBC); } iqcal_chanspec->center_freq = bwn_get_centre_freq(mac); iqcal_chanspec->channel_type = bwn_get_chan_type(mac, NULL); bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 80), 8, table); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, 0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreCal */ static void bwn_nphy_restore_cal(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint16_t coef[4]; uint16_t *loft = NULL; uint16_t *table = NULL; int i; uint16_t *txcal_radio_regs = NULL; struct bwn_phy_n_iq_comp *rxcal_coeffs = NULL; if (bwn_current_band(mac) == BWN_BAND_2G) { if (!nphy->iqcal_chanspec_2G.center_freq) return; table = nphy->cal_cache.txcal_coeffs_2G; loft = &nphy->cal_cache.txcal_coeffs_2G[5]; } else { if (!nphy->iqcal_chanspec_5G.center_freq) return; table = nphy->cal_cache.txcal_coeffs_5G; loft = &nphy->cal_cache.txcal_coeffs_5G[5]; } bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 80), 4, table); for (i = 0; i < 4; i++) { if (mac->mac_phy.rev >= 3) table[i] = coef[i]; else coef[i] = 0; } bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 88), 4, coef); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 85), 2, loft); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 93), 2, loft); if (mac->mac_phy.rev < 2) bwn_nphy_tx_iq_workaround(mac); if (bwn_current_band(mac) == BWN_BAND_2G) { txcal_radio_regs = nphy->cal_cache.txcal_radio_regs_2G; rxcal_coeffs = &nphy->cal_cache.rxcal_coeffs_2G; } else { txcal_radio_regs = nphy->cal_cache.txcal_radio_regs_5G; rxcal_coeffs = &nphy->cal_cache.rxcal_coeffs_5G; } /* TODO use some definitions */ if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { BWN_RF_WRITE(mac, R2057_TX0_LOFT_FINE_I, txcal_radio_regs[0]); BWN_RF_WRITE(mac, R2057_TX0_LOFT_FINE_Q, txcal_radio_regs[1]); BWN_RF_WRITE(mac, R2057_TX0_LOFT_COARSE_I, txcal_radio_regs[4]); BWN_RF_WRITE(mac, R2057_TX0_LOFT_COARSE_Q, txcal_radio_regs[5]); BWN_RF_WRITE(mac, R2057_TX1_LOFT_FINE_I, txcal_radio_regs[2]); BWN_RF_WRITE(mac, R2057_TX1_LOFT_FINE_Q, txcal_radio_regs[3]); BWN_RF_WRITE(mac, R2057_TX1_LOFT_COARSE_I, txcal_radio_regs[6]); BWN_RF_WRITE(mac, R2057_TX1_LOFT_COARSE_Q, txcal_radio_regs[7]); } else if (phy->rev >= 3) { BWN_RF_WRITE(mac, 0x2021, txcal_radio_regs[0]); BWN_RF_WRITE(mac, 0x2022, txcal_radio_regs[1]); BWN_RF_WRITE(mac, 0x3021, txcal_radio_regs[2]); BWN_RF_WRITE(mac, 0x3022, txcal_radio_regs[3]); BWN_RF_WRITE(mac, 0x2023, txcal_radio_regs[4]); BWN_RF_WRITE(mac, 0x2024, txcal_radio_regs[5]); BWN_RF_WRITE(mac, 0x3023, txcal_radio_regs[6]); BWN_RF_WRITE(mac, 0x3024, txcal_radio_regs[7]); } else { BWN_RF_WRITE(mac, 0x8B, txcal_radio_regs[0]); BWN_RF_WRITE(mac, 0xBA, txcal_radio_regs[1]); BWN_RF_WRITE(mac, 0x8D, txcal_radio_regs[2]); BWN_RF_WRITE(mac, 0xBC, txcal_radio_regs[3]); } bwn_nphy_rx_iq_coeffs(mac, true, rxcal_coeffs); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalTxIqlo */ static int bwn_nphy_cal_tx_iq_lo(struct bwn_mac *mac, struct bwn_nphy_txgains target, bool full, bool mphase) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; int i; int error = 0; int freq; bool avoid = false; uint8_t length; uint16_t tmp, core, type, count, max, numb, last = 0, cmd; const uint16_t *table; bool phy6or5x; uint16_t buffer[11]; uint16_t diq_start = 0; uint16_t save[2]; uint16_t gain[2]; struct bwn_nphy_iqcal_params params[2]; bool updated[2] = { }; bwn_nphy_stay_in_carrier_search(mac, true); if (mac->mac_phy.rev >= 4) { avoid = nphy->hang_avoid; nphy->hang_avoid = false; } bwn_ntab_read_bulk(mac, BWN_NTAB16(7, 0x110), 2, save); for (i = 0; i < 2; i++) { bwn_nphy_iq_cal_gain_params(mac, i, target, ¶ms[i]); gain[i] = params[i].cal_gain; } bwn_ntab_write_bulk(mac, BWN_NTAB16(7, 0x110), 2, gain); bwn_nphy_tx_cal_radio_setup(mac); bwn_nphy_tx_cal_phy_setup(mac); phy6or5x = mac->mac_phy.rev >= 6 || (mac->mac_phy.rev == 5 && nphy->ipa2g_on && bwn_current_band(mac) == BWN_BAND_2G); if (phy6or5x) { if (bwn_is_40mhz(mac)) { bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 0), 18, tbl_tx_iqlo_cal_loft_ladder_40); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 32), 18, tbl_tx_iqlo_cal_iqimb_ladder_40); } else { bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 0), 18, tbl_tx_iqlo_cal_loft_ladder_20); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 32), 18, tbl_tx_iqlo_cal_iqimb_ladder_20); } } if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { BWN_PHY_WRITE(mac, BWN_NPHY_IQLOCAL_CMDGCTL, 0x8AD9); } else { BWN_PHY_WRITE(mac, BWN_NPHY_IQLOCAL_CMDGCTL, 0x8AA9); } if (!bwn_is_40mhz(mac)) freq = 2500; else freq = 5000; if (nphy->mphase_cal_phase_id > 2) bwn_nphy_run_samples(mac, (bwn_is_40mhz(mac) ? 40 : 20) * 8, 0xFFFF, 0, true, false, false); else error = bwn_nphy_tx_tone(mac, freq, 250, true, false, false); if (error == 0) { if (nphy->mphase_cal_phase_id > 2) { table = nphy->mphase_txcal_bestcoeffs; length = 11; if (mac->mac_phy.rev < 3) length -= 2; } else { if (!full && nphy->txiqlocal_coeffsvalid) { table = nphy->txiqlocal_bestc; length = 11; if (mac->mac_phy.rev < 3) length -= 2; } else { full = true; if (mac->mac_phy.rev >= 3) { table = tbl_tx_iqlo_cal_startcoefs_nphyrev3; length = BWN_NTAB_TX_IQLO_CAL_STARTCOEFS_REV3; } else { table = tbl_tx_iqlo_cal_startcoefs; length = BWN_NTAB_TX_IQLO_CAL_STARTCOEFS; } } } bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 64), length, table); if (full) { if (mac->mac_phy.rev >= 3) max = BWN_NTAB_TX_IQLO_CAL_CMDS_FULLCAL_REV3; else max = BWN_NTAB_TX_IQLO_CAL_CMDS_FULLCAL; } else { if (mac->mac_phy.rev >= 3) max = BWN_NTAB_TX_IQLO_CAL_CMDS_RECAL_REV3; else max = BWN_NTAB_TX_IQLO_CAL_CMDS_RECAL; } if (mphase) { count = nphy->mphase_txcal_cmdidx; numb = min(max, (uint16_t)(count + nphy->mphase_txcal_numcmds)); } else { count = 0; numb = max; } for (; count < numb; count++) { if (full) { if (mac->mac_phy.rev >= 3) cmd = tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[count]; else cmd = tbl_tx_iqlo_cal_cmds_fullcal[count]; } else { if (mac->mac_phy.rev >= 3) cmd = tbl_tx_iqlo_cal_cmds_recal_nphyrev3[count]; else cmd = tbl_tx_iqlo_cal_cmds_recal[count]; } core = (cmd & 0x3000) >> 12; type = (cmd & 0x0F00) >> 8; if (phy6or5x && updated[core] == 0) { bwn_nphy_update_tx_cal_ladder(mac, core); updated[core] = true; } tmp = (params[core].ncorr[type] << 8) | 0x66; BWN_PHY_WRITE(mac, BWN_NPHY_IQLOCAL_CMDNNUM, tmp); if (type == 1 || type == 3 || type == 4) { buffer[0] = bwn_ntab_read(mac, BWN_NTAB16(15, 69 + core)); diq_start = buffer[0]; buffer[0] = 0; bwn_ntab_write(mac, BWN_NTAB16(15, 69 + core), 0); } BWN_PHY_WRITE(mac, BWN_NPHY_IQLOCAL_CMD, cmd); for (i = 0; i < 2000; i++) { tmp = BWN_PHY_READ(mac, BWN_NPHY_IQLOCAL_CMD); if (tmp & 0xC000) break; DELAY(10); } bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 96), length, buffer); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 64), length, buffer); if (type == 1 || type == 3 || type == 4) buffer[0] = diq_start; } if (mphase) nphy->mphase_txcal_cmdidx = (numb >= max) ? 0 : numb; last = (mac->mac_phy.rev < 3) ? 6 : 7; if (!mphase || nphy->mphase_cal_phase_id == last) { bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 96), 4, buffer); bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 80), 4, buffer); if (mac->mac_phy.rev < 3) { buffer[0] = 0; buffer[1] = 0; buffer[2] = 0; buffer[3] = 0; } bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 88), 4, buffer); bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 101), 2, buffer); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 85), 2, buffer); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 93), 2, buffer); length = 11; if (mac->mac_phy.rev < 3) length -= 2; bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 96), length, nphy->txiqlocal_bestc); nphy->txiqlocal_coeffsvalid = true; nphy->txiqlocal_chanspec.center_freq = bwn_get_centre_freq(mac); nphy->txiqlocal_chanspec.channel_type = bwn_get_chan_type(mac, NULL); } else { length = 11; if (mac->mac_phy.rev < 3) length -= 2; bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 96), length, nphy->mphase_txcal_bestcoeffs); } bwn_nphy_stop_playback(mac); BWN_PHY_WRITE(mac, BWN_NPHY_IQLOCAL_CMDGCTL, 0); } bwn_nphy_tx_cal_phy_cleanup(mac); bwn_ntab_write_bulk(mac, BWN_NTAB16(7, 0x110), 2, save); if (mac->mac_phy.rev < 2 && (!mphase || nphy->mphase_cal_phase_id == last)) bwn_nphy_tx_iq_workaround(mac); if (mac->mac_phy.rev >= 4) nphy->hang_avoid = avoid; bwn_nphy_stay_in_carrier_search(mac, false); return error; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ReapplyTxCalCoeffs */ static void bwn_nphy_reapply_tx_cal_coeffs(struct bwn_mac *mac) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; uint8_t i; uint16_t buffer[7]; bool equal = true; if (!nphy->txiqlocal_coeffsvalid || nphy->txiqlocal_chanspec.center_freq != bwn_get_centre_freq(mac) || nphy->txiqlocal_chanspec.channel_type != bwn_get_chan_type(mac, NULL)) return; bwn_ntab_read_bulk(mac, BWN_NTAB16(15, 80), 7, buffer); for (i = 0; i < 4; i++) { if (buffer[i] != nphy->txiqlocal_bestc[i]) { equal = false; break; } } if (!equal) { bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 80), 4, nphy->txiqlocal_bestc); for (i = 0; i < 4; i++) buffer[i] = 0; bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 88), 4, buffer); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 85), 2, &nphy->txiqlocal_bestc[5]); bwn_ntab_write_bulk(mac, BWN_NTAB16(15, 93), 2, &nphy->txiqlocal_bestc[5]); } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIqRev2 */ static int bwn_nphy_rev2_cal_rx_iq(struct bwn_mac *mac, struct bwn_nphy_txgains target, uint8_t type, bool debug) { struct bwn_phy_n *nphy = mac->mac_phy.phy_n; int i, j, index; uint8_t rfctl[2]; uint8_t afectl_core; uint16_t tmp[6]; uint16_t cur_hpf1, cur_hpf2, cur_lna; uint32_t real, imag; bwn_band_t band; uint8_t use; uint16_t cur_hpf; uint16_t lna[3] = { 3, 3, 1 }; uint16_t hpf1[3] = { 7, 2, 0 }; uint16_t hpf2[3] = { 2, 0, 0 }; uint32_t power[3] = { }; uint16_t gain_save[2]; uint16_t cal_gain[2]; struct bwn_nphy_iqcal_params cal_params[2]; struct bwn_nphy_iq_est est; int ret = 0; bool playtone = true; int desired = 13; bwn_nphy_stay_in_carrier_search(mac, 1); if (mac->mac_phy.rev < 2) bwn_nphy_reapply_tx_cal_coeffs(mac); bwn_ntab_read_bulk(mac, BWN_NTAB16(7, 0x110), 2, gain_save); for (i = 0; i < 2; i++) { bwn_nphy_iq_cal_gain_params(mac, i, target, &cal_params[i]); cal_gain[i] = cal_params[i].cal_gain; } bwn_ntab_write_bulk(mac, BWN_NTAB16(7, 0x110), 2, cal_gain); for (i = 0; i < 2; i++) { if (i == 0) { rfctl[0] = BWN_NPHY_RFCTL_INTC1; rfctl[1] = BWN_NPHY_RFCTL_INTC2; afectl_core = BWN_NPHY_AFECTL_C1; } else { rfctl[0] = BWN_NPHY_RFCTL_INTC2; rfctl[1] = BWN_NPHY_RFCTL_INTC1; afectl_core = BWN_NPHY_AFECTL_C2; } tmp[1] = BWN_PHY_READ(mac, BWN_NPHY_RFSEQCA); tmp[2] = BWN_PHY_READ(mac, afectl_core); tmp[3] = BWN_PHY_READ(mac, BWN_NPHY_AFECTL_OVER); tmp[4] = BWN_PHY_READ(mac, rfctl[0]); tmp[5] = BWN_PHY_READ(mac, rfctl[1]); BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~BWN_NPHY_RFSEQCA_RXDIS & 0xFFFF, ((1 - i) << BWN_NPHY_RFSEQCA_RXDIS_SHIFT)); BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~BWN_NPHY_RFSEQCA_TXEN, (1 - i)); BWN_PHY_SET(mac, afectl_core, 0x0006); BWN_PHY_SET(mac, BWN_NPHY_AFECTL_OVER, 0x0006); band = bwn_current_band(mac); if (nphy->rxcalparams & 0xFF000000) { if (band == BWN_BAND_5G) BWN_PHY_WRITE(mac, rfctl[0], 0x140); else BWN_PHY_WRITE(mac, rfctl[0], 0x110); } else { if (band == BWN_BAND_5G) BWN_PHY_WRITE(mac, rfctl[0], 0x180); else BWN_PHY_WRITE(mac, rfctl[0], 0x120); } if (band == BWN_BAND_5G) BWN_PHY_WRITE(mac, rfctl[1], 0x148); else BWN_PHY_WRITE(mac, rfctl[1], 0x114); if (nphy->rxcalparams & 0x10000) { BWN_RF_SETMASK(mac, B2055_C1_GENSPARE2, 0xFC, (i + 1)); BWN_RF_SETMASK(mac, B2055_C2_GENSPARE2, 0xFC, (2 - i)); } for (j = 0; j < 4; j++) { if (j < 3) { cur_lna = lna[j]; cur_hpf1 = hpf1[j]; cur_hpf2 = hpf2[j]; } else { if (power[1] > 10000) { use = 1; cur_hpf = cur_hpf1; index = 2; } else { if (power[0] > 10000) { use = 1; cur_hpf = cur_hpf1; index = 1; } else { index = 0; use = 2; cur_hpf = cur_hpf2; } } cur_lna = lna[index]; cur_hpf1 = hpf1[index]; cur_hpf2 = hpf2[index]; cur_hpf += desired - bwn_hweight32(power[index]); cur_hpf = bwn_clamp_val(cur_hpf, 0, 10); if (use == 1) cur_hpf1 = cur_hpf; else cur_hpf2 = cur_hpf; } tmp[0] = ((cur_hpf2 << 8) | (cur_hpf1 << 4) | (cur_lna << 2)); bwn_nphy_rf_ctl_override(mac, 0x400, tmp[0], 3, false); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); bwn_nphy_stop_playback(mac); if (playtone) { ret = bwn_nphy_tx_tone(mac, 4000, (nphy->rxcalparams & 0xFFFF), false, false, true); playtone = false; } else { bwn_nphy_run_samples(mac, 160, 0xFFFF, 0, false, false, true); } if (ret == 0) { if (j < 3) { bwn_nphy_rx_iq_est(mac, &est, 1024, 32, false); if (i == 0) { real = est.i0_pwr; imag = est.q0_pwr; } else { real = est.i1_pwr; imag = est.q1_pwr; } power[i] = ((real + imag) / 1024) + 1; } else { bwn_nphy_calc_rx_iq_comp(mac, 1 << i); } bwn_nphy_stop_playback(mac); } if (ret != 0) break; } BWN_RF_MASK(mac, B2055_C1_GENSPARE2, 0xFC); BWN_RF_MASK(mac, B2055_C2_GENSPARE2, 0xFC); BWN_PHY_WRITE(mac, rfctl[1], tmp[5]); BWN_PHY_WRITE(mac, rfctl[0], tmp[4]); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, tmp[3]); BWN_PHY_WRITE(mac, afectl_core, tmp[2]); BWN_PHY_WRITE(mac, BWN_NPHY_RFSEQCA, tmp[1]); if (ret != 0) break; } bwn_nphy_rf_ctl_override(mac, 0x400, 0, 3, true); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); bwn_ntab_write_bulk(mac, BWN_NTAB16(7, 0x110), 2, gain_save); bwn_nphy_stay_in_carrier_search(mac, 0); return ret; } static int bwn_nphy_rev3_cal_rx_iq(struct bwn_mac *mac, struct bwn_nphy_txgains target, uint8_t type, bool debug) { return -1; } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/CalRxIq */ static int bwn_nphy_cal_rx_iq(struct bwn_mac *mac, struct bwn_nphy_txgains target, uint8_t type, bool debug) { if (mac->mac_phy.rev >= 7) type = 0; if (mac->mac_phy.rev >= 3) return bwn_nphy_rev3_cal_rx_iq(mac, target, type, debug); else return bwn_nphy_rev2_cal_rx_iq(mac, target, type, debug); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCoreSetState */ static void bwn_nphy_set_rx_core_state(struct bwn_mac *mac, uint8_t mask) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = phy->phy_n; /* uint16_t buf[16]; it's rev3+ */ nphy->phyrxchain = mask; if (0 /* FIXME clk */) return; bwn_mac_suspend(mac); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, true); BWN_PHY_SETMASK(mac, BWN_NPHY_RFSEQCA, ~BWN_NPHY_RFSEQCA_RXEN, (mask & 0x3) << BWN_NPHY_RFSEQCA_RXEN_SHIFT); if ((mask & 0x3) != 0x3) { BWN_PHY_WRITE(mac, BWN_NPHY_HPANT_SWTHRES, 1); if (mac->mac_phy.rev >= 3) { /* TODO */ } } else { BWN_PHY_WRITE(mac, BWN_NPHY_HPANT_SWTHRES, 0x1E); if (mac->mac_phy.rev >= 3) { /* TODO */ } } bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); if (nphy->hang_avoid) bwn_nphy_stay_in_carrier_search(mac, false); bwn_mac_enable(mac); } bwn_txpwr_result_t bwn_nphy_op_recalc_txpower(struct bwn_mac *mac, bool ignore_tssi) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; struct ieee80211_channel *channel = bwn_get_channel(mac); struct bwn_softc *sc = mac->mac_sc; struct bwn_ppr *ppr = &nphy->tx_pwr_max_ppr; uint8_t max; /* qdBm */ - bool tx_pwr_state; if (nphy->tx_pwr_last_recalc_freq == bwn_get_centre_freq(mac) && nphy->tx_pwr_last_recalc_limit == phy->txpower) return BWN_TXPWR_RES_DONE; /* Make sure we have a clean PPR */ bwn_ppr_clear(mac, ppr); /* HW limitations */ bwn_ppr_load_max_from_sprom(mac, ppr, BWN_PHY_BAND_2G); /* XXX TODO: other bands? */ /* Regulatory & user settings */ max = INT_TO_Q52(bwn_get_chan_power(mac, channel)); /* uint8_t */ if (phy->txpower) max = min(max, INT_TO_Q52(phy->txpower)); bwn_ppr_apply_max(mac, ppr, max); DPRINTF(mac->mac_sc, BWN_DEBUG_XMIT_POWER, "Calculated TX power: " Q52_FMT "\n", Q52_ARG(bwn_ppr_get_max(mac, ppr))); /* TODO: Enable this once we get gains working */ #if 0 /* Some extra gains */ hw_gain = 6; /* N-PHY specific */ if (bwn_current_band(mac) == BWN_BAND_2G) hw_gain += sprom->antenna_gain.a0; else hw_gain += sprom->antenna_gain.a1; bwn_ppr_add(mac, ppr, -hw_gain); #endif /* Make sure we didn't go too low */ bwn_ppr_apply_min(mac, ppr, INT_TO_Q52(8)); /* Apply */ - tx_pwr_state = nphy->txpwrctrl; bwn_mac_suspend(mac); bwn_nphy_tx_power_ctl_setup(mac); if (bhnd_get_hwrev(sc->sc_dev) == 11 || bhnd_get_hwrev(sc->sc_dev) == 12) { BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~0, BWN_MACCTL_PHY_LOCK); BWN_READ_4(mac, BWN_MACCTL); DELAY(1); } bwn_nphy_tx_power_ctrl(mac, nphy->txpwrctrl); if (bhnd_get_hwrev(sc->sc_dev) == 11 || bhnd_get_hwrev(sc->sc_dev) == 12) BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~BWN_MACCTL_PHY_LOCK, 0); bwn_mac_enable(mac); nphy->tx_pwr_last_recalc_freq = bwn_get_centre_freq(mac); nphy->tx_pwr_last_recalc_limit = phy->txpower; return BWN_TXPWR_RES_DONE; } /************************************************** * N-PHY init **************************************************/ /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MIMOConfig */ static void bwn_nphy_update_mimo_config(struct bwn_mac *mac, int32_t preamble) { uint16_t mimocfg = BWN_PHY_READ(mac, BWN_NPHY_MIMOCFG); mimocfg |= BWN_NPHY_MIMOCFG_AUTO; if (preamble == 1) mimocfg |= BWN_NPHY_MIMOCFG_GFMIX; else mimocfg &= ~BWN_NPHY_MIMOCFG_GFMIX; BWN_PHY_WRITE(mac, BWN_NPHY_MIMOCFG, mimocfg); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/BPHYInit */ static void bwn_nphy_bphy_init(struct bwn_mac *mac) { unsigned int i; uint16_t val; val = 0x1E1F; for (i = 0; i < 16; i++) { BWN_PHY_WRITE(mac, BWN_PHY_N_BMODE(0x88 + i), val); val -= 0x202; } val = 0x3E3F; for (i = 0; i < 16; i++) { BWN_PHY_WRITE(mac, BWN_PHY_N_BMODE(0x98 + i), val); val -= 0x202; } BWN_PHY_WRITE(mac, BWN_PHY_N_BMODE(0x38), 0x668); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SuperSwitchInit */ static int bwn_nphy_superswitch_init(struct bwn_mac *mac, bool init) { int error; if (mac->mac_phy.rev >= 7) return (0); if (mac->mac_phy.rev >= 3) { if (!init) return (0); if (0 /* FIXME */) { bwn_ntab_write(mac, BWN_NTAB16(9, 2), 0x211); bwn_ntab_write(mac, BWN_NTAB16(9, 3), 0x222); bwn_ntab_write(mac, BWN_NTAB16(9, 8), 0x144); bwn_ntab_write(mac, BWN_NTAB16(9, 12), 0x188); } } else { BWN_PHY_WRITE(mac, BWN_NPHY_GPIO_LOOEN, 0); BWN_PHY_WRITE(mac, BWN_NPHY_GPIO_HIOEN, 0); if ((error = bwn_gpio_control(mac, 0xfc00))) return (error); BWN_WRITE_SETMASK4(mac, BWN_MACCTL, ~BWN_MACCTL_GPOUT_MASK, 0); BWN_WRITE_SETMASK2(mac, BWN_GPIO_MASK, ~0, 0xFC00); BWN_WRITE_SETMASK2(mac, BWN_GPIO_CONTROL, (~0xFC00 & 0xFFFF), 0); if (init) { BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_LO1, 0x2D8); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP1, 0x301); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_LO2, 0x2D8); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_LUT_TRSW_UP2, 0x301); } } return (0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/Init/N */ static int bwn_phy_initn(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = phy->phy_n; uint8_t tx_pwr_state; struct bwn_nphy_txgains target; int error; uint16_t tmp; - bwn_band_t tmp2; bool do_rssi_cal; uint16_t clip[2]; bool do_cal = false; if (mac->mac_phy.rev >= 3) { error = bhnd_nvram_getvar_uint8(sc->sc_dev, BHND_NVAR_TSSIPOS2G, &nphy->tsspos_2g); if (error) { BWN_ERRPRINTF(mac->mac_sc, "Error reading %s from " "NVRAM: %d\n", BHND_NVAR_TSSIPOS2G, error); return (error); } } else { nphy->tsspos_2g = 0; } if ((mac->mac_phy.rev >= 3) && (sc->sc_board_info.board_flags & BHND_BFL_EXTLNA) && (bwn_current_band(mac) == BWN_BAND_2G)) { BHND_CHIPC_WRITE_CHIPCTRL(sc->sc_chipc, 0x40, 0x40); } nphy->use_int_tx_iq_lo_cal = bwn_nphy_ipa(mac) || phy->rev >= 7 || (phy->rev >= 5 && sc->sc_board_info.board_flags2 & BHND_BFL2_INTERNDET_TXIQCAL); nphy->deaf_count = 0; bwn_nphy_tables_init(mac); nphy->crsminpwr_adjusted = false; nphy->noisevars_adjusted = false; /* Clear all overrides */ if (mac->mac_phy.rev >= 3) { BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B1S1, 0); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_OVER, 0); if (phy->rev >= 7) { BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER3, 0); BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER4, 0); BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER5, 0); BWN_PHY_WRITE(mac, BWN_NPHY_REV7_RF_CTL_OVER6, 0); } if (phy->rev >= 19) { /* TODO */ } BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B1S0, 0); BWN_PHY_WRITE(mac, BWN_NPHY_TXF_40CO_B32S1, 0); } else { BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_OVER, 0); } BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC1, 0); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC2, 0); if (mac->mac_phy.rev < 6) { BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC3, 0); BWN_PHY_WRITE(mac, BWN_NPHY_RFCTL_INTC4, 0); } BWN_PHY_MASK(mac, BWN_NPHY_RFSEQMODE, ~(BWN_NPHY_RFSEQMODE_CAOVER | BWN_NPHY_RFSEQMODE_TROVER)); if (mac->mac_phy.rev >= 3) BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER1, 0); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, 0); if (mac->mac_phy.rev <= 2) { tmp = (mac->mac_phy.rev == 2) ? 0x3B : 0x40; BWN_PHY_SETMASK(mac, BWN_NPHY_BPHY_CTL3, ~BWN_NPHY_BPHY_CTL3_SCALE, tmp << BWN_NPHY_BPHY_CTL3_SCALE_SHIFT); } BWN_PHY_WRITE(mac, BWN_NPHY_AFESEQ_TX2RX_PUD_20M, 0x20); BWN_PHY_WRITE(mac, BWN_NPHY_AFESEQ_TX2RX_PUD_40M, 0x20); if (sc->sc_board_info.board_flags2 & BHND_BFL2_SKWRKFEM_BRD || (sc->sc_board_info.board_vendor == PCI_VENDOR_APPLE && sc->sc_board_info.board_type == BHND_BOARD_BCM943224M93)) BWN_PHY_WRITE(mac, BWN_NPHY_TXREALFD, 0xA0); else BWN_PHY_WRITE(mac, BWN_NPHY_TXREALFD, 0xB8); BWN_PHY_WRITE(mac, BWN_NPHY_MIMO_CRSTXEXT, 0xC8); BWN_PHY_WRITE(mac, BWN_NPHY_PLOAD_CSENSE_EXTLEN, 0x50); BWN_PHY_WRITE(mac, BWN_NPHY_TXRIFS_FRDEL, 0x30); if (phy->rev < 8) bwn_nphy_update_mimo_config(mac, nphy->preamble_override); bwn_nphy_update_txrx_chain(mac); if (phy->rev < 2) { BWN_PHY_WRITE(mac, BWN_NPHY_DUP40_GFBL, 0xAA8); BWN_PHY_WRITE(mac, BWN_NPHY_DUP40_BL, 0x9A4); } - tmp2 = bwn_current_band(mac); if (bwn_nphy_ipa(mac)) { BWN_PHY_SET(mac, BWN_NPHY_PAPD_EN0, 0x1); BWN_PHY_SETMASK(mac, BWN_NPHY_EPS_TABLE_ADJ0, 0x007F, nphy->papd_epsilon_offset[0] << 7); BWN_PHY_SET(mac, BWN_NPHY_PAPD_EN1, 0x1); BWN_PHY_SETMASK(mac, BWN_NPHY_EPS_TABLE_ADJ1, 0x007F, nphy->papd_epsilon_offset[1] << 7); bwn_nphy_int_pa_set_tx_dig_filters(mac); } else if (phy->rev >= 5) { bwn_nphy_ext_pa_set_tx_dig_filters(mac); } if ((error = bwn_nphy_workarounds(mac))) return (error); /* Reset CCA, in init code it differs a little from standard way */ bwn_phy_force_clock(mac, 1); tmp = BWN_PHY_READ(mac, BWN_NPHY_BBCFG); BWN_PHY_WRITE(mac, BWN_NPHY_BBCFG, tmp | BWN_NPHY_BBCFG_RSTCCA); BWN_PHY_WRITE(mac, BWN_NPHY_BBCFG, tmp & ~BWN_NPHY_BBCFG_RSTCCA); bwn_phy_force_clock(mac, 0); bwn_mac_phy_clock_set(mac, true); if (phy->rev < 7) { bwn_nphy_pa_override(mac, false); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RX2TX); bwn_nphy_force_rf_sequence(mac, BWN_RFSEQ_RESET2RX); bwn_nphy_pa_override(mac, true); } bwn_nphy_classifier(mac, 0, 0); bwn_nphy_read_clip_detection(mac, clip); if (bwn_current_band(mac) == BWN_BAND_2G) bwn_nphy_bphy_init(mac); tx_pwr_state = nphy->txpwrctrl; bwn_nphy_tx_power_ctrl(mac, false); if ((error = bwn_nphy_tx_power_fix(mac))) return (error); bwn_nphy_tx_power_ctl_idle_tssi(mac); bwn_nphy_tx_power_ctl_setup(mac); bwn_nphy_tx_gain_table_upload(mac); if (nphy->phyrxchain != 3) bwn_nphy_set_rx_core_state(mac, nphy->phyrxchain); if (nphy->mphase_cal_phase_id > 0) ;/* TODO PHY Periodic Calibration Multi-Phase Restart */ do_rssi_cal = false; if (phy->rev >= 3) { if (bwn_current_band(mac) == BWN_BAND_2G) do_rssi_cal = !nphy->rssical_chanspec_2G.center_freq; else do_rssi_cal = !nphy->rssical_chanspec_5G.center_freq; if (do_rssi_cal) bwn_nphy_rssi_cal(mac); else bwn_nphy_restore_rssi_cal(mac); } else { bwn_nphy_rssi_cal(mac); } if (!((nphy->measure_hold & 0x6) != 0)) { if (bwn_current_band(mac) == BWN_BAND_2G) do_cal = !nphy->iqcal_chanspec_2G.center_freq; else do_cal = !nphy->iqcal_chanspec_5G.center_freq; if (nphy->mute) do_cal = false; if (do_cal) { target = bwn_nphy_get_tx_gains(mac); if (nphy->antsel_type == 2) { error = bwn_nphy_superswitch_init(mac, true); if (error) return (error); } if (nphy->perical != 2) { bwn_nphy_rssi_cal(mac); if (phy->rev >= 3) { nphy->cal_orig_pwr_idx[0] = nphy->txpwrindex[0].index_internal; nphy->cal_orig_pwr_idx[1] = nphy->txpwrindex[1].index_internal; /* TODO N PHY Pre Calibrate TX Gain */ target = bwn_nphy_get_tx_gains(mac); } if (!bwn_nphy_cal_tx_iq_lo(mac, target, true, false)) if (bwn_nphy_cal_rx_iq(mac, target, 2, 0) == 0) bwn_nphy_save_cal(mac); } else if (nphy->mphase_cal_phase_id == 0) ;/* N PHY Periodic Calibration with arg 3 */ } else { bwn_nphy_restore_cal(mac); } } bwn_nphy_tx_pwr_ctrl_coef_setup(mac); bwn_nphy_tx_power_ctrl(mac, tx_pwr_state); BWN_PHY_WRITE(mac, BWN_NPHY_TXMACIF_HOLDOFF, 0x0015); BWN_PHY_WRITE(mac, BWN_NPHY_TXMACDELAY, 0x0320); if (phy->rev >= 3 && phy->rev <= 6) BWN_PHY_WRITE(mac, BWN_NPHY_PLOAD_CSENSE_EXTLEN, 0x0032); bwn_nphy_tx_lpf_bw(mac); if (phy->rev >= 3) bwn_nphy_spur_workaround(mac); return 0; } /************************************************** * Channel switching ops. **************************************************/ static void bwn_chantab_phy_upload(struct bwn_mac *mac, const struct bwn_phy_n_sfo_cfg *e) { BWN_PHY_WRITE(mac, BWN_NPHY_BW1A, e->phy_bw1a); BWN_PHY_WRITE(mac, BWN_NPHY_BW2, e->phy_bw2); BWN_PHY_WRITE(mac, BWN_NPHY_BW3, e->phy_bw3); BWN_PHY_WRITE(mac, BWN_NPHY_BW4, e->phy_bw4); BWN_PHY_WRITE(mac, BWN_NPHY_BW5, e->phy_bw5); BWN_PHY_WRITE(mac, BWN_NPHY_BW6, e->phy_bw6); } /* http://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */ static void bwn_nphy_pmu_spur_avoid(struct bwn_mac *mac, bhnd_pmu_spuravoid mode) { struct bwn_softc *sc = mac->mac_sc; int error; DPRINTF(sc, BWN_DEBUG_RESET, "%s: spuravoid %d\n", __func__, mode); if (sc->sc_pmu == NULL) { BWN_ERRPRINTF(mac->mac_sc, "no PMU; cannot configure spurious " "signal avoidance\n"); return; } if ((error = bhnd_pmu_request_spuravoid(sc->sc_pmu, mode))) { device_printf(sc->sc_dev, "spuravoid request failed: %d", error); } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */ static int bwn_nphy_channel_setup(struct bwn_mac *mac, const struct bwn_phy_n_sfo_cfg *e, struct ieee80211_channel *new_channel) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = mac->mac_phy.phy_n; int ch = new_channel->ic_ieee; int error; uint16_t tmp16; if (bwn_channel_band(mac, new_channel) == BWN_BAND_5G) { DPRINTF(sc, BWN_DEBUG_RESET, "%s: BAND_5G; chan=%d\n", __func__, ch); /* Switch to 2 GHz for a moment to access BWN_PHY_B_BBCFG */ BWN_PHY_MASK(mac, BWN_NPHY_BANDCTL, ~BWN_NPHY_BANDCTL_5GHZ); tmp16 = BWN_READ_2(mac, BWN_PSM_PHY_HDR); BWN_WRITE_2(mac, BWN_PSM_PHY_HDR, tmp16 | 4); /* Put BPHY in the reset */ BWN_PHY_SET(mac, BWN_PHY_B_BBCFG, BWN_PHY_B_BBCFG_RSTCCA | BWN_PHY_B_BBCFG_RSTRX); BWN_WRITE_2(mac, BWN_PSM_PHY_HDR, tmp16); BWN_PHY_SET(mac, BWN_NPHY_BANDCTL, BWN_NPHY_BANDCTL_5GHZ); } else if (bwn_channel_band(mac, new_channel) == BWN_BAND_2G) { DPRINTF(sc, BWN_DEBUG_RESET, "%s: BAND_2G; chan=%d\n", __func__, ch); BWN_PHY_MASK(mac, BWN_NPHY_BANDCTL, ~BWN_NPHY_BANDCTL_5GHZ); tmp16 = BWN_READ_2(mac, BWN_PSM_PHY_HDR); BWN_WRITE_2(mac, BWN_PSM_PHY_HDR, tmp16 | 4); /* Take BPHY out of the reset */ BWN_PHY_MASK(mac, BWN_PHY_B_BBCFG, (uint16_t)~(BWN_PHY_B_BBCFG_RSTCCA | BWN_PHY_B_BBCFG_RSTRX)); BWN_WRITE_2(mac, BWN_PSM_PHY_HDR, tmp16); } else { BWN_ERRPRINTF(mac->mac_sc, "%s: unknown band?\n", __func__); } bwn_chantab_phy_upload(mac, e); if (new_channel->ic_ieee == 14) { bwn_nphy_classifier(mac, 2, 0); BWN_PHY_SET(mac, BWN_PHY_B_TEST, 0x0800); } else { bwn_nphy_classifier(mac, 2, 2); if (bwn_channel_band(mac, new_channel) == BWN_BAND_2G) BWN_PHY_MASK(mac, BWN_PHY_B_TEST, ~0x840); } if (!nphy->txpwrctrl) { if ((error = bwn_nphy_tx_power_fix(mac))) return (error); } if (mac->mac_phy.rev < 3) bwn_nphy_adjust_lna_gain_table(mac); bwn_nphy_tx_lpf_bw(mac); if (mac->mac_phy.rev >= 3 && mac->mac_phy.phy_n->spur_avoid != BWN_SPUR_AVOID_DISABLE) { bhnd_pmu_spuravoid spuravoid = BHND_PMU_SPURAVOID_NONE; if (mac->mac_phy.phy_n->spur_avoid == BWN_SPUR_AVOID_FORCE) { spuravoid = BHND_PMU_SPURAVOID_M1; } else if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 18) { /* TODO */ } else if (phy->rev >= 17) { /* TODO: Off for channels 1-11, but check 12-14! */ } else if (phy->rev >= 16) { /* TODO: Off for 2 GHz, but check 5 GHz! */ } else if (phy->rev >= 7) { if (!bwn_is_40mhz(mac)) { /* 20MHz */ if (ch == 13 || ch == 14 || ch == 153) spuravoid = BHND_PMU_SPURAVOID_M1; } else { /* 40 MHz */ if (ch == 54) spuravoid = BHND_PMU_SPURAVOID_M1; } } else { if (!bwn_is_40mhz(mac)) { /* 20MHz */ if ((ch >= 5 && ch <= 8) || ch == 13 || ch == 14) spuravoid = BHND_PMU_SPURAVOID_M1; } else { /* 40MHz */ if (nphy->aband_spurwar_en && (ch == 38 || ch == 102 || ch == 118) && sc->sc_cid.chip_id == BHND_CHIPID_BCM4716) spuravoid = BHND_PMU_SPURAVOID_M1; } } bwn_nphy_pmu_spur_avoid(mac, spuravoid); bwn_mac_switch_freq(mac, spuravoid); if (mac->mac_phy.rev == 3 || mac->mac_phy.rev == 4) bwn_wireless_core_phy_pll_reset(mac); if (spuravoid != BHND_PMU_SPURAVOID_NONE) BWN_PHY_SET(mac, BWN_NPHY_BBCFG, BWN_NPHY_BBCFG_RSTRX); else BWN_PHY_MASK(mac, BWN_NPHY_BBCFG, ~BWN_NPHY_BBCFG_RSTRX & 0xFFFF); bwn_nphy_reset_cca(mac); /* wl sets useless phy_isspuravoid here */ } BWN_PHY_WRITE(mac, BWN_NPHY_NDATAT_DUP40, 0x3830); if (phy->rev >= 3) bwn_nphy_spur_workaround(mac); return (0); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/SetChanspec */ static int bwn_nphy_set_channel(struct bwn_mac *mac, struct ieee80211_channel *channel, bwn_chan_type_t channel_type) { struct bwn_phy *phy = &mac->mac_phy; const struct bwn_nphy_channeltab_entry_rev2 *tabent_r2 = NULL; const struct bwn_nphy_channeltab_entry_rev3 *tabent_r3 = NULL; const struct bwn_nphy_chantabent_rev7 *tabent_r7 = NULL; const struct bwn_nphy_chantabent_rev7_2g *tabent_r7_2g = NULL; int error; uint8_t tmp; if (phy->rev >= 19) { return -ESRCH; /* TODO */ } else if (phy->rev >= 7) { r2057_get_chantabent_rev7(mac, bwn_get_chan_centre_freq(mac, channel), &tabent_r7, &tabent_r7_2g); if (!tabent_r7 && !tabent_r7_2g) return -ESRCH; } else if (phy->rev >= 3) { tabent_r3 = bwn_nphy_get_chantabent_rev3(mac, bwn_get_chan_centre_freq(mac, channel)); if (!tabent_r3) return -ESRCH; } else { tabent_r2 = bwn_nphy_get_chantabent_rev2(mac, channel->ic_ieee); if (!tabent_r2) return -ESRCH; } /* Channel is set later in common code, but we need to set it on our own to let this function's subcalls work properly. */ #if 0 phy->channel = channel->ic_ieee; #endif #if 0 if (bwn_channel_type_is_40mhz(phy->channel_type) != bwn_channel_type_is_40mhz(channel_type)) ; /* TODO: BMAC BW Set (channel_type) */ #endif if (channel_type == BWN_CHAN_TYPE_40_HT_U) { BWN_PHY_SET(mac, BWN_NPHY_RXCTL, BWN_NPHY_RXCTL_BSELU20); if (phy->rev >= 7) BWN_PHY_SET(mac, 0x310, 0x8000); } else if (channel_type == BWN_CHAN_TYPE_40_HT_D) { BWN_PHY_MASK(mac, BWN_NPHY_RXCTL, ~BWN_NPHY_RXCTL_BSELU20); if (phy->rev >= 7) BWN_PHY_MASK(mac, 0x310, (uint16_t)~0x8000); } if (phy->rev >= 19) { /* TODO */ error = ENODEV; } else if (phy->rev >= 7) { const struct bwn_phy_n_sfo_cfg *phy_regs = tabent_r7 ? &(tabent_r7->phy_regs) : &(tabent_r7_2g->phy_regs); if (phy->rf_rev <= 4 || phy->rf_rev == 6) { tmp = (bwn_channel_band(mac, channel) == BWN_BAND_5G) ? 2 : 0; BWN_RF_SETMASK(mac, R2057_TIA_CONFIG_CORE0, ~2, tmp); BWN_RF_SETMASK(mac, R2057_TIA_CONFIG_CORE1, ~2, tmp); } bwn_radio_2057_setup(mac, tabent_r7, tabent_r7_2g); error = bwn_nphy_channel_setup(mac, phy_regs, channel); } else if (phy->rev >= 3) { tmp = (bwn_channel_band(mac, channel) == BWN_BAND_5G) ? 4 : 0; BWN_RF_SETMASK(mac, 0x08, 0xFFFB, tmp); bwn_radio_2056_setup(mac, tabent_r3); error = bwn_nphy_channel_setup(mac, &(tabent_r3->phy_regs), channel); } else { tmp = (bwn_channel_band(mac, channel) == BWN_BAND_5G) ? 0x0020 : 0x0050; BWN_RF_SETMASK(mac, B2055_MASTER1, 0xFF8F, tmp); bwn_radio_2055_setup(mac, tabent_r2); error = bwn_nphy_channel_setup(mac, &(tabent_r2->phy_regs), channel); } return (error); } /************************************************** * Basic PHY ops. **************************************************/ int bwn_nphy_op_allocate(struct bwn_mac *mac) { struct bwn_phy_n *nphy; nphy = malloc(sizeof(*nphy), M_DEVBUF, M_ZERO | M_NOWAIT); if (!nphy) return -ENOMEM; mac->mac_phy.phy_n = nphy; return 0; } int bwn_nphy_op_prepare_structs(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = phy->phy_n; int error; memset(nphy, 0, sizeof(*nphy)); nphy->hang_avoid = (phy->rev == 3 || phy->rev == 4); nphy->spur_avoid = (phy->rev >= 3) ? BWN_SPUR_AVOID_AUTO : BWN_SPUR_AVOID_DISABLE; nphy->gain_boost = true; /* this way we follow wl, assume it is true */ nphy->txrx_chain = 2; /* sth different than 0 and 1 for now */ nphy->phyrxchain = 3; /* to avoid bwn_nphy_set_rx_core_state like wl */ nphy->perical = 2; /* avoid additional rssi cal on init (like wl) */ /* 128 can mean disabled-by-default state of TX pwr ctl. Max value is * 0x7f == 127 and we check for 128 when restoring TX pwr ctl. */ nphy->tx_pwr_idx[0] = 128; nphy->tx_pwr_idx[1] = 128; /* Hardware TX power control and 5GHz power gain */ nphy->txpwrctrl = false; nphy->pwg_gain_5ghz = false; if (mac->mac_phy.rev >= 3 || (sc->sc_board_info.board_vendor == PCI_VENDOR_APPLE && (bhnd_get_hwrev(sc->sc_dev) == 11 || bhnd_get_hwrev(sc->sc_dev) == 12))) { nphy->txpwrctrl = true; nphy->pwg_gain_5ghz = true; } else if (sc->sc_board_info.board_srom_rev >= 4) { if (mac->mac_phy.rev >= 2 && (sc->sc_board_info.board_flags2 & BHND_BFL2_TXPWRCTRL_EN)) { nphy->txpwrctrl = true; if ((sc->sc_board_info.board_devid == PCI_DEVID_BCM4321_D11N) || (sc->sc_board_info.board_devid == PCI_DEVID_BCM4321_D11N5G)) nphy->pwg_gain_5ghz = true; } else if (sc->sc_board_info.board_flags2 & BHND_BFL2_5G_PWRGAIN) { nphy->pwg_gain_5ghz = true; } } if (mac->mac_phy.rev >= 3) { uint8_t extpa_gain2g, extpa_gain5g; error = bhnd_nvram_getvar_uint8(sc->sc_dev, BHND_NVAR_EXTPAGAIN2G, &extpa_gain2g); if (error) { BWN_ERRPRINTF(mac->mac_sc, "Error reading 2GHz EPA " "gain configuration from NVRAM: %d\n", error); return (error); } error = bhnd_nvram_getvar_uint8(sc->sc_dev, BHND_NVAR_EXTPAGAIN5G, &extpa_gain5g); if (error) { BWN_ERRPRINTF(mac->mac_sc, "Error reading 5GHz EPA " "gain configuration from NVRAM: %d\n", error); return (error); } nphy->ipa2g_on = (extpa_gain2g == 2); nphy->ipa5g_on = (extpa_gain5g == 2); } return (0); } void bwn_nphy_op_free(struct bwn_mac *mac) { struct bwn_phy *phy = &mac->mac_phy; struct bwn_phy_n *nphy = phy->phy_n; free(nphy, M_DEVBUF); phy->phy_n = NULL; } int bwn_nphy_op_init(struct bwn_mac *mac) { return bwn_phy_initn(mac); } static inline void check_phyreg(struct bwn_mac *mac, uint16_t offset) { #ifdef BWN_DEBUG if ((offset & BWN_PHYROUTE_MASK) == BWN_PHYROUTE_OFDM_GPHY) { /* OFDM registers are onnly available on A/G-PHYs */ BWN_ERRPRINTF(mac->mac_sc, "Invalid OFDM PHY access at " "0x%04X on N-PHY\n", offset); } if ((offset & BWN_PHYROUTE_MASK) == BWN_PHYROUTE_EXT_GPHY) { /* Ext-G registers are only available on G-PHYs */ BWN_ERRPRINTF(mac->mac_sc, "Invalid EXT-G PHY access at " "0x%04X on N-PHY\n", offset); } #endif /* BWN_DEBUG */ } void bwn_nphy_op_maskset(struct bwn_mac *mac, uint16_t reg, uint16_t mask, uint16_t set) { check_phyreg(mac, reg); BWN_WRITE_2_F(mac, BWN_PHYCTL, reg); BWN_WRITE_SETMASK2(mac, BWN_PHYDATA, mask, set); } #if 0 uint16_t bwn_nphy_op_radio_read(struct bwn_mac *mac, uint16_t reg) { /* Register 1 is a 32-bit register. */ if (mac->mac_phy.rev < 7 && reg == 1) { BWN_ERRPRINTF(mac->mac_sc, "%s: bad reg access\n", __func__); } if (mac->mac_phy.rev >= 7) reg |= 0x200; /* Radio 0x2057 */ else reg |= 0x100; BWN_WRITE_2_F(mac, BWN_RFCTL, reg); return BWN_READ_2(mac, BWN_RFDATALO); } #endif #if 0 void bwn_nphy_op_radio_write(struct bwn_mac *mac, uint16_t reg, uint16_t value) { /* Register 1 is a 32-bit register. */ if (mac->mac_phy.rev < 7 && reg == 1) { BWN_ERRPRINTF(mac->mac_sc, "%s: bad reg access\n", __func__); } BWN_WRITE_2_F(mac, BWN_RFCTL, reg); BWN_WRITE_2(mac, BWN_RFDATALO, value); } #endif /* http://bcm-v4.sipsolutions.net/802.11/Radio/Switch%20Radio */ void bwn_nphy_op_software_rfkill(struct bwn_mac *mac, bool active) { struct bwn_phy *phy = &mac->mac_phy; if (BWN_READ_4(mac, BWN_MACCTL) & BWN_MACCTL_ON) BWN_ERRPRINTF(mac->mac_sc, "MAC not suspended\n"); DPRINTF(mac->mac_sc, BWN_DEBUG_RESET | BWN_DEBUG_PHY, "%s: called; rev=%d, rf_on=%d, active=%d\n", __func__, phy->rev, mac->mac_phy.rf_on, active); /* * XXX TODO: don't bother doing RF programming if it's * already done. But, bwn(4) currently sets rf_on in the * PHY setup and leaves it on after startup, which causes * the below to not init the 2056/2057 radios. */ if (active) { if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 7) { // if (!mac->mac_phy.rf_on) bwn_radio_2057_init(mac); bwn_switch_channel(mac, bwn_get_chan(mac)); } else if (phy->rev >= 3) { // if (!mac->mac_phy.rf_on) bwn_radio_init2056(mac); bwn_switch_channel(mac, bwn_get_chan(mac)); } else { bwn_radio_init2055(mac); } } else { if (phy->rev >= 19) { /* TODO */ } else if (phy->rev >= 8) { BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_CHIP0PU); } else if (phy->rev >= 7) { /* Nothing needed */ } else if (phy->rev >= 3) { BWN_PHY_MASK(mac, BWN_NPHY_RFCTL_CMD, ~BWN_NPHY_RFCTL_CMD_CHIP0PU); BWN_RF_MASK(mac, 0x09, ~0x2); BWN_RF_WRITE(mac, 0x204D, 0); BWN_RF_WRITE(mac, 0x2053, 0); BWN_RF_WRITE(mac, 0x2058, 0); BWN_RF_WRITE(mac, 0x205E, 0); BWN_RF_MASK(mac, 0x2062, ~0xF0); BWN_RF_WRITE(mac, 0x2064, 0); BWN_RF_WRITE(mac, 0x304D, 0); BWN_RF_WRITE(mac, 0x3053, 0); BWN_RF_WRITE(mac, 0x3058, 0); BWN_RF_WRITE(mac, 0x305E, 0); BWN_RF_MASK(mac, 0x3062, ~0xF0); BWN_RF_WRITE(mac, 0x3064, 0); } } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/Anacore */ void bwn_nphy_op_switch_analog(struct bwn_mac *mac, bool on) { struct bwn_phy *phy = &mac->mac_phy; uint16_t override = on ? 0x0 : 0x7FFF; uint16_t core = on ? 0xD : 0x00FD; if (phy->rev >= 19) { /* TODO */ device_printf(mac->mac_sc->sc_dev, "%s: TODO\n", __func__); } else if (phy->rev >= 3) { if (on) { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C1, core); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER1, override); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C2, core); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, override); } else { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER1, override); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C1, core); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, override); BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_C2, core); } } else { BWN_PHY_WRITE(mac, BWN_NPHY_AFECTL_OVER, override); } } int bwn_nphy_op_switch_channel(struct bwn_mac *mac, unsigned int new_channel) { struct ieee80211_channel *channel = bwn_get_channel(mac); bwn_chan_type_t channel_type = bwn_get_chan_type(mac, NULL); if (bwn_current_band(mac) == BWN_BAND_2G) { if ((new_channel < 1) || (new_channel > 14)) return -EINVAL; } else { if (new_channel > 200) return -EINVAL; } return bwn_nphy_set_channel(mac, channel, channel_type); } #if 0 unsigned int bwn_nphy_op_get_default_chan(struct bwn_mac *mac) { if (bwn_current_band(mac) == BWN_BAND_2G) return 1; return 36; } #endif diff --git a/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_tables.c b/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_tables.c index b59271f65933..c1fc199b75d4 100644 --- a/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_tables.c +++ b/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_tables.c @@ -1,4005 +1,4014 @@ /* Broadcom B43 wireless driver IEEE 802.11n PHY data tables Copyright (c) 2008 Michael Buesch Copyright (c) 2010 Rafał Miłecki This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. */ #include __FBSDID("$FreeBSD$"); /* * The Broadcom Wireless LAN controller driver. */ #include "opt_wlan.h" #include "opt_bwn.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "bhnd_nvram_map.h" static const uint8_t bwn_ntab_adjustpower0[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t bwn_ntab_adjustpower1[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint16_t bwn_ntab_bdi[] = { 0x0070, 0x0126, 0x012C, 0x0246, 0x048D, 0x04D2, }; static const uint32_t bwn_ntab_channelest[] = { 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, }; static const uint8_t bwn_ntab_estimatepowerlt0[] = { 0x50, 0x4F, 0x4E, 0x4D, 0x4C, 0x4B, 0x4A, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2F, 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, }; static const uint8_t bwn_ntab_estimatepowerlt1[] = { 0x50, 0x4F, 0x4E, 0x4D, 0x4C, 0x4B, 0x4A, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x3F, 0x3E, 0x3D, 0x3C, 0x3B, 0x3A, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30, 0x2F, 0x2E, 0x2D, 0x2C, 0x2B, 0x2A, 0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, }; static const uint8_t bwn_ntab_framelookup[] = { 0x02, 0x04, 0x14, 0x14, 0x03, 0x05, 0x16, 0x16, 0x0A, 0x0C, 0x1C, 0x1C, 0x0B, 0x0D, 0x1E, 0x1E, 0x06, 0x08, 0x18, 0x18, 0x07, 0x09, 0x1A, 0x1A, 0x0E, 0x10, 0x20, 0x28, 0x0F, 0x11, 0x22, 0x2A, }; static const uint32_t bwn_ntab_framestruct[] = { 0x08004A04, 0x00100000, 0x01000A05, 0x00100020, 0x09804506, 0x00100030, 0x09804507, 0x00100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004A0C, 0x00100004, 0x01000A0D, 0x00100024, 0x0980450E, 0x00100034, 0x0980450F, 0x00100034, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000A04, 0x00100000, 0x11008A05, 0x00100020, 0x1980C506, 0x00100030, 0x21810506, 0x00100030, 0x21810506, 0x00100030, 0x01800504, 0x00100030, 0x11808505, 0x00100030, 0x29814507, 0x01100030, 0x00000A04, 0x00100000, 0x11008A05, 0x00100020, 0x21810506, 0x00100030, 0x21810506, 0x00100030, 0x29814507, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000A0C, 0x00100008, 0x11008A0D, 0x00100028, 0x1980C50E, 0x00100038, 0x2181050E, 0x00100038, 0x2181050E, 0x00100038, 0x0180050C, 0x00100038, 0x1180850D, 0x00100038, 0x2981450F, 0x01100038, 0x00000A0C, 0x00100008, 0x11008A0D, 0x00100028, 0x2181050E, 0x00100038, 0x2181050E, 0x00100038, 0x2981450F, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004A04, 0x00100000, 0x01000A05, 0x00100020, 0x1980C506, 0x00100030, 0x1980C506, 0x00100030, 0x11808504, 0x00100030, 0x3981CA05, 0x00100030, 0x29814507, 0x01100030, 0x00000000, 0x00000000, 0x10008A04, 0x00100000, 0x3981CA05, 0x00100030, 0x1980C506, 0x00100030, 0x29814507, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004A0C, 0x00100008, 0x01000A0D, 0x00100028, 0x1980C50E, 0x00100038, 0x1980C50E, 0x00100038, 0x1180850C, 0x00100038, 0x3981CA0D, 0x00100038, 0x2981450F, 0x01100038, 0x00000000, 0x00000000, 0x10008A0C, 0x00100008, 0x3981CA0D, 0x00100038, 0x1980C50E, 0x00100038, 0x2981450F, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x00100000, 0x02001405, 0x00100040, 0x0B004A06, 0x01900060, 0x13008A06, 0x01900060, 0x13008A06, 0x01900060, 0x43020A04, 0x00100060, 0x1B00CA05, 0x00100060, 0x23010A07, 0x01500060, 0x40021404, 0x00100000, 0x1A00D405, 0x00100040, 0x13008A06, 0x01900060, 0x13008A06, 0x01900060, 0x23010A07, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140C, 0x00100010, 0x0200140D, 0x00100050, 0x0B004A0E, 0x01900070, 0x13008A0E, 0x01900070, 0x13008A0E, 0x01900070, 0x43020A0C, 0x00100070, 0x1B00CA0D, 0x00100070, 0x23010A0F, 0x01500070, 0x4002140C, 0x00100010, 0x1A00D40D, 0x00100050, 0x13008A0E, 0x01900070, 0x13008A0E, 0x01900070, 0x23010A0F, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x50029404, 0x00100000, 0x32019405, 0x00100040, 0x0B004A06, 0x01900060, 0x0B004A06, 0x01900060, 0x5B02CA04, 0x00100060, 0x3B01D405, 0x00100060, 0x23010A07, 0x01500060, 0x00000000, 0x00000000, 0x5802D404, 0x00100000, 0x3B01D405, 0x00100060, 0x0B004A06, 0x01900060, 0x23010A07, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5002940C, 0x00100010, 0x3201940D, 0x00100050, 0x0B004A0E, 0x01900070, 0x0B004A0E, 0x01900070, 0x5B02CA0C, 0x00100070, 0x3B01D40D, 0x00100070, 0x23010A0F, 0x01500070, 0x00000000, 0x00000000, 0x5802D40C, 0x00100010, 0x3B01D40D, 0x00100070, 0x0B004A0E, 0x01900070, 0x23010A0F, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x000F4800, 0x62031405, 0x00100040, 0x53028A06, 0x01900060, 0x53028A07, 0x01900060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140C, 0x000F4808, 0x6203140D, 0x00100048, 0x53028A0E, 0x01900068, 0x53028A0F, 0x01900068, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000A0C, 0x00100004, 0x11008A0D, 0x00100024, 0x1980C50E, 0x00100034, 0x2181050E, 0x00100034, 0x2181050E, 0x00100034, 0x0180050C, 0x00100038, 0x1180850D, 0x00100038, 0x1181850D, 0x00100038, 0x2981450F, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000A0C, 0x00100008, 0x11008A0D, 0x00100028, 0x2181050E, 0x00100038, 0x2181050E, 0x00100038, 0x1181850D, 0x00100038, 0x2981450F, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004A04, 0x00100000, 0x01000A05, 0x00100020, 0x0180C506, 0x00100030, 0x0180C506, 0x00100030, 0x2180C50C, 0x00100030, 0x49820A0D, 0x0016A130, 0x41824A0D, 0x0016A130, 0x2981450F, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2000CA0C, 0x00100000, 0x49820A0D, 0x0016A130, 0x1980C50E, 0x00100030, 0x41824A0D, 0x0016A130, 0x2981450F, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140C, 0x00100008, 0x0200140D, 0x00100048, 0x0B004A0E, 0x01900068, 0x13008A0E, 0x01900068, 0x13008A0E, 0x01900068, 0x43020A0C, 0x00100070, 0x1B00CA0D, 0x00100070, 0x1B014A0D, 0x00100070, 0x23010A0F, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140C, 0x00100010, 0x1A00D40D, 0x00100050, 0x13008A0E, 0x01900070, 0x13008A0E, 0x01900070, 0x1B014A0D, 0x00100070, 0x23010A0F, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x50029404, 0x00100000, 0x32019405, 0x00100040, 0x03004A06, 0x01900060, 0x03004A06, 0x01900060, 0x6B030A0C, 0x00100060, 0x4B02140D, 0x0016A160, 0x4302540D, 0x0016A160, 0x23010A0F, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x6B03140C, 0x00100060, 0x4B02140D, 0x0016A160, 0x0B004A0E, 0x01900060, 0x4302540D, 0x0016A160, 0x23010A0F, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x00100000, 0x1A00D405, 0x00100040, 0x53028A06, 0x01900060, 0x5B02CA06, 0x01900060, 0x5B02CA06, 0x01900060, 0x43020A04, 0x00100060, 0x1B00CA05, 0x00100060, 0x53028A07, 0x0190C060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140C, 0x00100010, 0x1A00D40D, 0x00100050, 0x53028A0E, 0x01900070, 0x5B02CA0E, 0x01900070, 0x5B02CA0E, 0x01900070, 0x43020A0C, 0x00100070, 0x1B00CA0D, 0x00100070, 0x53028A0F, 0x0190C070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x00100000, 0x1A00D405, 0x00100040, 0x5B02CA06, 0x01900060, 0x5B02CA06, 0x01900060, 0x53028A07, 0x0190C060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140C, 0x00100010, 0x1A00D40D, 0x00100050, 0x5B02CA0E, 0x01900070, 0x5B02CA0E, 0x01900070, 0x53028A0F, 0x0190C070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_gainctl0[] = { 0x03CC2B44, 0x03CC2B42, 0x03CC2B40, 0x03CC2B3E, 0x03CC2B3D, 0x03CC2B3B, 0x03C82B44, 0x03C82B42, 0x03C82B40, 0x03C82B3E, 0x03C82B3D, 0x03C82B3B, 0x03C82B39, 0x03C82B38, 0x03C82B36, 0x03C82B34, 0x03C42B44, 0x03C42B42, 0x03C42B40, 0x03C42B3E, 0x03C42B3D, 0x03C42B3B, 0x03C42B39, 0x03C42B38, 0x03C42B36, 0x03C42B34, 0x03C42B33, 0x03C42B32, 0x03C42B30, 0x03C42B2F, 0x03C42B2D, 0x03C02B44, 0x03C02B42, 0x03C02B40, 0x03C02B3E, 0x03C02B3D, 0x03C02B3B, 0x03C02B39, 0x03C02B38, 0x03C02B36, 0x03C02B34, 0x03B02B44, 0x03B02B42, 0x03B02B40, 0x03B02B3E, 0x03B02B3D, 0x03B02B3B, 0x03B02B39, 0x03B02B38, 0x03B02B36, 0x03B02B34, 0x03B02B33, 0x03B02B32, 0x03B02B30, 0x03B02B2F, 0x03B02B2D, 0x03A02B44, 0x03A02B42, 0x03A02B40, 0x03A02B3E, 0x03A02B3D, 0x03A02B3B, 0x03A02B39, 0x03A02B38, 0x03A02B36, 0x03A02B34, 0x03902B44, 0x03902B42, 0x03902B40, 0x03902B3E, 0x03902B3D, 0x03902B3B, 0x03902B39, 0x03902B38, 0x03902B36, 0x03902B34, 0x03902B33, 0x03902B32, 0x03902B30, 0x03802B44, 0x03802B42, 0x03802B40, 0x03802B3E, 0x03802B3D, 0x03802B3B, 0x03802B39, 0x03802B38, 0x03802B36, 0x03802B34, 0x03802B33, 0x03802B32, 0x03802B30, 0x03802B2F, 0x03802B2D, 0x03802B2C, 0x03802B2B, 0x03802B2A, 0x03802B29, 0x03802B27, 0x03802B26, 0x03802B25, 0x03802B24, 0x03802B23, 0x03802B22, 0x03802B21, 0x03802B20, 0x03802B1F, 0x03802B1E, 0x03802B1E, 0x03802B1D, 0x03802B1C, 0x03802B1B, 0x03802B1A, 0x03802B1A, 0x03802B19, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x00002B00, }; static const uint32_t bwn_ntab_gainctl1[] = { 0x03CC2B44, 0x03CC2B42, 0x03CC2B40, 0x03CC2B3E, 0x03CC2B3D, 0x03CC2B3B, 0x03C82B44, 0x03C82B42, 0x03C82B40, 0x03C82B3E, 0x03C82B3D, 0x03C82B3B, 0x03C82B39, 0x03C82B38, 0x03C82B36, 0x03C82B34, 0x03C42B44, 0x03C42B42, 0x03C42B40, 0x03C42B3E, 0x03C42B3D, 0x03C42B3B, 0x03C42B39, 0x03C42B38, 0x03C42B36, 0x03C42B34, 0x03C42B33, 0x03C42B32, 0x03C42B30, 0x03C42B2F, 0x03C42B2D, 0x03C02B44, 0x03C02B42, 0x03C02B40, 0x03C02B3E, 0x03C02B3D, 0x03C02B3B, 0x03C02B39, 0x03C02B38, 0x03C02B36, 0x03C02B34, 0x03B02B44, 0x03B02B42, 0x03B02B40, 0x03B02B3E, 0x03B02B3D, 0x03B02B3B, 0x03B02B39, 0x03B02B38, 0x03B02B36, 0x03B02B34, 0x03B02B33, 0x03B02B32, 0x03B02B30, 0x03B02B2F, 0x03B02B2D, 0x03A02B44, 0x03A02B42, 0x03A02B40, 0x03A02B3E, 0x03A02B3D, 0x03A02B3B, 0x03A02B39, 0x03A02B38, 0x03A02B36, 0x03A02B34, 0x03902B44, 0x03902B42, 0x03902B40, 0x03902B3E, 0x03902B3D, 0x03902B3B, 0x03902B39, 0x03902B38, 0x03902B36, 0x03902B34, 0x03902B33, 0x03902B32, 0x03902B30, 0x03802B44, 0x03802B42, 0x03802B40, 0x03802B3E, 0x03802B3D, 0x03802B3B, 0x03802B39, 0x03802B38, 0x03802B36, 0x03802B34, 0x03802B33, 0x03802B32, 0x03802B30, 0x03802B2F, 0x03802B2D, 0x03802B2C, 0x03802B2B, 0x03802B2A, 0x03802B29, 0x03802B27, 0x03802B26, 0x03802B25, 0x03802B24, 0x03802B23, 0x03802B22, 0x03802B21, 0x03802B20, 0x03802B1F, 0x03802B1E, 0x03802B1E, 0x03802B1D, 0x03802B1C, 0x03802B1B, 0x03802B1A, 0x03802B1A, 0x03802B19, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x03802B18, 0x00002B00, }; static const uint32_t bwn_ntab_intlevel[] = { 0x00802070, 0x0671188D, 0x0A60192C, 0x0A300E46, 0x00C1188D, 0x080024D2, 0x00000070, }; static const uint32_t bwn_ntab_iqlt0[] = { 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, }; static const uint32_t bwn_ntab_iqlt1[] = { 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, 0x0000007F, }; static const uint16_t bwn_ntab_loftlt0[] = { 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, }; static const uint16_t bwn_ntab_loftlt1[] = { 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, 0x0000, 0x0101, 0x0002, 0x0103, }; static const uint8_t bwn_ntab_mcs[] = { 0x00, 0x08, 0x0A, 0x10, 0x12, 0x19, 0x1A, 0x1C, 0x40, 0x48, 0x4A, 0x50, 0x52, 0x59, 0x5A, 0x5C, 0x80, 0x88, 0x8A, 0x90, 0x92, 0x99, 0x9A, 0x9C, 0xC0, 0xC8, 0xCA, 0xD0, 0xD2, 0xD9, 0xDA, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x09, 0x0A, 0x0C, 0x10, 0x11, 0x12, 0x14, 0x18, 0x19, 0x1A, 0x1C, 0x20, 0x21, 0x22, 0x24, 0x40, 0x41, 0x42, 0x44, 0x48, 0x49, 0x4A, 0x4C, 0x50, 0x51, 0x52, 0x54, 0x58, 0x59, 0x5A, 0x5C, 0x60, 0x61, 0x62, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint32_t bwn_ntab_noisevar10[] = { 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, }; static const uint32_t bwn_ntab_noisevar11[] = { 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, 0x020C020C, 0x0000014D, }; static const uint16_t bwn_ntab_pilot[] = { 0xFF08, 0xFF08, 0xFF08, 0xFF08, 0xFF08, 0xFF08, 0xFF08, 0xFF08, 0x80D5, 0x80D5, 0x80D5, 0x80D5, 0x80D5, 0x80D5, 0x80D5, 0x80D5, 0xFF0A, 0xFF82, 0xFFA0, 0xFF28, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFF82, 0xFFA0, 0xFF28, 0xFF0A, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xF83F, 0xFA1F, 0xFA97, 0xFAB5, 0xF2BD, 0xF0BF, 0xFFFF, 0xFFFF, 0xF017, 0xF815, 0xF215, 0xF095, 0xF035, 0xF01D, 0xFFFF, 0xFFFF, 0xFF08, 0xFF02, 0xFF80, 0xFF20, 0xFF08, 0xFF02, 0xFF80, 0xFF20, 0xF01F, 0xF817, 0xFA15, 0xF295, 0xF0B5, 0xF03D, 0xFFFF, 0xFFFF, 0xF82A, 0xFA0A, 0xFA82, 0xFAA0, 0xF2A8, 0xF0AA, 0xFFFF, 0xFFFF, 0xF002, 0xF800, 0xF200, 0xF080, 0xF020, 0xF008, 0xFFFF, 0xFFFF, 0xF00A, 0xF802, 0xFA00, 0xF280, 0xF0A0, 0xF028, 0xFFFF, 0xFFFF, }; static const uint32_t bwn_ntab_pilotlt[] = { 0x76540123, 0x62407351, 0x76543201, 0x76540213, 0x76540123, 0x76430521, }; static const uint32_t bwn_ntab_tdi20a0[] = { 0x00091226, 0x000A1429, 0x000B56AD, 0x000C58B0, 0x000D5AB3, 0x000E9CB6, 0x000F9EBA, 0x0000C13D, 0x00020301, 0x00030504, 0x00040708, 0x0005090B, 0x00064B8E, 0x00095291, 0x000A5494, 0x000B9718, 0x000C9927, 0x000D9B2A, 0x000EDD2E, 0x000FDF31, 0x000101B4, 0x000243B7, 0x000345BB, 0x000447BE, 0x00058982, 0x00068C05, 0x00099309, 0x000A950C, 0x000BD78F, 0x000CD992, 0x000DDB96, 0x000F1D99, 0x00005FA8, 0x0001422C, 0x0002842F, 0x00038632, 0x00048835, 0x0005CA38, 0x0006CCBC, 0x0009D3BF, 0x000B1603, 0x000C1806, 0x000D1A0A, 0x000E1C0D, 0x000F5E10, 0x00008093, 0x00018297, 0x0002C49A, 0x0003C680, 0x0004C880, 0x00060B00, 0x00070D00, 0x00000000, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_tdi20a1[] = { 0x00014B26, 0x00028D29, 0x000393AD, 0x00049630, 0x0005D833, 0x0006DA36, 0x00099C3A, 0x000A9E3D, 0x000BC081, 0x000CC284, 0x000DC488, 0x000F068B, 0x0000488E, 0x00018B91, 0x0002D214, 0x0003D418, 0x0004D6A7, 0x000618AA, 0x00071AAE, 0x0009DCB1, 0x000B1EB4, 0x000C0137, 0x000D033B, 0x000E053E, 0x000F4702, 0x00008905, 0x00020C09, 0x0003128C, 0x0004148F, 0x00051712, 0x00065916, 0x00091B19, 0x000A1D28, 0x000B5F2C, 0x000C41AF, 0x000D43B2, 0x000E85B5, 0x000F87B8, 0x0000C9BC, 0x00024CBF, 0x00035303, 0x00045506, 0x0005978A, 0x0006998D, 0x00095B90, 0x000A5D93, 0x000B9F97, 0x000C821A, 0x000D8400, 0x000EC600, 0x000FC800, 0x00010A00, 0x00000000, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_tdi40a0[] = { 0x0011A346, 0x00136CCF, 0x0014F5D9, 0x001641E2, 0x0017CB6B, 0x00195475, 0x001B2383, 0x001CAD0C, 0x001E7616, 0x0000821F, 0x00020BA8, 0x0003D4B2, 0x00056447, 0x00072DD0, 0x0008B6DA, 0x000A02E3, 0x000B8C6C, 0x000D15F6, 0x0011E484, 0x0013AE0D, 0x00153717, 0x00168320, 0x00180CA9, 0x00199633, 0x001B6548, 0x001CEED1, 0x001EB7DB, 0x0000C3E4, 0x00024D6D, 0x000416F7, 0x0005A585, 0x00076F0F, 0x0008F818, 0x000A4421, 0x000BCDAB, 0x000D9734, 0x00122649, 0x0013EFD2, 0x001578DC, 0x0016C4E5, 0x00184E6E, 0x001A17F8, 0x001BA686, 0x001D3010, 0x001EF999, 0x00010522, 0x00028EAC, 0x00045835, 0x0005E74A, 0x0007B0D3, 0x00093A5D, 0x000A85E6, 0x000C0F6F, 0x000DD8F9, 0x00126787, 0x00143111, 0x0015BA9A, 0x00170623, 0x00188FAD, 0x001A5936, 0x001BE84B, 0x001DB1D4, 0x001F3B5E, 0x000146E7, 0x00031070, 0x000499FA, 0x00062888, 0x0007F212, 0x00097B9B, 0x000AC7A4, 0x000C50AE, 0x000E1A37, 0x0012A94C, 0x001472D5, 0x0015FC5F, 0x00174868, 0x0018D171, 0x001A9AFB, 0x001C2989, 0x001DF313, 0x001F7C9C, 0x000188A5, 0x000351AF, 0x0004DB38, 0x0006AA4D, 0x000833D7, 0x0009BD60, 0x000B0969, 0x000C9273, 0x000E5BFC, 0x00132A8A, 0x0014B414, 0x00163D9D, 0x001789A6, 0x001912B0, 0x001ADC39, 0x001C6BCE, 0x001E34D8, 0x001FBE61, 0x0001CA6A, 0x00039374, 0x00051CFD, 0x0006EC0B, 0x00087515, 0x0009FE9E, 0x000B4AA7, 0x000CD3B1, 0x000E9D3A, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_tdi40a1[] = { 0x001EDB36, 0x000129CA, 0x0002B353, 0x00047CDD, 0x0005C8E6, 0x000791EF, 0x00091BF9, 0x000AAA07, 0x000C3391, 0x000DFD1A, 0x00120923, 0x0013D22D, 0x00155C37, 0x0016EACB, 0x00187454, 0x001A3DDE, 0x001B89E7, 0x001D12F0, 0x001F1CFA, 0x00016B88, 0x00033492, 0x0004BE1B, 0x00060A24, 0x0007D32E, 0x00095D38, 0x000AEC4C, 0x000C7555, 0x000E3EDF, 0x00124AE8, 0x001413F1, 0x0015A37B, 0x00172C89, 0x0018B593, 0x001A419C, 0x001BCB25, 0x001D942F, 0x001F63B9, 0x0001AD4D, 0x00037657, 0x0004C260, 0x00068BE9, 0x000814F3, 0x0009A47C, 0x000B2D8A, 0x000CB694, 0x000E429D, 0x00128C26, 0x001455B0, 0x0015E4BA, 0x00176E4E, 0x0018F758, 0x001A8361, 0x001C0CEA, 0x001DD674, 0x001FA57D, 0x0001EE8B, 0x0003B795, 0x0005039E, 0x0006CD27, 0x000856B1, 0x0009E5C6, 0x000B6F4F, 0x000CF859, 0x000E8462, 0x00130DEB, 0x00149775, 0x00162603, 0x0017AF8C, 0x00193896, 0x001AC49F, 0x001C4E28, 0x001E17B2, 0x0000A6C7, 0x00023050, 0x0003F9DA, 0x00054563, 0x00070EEC, 0x00089876, 0x000A2704, 0x000BB08D, 0x000D3A17, 0x001185A0, 0x00134F29, 0x0014D8B3, 0x001667C8, 0x0017F151, 0x00197ADB, 0x001B0664, 0x001C8FED, 0x001E5977, 0x0000E805, 0x0002718F, 0x00043B18, 0x000586A1, 0x0007502B, 0x0008D9B4, 0x000A68C9, 0x000BF252, 0x000DBBDC, 0x0011C7E5, 0x001390EE, 0x00151A78, 0x0016A906, 0x00183290, 0x0019BC19, 0x001B4822, 0x001CD12C, 0x001E9AB5, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_tdtrn[] = { 0x061C061C, 0x0050EE68, 0xF592FE36, 0xFE5212F6, 0x00000C38, 0xFE5212F6, 0xF592FE36, 0x0050EE68, 0x061C061C, 0xEE680050, 0xFE36F592, 0x12F6FE52, 0x0C380000, 0x12F6FE52, 0xFE36F592, 0xEE680050, 0x061C061C, 0x0050EE68, 0xF592FE36, 0xFE5212F6, 0x00000C38, 0xFE5212F6, 0xF592FE36, 0x0050EE68, 0x061C061C, 0xEE680050, 0xFE36F592, 0x12F6FE52, 0x0C380000, 0x12F6FE52, 0xFE36F592, 0xEE680050, 0x05E305E3, 0x004DEF0C, 0xF5F3FE47, 0xFE611246, 0x00000BC7, 0xFE611246, 0xF5F3FE47, 0x004DEF0C, 0x05E305E3, 0xEF0C004D, 0xFE47F5F3, 0x1246FE61, 0x0BC70000, 0x1246FE61, 0xFE47F5F3, 0xEF0C004D, 0x05E305E3, 0x004DEF0C, 0xF5F3FE47, 0xFE611246, 0x00000BC7, 0xFE611246, 0xF5F3FE47, 0x004DEF0C, 0x05E305E3, 0xEF0C004D, 0xFE47F5F3, 0x1246FE61, 0x0BC70000, 0x1246FE61, 0xFE47F5F3, 0xEF0C004D, 0xFA58FA58, 0xF895043B, 0xFF4C09C0, 0xFBC6FFA8, 0xFB84F384, 0x0798F6F9, 0x05760122, 0x058409F6, 0x0B500000, 0x05B7F542, 0x08860432, 0x06DDFEE7, 0xFB84F384, 0xF9D90664, 0xF7E8025C, 0x00FFF7BD, 0x05A805A8, 0xF7BD00FF, 0x025CF7E8, 0x0664F9D9, 0xF384FB84, 0xFEE706DD, 0x04320886, 0xF54205B7, 0x00000B50, 0x09F60584, 0x01220576, 0xF6F90798, 0xF384FB84, 0xFFA8FBC6, 0x09C0FF4C, 0x043BF895, 0x02D402D4, 0x07DE0270, 0xFC96079C, 0xF90AFE94, 0xFE00FF2C, 0x02D4065D, 0x092A0096, 0x0014FBB8, 0xFD2CFD2C, 0x076AFB3C, 0x0096F752, 0xF991FD87, 0xFB2C0200, 0xFEB8F960, 0x08E0FC96, 0x049802A8, 0xFD2CFD2C, 0x02A80498, 0xFC9608E0, 0xF960FEB8, 0x0200FB2C, 0xFD87F991, 0xF7520096, 0xFB3C076A, 0xFD2CFD2C, 0xFBB80014, 0x0096092A, 0x065D02D4, 0xFF2CFE00, 0xFE94F90A, 0x079CFC96, 0x027007DE, 0x02D402D4, 0x027007DE, 0x079CFC96, 0xFE94F90A, 0xFF2CFE00, 0x065D02D4, 0x0096092A, 0xFBB80014, 0xFD2CFD2C, 0xFB3C076A, 0xF7520096, 0xFD87F991, 0x0200FB2C, 0xF960FEB8, 0xFC9608E0, 0x02A80498, 0xFD2CFD2C, 0x049802A8, 0x08E0FC96, 0xFEB8F960, 0xFB2C0200, 0xF991FD87, 0x0096F752, 0x076AFB3C, 0xFD2CFD2C, 0x0014FBB8, 0x092A0096, 0x02D4065D, 0xFE00FF2C, 0xF90AFE94, 0xFC96079C, 0x07DE0270, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x062A0000, 0xFEFA0759, 0x08B80908, 0xF396FC2D, 0xF9D6045C, 0xFC4EF608, 0xF748F596, 0x07B207BF, 0x062A062A, 0xF84EF841, 0xF748F596, 0x03B209F8, 0xF9D6045C, 0x0C6A03D3, 0x08B80908, 0x0106F8A7, 0x062A0000, 0xFEFAF8A7, 0x08B8F6F8, 0xF39603D3, 0xF9D6FBA4, 0xFC4E09F8, 0xF7480A6A, 0x07B2F841, 0x062AF9D6, 0xF84E07BF, 0xF7480A6A, 0x03B2F608, 0xF9D6FBA4, 0x0C6AFC2D, 0x08B8F6F8, 0x01060759, 0x062A0000, 0xFEFA0759, 0x08B80908, 0xF396FC2D, 0xF9D6045C, 0xFC4EF608, 0xF748F596, 0x07B207BF, 0x062A062A, 0xF84EF841, 0xF748F596, 0x03B209F8, 0xF9D6045C, 0x0C6A03D3, 0x08B80908, 0x0106F8A7, 0x062A0000, 0xFEFAF8A7, 0x08B8F6F8, 0xF39603D3, 0xF9D6FBA4, 0xFC4E09F8, 0xF7480A6A, 0x07B2F841, 0x062AF9D6, 0xF84E07BF, 0xF7480A6A, 0x03B2F608, 0xF9D6FBA4, 0x0C6AFC2D, 0x08B8F6F8, 0x01060759, 0x061C061C, 0xFF30009D, 0xFFB21141, 0xFD87FB54, 0xF65DFE59, 0x02EEF99E, 0x0166F03C, 0xFFF809B6, 0x000008A4, 0x000AF42B, 0x00EFF577, 0xFA840BF2, 0xFC02FF51, 0x08260F67, 0xFFF0036F, 0x0842F9C3, 0x00000000, 0x063DF7BE, 0xFC910010, 0xF099F7DA, 0x00AF03FE, 0xF40E057C, 0x0A89FF11, 0x0BD5FFF6, 0xF75C0000, 0xF64A0008, 0x0FC4FE9A, 0x0662FD12, 0x01A709A3, 0x04AC0279, 0xEEBF004E, 0xFF6300D0, 0xF9E4F9E4, 0x00D0FF63, 0x004EEEBF, 0x027904AC, 0x09A301A7, 0xFD120662, 0xFE9A0FC4, 0x0008F64A, 0x0000F75C, 0xFFF60BD5, 0xFF110A89, 0x057CF40E, 0x03FE00AF, 0xF7DAF099, 0x0010FC91, 0xF7BE063D, 0x00000000, 0xF9C30842, 0x036FFFF0, 0x0F670826, 0xFF51FC02, 0x0BF2FA84, 0xF57700EF, 0xF42B000A, 0x08A40000, 0x09B6FFF8, 0xF03C0166, 0xF99E02EE, 0xFE59F65D, 0xFB54FD87, 0x1141FFB2, 0x009DFF30, 0x05E30000, 0xFF060705, 0x085408A0, 0xF425FC59, 0xFA1D042A, 0xFC78F67A, 0xF7ACF60E, 0x075A0766, 0x05E305E3, 0xF8A6F89A, 0xF7ACF60E, 0x03880986, 0xFA1D042A, 0x0BDB03A7, 0x085408A0, 0x00FAF8FB, 0x05E30000, 0xFF06F8FB, 0x0854F760, 0xF42503A7, 0xFA1DFBD6, 0xFC780986, 0xF7AC09F2, 0x075AF89A, 0x05E3FA1D, 0xF8A60766, 0xF7AC09F2, 0x0388F67A, 0xFA1DFBD6, 0x0BDBFC59, 0x0854F760, 0x00FA0705, 0x05E30000, 0xFF060705, 0x085408A0, 0xF425FC59, 0xFA1D042A, 0xFC78F67A, 0xF7ACF60E, 0x075A0766, 0x05E305E3, 0xF8A6F89A, 0xF7ACF60E, 0x03880986, 0xFA1D042A, 0x0BDB03A7, 0x085408A0, 0x00FAF8FB, 0x05E30000, 0xFF06F8FB, 0x0854F760, 0xF42503A7, 0xFA1DFBD6, 0xFC780986, 0xF7AC09F2, 0x075AF89A, 0x05E3FA1D, 0xF8A60766, 0xF7AC09F2, 0x0388F67A, 0xFA1DFBD6, 0x0BDBFC59, 0x0854F760, 0x00FA0705, 0xFA58FA58, 0xF8F0FE00, 0x0448073D, 0xFDC9FE46, 0xF9910258, 0x089D0407, 0xFD5CF71A, 0x02AFFDE0, 0x083E0496, 0xFF5A0740, 0xFF7AFD97, 0x00FE01F1, 0x0009082E, 0xFA94FF75, 0xFECDF8EA, 0xFFB0F693, 0xFD2CFA58, 0x0433FF16, 0xFBA405DD, 0xFA610341, 0x06A606CB, 0x0039FD2D, 0x0677FA97, 0x01FA05E0, 0xF896003E, 0x075A068B, 0x012CFC3E, 0xFA23F98D, 0xFC7CFD43, 0xFF90FC0D, 0x01C10982, 0x00C601D6, 0xFD2CFD2C, 0x01D600C6, 0x098201C1, 0xFC0DFF90, 0xFD43FC7C, 0xF98DFA23, 0xFC3E012C, 0x068B075A, 0x003EF896, 0x05E001FA, 0xFA970677, 0xFD2D0039, 0x06CB06A6, 0x0341FA61, 0x05DDFBA4, 0xFF160433, 0xFA58FD2C, 0xF693FFB0, 0xF8EAFECD, 0xFF75FA94, 0x082E0009, 0x01F100FE, 0xFD97FF7A, 0x0740FF5A, 0x0496083E, 0xFDE002AF, 0xF71AFD5C, 0x0407089D, 0x0258F991, 0xFE46FDC9, 0x073D0448, 0xFE00F8F0, 0xFD2CFD2C, 0xFCE00500, 0xFC09FDDC, 0xFE680157, 0x04C70571, 0xFC3AFF21, 0xFCD70228, 0x056D0277, 0x0200FE00, 0x0022F927, 0xFE3C032B, 0xFC44FF3C, 0x03E9FBDB, 0x04570313, 0x04C9FF5C, 0x000D03B8, 0xFA580000, 0xFBE900D2, 0xF9D0FE0B, 0x0125FDF9, 0x042501BF, 0x0328FA2B, 0xFFA902F0, 0xFA250157, 0x0200FE00, 0x03740438, 0xFF0405FD, 0x030CFE52, 0x0037FB39, 0xFF6904C5, 0x04F8FD23, 0xFD31FC1B, 0xFD2CFD2C, 0xFC1BFD31, 0xFD2304F8, 0x04C5FF69, 0xFB390037, 0xFE52030C, 0x05FDFF04, 0x04380374, 0xFE000200, 0x0157FA25, 0x02F0FFA9, 0xFA2B0328, 0x01BF0425, 0xFDF90125, 0xFE0BF9D0, 0x00D2FBE9, 0x0000FA58, 0x03B8000D, 0xFF5C04C9, 0x03130457, 0xFBDB03E9, 0xFF3CFC44, 0x032BFE3C, 0xF9270022, 0xFE000200, 0x0277056D, 0x0228FCD7, 0xFF21FC3A, 0x057104C7, 0x0157FE68, 0xFDDCFC09, 0x0500FCE0, 0xFD2CFD2C, 0x0500FCE0, 0xFDDCFC09, 0x0157FE68, 0x057104C7, 0xFF21FC3A, 0x0228FCD7, 0x0277056D, 0xFE000200, 0xF9270022, 0x032BFE3C, 0xFF3CFC44, 0xFBDB03E9, 0x03130457, 0xFF5C04C9, 0x03B8000D, 0x0000FA58, 0x00D2FBE9, 0xFE0BF9D0, 0xFDF90125, 0x01BF0425, 0xFA2B0328, 0x02F0FFA9, 0x0157FA25, 0xFE000200, 0x04380374, 0x05FDFF04, 0xFE52030C, 0xFB390037, 0x04C5FF69, 0xFD2304F8, 0xFC1BFD31, 0xFD2CFD2C, 0xFD31FC1B, 0x04F8FD23, 0xFF6904C5, 0x0037FB39, 0x030CFE52, 0xFF0405FD, 0x03740438, 0x0200FE00, 0xFA250157, 0xFFA902F0, 0x0328FA2B, 0x042501BF, 0x0125FDF9, 0xF9D0FE0B, 0xFBE900D2, 0xFA580000, 0x000D03B8, 0x04C9FF5C, 0x04570313, 0x03E9FBDB, 0xFC44FF3C, 0xFE3C032B, 0x0022F927, 0x0200FE00, 0x056D0277, 0xFCD70228, 0xFC3AFF21, 0x04C70571, 0xFE680157, 0xFC09FDDC, 0xFCE00500, 0x05A80000, 0xFF1006BE, 0x0800084A, 0xF49CFC7E, 0xFA580400, 0xFC9CF6DA, 0xF800F672, 0x0710071C, 0x05A805A8, 0xF8F0F8E4, 0xF800F672, 0x03640926, 0xFA580400, 0x0B640382, 0x0800084A, 0x00F0F942, 0x05A80000, 0xFF10F942, 0x0800F7B6, 0xF49C0382, 0xFA58FC00, 0xFC9C0926, 0xF800098E, 0x0710F8E4, 0x05A8FA58, 0xF8F0071C, 0xF800098E, 0x0364F6DA, 0xFA58FC00, 0x0B64FC7E, 0x0800F7B6, 0x00F006BE, 0x05A80000, 0xFF1006BE, 0x0800084A, 0xF49CFC7E, 0xFA580400, 0xFC9CF6DA, 0xF800F672, 0x0710071C, 0x05A805A8, 0xF8F0F8E4, 0xF800F672, 0x03640926, 0xFA580400, 0x0B640382, 0x0800084A, 0x00F0F942, 0x05A80000, 0xFF10F942, 0x0800F7B6, 0xF49C0382, 0xFA58FC00, 0xFC9C0926, 0xF800098E, 0x0710F8E4, 0x05A8FA58, 0xF8F0071C, 0xF800098E, 0x0364F6DA, 0xFA58FC00, 0x0B64FC7E, 0x0800F7B6, 0x00F006BE, }; static const uint32_t bwn_ntab_tmap[] = { 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00000888, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0xF1111110, 0x11111111, 0x11F11111, 0x00000111, 0x11000000, 0x1111F111, 0x11111111, 0x111111F1, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x000AA888, 0x88880000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0xA1111110, 0x11111111, 0x11C11111, 0x00000111, 0x11000000, 0x1111A111, 0x11111111, 0x111111A1, 0xA2222220, 0x22222222, 0x22C22222, 0x00000222, 0x22000000, 0x2222A222, 0x22222222, 0x222222A2, 0xF1111110, 0x11111111, 0x11F11111, 0x00011111, 0x11110000, 0x1111F111, 0x11111111, 0x111111F1, 0xA8AA88A0, 0xA88888A8, 0xA8A8A88A, 0x00088AAA, 0xAAAA0000, 0xA8A8AA88, 0xA88AAAAA, 0xAAAA8A8A, 0xAAA8AAA0, 0x8AAA8AAA, 0xAA8A8A8A, 0x000AAA88, 0x8AAA0000, 0xAAA8A888, 0x8AA88A8A, 0x8A88A888, 0x08080A00, 0x0A08080A, 0x080A0A08, 0x00080808, 0x080A0000, 0x080A0808, 0x080A0808, 0x0A0A0A08, 0xA0A0A0A0, 0x80A0A080, 0x8080A0A0, 0x00008080, 0x80A00000, 0x80A080A0, 0xA080A0A0, 0x8080A0A0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99999000, 0x9B9B99BB, 0x9BB99999, 0x9999B9B9, 0x9B99BB90, 0x9BBBBB9B, 0x9B9B9BB9, 0x00000999, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00AAA888, 0x22000000, 0x2222B222, 0x22222222, 0x222222B2, 0xB2222220, 0x22222222, 0x22D22222, 0x00000222, 0x11000000, 0x1111A111, 0x11111111, 0x111111A1, 0xA1111110, 0x11111111, 0x11C11111, 0x00000111, 0x33000000, 0x3333B333, 0x33333333, 0x333333B3, 0xB3333330, 0x33333333, 0x33D33333, 0x00000333, 0x22000000, 0x2222A222, 0x22222222, 0x222222A2, 0xA2222220, 0x22222222, 0x22C22222, 0x00000222, 0x99B99B00, 0x9B9B99BB, 0x9BB99999, 0x9999B9B9, 0x9B99BB99, 0x9BBBBB9B, 0x9B9B9BB9, 0x00000999, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA88, 0x8AAAAA8A, 0x8A8A8AA8, 0x08AAA888, 0x22222200, 0x2222F222, 0x22222222, 0x222222F2, 0x22222222, 0x22222222, 0x22F22222, 0x00000222, 0x11000000, 0x1111F111, 0x11111111, 0x11111111, 0xF1111111, 0x11111111, 0x11F11111, 0x01111111, 0xBB9BB900, 0xB9B9BB99, 0xB99BBBBB, 0xBBBB9B9B, 0xB9BB99BB, 0xB99999B9, 0xB9B9B99B, 0x00000BBB, 0xAA000000, 0xA8A8AA88, 0xA88AAAAA, 0xAAAA8A8A, 0xA8AA88AA, 0xA88888A8, 0xA8A8A88A, 0x0A888AAA, 0xAA000000, 0xA8A8AA88, 0xA88AAAAA, 0xAAAA8A8A, 0xA8AA88A0, 0xA88888A8, 0xA8A8A88A, 0x00000AAA, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00000888, 0xBBBBBB00, 0x999BBBBB, 0x9BB99B9B, 0xB9B9B9BB, 0xB9B99BBB, 0xB9B9B9BB, 0xB9BB9B99, 0x00000999, 0x8A000000, 0xAA88A888, 0xA88888AA, 0xA88A8A88, 0xA88AA88A, 0x88A8AAAA, 0xA8AA8AAA, 0x0888A88A, 0x0B0B0B00, 0x090B0B0B, 0x0B090B0B, 0x0909090B, 0x09090B0B, 0x09090B0B, 0x09090B09, 0x00000909, 0x0A000000, 0x0A080808, 0x080A080A, 0x080A0A08, 0x080A080A, 0x0808080A, 0x0A0A0A08, 0x0808080A, 0xB0B0B000, 0x9090B0B0, 0x90B09090, 0xB0B0B090, 0xB0B090B0, 0x90B0B0B0, 0xB0B09090, 0x00000090, 0x80000000, 0xA080A080, 0xA08080A0, 0xA0808080, 0xA080A080, 0x80A0A0A0, 0xA0A080A0, 0x00A0A0A0, 0x22000000, 0x2222F222, 0x22222222, 0x222222F2, 0xF2222220, 0x22222222, 0x22F22222, 0x00000222, 0x11000000, 0x1111F111, 0x11111111, 0x111111F1, 0xF1111110, 0x11111111, 0x11F11111, 0x00000111, 0x33000000, 0x3333F333, 0x33333333, 0x333333F3, 0xF3333330, 0x33333333, 0x33F33333, 0x00000333, 0x22000000, 0x2222F222, 0x22222222, 0x222222F2, 0xF2222220, 0x22222222, 0x22F22222, 0x00000222, 0x99000000, 0x9B9B99BB, 0x9BB99999, 0x9999B9B9, 0x9B99BB90, 0x9BBBBB9B, 0x9B9B9BB9, 0x00000999, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00000888, 0x88888000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00000888, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00AAA888, 0x88A88A00, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA88, 0x8AAAAA8A, 0x8A8A8AA8, 0x00000888, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA88, 0x8AAAAA8A, 0x8A8A8AA8, 0x08AAA888, 0x11000000, 0x1111A111, 0x11111111, 0x111111A1, 0xA1111110, 0x11111111, 0x11C11111, 0x00000111, 0x11000000, 0x1111A111, 0x11111111, 0x111111A1, 0xA1111110, 0x11111111, 0x11C11111, 0x00000111, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00000888, 0x88000000, 0x8A8A88AA, 0x8AA88888, 0x8888A8A8, 0x8A88AA80, 0x8AAAAA8A, 0x8A8A8AA8, 0x00000888, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; /* static tables, PHY revision >= 3 */ static const uint32_t bwn_ntab_framestruct_r3[] = { 0x08004a04, 0x00100000, 0x01000a05, 0x00100020, 0x09804506, 0x00100030, 0x09804507, 0x00100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004a0c, 0x00100004, 0x01000a0d, 0x00100024, 0x0980450e, 0x00100034, 0x0980450f, 0x00100034, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000a04, 0x00100000, 0x11008a05, 0x00100020, 0x1980c506, 0x00100030, 0x21810506, 0x00100030, 0x21810506, 0x00100030, 0x01800504, 0x00100030, 0x11808505, 0x00100030, 0x29814507, 0x01100030, 0x00000a04, 0x00100000, 0x11008a05, 0x00100020, 0x21810506, 0x00100030, 0x21810506, 0x00100030, 0x29814507, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000a0c, 0x00100008, 0x11008a0d, 0x00100028, 0x1980c50e, 0x00100038, 0x2181050e, 0x00100038, 0x2181050e, 0x00100038, 0x0180050c, 0x00100038, 0x1180850d, 0x00100038, 0x2981450f, 0x01100038, 0x00000a0c, 0x00100008, 0x11008a0d, 0x00100028, 0x2181050e, 0x00100038, 0x2181050e, 0x00100038, 0x2981450f, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004a04, 0x00100000, 0x01000a05, 0x00100020, 0x1980c506, 0x00100030, 0x1980c506, 0x00100030, 0x11808504, 0x00100030, 0x3981ca05, 0x00100030, 0x29814507, 0x01100030, 0x00000000, 0x00000000, 0x10008a04, 0x00100000, 0x3981ca05, 0x00100030, 0x1980c506, 0x00100030, 0x29814507, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004a0c, 0x00100008, 0x01000a0d, 0x00100028, 0x1980c50e, 0x00100038, 0x1980c50e, 0x00100038, 0x1180850c, 0x00100038, 0x3981ca0d, 0x00100038, 0x2981450f, 0x01100038, 0x00000000, 0x00000000, 0x10008a0c, 0x00100008, 0x3981ca0d, 0x00100038, 0x1980c50e, 0x00100038, 0x2981450f, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x00100000, 0x02001405, 0x00100040, 0x0b004a06, 0x01900060, 0x13008a06, 0x01900060, 0x13008a06, 0x01900060, 0x43020a04, 0x00100060, 0x1b00ca05, 0x00100060, 0x23010a07, 0x01500060, 0x40021404, 0x00100000, 0x1a00d405, 0x00100040, 0x13008a06, 0x01900060, 0x13008a06, 0x01900060, 0x23010a07, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140c, 0x00100010, 0x0200140d, 0x00100050, 0x0b004a0e, 0x01900070, 0x13008a0e, 0x01900070, 0x13008a0e, 0x01900070, 0x43020a0c, 0x00100070, 0x1b00ca0d, 0x00100070, 0x23010a0f, 0x01500070, 0x4002140c, 0x00100010, 0x1a00d40d, 0x00100050, 0x13008a0e, 0x01900070, 0x13008a0e, 0x01900070, 0x23010a0f, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x50029404, 0x00100000, 0x32019405, 0x00100040, 0x0b004a06, 0x01900060, 0x0b004a06, 0x01900060, 0x5b02ca04, 0x00100060, 0x3b01d405, 0x00100060, 0x23010a07, 0x01500060, 0x00000000, 0x00000000, 0x5802d404, 0x00100000, 0x3b01d405, 0x00100060, 0x0b004a06, 0x01900060, 0x23010a07, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x5002940c, 0x00100010, 0x3201940d, 0x00100050, 0x0b004a0e, 0x01900070, 0x0b004a0e, 0x01900070, 0x5b02ca0c, 0x00100070, 0x3b01d40d, 0x00100070, 0x23010a0f, 0x01500070, 0x00000000, 0x00000000, 0x5802d40c, 0x00100010, 0x3b01d40d, 0x00100070, 0x0b004a0e, 0x01900070, 0x23010a0f, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x000f4800, 0x62031405, 0x00100040, 0x53028a06, 0x01900060, 0x53028a07, 0x01900060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140c, 0x000f4808, 0x6203140d, 0x00100048, 0x53028a0e, 0x01900068, 0x53028a0f, 0x01900068, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000a0c, 0x00100004, 0x11008a0d, 0x00100024, 0x1980c50e, 0x00100034, 0x2181050e, 0x00100034, 0x2181050e, 0x00100034, 0x0180050c, 0x00100038, 0x1180850d, 0x00100038, 0x1181850d, 0x00100038, 0x2981450f, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000a0c, 0x00100008, 0x11008a0d, 0x00100028, 0x2181050e, 0x00100038, 0x2181050e, 0x00100038, 0x1181850d, 0x00100038, 0x2981450f, 0x01100038, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x08004a04, 0x00100000, 0x01000a05, 0x00100020, 0x0180c506, 0x00100030, 0x0180c506, 0x00100030, 0x2180c50c, 0x00100030, 0x49820a0d, 0x0016a130, 0x41824a0d, 0x0016a130, 0x2981450f, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x2000ca0c, 0x00100000, 0x49820a0d, 0x0016a130, 0x1980c50e, 0x00100030, 0x41824a0d, 0x0016a130, 0x2981450f, 0x01100030, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140c, 0x00100008, 0x0200140d, 0x00100048, 0x0b004a0e, 0x01900068, 0x13008a0e, 0x01900068, 0x13008a0e, 0x01900068, 0x43020a0c, 0x00100070, 0x1b00ca0d, 0x00100070, 0x1b014a0d, 0x00100070, 0x23010a0f, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140c, 0x00100010, 0x1a00d40d, 0x00100050, 0x13008a0e, 0x01900070, 0x13008a0e, 0x01900070, 0x1b014a0d, 0x00100070, 0x23010a0f, 0x01500070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x50029404, 0x00100000, 0x32019405, 0x00100040, 0x03004a06, 0x01900060, 0x03004a06, 0x01900060, 0x6b030a0c, 0x00100060, 0x4b02140d, 0x0016a160, 0x4302540d, 0x0016a160, 0x23010a0f, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x6b03140c, 0x00100060, 0x4b02140d, 0x0016a160, 0x0b004a0e, 0x01900060, 0x4302540d, 0x0016a160, 0x23010a0f, 0x01500060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x00100000, 0x1a00d405, 0x00100040, 0x53028a06, 0x01900060, 0x5b02ca06, 0x01900060, 0x5b02ca06, 0x01900060, 0x43020a04, 0x00100060, 0x1b00ca05, 0x00100060, 0x53028a07, 0x0190c060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140c, 0x00100010, 0x1a00d40d, 0x00100050, 0x53028a0e, 0x01900070, 0x5b02ca0e, 0x01900070, 0x5b02ca0e, 0x01900070, 0x43020a0c, 0x00100070, 0x1b00ca0d, 0x00100070, 0x53028a0f, 0x0190c070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x40021404, 0x00100000, 0x1a00d405, 0x00100040, 0x5b02ca06, 0x01900060, 0x5b02ca06, 0x01900060, 0x53028a07, 0x0190c060, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x4002140c, 0x00100010, 0x1a00d40d, 0x00100050, 0x5b02ca0e, 0x01900070, 0x5b02ca0e, 0x01900070, 0x53028a0f, 0x0190c070, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; static const uint16_t bwn_ntab_pilot_r3[] = { 0xff08, 0xff08, 0xff08, 0xff08, 0xff08, 0xff08, 0xff08, 0xff08, 0x80d5, 0x80d5, 0x80d5, 0x80d5, 0x80d5, 0x80d5, 0x80d5, 0x80d5, 0xff0a, 0xff82, 0xffa0, 0xff28, 0xffff, 0xffff, 0xffff, 0xffff, 0xff82, 0xffa0, 0xff28, 0xff0a, 0xffff, 0xffff, 0xffff, 0xffff, 0xf83f, 0xfa1f, 0xfa97, 0xfab5, 0xf2bd, 0xf0bf, 0xffff, 0xffff, 0xf017, 0xf815, 0xf215, 0xf095, 0xf035, 0xf01d, 0xffff, 0xffff, 0xff08, 0xff02, 0xff80, 0xff20, 0xff08, 0xff02, 0xff80, 0xff20, 0xf01f, 0xf817, 0xfa15, 0xf295, 0xf0b5, 0xf03d, 0xffff, 0xffff, 0xf82a, 0xfa0a, 0xfa82, 0xfaa0, 0xf2a8, 0xf0aa, 0xffff, 0xffff, 0xf002, 0xf800, 0xf200, 0xf080, 0xf020, 0xf008, 0xffff, 0xffff, 0xf00a, 0xf802, 0xfa00, 0xf280, 0xf0a0, 0xf028, 0xffff, 0xffff, }; static const uint32_t bwn_ntab_tmap_r3[] = { 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0xf1111110, 0x11111111, 0x11f11111, 0x00000111, 0x11000000, 0x1111f111, 0x11111111, 0x111111f1, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x000aa888, 0x88880000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa2222220, 0x22222222, 0x22c22222, 0x00000222, 0x22000000, 0x2222a222, 0x22222222, 0x222222a2, 0xf1111110, 0x11111111, 0x11f11111, 0x00011111, 0x11110000, 0x1111f111, 0x11111111, 0x111111f1, 0xa8aa88a0, 0xa88888a8, 0xa8a8a88a, 0x00088aaa, 0xaaaa0000, 0xa8a8aa88, 0xa88aaaaa, 0xaaaa8a8a, 0xaaa8aaa0, 0x8aaa8aaa, 0xaa8a8a8a, 0x000aaa88, 0x8aaa0000, 0xaaa8a888, 0x8aa88a8a, 0x8a88a888, 0x08080a00, 0x0a08080a, 0x080a0a08, 0x00080808, 0x080a0000, 0x080a0808, 0x080a0808, 0x0a0a0a08, 0xa0a0a0a0, 0x80a0a080, 0x8080a0a0, 0x00008080, 0x80a00000, 0x80a080a0, 0xa080a0a0, 0x8080a0a0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99999000, 0x9b9b99bb, 0x9bb99999, 0x9999b9b9, 0x9b99bb90, 0x9bbbbb9b, 0x9b9b9bb9, 0x00000999, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00aaa888, 0x22000000, 0x2222b222, 0x22222222, 0x222222b2, 0xb2222220, 0x22222222, 0x22d22222, 0x00000222, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x33000000, 0x3333b333, 0x33333333, 0x333333b3, 0xb3333330, 0x33333333, 0x33d33333, 0x00000333, 0x22000000, 0x2222a222, 0x22222222, 0x222222a2, 0xa2222220, 0x22222222, 0x22c22222, 0x00000222, 0x99b99b00, 0x9b9b99bb, 0x9bb99999, 0x9999b9b9, 0x9b99bb99, 0x9bbbbb9b, 0x9b9b9bb9, 0x00000999, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa88, 0x8aaaaa8a, 0x8a8a8aa8, 0x08aaa888, 0x22222200, 0x2222f222, 0x22222222, 0x222222f2, 0x22222222, 0x22222222, 0x22f22222, 0x00000222, 0x11000000, 0x1111f111, 0x11111111, 0x11111111, 0xf1111111, 0x11111111, 0x11f11111, 0x01111111, 0xbb9bb900, 0xb9b9bb99, 0xb99bbbbb, 0xbbbb9b9b, 0xb9bb99bb, 0xb99999b9, 0xb9b9b99b, 0x00000bbb, 0xaa000000, 0xa8a8aa88, 0xa88aaaaa, 0xaaaa8a8a, 0xa8aa88aa, 0xa88888a8, 0xa8a8a88a, 0x0a888aaa, 0xaa000000, 0xa8a8aa88, 0xa88aaaaa, 0xaaaa8a8a, 0xa8aa88a0, 0xa88888a8, 0xa8a8a88a, 0x00000aaa, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0xbbbbbb00, 0x999bbbbb, 0x9bb99b9b, 0xb9b9b9bb, 0xb9b99bbb, 0xb9b9b9bb, 0xb9bb9b99, 0x00000999, 0x8a000000, 0xaa88a888, 0xa88888aa, 0xa88a8a88, 0xa88aa88a, 0x88a8aaaa, 0xa8aa8aaa, 0x0888a88a, 0x0b0b0b00, 0x090b0b0b, 0x0b090b0b, 0x0909090b, 0x09090b0b, 0x09090b0b, 0x09090b09, 0x00000909, 0x0a000000, 0x0a080808, 0x080a080a, 0x080a0a08, 0x080a080a, 0x0808080a, 0x0a0a0a08, 0x0808080a, 0xb0b0b000, 0x9090b0b0, 0x90b09090, 0xb0b0b090, 0xb0b090b0, 0x90b0b0b0, 0xb0b09090, 0x00000090, 0x80000000, 0xa080a080, 0xa08080a0, 0xa0808080, 0xa080a080, 0x80a0a0a0, 0xa0a080a0, 0x00a0a0a0, 0x22000000, 0x2222f222, 0x22222222, 0x222222f2, 0xf2222220, 0x22222222, 0x22f22222, 0x00000222, 0x11000000, 0x1111f111, 0x11111111, 0x111111f1, 0xf1111110, 0x11111111, 0x11f11111, 0x00000111, 0x33000000, 0x3333f333, 0x33333333, 0x333333f3, 0xf3333330, 0x33333333, 0x33f33333, 0x00000333, 0x22000000, 0x2222f222, 0x22222222, 0x222222f2, 0xf2222220, 0x22222222, 0x22f22222, 0x00000222, 0x99000000, 0x9b9b99bb, 0x9bb99999, 0x9999b9b9, 0x9b99bb90, 0x9bbbbb9b, 0x9b9b9bb9, 0x00000999, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88888000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00aaa888, 0x88a88a00, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa88, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa88, 0x8aaaaa8a, 0x8a8a8aa8, 0x08aaa888, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_intlevel_r3[] = { 0x00802070, 0x0671188d, 0x0a60192c, 0x0a300e46, 0x00c1188d, 0x080024d2, 0x00000070, }; static const uint32_t bwn_ntab_tdtrn_r3[] = { 0x061c061c, 0x0050ee68, 0xf592fe36, 0xfe5212f6, 0x00000c38, 0xfe5212f6, 0xf592fe36, 0x0050ee68, 0x061c061c, 0xee680050, 0xfe36f592, 0x12f6fe52, 0x0c380000, 0x12f6fe52, 0xfe36f592, 0xee680050, 0x061c061c, 0x0050ee68, 0xf592fe36, 0xfe5212f6, 0x00000c38, 0xfe5212f6, 0xf592fe36, 0x0050ee68, 0x061c061c, 0xee680050, 0xfe36f592, 0x12f6fe52, 0x0c380000, 0x12f6fe52, 0xfe36f592, 0xee680050, 0x05e305e3, 0x004def0c, 0xf5f3fe47, 0xfe611246, 0x00000bc7, 0xfe611246, 0xf5f3fe47, 0x004def0c, 0x05e305e3, 0xef0c004d, 0xfe47f5f3, 0x1246fe61, 0x0bc70000, 0x1246fe61, 0xfe47f5f3, 0xef0c004d, 0x05e305e3, 0x004def0c, 0xf5f3fe47, 0xfe611246, 0x00000bc7, 0xfe611246, 0xf5f3fe47, 0x004def0c, 0x05e305e3, 0xef0c004d, 0xfe47f5f3, 0x1246fe61, 0x0bc70000, 0x1246fe61, 0xfe47f5f3, 0xef0c004d, 0xfa58fa58, 0xf895043b, 0xff4c09c0, 0xfbc6ffa8, 0xfb84f384, 0x0798f6f9, 0x05760122, 0x058409f6, 0x0b500000, 0x05b7f542, 0x08860432, 0x06ddfee7, 0xfb84f384, 0xf9d90664, 0xf7e8025c, 0x00fff7bd, 0x05a805a8, 0xf7bd00ff, 0x025cf7e8, 0x0664f9d9, 0xf384fb84, 0xfee706dd, 0x04320886, 0xf54205b7, 0x00000b50, 0x09f60584, 0x01220576, 0xf6f90798, 0xf384fb84, 0xffa8fbc6, 0x09c0ff4c, 0x043bf895, 0x02d402d4, 0x07de0270, 0xfc96079c, 0xf90afe94, 0xfe00ff2c, 0x02d4065d, 0x092a0096, 0x0014fbb8, 0xfd2cfd2c, 0x076afb3c, 0x0096f752, 0xf991fd87, 0xfb2c0200, 0xfeb8f960, 0x08e0fc96, 0x049802a8, 0xfd2cfd2c, 0x02a80498, 0xfc9608e0, 0xf960feb8, 0x0200fb2c, 0xfd87f991, 0xf7520096, 0xfb3c076a, 0xfd2cfd2c, 0xfbb80014, 0x0096092a, 0x065d02d4, 0xff2cfe00, 0xfe94f90a, 0x079cfc96, 0x027007de, 0x02d402d4, 0x027007de, 0x079cfc96, 0xfe94f90a, 0xff2cfe00, 0x065d02d4, 0x0096092a, 0xfbb80014, 0xfd2cfd2c, 0xfb3c076a, 0xf7520096, 0xfd87f991, 0x0200fb2c, 0xf960feb8, 0xfc9608e0, 0x02a80498, 0xfd2cfd2c, 0x049802a8, 0x08e0fc96, 0xfeb8f960, 0xfb2c0200, 0xf991fd87, 0x0096f752, 0x076afb3c, 0xfd2cfd2c, 0x0014fbb8, 0x092a0096, 0x02d4065d, 0xfe00ff2c, 0xf90afe94, 0xfc96079c, 0x07de0270, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x062a0000, 0xfefa0759, 0x08b80908, 0xf396fc2d, 0xf9d6045c, 0xfc4ef608, 0xf748f596, 0x07b207bf, 0x062a062a, 0xf84ef841, 0xf748f596, 0x03b209f8, 0xf9d6045c, 0x0c6a03d3, 0x08b80908, 0x0106f8a7, 0x062a0000, 0xfefaf8a7, 0x08b8f6f8, 0xf39603d3, 0xf9d6fba4, 0xfc4e09f8, 0xf7480a6a, 0x07b2f841, 0x062af9d6, 0xf84e07bf, 0xf7480a6a, 0x03b2f608, 0xf9d6fba4, 0x0c6afc2d, 0x08b8f6f8, 0x01060759, 0x062a0000, 0xfefa0759, 0x08b80908, 0xf396fc2d, 0xf9d6045c, 0xfc4ef608, 0xf748f596, 0x07b207bf, 0x062a062a, 0xf84ef841, 0xf748f596, 0x03b209f8, 0xf9d6045c, 0x0c6a03d3, 0x08b80908, 0x0106f8a7, 0x062a0000, 0xfefaf8a7, 0x08b8f6f8, 0xf39603d3, 0xf9d6fba4, 0xfc4e09f8, 0xf7480a6a, 0x07b2f841, 0x062af9d6, 0xf84e07bf, 0xf7480a6a, 0x03b2f608, 0xf9d6fba4, 0x0c6afc2d, 0x08b8f6f8, 0x01060759, 0x061c061c, 0xff30009d, 0xffb21141, 0xfd87fb54, 0xf65dfe59, 0x02eef99e, 0x0166f03c, 0xfff809b6, 0x000008a4, 0x000af42b, 0x00eff577, 0xfa840bf2, 0xfc02ff51, 0x08260f67, 0xfff0036f, 0x0842f9c3, 0x00000000, 0x063df7be, 0xfc910010, 0xf099f7da, 0x00af03fe, 0xf40e057c, 0x0a89ff11, 0x0bd5fff6, 0xf75c0000, 0xf64a0008, 0x0fc4fe9a, 0x0662fd12, 0x01a709a3, 0x04ac0279, 0xeebf004e, 0xff6300d0, 0xf9e4f9e4, 0x00d0ff63, 0x004eeebf, 0x027904ac, 0x09a301a7, 0xfd120662, 0xfe9a0fc4, 0x0008f64a, 0x0000f75c, 0xfff60bd5, 0xff110a89, 0x057cf40e, 0x03fe00af, 0xf7daf099, 0x0010fc91, 0xf7be063d, 0x00000000, 0xf9c30842, 0x036ffff0, 0x0f670826, 0xff51fc02, 0x0bf2fa84, 0xf57700ef, 0xf42b000a, 0x08a40000, 0x09b6fff8, 0xf03c0166, 0xf99e02ee, 0xfe59f65d, 0xfb54fd87, 0x1141ffb2, 0x009dff30, 0x05e30000, 0xff060705, 0x085408a0, 0xf425fc59, 0xfa1d042a, 0xfc78f67a, 0xf7acf60e, 0x075a0766, 0x05e305e3, 0xf8a6f89a, 0xf7acf60e, 0x03880986, 0xfa1d042a, 0x0bdb03a7, 0x085408a0, 0x00faf8fb, 0x05e30000, 0xff06f8fb, 0x0854f760, 0xf42503a7, 0xfa1dfbd6, 0xfc780986, 0xf7ac09f2, 0x075af89a, 0x05e3fa1d, 0xf8a60766, 0xf7ac09f2, 0x0388f67a, 0xfa1dfbd6, 0x0bdbfc59, 0x0854f760, 0x00fa0705, 0x05e30000, 0xff060705, 0x085408a0, 0xf425fc59, 0xfa1d042a, 0xfc78f67a, 0xf7acf60e, 0x075a0766, 0x05e305e3, 0xf8a6f89a, 0xf7acf60e, 0x03880986, 0xfa1d042a, 0x0bdb03a7, 0x085408a0, 0x00faf8fb, 0x05e30000, 0xff06f8fb, 0x0854f760, 0xf42503a7, 0xfa1dfbd6, 0xfc780986, 0xf7ac09f2, 0x075af89a, 0x05e3fa1d, 0xf8a60766, 0xf7ac09f2, 0x0388f67a, 0xfa1dfbd6, 0x0bdbfc59, 0x0854f760, 0x00fa0705, 0xfa58fa58, 0xf8f0fe00, 0x0448073d, 0xfdc9fe46, 0xf9910258, 0x089d0407, 0xfd5cf71a, 0x02affde0, 0x083e0496, 0xff5a0740, 0xff7afd97, 0x00fe01f1, 0x0009082e, 0xfa94ff75, 0xfecdf8ea, 0xffb0f693, 0xfd2cfa58, 0x0433ff16, 0xfba405dd, 0xfa610341, 0x06a606cb, 0x0039fd2d, 0x0677fa97, 0x01fa05e0, 0xf896003e, 0x075a068b, 0x012cfc3e, 0xfa23f98d, 0xfc7cfd43, 0xff90fc0d, 0x01c10982, 0x00c601d6, 0xfd2cfd2c, 0x01d600c6, 0x098201c1, 0xfc0dff90, 0xfd43fc7c, 0xf98dfa23, 0xfc3e012c, 0x068b075a, 0x003ef896, 0x05e001fa, 0xfa970677, 0xfd2d0039, 0x06cb06a6, 0x0341fa61, 0x05ddfba4, 0xff160433, 0xfa58fd2c, 0xf693ffb0, 0xf8eafecd, 0xff75fa94, 0x082e0009, 0x01f100fe, 0xfd97ff7a, 0x0740ff5a, 0x0496083e, 0xfde002af, 0xf71afd5c, 0x0407089d, 0x0258f991, 0xfe46fdc9, 0x073d0448, 0xfe00f8f0, 0xfd2cfd2c, 0xfce00500, 0xfc09fddc, 0xfe680157, 0x04c70571, 0xfc3aff21, 0xfcd70228, 0x056d0277, 0x0200fe00, 0x0022f927, 0xfe3c032b, 0xfc44ff3c, 0x03e9fbdb, 0x04570313, 0x04c9ff5c, 0x000d03b8, 0xfa580000, 0xfbe900d2, 0xf9d0fe0b, 0x0125fdf9, 0x042501bf, 0x0328fa2b, 0xffa902f0, 0xfa250157, 0x0200fe00, 0x03740438, 0xff0405fd, 0x030cfe52, 0x0037fb39, 0xff6904c5, 0x04f8fd23, 0xfd31fc1b, 0xfd2cfd2c, 0xfc1bfd31, 0xfd2304f8, 0x04c5ff69, 0xfb390037, 0xfe52030c, 0x05fdff04, 0x04380374, 0xfe000200, 0x0157fa25, 0x02f0ffa9, 0xfa2b0328, 0x01bf0425, 0xfdf90125, 0xfe0bf9d0, 0x00d2fbe9, 0x0000fa58, 0x03b8000d, 0xff5c04c9, 0x03130457, 0xfbdb03e9, 0xff3cfc44, 0x032bfe3c, 0xf9270022, 0xfe000200, 0x0277056d, 0x0228fcd7, 0xff21fc3a, 0x057104c7, 0x0157fe68, 0xfddcfc09, 0x0500fce0, 0xfd2cfd2c, 0x0500fce0, 0xfddcfc09, 0x0157fe68, 0x057104c7, 0xff21fc3a, 0x0228fcd7, 0x0277056d, 0xfe000200, 0xf9270022, 0x032bfe3c, 0xff3cfc44, 0xfbdb03e9, 0x03130457, 0xff5c04c9, 0x03b8000d, 0x0000fa58, 0x00d2fbe9, 0xfe0bf9d0, 0xfdf90125, 0x01bf0425, 0xfa2b0328, 0x02f0ffa9, 0x0157fa25, 0xfe000200, 0x04380374, 0x05fdff04, 0xfe52030c, 0xfb390037, 0x04c5ff69, 0xfd2304f8, 0xfc1bfd31, 0xfd2cfd2c, 0xfd31fc1b, 0x04f8fd23, 0xff6904c5, 0x0037fb39, 0x030cfe52, 0xff0405fd, 0x03740438, 0x0200fe00, 0xfa250157, 0xffa902f0, 0x0328fa2b, 0x042501bf, 0x0125fdf9, 0xf9d0fe0b, 0xfbe900d2, 0xfa580000, 0x000d03b8, 0x04c9ff5c, 0x04570313, 0x03e9fbdb, 0xfc44ff3c, 0xfe3c032b, 0x0022f927, 0x0200fe00, 0x056d0277, 0xfcd70228, 0xfc3aff21, 0x04c70571, 0xfe680157, 0xfc09fddc, 0xfce00500, 0x05a80000, 0xff1006be, 0x0800084a, 0xf49cfc7e, 0xfa580400, 0xfc9cf6da, 0xf800f672, 0x0710071c, 0x05a805a8, 0xf8f0f8e4, 0xf800f672, 0x03640926, 0xfa580400, 0x0b640382, 0x0800084a, 0x00f0f942, 0x05a80000, 0xff10f942, 0x0800f7b6, 0xf49c0382, 0xfa58fc00, 0xfc9c0926, 0xf800098e, 0x0710f8e4, 0x05a8fa58, 0xf8f0071c, 0xf800098e, 0x0364f6da, 0xfa58fc00, 0x0b64fc7e, 0x0800f7b6, 0x00f006be, 0x05a80000, 0xff1006be, 0x0800084a, 0xf49cfc7e, 0xfa580400, 0xfc9cf6da, 0xf800f672, 0x0710071c, 0x05a805a8, 0xf8f0f8e4, 0xf800f672, 0x03640926, 0xfa580400, 0x0b640382, 0x0800084a, 0x00f0f942, 0x05a80000, 0xff10f942, 0x0800f7b6, 0xf49c0382, 0xfa58fc00, 0xfc9c0926, 0xf800098e, 0x0710f8e4, 0x05a8fa58, 0xf8f0071c, 0xf800098e, 0x0364f6da, 0xfa58fc00, 0x0b64fc7e, 0x0800f7b6, 0x00f006be, }; static const uint32_t bwn_ntab_noisevar_r3[] = { 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, 0x02110211, 0x0000014d, }; static const uint16_t bwn_ntab_mcs_r3[] = { 0x0000, 0x0008, 0x000a, 0x0010, 0x0012, 0x0019, 0x001a, 0x001c, 0x0080, 0x0088, 0x008a, 0x0090, 0x0092, 0x0099, 0x009a, 0x009c, 0x0100, 0x0108, 0x010a, 0x0110, 0x0112, 0x0119, 0x011a, 0x011c, 0x0180, 0x0188, 0x018a, 0x0190, 0x0192, 0x0199, 0x019a, 0x019c, 0x0000, 0x0098, 0x00a0, 0x00a8, 0x009a, 0x00a2, 0x00aa, 0x0120, 0x0128, 0x0128, 0x0130, 0x0138, 0x0138, 0x0140, 0x0122, 0x012a, 0x012a, 0x0132, 0x013a, 0x013a, 0x0142, 0x01a8, 0x01b0, 0x01b8, 0x01b0, 0x01b8, 0x01c0, 0x01c8, 0x01c0, 0x01c8, 0x01d0, 0x01d0, 0x01d8, 0x01aa, 0x01b2, 0x01ba, 0x01b2, 0x01ba, 0x01c2, 0x01ca, 0x01c2, 0x01ca, 0x01d2, 0x01d2, 0x01da, 0x0001, 0x0002, 0x0004, 0x0009, 0x000c, 0x0011, 0x0014, 0x0018, 0x0020, 0x0021, 0x0022, 0x0024, 0x0081, 0x0082, 0x0084, 0x0089, 0x008c, 0x0091, 0x0094, 0x0098, 0x00a0, 0x00a1, 0x00a2, 0x00a4, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, }; static const uint32_t bwn_ntab_tdi20a0_r3[] = { 0x00091226, 0x000a1429, 0x000b56ad, 0x000c58b0, 0x000d5ab3, 0x000e9cb6, 0x000f9eba, 0x0000c13d, 0x00020301, 0x00030504, 0x00040708, 0x0005090b, 0x00064b8e, 0x00095291, 0x000a5494, 0x000b9718, 0x000c9927, 0x000d9b2a, 0x000edd2e, 0x000fdf31, 0x000101b4, 0x000243b7, 0x000345bb, 0x000447be, 0x00058982, 0x00068c05, 0x00099309, 0x000a950c, 0x000bd78f, 0x000cd992, 0x000ddb96, 0x000f1d99, 0x00005fa8, 0x0001422c, 0x0002842f, 0x00038632, 0x00048835, 0x0005ca38, 0x0006ccbc, 0x0009d3bf, 0x000b1603, 0x000c1806, 0x000d1a0a, 0x000e1c0d, 0x000f5e10, 0x00008093, 0x00018297, 0x0002c49a, 0x0003c680, 0x0004c880, 0x00060b00, 0x00070d00, 0x00000000, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_tdi20a1_r3[] = { 0x00014b26, 0x00028d29, 0x000393ad, 0x00049630, 0x0005d833, 0x0006da36, 0x00099c3a, 0x000a9e3d, 0x000bc081, 0x000cc284, 0x000dc488, 0x000f068b, 0x0000488e, 0x00018b91, 0x0002d214, 0x0003d418, 0x0004d6a7, 0x000618aa, 0x00071aae, 0x0009dcb1, 0x000b1eb4, 0x000c0137, 0x000d033b, 0x000e053e, 0x000f4702, 0x00008905, 0x00020c09, 0x0003128c, 0x0004148f, 0x00051712, 0x00065916, 0x00091b19, 0x000a1d28, 0x000b5f2c, 0x000c41af, 0x000d43b2, 0x000e85b5, 0x000f87b8, 0x0000c9bc, 0x00024cbf, 0x00035303, 0x00045506, 0x0005978a, 0x0006998d, 0x00095b90, 0x000a5d93, 0x000b9f97, 0x000c821a, 0x000d8400, 0x000ec600, 0x000fc800, 0x00010a00, 0x00000000, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_tdi40a0_r3[] = { 0x0011a346, 0x00136ccf, 0x0014f5d9, 0x001641e2, 0x0017cb6b, 0x00195475, 0x001b2383, 0x001cad0c, 0x001e7616, 0x0000821f, 0x00020ba8, 0x0003d4b2, 0x00056447, 0x00072dd0, 0x0008b6da, 0x000a02e3, 0x000b8c6c, 0x000d15f6, 0x0011e484, 0x0013ae0d, 0x00153717, 0x00168320, 0x00180ca9, 0x00199633, 0x001b6548, 0x001ceed1, 0x001eb7db, 0x0000c3e4, 0x00024d6d, 0x000416f7, 0x0005a585, 0x00076f0f, 0x0008f818, 0x000a4421, 0x000bcdab, 0x000d9734, 0x00122649, 0x0013efd2, 0x001578dc, 0x0016c4e5, 0x00184e6e, 0x001a17f8, 0x001ba686, 0x001d3010, 0x001ef999, 0x00010522, 0x00028eac, 0x00045835, 0x0005e74a, 0x0007b0d3, 0x00093a5d, 0x000a85e6, 0x000c0f6f, 0x000dd8f9, 0x00126787, 0x00143111, 0x0015ba9a, 0x00170623, 0x00188fad, 0x001a5936, 0x001be84b, 0x001db1d4, 0x001f3b5e, 0x000146e7, 0x00031070, 0x000499fa, 0x00062888, 0x0007f212, 0x00097b9b, 0x000ac7a4, 0x000c50ae, 0x000e1a37, 0x0012a94c, 0x001472d5, 0x0015fc5f, 0x00174868, 0x0018d171, 0x001a9afb, 0x001c2989, 0x001df313, 0x001f7c9c, 0x000188a5, 0x000351af, 0x0004db38, 0x0006aa4d, 0x000833d7, 0x0009bd60, 0x000b0969, 0x000c9273, 0x000e5bfc, 0x00132a8a, 0x0014b414, 0x00163d9d, 0x001789a6, 0x001912b0, 0x001adc39, 0x001c6bce, 0x001e34d8, 0x001fbe61, 0x0001ca6a, 0x00039374, 0x00051cfd, 0x0006ec0b, 0x00087515, 0x0009fe9e, 0x000b4aa7, 0x000cd3b1, 0x000e9d3a, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_tdi40a1_r3[] = { 0x001edb36, 0x000129ca, 0x0002b353, 0x00047cdd, 0x0005c8e6, 0x000791ef, 0x00091bf9, 0x000aaa07, 0x000c3391, 0x000dfd1a, 0x00120923, 0x0013d22d, 0x00155c37, 0x0016eacb, 0x00187454, 0x001a3dde, 0x001b89e7, 0x001d12f0, 0x001f1cfa, 0x00016b88, 0x00033492, 0x0004be1b, 0x00060a24, 0x0007d32e, 0x00095d38, 0x000aec4c, 0x000c7555, 0x000e3edf, 0x00124ae8, 0x001413f1, 0x0015a37b, 0x00172c89, 0x0018b593, 0x001a419c, 0x001bcb25, 0x001d942f, 0x001f63b9, 0x0001ad4d, 0x00037657, 0x0004c260, 0x00068be9, 0x000814f3, 0x0009a47c, 0x000b2d8a, 0x000cb694, 0x000e429d, 0x00128c26, 0x001455b0, 0x0015e4ba, 0x00176e4e, 0x0018f758, 0x001a8361, 0x001c0cea, 0x001dd674, 0x001fa57d, 0x0001ee8b, 0x0003b795, 0x0005039e, 0x0006cd27, 0x000856b1, 0x0009e5c6, 0x000b6f4f, 0x000cf859, 0x000e8462, 0x00130deb, 0x00149775, 0x00162603, 0x0017af8c, 0x00193896, 0x001ac49f, 0x001c4e28, 0x001e17b2, 0x0000a6c7, 0x00023050, 0x0003f9da, 0x00054563, 0x00070eec, 0x00089876, 0x000a2704, 0x000bb08d, 0x000d3a17, 0x001185a0, 0x00134f29, 0x0014d8b3, 0x001667c8, 0x0017f151, 0x00197adb, 0x001b0664, 0x001c8fed, 0x001e5977, 0x0000e805, 0x0002718f, 0x00043b18, 0x000586a1, 0x0007502b, 0x0008d9b4, 0x000a68c9, 0x000bf252, 0x000dbbdc, 0x0011c7e5, 0x001390ee, 0x00151a78, 0x0016a906, 0x00183290, 0x0019bc19, 0x001b4822, 0x001cd12c, 0x001e9ab5, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_pilotlt_r3[] = { 0x76540213, 0x62407351, 0x76543210, 0x76540213, 0x76540213, 0x76430521, }; static const uint32_t bwn_ntab_channelest_r3[] = { 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x44444444, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, }; static const uint8_t bwn_ntab_framelookup_r3[] = { 0x02, 0x04, 0x14, 0x14, 0x03, 0x05, 0x16, 0x16, 0x0a, 0x0c, 0x1c, 0x1c, 0x0b, 0x0d, 0x1e, 0x1e, 0x06, 0x08, 0x18, 0x18, 0x07, 0x09, 0x1a, 0x1a, 0x0e, 0x10, 0x20, 0x28, 0x0f, 0x11, 0x22, 0x2a, }; static const uint8_t bwn_ntab_estimatepowerlt0_r3[] = { 0x55, 0x54, 0x54, 0x53, 0x52, 0x52, 0x51, 0x51, 0x50, 0x4f, 0x4f, 0x4e, 0x4e, 0x4d, 0x4c, 0x4c, 0x4b, 0x4a, 0x49, 0x49, 0x48, 0x47, 0x46, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x33, 0x32, 0x31, 0x2f, 0x2e, 0x2c, 0x2b, 0x29, 0x27, 0x25, 0x23, 0x21, 0x1f, 0x1d, 0x1a, 0x18, 0x15, 0x12, 0x0e, 0x0b, 0x07, 0x02, 0xfd, }; static const uint8_t bwn_ntab_estimatepowerlt1_r3[] = { 0x55, 0x54, 0x54, 0x53, 0x52, 0x52, 0x51, 0x51, 0x50, 0x4f, 0x4f, 0x4e, 0x4e, 0x4d, 0x4c, 0x4c, 0x4b, 0x4a, 0x49, 0x49, 0x48, 0x47, 0x46, 0x46, 0x45, 0x44, 0x43, 0x42, 0x41, 0x40, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3a, 0x39, 0x38, 0x37, 0x36, 0x35, 0x33, 0x32, 0x31, 0x2f, 0x2e, 0x2c, 0x2b, 0x29, 0x27, 0x25, 0x23, 0x21, 0x1f, 0x1d, 0x1a, 0x18, 0x15, 0x12, 0x0e, 0x0b, 0x07, 0x02, 0xfd, }; static const uint8_t bwn_ntab_adjustpower0_r3[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint8_t bwn_ntab_adjustpower1_r3[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const uint32_t bwn_ntab_gainctl0_r3[] = { 0x5bf70044, 0x5bf70042, 0x5bf70040, 0x5bf7003e, 0x5bf7003c, 0x5bf7003b, 0x5bf70039, 0x5bf70037, 0x5bf70036, 0x5bf70034, 0x5bf70033, 0x5bf70031, 0x5bf70030, 0x5ba70044, 0x5ba70042, 0x5ba70040, 0x5ba7003e, 0x5ba7003c, 0x5ba7003b, 0x5ba70039, 0x5ba70037, 0x5ba70036, 0x5ba70034, 0x5ba70033, 0x5b770044, 0x5b770042, 0x5b770040, 0x5b77003e, 0x5b77003c, 0x5b77003b, 0x5b770039, 0x5b770037, 0x5b770036, 0x5b770034, 0x5b770033, 0x5b770031, 0x5b770030, 0x5b77002f, 0x5b77002d, 0x5b77002c, 0x5b470044, 0x5b470042, 0x5b470040, 0x5b47003e, 0x5b47003c, 0x5b47003b, 0x5b470039, 0x5b470037, 0x5b470036, 0x5b470034, 0x5b470033, 0x5b470031, 0x5b470030, 0x5b47002f, 0x5b47002d, 0x5b47002c, 0x5b47002b, 0x5b47002a, 0x5b270044, 0x5b270042, 0x5b270040, 0x5b27003e, 0x5b27003c, 0x5b27003b, 0x5b270039, 0x5b270037, 0x5b270036, 0x5b270034, 0x5b270033, 0x5b270031, 0x5b270030, 0x5b27002f, 0x5b170044, 0x5b170042, 0x5b170040, 0x5b17003e, 0x5b17003c, 0x5b17003b, 0x5b170039, 0x5b170037, 0x5b170036, 0x5b170034, 0x5b170033, 0x5b170031, 0x5b170030, 0x5b17002f, 0x5b17002d, 0x5b17002c, 0x5b17002b, 0x5b17002a, 0x5b170028, 0x5b170027, 0x5b170026, 0x5b170025, 0x5b170024, 0x5b170023, 0x5b070044, 0x5b070042, 0x5b070040, 0x5b07003e, 0x5b07003c, 0x5b07003b, 0x5b070039, 0x5b070037, 0x5b070036, 0x5b070034, 0x5b070033, 0x5b070031, 0x5b070030, 0x5b07002f, 0x5b07002d, 0x5b07002c, 0x5b07002b, 0x5b07002a, 0x5b070028, 0x5b070027, 0x5b070026, 0x5b070025, 0x5b070024, 0x5b070023, 0x5b070022, 0x5b070021, 0x5b070020, 0x5b07001f, 0x5b07001e, 0x5b07001d, 0x5b07001d, 0x5b07001c, }; static const uint32_t bwn_ntab_gainctl1_r3[] = { 0x5bf70044, 0x5bf70042, 0x5bf70040, 0x5bf7003e, 0x5bf7003c, 0x5bf7003b, 0x5bf70039, 0x5bf70037, 0x5bf70036, 0x5bf70034, 0x5bf70033, 0x5bf70031, 0x5bf70030, 0x5ba70044, 0x5ba70042, 0x5ba70040, 0x5ba7003e, 0x5ba7003c, 0x5ba7003b, 0x5ba70039, 0x5ba70037, 0x5ba70036, 0x5ba70034, 0x5ba70033, 0x5b770044, 0x5b770042, 0x5b770040, 0x5b77003e, 0x5b77003c, 0x5b77003b, 0x5b770039, 0x5b770037, 0x5b770036, 0x5b770034, 0x5b770033, 0x5b770031, 0x5b770030, 0x5b77002f, 0x5b77002d, 0x5b77002c, 0x5b470044, 0x5b470042, 0x5b470040, 0x5b47003e, 0x5b47003c, 0x5b47003b, 0x5b470039, 0x5b470037, 0x5b470036, 0x5b470034, 0x5b470033, 0x5b470031, 0x5b470030, 0x5b47002f, 0x5b47002d, 0x5b47002c, 0x5b47002b, 0x5b47002a, 0x5b270044, 0x5b270042, 0x5b270040, 0x5b27003e, 0x5b27003c, 0x5b27003b, 0x5b270039, 0x5b270037, 0x5b270036, 0x5b270034, 0x5b270033, 0x5b270031, 0x5b270030, 0x5b27002f, 0x5b170044, 0x5b170042, 0x5b170040, 0x5b17003e, 0x5b17003c, 0x5b17003b, 0x5b170039, 0x5b170037, 0x5b170036, 0x5b170034, 0x5b170033, 0x5b170031, 0x5b170030, 0x5b17002f, 0x5b17002d, 0x5b17002c, 0x5b17002b, 0x5b17002a, 0x5b170028, 0x5b170027, 0x5b170026, 0x5b170025, 0x5b170024, 0x5b170023, 0x5b070044, 0x5b070042, 0x5b070040, 0x5b07003e, 0x5b07003c, 0x5b07003b, 0x5b070039, 0x5b070037, 0x5b070036, 0x5b070034, 0x5b070033, 0x5b070031, 0x5b070030, 0x5b07002f, 0x5b07002d, 0x5b07002c, 0x5b07002b, 0x5b07002a, 0x5b070028, 0x5b070027, 0x5b070026, 0x5b070025, 0x5b070024, 0x5b070023, 0x5b070022, 0x5b070021, 0x5b070020, 0x5b07001f, 0x5b07001e, 0x5b07001d, 0x5b07001d, 0x5b07001c, }; static const uint32_t bwn_ntab_iqlt0_r3[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; static const uint32_t bwn_ntab_iqlt1_r3[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; static const uint16_t bwn_ntab_loftlt0_r3[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static const uint16_t bwn_ntab_loftlt1_r3[] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; /* volatile tables, PHY revision >= 3 */ /* indexed by antswctl2g */ static const uint16_t bwn_ntab_antswctl_r3[4][32] = { { 0x0082, 0x0082, 0x0211, 0x0222, 0x0328, 0x0000, 0x0000, 0x0000, 0x0144, 0x0000, 0x0000, 0x0000, 0x0188, 0x0000, 0x0000, 0x0000, 0x0082, 0x0082, 0x0211, 0x0222, 0x0328, 0x0000, 0x0000, 0x0000, 0x0144, 0x0000, 0x0000, 0x0000, 0x0188, 0x0000, 0x0000, 0x0000, }, { 0x0022, 0x0022, 0x0011, 0x0022, 0x0022, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x0000, 0x0000, 0x0022, 0x0000, 0x0000, 0x0000, 0x0022, 0x0022, 0x0011, 0x0022, 0x0022, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x0000, 0x0000, 0x0022, 0x0000, 0x0000, 0x0000, }, { 0x0088, 0x0088, 0x0044, 0x0088, 0x0088, 0x0000, 0x0000, 0x0000, 0x0044, 0x0000, 0x0000, 0x0000, 0x0088, 0x0000, 0x0000, 0x0000, 0x0088, 0x0088, 0x0044, 0x0088, 0x0088, 0x0000, 0x0000, 0x0000, 0x0044, 0x0000, 0x0000, 0x0000, 0x0088, 0x0000, 0x0000, 0x0000, }, { 0x0022, 0x0022, 0x0011, 0x0022, 0x0000, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x0000, 0x0000, 0x0022, 0x0000, 0x0000, 0x03cc, 0x0022, 0x0022, 0x0011, 0x0022, 0x0000, 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, 0x0000, 0x0000, 0x0022, 0x0000, 0x0000, 0x03cc, } }; /* static tables, PHY revision >= 7 */ /* Copied from brcmsmac (5.75.11) */ static const uint32_t bwn_ntab_tmap_r7[] = { 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0xf1111110, 0x11111111, 0x11f11111, 0x00000111, 0x11000000, 0x1111f111, 0x11111111, 0x111111f1, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x000aa888, 0x88880000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa2222220, 0x22222222, 0x22c22222, 0x00000222, 0x22000000, 0x2222a222, 0x22222222, 0x222222a2, 0xf1111110, 0x11111111, 0x11f11111, 0x00011111, 0x11110000, 0x1111f111, 0x11111111, 0x111111f1, 0xa8aa88a0, 0xa88888a8, 0xa8a8a88a, 0x00088aaa, 0xaaaa0000, 0xa8a8aa88, 0xa88aaaaa, 0xaaaa8a8a, 0xaaa8aaa0, 0x8aaa8aaa, 0xaa8a8a8a, 0x000aaa88, 0x8aaa0000, 0xaaa8a888, 0x8aa88a8a, 0x8a88a888, 0x08080a00, 0x0a08080a, 0x080a0a08, 0x00080808, 0x080a0000, 0x080a0808, 0x080a0808, 0x0a0a0a08, 0xa0a0a0a0, 0x80a0a080, 0x8080a0a0, 0x00008080, 0x80a00000, 0x80a080a0, 0xa080a0a0, 0x8080a0a0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x99999000, 0x9b9b99bb, 0x9bb99999, 0x9999b9b9, 0x9b99bb90, 0x9bbbbb9b, 0x9b9b9bb9, 0x00000999, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00aaa888, 0x22000000, 0x2222b222, 0x22222222, 0x222222b2, 0xb2222220, 0x22222222, 0x22d22222, 0x00000222, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x33000000, 0x3333b333, 0x33333333, 0x333333b3, 0xb3333330, 0x33333333, 0x33d33333, 0x00000333, 0x22000000, 0x2222a222, 0x22222222, 0x222222a2, 0xa2222220, 0x22222222, 0x22c22222, 0x00000222, 0x99b99b00, 0x9b9b99bb, 0x9bb99999, 0x9999b9b9, 0x9b99bb99, 0x9bbbbb9b, 0x9b9b9bb9, 0x00000999, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa88, 0x8aaaaa8a, 0x8a8a8aa8, 0x08aaa888, 0x22222200, 0x2222f222, 0x22222222, 0x222222f2, 0x22222222, 0x22222222, 0x22f22222, 0x00000222, 0x11000000, 0x1111f111, 0x11111111, 0x11111111, 0xf1111111, 0x11111111, 0x11f11111, 0x01111111, 0xbb9bb900, 0xb9b9bb99, 0xb99bbbbb, 0xbbbb9b9b, 0xb9bb99bb, 0xb99999b9, 0xb9b9b99b, 0x00000bbb, 0xaa000000, 0xa8a8aa88, 0xa88aaaaa, 0xaaaa8a8a, 0xa8aa88aa, 0xa88888a8, 0xa8a8a88a, 0x0a888aaa, 0xaa000000, 0xa8a8aa88, 0xa88aaaaa, 0xaaaa8a8a, 0xa8aa88a0, 0xa88888a8, 0xa8a8a88a, 0x00000aaa, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0xbbbbbb00, 0x999bbbbb, 0x9bb99b9b, 0xb9b9b9bb, 0xb9b99bbb, 0xb9b9b9bb, 0xb9bb9b99, 0x00000999, 0x8a000000, 0xaa88a888, 0xa88888aa, 0xa88a8a88, 0xa88aa88a, 0x88a8aaaa, 0xa8aa8aaa, 0x0888a88a, 0x0b0b0b00, 0x090b0b0b, 0x0b090b0b, 0x0909090b, 0x09090b0b, 0x09090b0b, 0x09090b09, 0x00000909, 0x0a000000, 0x0a080808, 0x080a080a, 0x080a0a08, 0x080a080a, 0x0808080a, 0x0a0a0a08, 0x0808080a, 0xb0b0b000, 0x9090b0b0, 0x90b09090, 0xb0b0b090, 0xb0b090b0, 0x90b0b0b0, 0xb0b09090, 0x00000090, 0x80000000, 0xa080a080, 0xa08080a0, 0xa0808080, 0xa080a080, 0x80a0a0a0, 0xa0a080a0, 0x00a0a0a0, 0x22000000, 0x2222f222, 0x22222222, 0x222222f2, 0xf2222220, 0x22222222, 0x22f22222, 0x00000222, 0x11000000, 0x1111f111, 0x11111111, 0x111111f1, 0xf1111110, 0x11111111, 0x11f11111, 0x00000111, 0x33000000, 0x3333f333, 0x33333333, 0x333333f3, 0xf3333330, 0x33333333, 0x33f33333, 0x00000333, 0x22000000, 0x2222f222, 0x22222222, 0x222222f2, 0xf2222220, 0x22222222, 0x22f22222, 0x00000222, 0x99000000, 0x9b9b99bb, 0x9bb99999, 0x9999b9b9, 0x9b99bb90, 0x9bbbbb9b, 0x9b9b9bb9, 0x00000999, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88888000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00aaa888, 0x88a88a00, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa88, 0x8aaaaa8a, 0x8a8a8aa8, 0x000aa888, 0x88880000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa88, 0x8aaaaa8a, 0x8a8a8aa8, 0x08aaa888, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x11000000, 0x1111a111, 0x11111111, 0x111111a1, 0xa1111110, 0x11111111, 0x11c11111, 0x00000111, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x88000000, 0x8a8a88aa, 0x8aa88888, 0x8888a8a8, 0x8a88aa80, 0x8aaaaa8a, 0x8a8a8aa8, 0x00000888, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; /* Extracted from MMIO dump of 6.30.223.141 */ static const uint32_t bwn_ntab_noisevar_r7[] = { 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, 0x020c020c, 0x0000014d, }; /************************************************** * TX gain tables **************************************************/ static const uint32_t bwn_ntab_tx_gain_rev0_1_2[] = { 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42, 0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44, 0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844, 0x03c82842, 0x03c42b44, 0x03c42b42, 0x03c42a44, 0x03c42a42, 0x03c42944, 0x03c42942, 0x03c42844, 0x03c42842, 0x03c42744, 0x03c42742, 0x03c42644, 0x03c42642, 0x03c42544, 0x03c42542, 0x03c42444, 0x03c42442, 0x03c02b44, 0x03c02b42, 0x03c02a44, 0x03c02a42, 0x03c02944, 0x03c02942, 0x03c02844, 0x03c02842, 0x03c02744, 0x03c02742, 0x03b02b44, 0x03b02b42, 0x03b02a44, 0x03b02a42, 0x03b02944, 0x03b02942, 0x03b02844, 0x03b02842, 0x03b02744, 0x03b02742, 0x03b02644, 0x03b02642, 0x03b02544, 0x03b02542, 0x03a02b44, 0x03a02b42, 0x03a02a44, 0x03a02a42, 0x03a02944, 0x03a02942, 0x03a02844, 0x03a02842, 0x03a02744, 0x03a02742, 0x03902b44, 0x03902b42, 0x03902a44, 0x03902a42, 0x03902944, 0x03902942, 0x03902844, 0x03902842, 0x03902744, 0x03902742, 0x03902644, 0x03902642, 0x03902544, 0x03902542, 0x03802b44, 0x03802b42, 0x03802a44, 0x03802a42, 0x03802944, 0x03802942, 0x03802844, 0x03802842, 0x03802744, 0x03802742, 0x03802644, 0x03802642, 0x03802544, 0x03802542, 0x03802444, 0x03802442, 0x03802344, 0x03802342, 0x03802244, 0x03802242, 0x03802144, 0x03802142, 0x03802044, 0x03802042, 0x03801f44, 0x03801f42, 0x03801e44, 0x03801e42, 0x03801d44, 0x03801d42, 0x03801c44, 0x03801c42, 0x03801b44, 0x03801b42, 0x03801a44, 0x03801a42, 0x03801944, 0x03801942, 0x03801844, 0x03801842, 0x03801744, 0x03801742, 0x03801644, 0x03801642, 0x03801544, 0x03801542, 0x03801444, 0x03801442, 0x03801344, 0x03801342, 0x00002b00, }; /* EPA 2 GHz */ static const uint32_t bwn_ntab_tx_gain_epa_rev3_2g[] = { 0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e, 0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037, 0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e, 0x1e41003c, 0x1e41003b, 0x1e410039, 0x1e410037, 0x1d410044, 0x1d410042, 0x1d410040, 0x1d41003e, 0x1d41003c, 0x1d41003b, 0x1d410039, 0x1d410037, 0x1c410044, 0x1c410042, 0x1c410040, 0x1c41003e, 0x1c41003c, 0x1c41003b, 0x1c410039, 0x1c410037, 0x1b410044, 0x1b410042, 0x1b410040, 0x1b41003e, 0x1b41003c, 0x1b41003b, 0x1b410039, 0x1b410037, 0x1a410044, 0x1a410042, 0x1a410040, 0x1a41003e, 0x1a41003c, 0x1a41003b, 0x1a410039, 0x1a410037, 0x19410044, 0x19410042, 0x19410040, 0x1941003e, 0x1941003c, 0x1941003b, 0x19410039, 0x19410037, 0x18410044, 0x18410042, 0x18410040, 0x1841003e, 0x1841003c, 0x1841003b, 0x18410039, 0x18410037, 0x17410044, 0x17410042, 0x17410040, 0x1741003e, 0x1741003c, 0x1741003b, 0x17410039, 0x17410037, 0x16410044, 0x16410042, 0x16410040, 0x1641003e, 0x1641003c, 0x1641003b, 0x16410039, 0x16410037, 0x15410044, 0x15410042, 0x15410040, 0x1541003e, 0x1541003c, 0x1541003b, 0x15410039, 0x15410037, 0x14410044, 0x14410042, 0x14410040, 0x1441003e, 0x1441003c, 0x1441003b, 0x14410039, 0x14410037, 0x13410044, 0x13410042, 0x13410040, 0x1341003e, 0x1341003c, 0x1341003b, 0x13410039, 0x13410037, 0x12410044, 0x12410042, 0x12410040, 0x1241003e, 0x1241003c, 0x1241003b, 0x12410039, 0x12410037, 0x11410044, 0x11410042, 0x11410040, 0x1141003e, 0x1141003c, 0x1141003b, 0x11410039, 0x11410037, 0x10410044, 0x10410042, 0x10410040, 0x1041003e, 0x1041003c, 0x1041003b, 0x10410039, 0x10410037, }; static const uint32_t bwn_ntab_tx_gain_epa_rev3_hi_pwr_2g[] = { 0x0f410044, 0x0f410042, 0x0f410040, 0x0f41003e, 0x0f41003c, 0x0f41003b, 0x0f410039, 0x0f410037, 0x0e410044, 0x0e410042, 0x0e410040, 0x0e41003e, 0x0e41003c, 0x0e41003b, 0x0e410039, 0x0e410037, 0x0d410044, 0x0d410042, 0x0d410040, 0x0d41003e, 0x0d41003c, 0x0d41003b, 0x0d410039, 0x0d410037, 0x0c410044, 0x0c410042, 0x0c410040, 0x0c41003e, 0x0c41003c, 0x0c41003b, 0x0c410039, 0x0c410037, 0x0b410044, 0x0b410042, 0x0b410040, 0x0b41003e, 0x0b41003c, 0x0b41003b, 0x0b410039, 0x0b410037, 0x0a410044, 0x0a410042, 0x0a410040, 0x0a41003e, 0x0a41003c, 0x0a41003b, 0x0a410039, 0x0a410037, 0x09410044, 0x09410042, 0x09410040, 0x0941003e, 0x0941003c, 0x0941003b, 0x09410039, 0x09410037, 0x08410044, 0x08410042, 0x08410040, 0x0841003e, 0x0841003c, 0x0841003b, 0x08410039, 0x08410037, 0x07410044, 0x07410042, 0x07410040, 0x0741003e, 0x0741003c, 0x0741003b, 0x07410039, 0x07410037, 0x06410044, 0x06410042, 0x06410040, 0x0641003e, 0x0641003c, 0x0641003b, 0x06410039, 0x06410037, 0x05410044, 0x05410042, 0x05410040, 0x0541003e, 0x0541003c, 0x0541003b, 0x05410039, 0x05410037, 0x04410044, 0x04410042, 0x04410040, 0x0441003e, 0x0441003c, 0x0441003b, 0x04410039, 0x04410037, 0x03410044, 0x03410042, 0x03410040, 0x0341003e, 0x0341003c, 0x0341003b, 0x03410039, 0x03410037, 0x02410044, 0x02410042, 0x02410040, 0x0241003e, 0x0241003c, 0x0241003b, 0x02410039, 0x02410037, 0x01410044, 0x01410042, 0x01410040, 0x0141003e, 0x0141003c, 0x0141003b, 0x01410039, 0x01410037, 0x00410044, 0x00410042, 0x00410040, 0x0041003e, 0x0041003c, 0x0041003b, 0x00410039, 0x00410037 }; /* EPA 5 GHz */ static const uint32_t bwn_ntab_tx_gain_epa_rev3_5g[] = { 0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e, 0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037, 0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e, 0xcef7003c, 0xcef7003b, 0xcef70039, 0xcef70037, 0xcdf70044, 0xcdf70042, 0xcdf70040, 0xcdf7003e, 0xcdf7003c, 0xcdf7003b, 0xcdf70039, 0xcdf70037, 0xccf70044, 0xccf70042, 0xccf70040, 0xccf7003e, 0xccf7003c, 0xccf7003b, 0xccf70039, 0xccf70037, 0xcbf70044, 0xcbf70042, 0xcbf70040, 0xcbf7003e, 0xcbf7003c, 0xcbf7003b, 0xcbf70039, 0xcbf70037, 0xcaf70044, 0xcaf70042, 0xcaf70040, 0xcaf7003e, 0xcaf7003c, 0xcaf7003b, 0xcaf70039, 0xcaf70037, 0xc9f70044, 0xc9f70042, 0xc9f70040, 0xc9f7003e, 0xc9f7003c, 0xc9f7003b, 0xc9f70039, 0xc9f70037, 0xc8f70044, 0xc8f70042, 0xc8f70040, 0xc8f7003e, 0xc8f7003c, 0xc8f7003b, 0xc8f70039, 0xc8f70037, 0xc7f70044, 0xc7f70042, 0xc7f70040, 0xc7f7003e, 0xc7f7003c, 0xc7f7003b, 0xc7f70039, 0xc7f70037, 0xc6f70044, 0xc6f70042, 0xc6f70040, 0xc6f7003e, 0xc6f7003c, 0xc6f7003b, 0xc6f70039, 0xc6f70037, 0xc5f70044, 0xc5f70042, 0xc5f70040, 0xc5f7003e, 0xc5f7003c, 0xc5f7003b, 0xc5f70039, 0xc5f70037, 0xc4f70044, 0xc4f70042, 0xc4f70040, 0xc4f7003e, 0xc4f7003c, 0xc4f7003b, 0xc4f70039, 0xc4f70037, 0xc3f70044, 0xc3f70042, 0xc3f70040, 0xc3f7003e, 0xc3f7003c, 0xc3f7003b, 0xc3f70039, 0xc3f70037, 0xc2f70044, 0xc2f70042, 0xc2f70040, 0xc2f7003e, 0xc2f7003c, 0xc2f7003b, 0xc2f70039, 0xc2f70037, 0xc1f70044, 0xc1f70042, 0xc1f70040, 0xc1f7003e, 0xc1f7003c, 0xc1f7003b, 0xc1f70039, 0xc1f70037, 0xc0f70044, 0xc0f70042, 0xc0f70040, 0xc0f7003e, 0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037, }; static const uint32_t bwn_ntab_tx_gain_epa_rev4_5g[] = { 0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e, 0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037, 0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e, 0x2ef2003c, 0x2ef2003b, 0x2ef20039, 0x2ef20037, 0x2df20044, 0x2df20042, 0x2df20040, 0x2df2003e, 0x2df2003c, 0x2df2003b, 0x2df20039, 0x2df20037, 0x2cf20044, 0x2cf20042, 0x2cf20040, 0x2cf2003e, 0x2cf2003c, 0x2cf2003b, 0x2cf20039, 0x2cf20037, 0x2bf20044, 0x2bf20042, 0x2bf20040, 0x2bf2003e, 0x2bf2003c, 0x2bf2003b, 0x2bf20039, 0x2bf20037, 0x2af20044, 0x2af20042, 0x2af20040, 0x2af2003e, 0x2af2003c, 0x2af2003b, 0x2af20039, 0x2af20037, 0x29f20044, 0x29f20042, 0x29f20040, 0x29f2003e, 0x29f2003c, 0x29f2003b, 0x29f20039, 0x29f20037, 0x28f20044, 0x28f20042, 0x28f20040, 0x28f2003e, 0x28f2003c, 0x28f2003b, 0x28f20039, 0x28f20037, 0x27f20044, 0x27f20042, 0x27f20040, 0x27f2003e, 0x27f2003c, 0x27f2003b, 0x27f20039, 0x27f20037, 0x26f20044, 0x26f20042, 0x26f20040, 0x26f2003e, 0x26f2003c, 0x26f2003b, 0x26f20039, 0x26f20037, 0x25f20044, 0x25f20042, 0x25f20040, 0x25f2003e, 0x25f2003c, 0x25f2003b, 0x25f20039, 0x25f20037, 0x24f20044, 0x24f20042, 0x24f20040, 0x24f2003e, 0x24f2003c, 0x24f2003b, 0x24f20039, 0x24f20038, 0x23f20041, 0x23f20040, 0x23f2003f, 0x23f2003e, 0x23f2003c, 0x23f2003b, 0x23f20039, 0x23f20037, 0x22f20044, 0x22f20042, 0x22f20040, 0x22f2003e, 0x22f2003c, 0x22f2003b, 0x22f20039, 0x22f20037, 0x21f20044, 0x21f20042, 0x21f20040, 0x21f2003e, 0x21f2003c, 0x21f2003b, 0x21f20039, 0x21f20037, 0x20d20043, 0x20d20041, 0x20d2003e, 0x20d2003c, 0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034, }; static const uint32_t bwn_ntab_tx_gain_epa_rev4_hi_pwr_5g[] = { 0x2ff10044, 0x2ff10042, 0x2ff10040, 0x2ff1003e, 0x2ff1003c, 0x2ff1003b, 0x2ff10039, 0x2ff10037, 0x2ef10044, 0x2ef10042, 0x2ef10040, 0x2ef1003e, 0x2ef1003c, 0x2ef1003b, 0x2ef10039, 0x2ef10037, 0x2df10044, 0x2df10042, 0x2df10040, 0x2df1003e, 0x2df1003c, 0x2df1003b, 0x2df10039, 0x2df10037, 0x2cf10044, 0x2cf10042, 0x2cf10040, 0x2cf1003e, 0x2cf1003c, 0x2cf1003b, 0x2cf10039, 0x2cf10037, 0x2bf10044, 0x2bf10042, 0x2bf10040, 0x2bf1003e, 0x2bf1003c, 0x2bf1003b, 0x2bf10039, 0x2bf10037, 0x2af10044, 0x2af10042, 0x2af10040, 0x2af1003e, 0x2af1003c, 0x2af1003b, 0x2af10039, 0x2af10037, 0x29f10044, 0x29f10042, 0x29f10040, 0x29f1003e, 0x29f1003c, 0x29f1003b, 0x29f10039, 0x29f10037, 0x28f10044, 0x28f10042, 0x28f10040, 0x28f1003e, 0x28f1003c, 0x28f1003b, 0x28f10039, 0x28f10037, 0x27f10044, 0x27f10042, 0x27f10040, 0x27f1003e, 0x27f1003c, 0x27f1003b, 0x27f10039, 0x27f10037, 0x26f10044, 0x26f10042, 0x26f10040, 0x26f1003e, 0x26f1003c, 0x26f1003b, 0x26f10039, 0x26f10037, 0x25f10044, 0x25f10042, 0x25f10040, 0x25f1003e, 0x25f1003c, 0x25f1003b, 0x25f10039, 0x25f10037, 0x24f10044, 0x24f10042, 0x24f10040, 0x24f1003e, 0x24f1003c, 0x24f1003b, 0x24f10039, 0x24f10038, 0x23f10041, 0x23f10040, 0x23f1003f, 0x23f1003e, 0x23f1003c, 0x23f1003b, 0x23f10039, 0x23f10037, 0x22f10044, 0x22f10042, 0x22f10040, 0x22f1003e, 0x22f1003c, 0x22f1003b, 0x22f10039, 0x22f10037, 0x21f10044, 0x21f10042, 0x21f10040, 0x21f1003e, 0x21f1003c, 0x21f1003b, 0x21f10039, 0x21f10037, 0x20d10043, 0x20d10041, 0x20d1003e, 0x20d1003c, 0x20d1003a, 0x20d10038, 0x20d10036, 0x20d10034 }; static const uint32_t bwn_ntab_tx_gain_epa_rev5_5g[] = { 0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044, 0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c, 0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e, 0x0e62003c, 0x0e62003d, 0x0e62003b, 0x0e62003a, 0x0d620043, 0x0d620041, 0x0d620040, 0x0d62003e, 0x0d62003d, 0x0d62003c, 0x0d62003b, 0x0d62003a, 0x0c620041, 0x0c620040, 0x0c62003f, 0x0c62003e, 0x0c62003c, 0x0c62003b, 0x0c620039, 0x0c620037, 0x0b620046, 0x0b620044, 0x0b620042, 0x0b620040, 0x0b62003e, 0x0b62003c, 0x0b62003b, 0x0b62003a, 0x0a620041, 0x0a620040, 0x0a62003e, 0x0a62003c, 0x0a62003b, 0x0a62003a, 0x0a620039, 0x0a620038, 0x0962003e, 0x0962003d, 0x0962003c, 0x0962003b, 0x09620039, 0x09620037, 0x09620035, 0x09620033, 0x08620044, 0x08620042, 0x08620040, 0x0862003e, 0x0862003c, 0x0862003b, 0x0862003a, 0x08620039, 0x07620043, 0x07620042, 0x07620040, 0x0762003f, 0x0762003d, 0x0762003b, 0x0762003a, 0x07620039, 0x0662003e, 0x0662003d, 0x0662003c, 0x0662003b, 0x06620039, 0x06620037, 0x06620035, 0x06620033, 0x05620046, 0x05620044, 0x05620042, 0x05620040, 0x0562003e, 0x0562003c, 0x0562003b, 0x05620039, 0x04620044, 0x04620042, 0x04620040, 0x0462003e, 0x0462003c, 0x0462003b, 0x04620039, 0x04620038, 0x0362003c, 0x0362003b, 0x0362003a, 0x03620039, 0x03620038, 0x03620037, 0x03620035, 0x03620033, 0x0262004c, 0x0262004a, 0x02620048, 0x02620047, 0x02620046, 0x02620044, 0x02620043, 0x02620042, 0x0162004a, 0x01620048, 0x01620046, 0x01620044, 0x01620043, 0x01620042, 0x01620041, 0x01620040, 0x00620042, 0x00620040, 0x0062003e, 0x0062003c, 0x0062003b, 0x00620039, 0x00620037, 0x00620035, }; /* IPA 2 GHz */ static const uint32_t bwn_ntab_tx_gain_ipa_rev3_2g[] = { 0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029, 0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025, 0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029, 0x5ef70028, 0x5ef70027, 0x5ef70026, 0x5ef70025, 0x5df7002d, 0x5df7002b, 0x5df7002a, 0x5df70029, 0x5df70028, 0x5df70027, 0x5df70026, 0x5df70025, 0x5cf7002d, 0x5cf7002b, 0x5cf7002a, 0x5cf70029, 0x5cf70028, 0x5cf70027, 0x5cf70026, 0x5cf70025, 0x5bf7002d, 0x5bf7002b, 0x5bf7002a, 0x5bf70029, 0x5bf70028, 0x5bf70027, 0x5bf70026, 0x5bf70025, 0x5af7002d, 0x5af7002b, 0x5af7002a, 0x5af70029, 0x5af70028, 0x5af70027, 0x5af70026, 0x5af70025, 0x59f7002d, 0x59f7002b, 0x59f7002a, 0x59f70029, 0x59f70028, 0x59f70027, 0x59f70026, 0x59f70025, 0x58f7002d, 0x58f7002b, 0x58f7002a, 0x58f70029, 0x58f70028, 0x58f70027, 0x58f70026, 0x58f70025, 0x57f7002d, 0x57f7002b, 0x57f7002a, 0x57f70029, 0x57f70028, 0x57f70027, 0x57f70026, 0x57f70025, 0x56f7002d, 0x56f7002b, 0x56f7002a, 0x56f70029, 0x56f70028, 0x56f70027, 0x56f70026, 0x56f70025, 0x55f7002d, 0x55f7002b, 0x55f7002a, 0x55f70029, 0x55f70028, 0x55f70027, 0x55f70026, 0x55f70025, 0x54f7002d, 0x54f7002b, 0x54f7002a, 0x54f70029, 0x54f70028, 0x54f70027, 0x54f70026, 0x54f70025, 0x53f7002d, 0x53f7002b, 0x53f7002a, 0x53f70029, 0x53f70028, 0x53f70027, 0x53f70026, 0x53f70025, 0x52f7002d, 0x52f7002b, 0x52f7002a, 0x52f70029, 0x52f70028, 0x52f70027, 0x52f70026, 0x52f70025, 0x51f7002d, 0x51f7002b, 0x51f7002a, 0x51f70029, 0x51f70028, 0x51f70027, 0x51f70026, 0x51f70025, 0x50f7002d, 0x50f7002b, 0x50f7002a, 0x50f70029, 0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025, }; static const uint32_t bwn_ntab_tx_gain_ipa_rev5_2g[] = { 0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029, 0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025, 0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029, 0x1ef70028, 0x1ef70027, 0x1ef70026, 0x1ef70025, 0x1df7002d, 0x1df7002b, 0x1df7002a, 0x1df70029, 0x1df70028, 0x1df70027, 0x1df70026, 0x1df70025, 0x1cf7002d, 0x1cf7002b, 0x1cf7002a, 0x1cf70029, 0x1cf70028, 0x1cf70027, 0x1cf70026, 0x1cf70025, 0x1bf7002d, 0x1bf7002b, 0x1bf7002a, 0x1bf70029, 0x1bf70028, 0x1bf70027, 0x1bf70026, 0x1bf70025, 0x1af7002d, 0x1af7002b, 0x1af7002a, 0x1af70029, 0x1af70028, 0x1af70027, 0x1af70026, 0x1af70025, 0x19f7002d, 0x19f7002b, 0x19f7002a, 0x19f70029, 0x19f70028, 0x19f70027, 0x19f70026, 0x19f70025, 0x18f7002d, 0x18f7002b, 0x18f7002a, 0x18f70029, 0x18f70028, 0x18f70027, 0x18f70026, 0x18f70025, 0x17f7002d, 0x17f7002b, 0x17f7002a, 0x17f70029, 0x17f70028, 0x17f70027, 0x17f70026, 0x17f70025, 0x16f7002d, 0x16f7002b, 0x16f7002a, 0x16f70029, 0x16f70028, 0x16f70027, 0x16f70026, 0x16f70025, 0x15f7002d, 0x15f7002b, 0x15f7002a, 0x15f70029, 0x15f70028, 0x15f70027, 0x15f70026, 0x15f70025, 0x14f7002d, 0x14f7002b, 0x14f7002a, 0x14f70029, 0x14f70028, 0x14f70027, 0x14f70026, 0x14f70025, 0x13f7002d, 0x13f7002b, 0x13f7002a, 0x13f70029, 0x13f70028, 0x13f70027, 0x13f70026, 0x13f70025, 0x12f7002d, 0x12f7002b, 0x12f7002a, 0x12f70029, 0x12f70028, 0x12f70027, 0x12f70026, 0x12f70025, 0x11f7002d, 0x11f7002b, 0x11f7002a, 0x11f70029, 0x11f70028, 0x11f70027, 0x11f70026, 0x11f70025, 0x10f7002d, 0x10f7002b, 0x10f7002a, 0x10f70029, 0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025, }; static const uint32_t bwn_ntab_tx_gain_ipa_rev6_2g[] = { 0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029, 0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025, 0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029, 0x0ef70028, 0x0ef70027, 0x0ef70026, 0x0ef70025, 0x0df7002d, 0x0df7002b, 0x0df7002a, 0x0df70029, 0x0df70028, 0x0df70027, 0x0df70026, 0x0df70025, 0x0cf7002d, 0x0cf7002b, 0x0cf7002a, 0x0cf70029, 0x0cf70028, 0x0cf70027, 0x0cf70026, 0x0cf70025, 0x0bf7002d, 0x0bf7002b, 0x0bf7002a, 0x0bf70029, 0x0bf70028, 0x0bf70027, 0x0bf70026, 0x0bf70025, 0x0af7002d, 0x0af7002b, 0x0af7002a, 0x0af70029, 0x0af70028, 0x0af70027, 0x0af70026, 0x0af70025, 0x09f7002d, 0x09f7002b, 0x09f7002a, 0x09f70029, 0x09f70028, 0x09f70027, 0x09f70026, 0x09f70025, 0x08f7002d, 0x08f7002b, 0x08f7002a, 0x08f70029, 0x08f70028, 0x08f70027, 0x08f70026, 0x08f70025, 0x07f7002d, 0x07f7002b, 0x07f7002a, 0x07f70029, 0x07f70028, 0x07f70027, 0x07f70026, 0x07f70025, 0x06f7002d, 0x06f7002b, 0x06f7002a, 0x06f70029, 0x06f70028, 0x06f70027, 0x06f70026, 0x06f70025, 0x05f7002d, 0x05f7002b, 0x05f7002a, 0x05f70029, 0x05f70028, 0x05f70027, 0x05f70026, 0x05f70025, 0x04f7002d, 0x04f7002b, 0x04f7002a, 0x04f70029, 0x04f70028, 0x04f70027, 0x04f70026, 0x04f70025, 0x03f7002d, 0x03f7002b, 0x03f7002a, 0x03f70029, 0x03f70028, 0x03f70027, 0x03f70026, 0x03f70025, 0x02f7002d, 0x02f7002b, 0x02f7002a, 0x02f70029, 0x02f70028, 0x02f70027, 0x02f70026, 0x02f70025, 0x01f7002d, 0x01f7002b, 0x01f7002a, 0x01f70029, 0x01f70028, 0x01f70027, 0x01f70026, 0x01f70025, 0x00f7002d, 0x00f7002b, 0x00f7002a, 0x00f70029, 0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025, }; /* Copied from brcmsmac (5.75.11): nphy_tpc_txgain_ipa_2g_2057rev5 */ static const uint32_t bwn_ntab_tx_gain_ipa_2057_rev5_2g[] = { 0x30ff0031, 0x30e70031, 0x30e7002e, 0x30cf002e, 0x30bf002e, 0x30af002e, 0x309f002f, 0x307f0033, 0x307f0031, 0x307f002e, 0x3077002e, 0x306f002e, 0x3067002e, 0x305f002f, 0x30570030, 0x3057002d, 0x304f002e, 0x30470031, 0x3047002e, 0x3047002c, 0x30470029, 0x303f002c, 0x303f0029, 0x3037002d, 0x3037002a, 0x30370028, 0x302f002c, 0x302f002a, 0x302f0028, 0x302f0026, 0x3027002c, 0x30270029, 0x30270027, 0x30270025, 0x30270023, 0x301f002c, 0x301f002a, 0x301f0028, 0x301f0025, 0x301f0024, 0x301f0022, 0x301f001f, 0x3017002d, 0x3017002b, 0x30170028, 0x30170026, 0x30170024, 0x30170022, 0x30170020, 0x3017001e, 0x3017001d, 0x3017001b, 0x3017001a, 0x30170018, 0x30170017, 0x30170015, 0x300f002c, 0x300f0029, 0x300f0027, 0x300f0024, 0x300f0022, 0x300f0021, 0x300f001f, 0x300f001d, 0x300f001b, 0x300f001a, 0x300f0018, 0x300f0017, 0x300f0016, 0x300f0015, 0x300f0115, 0x300f0215, 0x300f0315, 0x300f0415, 0x300f0515, 0x300f0615, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, 0x300f0715, }; /* Extracted from MMIO dump of 6.30.223.141 */ static const uint32_t bwn_ntab_tx_gain_ipa_2057_rev9_2g[] = { 0x60ff0031, 0x60e7002c, 0x60cf002a, 0x60c70029, 0x60b70029, 0x60a70029, 0x609f002a, 0x6097002b, 0x6087002e, 0x60770031, 0x606f0032, 0x60670034, 0x60670031, 0x605f0033, 0x605f0031, 0x60570033, 0x60570030, 0x6057002d, 0x6057002b, 0x604f002d, 0x604f002b, 0x604f0029, 0x604f0026, 0x60470029, 0x60470027, 0x603f0029, 0x603f0027, 0x603f0025, 0x60370029, 0x60370027, 0x60370024, 0x602f002a, 0x602f0028, 0x602f0026, 0x602f0024, 0x6027002a, 0x60270028, 0x60270026, 0x60270024, 0x60270022, 0x601f002b, 0x601f0029, 0x601f0027, 0x601f0024, 0x601f0022, 0x601f0020, 0x601f001f, 0x601f001d, 0x60170029, 0x60170027, 0x60170025, 0x60170023, 0x60170021, 0x6017001f, 0x6017001d, 0x6017001c, 0x6017001a, 0x60170018, 0x60170018, 0x60170016, 0x60170015, 0x600f0029, 0x600f0027, 0x600f0025, 0x600f0023, 0x600f0021, 0x600f001f, 0x600f001d, 0x600f001c, 0x600f001a, 0x600f0019, 0x600f0018, 0x600f0016, 0x600f0015, 0x600f0115, 0x600f0215, 0x600f0315, 0x600f0415, 0x600f0515, 0x600f0615, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, 0x600f0715, }; /* Extracted from MMIO dump of 6.30.223.248 */ static const uint32_t bwn_ntab_tx_gain_ipa_2057_rev14_2g[] = { 0x50df002e, 0x50cf002d, 0x50bf002c, 0x50b7002b, 0x50af002a, 0x50a70029, 0x509f0029, 0x50970028, 0x508f0027, 0x50870027, 0x507f0027, 0x50770027, 0x506f0027, 0x50670027, 0x505f0028, 0x50570029, 0x504f002b, 0x5047002e, 0x5047002b, 0x50470029, 0x503f002c, 0x503f0029, 0x5037002c, 0x5037002a, 0x50370028, 0x502f002d, 0x502f002b, 0x502f0028, 0x502f0026, 0x5027002d, 0x5027002a, 0x50270028, 0x50270026, 0x50270024, 0x501f002e, 0x501f002b, 0x501f0029, 0x501f0027, 0x501f0024, 0x501f0022, 0x501f0020, 0x501f001f, 0x5017002c, 0x50170029, 0x50170027, 0x50170024, 0x50170022, 0x50170021, 0x5017001f, 0x5017001d, 0x5017001b, 0x5017001a, 0x50170018, 0x50170017, 0x50170015, 0x500f002c, 0x500f002a, 0x500f0027, 0x500f0025, 0x500f0023, 0x500f0022, 0x500f001f, 0x500f001e, 0x500f001c, 0x500f001a, 0x500f0019, 0x500f0018, 0x500f0016, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, 0x500f0015, }; /* IPA 2 5Hz */ static const uint32_t bwn_ntab_tx_gain_ipa_rev3_5g[] = { 0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031, 0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b, 0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027, 0x7ff70026, 0x7ff70024, 0x7ff70023, 0x7ff70022, 0x7ef70028, 0x7ef70027, 0x7ef70026, 0x7ef70025, 0x7ef70024, 0x7ef70023, 0x7df70028, 0x7df70027, 0x7df70026, 0x7df70025, 0x7df70024, 0x7df70023, 0x7df70022, 0x7cf70029, 0x7cf70028, 0x7cf70027, 0x7cf70026, 0x7cf70025, 0x7cf70023, 0x7cf70022, 0x7bf70029, 0x7bf70028, 0x7bf70026, 0x7bf70025, 0x7bf70024, 0x7bf70023, 0x7bf70022, 0x7bf70021, 0x7af70029, 0x7af70028, 0x7af70027, 0x7af70026, 0x7af70025, 0x7af70024, 0x7af70023, 0x7af70022, 0x79f70029, 0x79f70028, 0x79f70027, 0x79f70026, 0x79f70025, 0x79f70024, 0x79f70023, 0x79f70022, 0x78f70029, 0x78f70028, 0x78f70027, 0x78f70026, 0x78f70025, 0x78f70024, 0x78f70023, 0x78f70022, 0x77f70029, 0x77f70028, 0x77f70027, 0x77f70026, 0x77f70025, 0x77f70024, 0x77f70023, 0x77f70022, 0x76f70029, 0x76f70028, 0x76f70027, 0x76f70026, 0x76f70024, 0x76f70023, 0x76f70022, 0x76f70021, 0x75f70029, 0x75f70028, 0x75f70027, 0x75f70026, 0x75f70025, 0x75f70024, 0x75f70023, 0x74f70029, 0x74f70028, 0x74f70026, 0x74f70025, 0x74f70024, 0x74f70023, 0x74f70022, 0x73f70029, 0x73f70027, 0x73f70026, 0x73f70025, 0x73f70024, 0x73f70023, 0x73f70022, 0x72f70028, 0x72f70027, 0x72f70026, 0x72f70025, 0x72f70024, 0x72f70023, 0x72f70022, 0x71f70028, 0x71f70027, 0x71f70026, 0x71f70025, 0x71f70024, 0x71f70023, 0x70f70028, 0x70f70027, 0x70f70026, 0x70f70024, 0x70f70023, 0x70f70022, 0x70f70021, 0x70f70020, 0x70f70020, 0x70f7001f, }; /* Extracted from MMIO dump of 6.30.223.141 */ static const uint32_t bwn_ntab_tx_gain_ipa_2057_rev9_5g[] = { 0x7f7f0053, 0x7f7f004b, 0x7f7f0044, 0x7f7f003f, 0x7f7f0039, 0x7f7f0035, 0x7f7f0032, 0x7f7f0030, 0x7f7f002d, 0x7e7f0030, 0x7e7f002d, 0x7d7f0032, 0x7d7f002f, 0x7d7f002c, 0x7c7f0032, 0x7c7f0030, 0x7c7f002d, 0x7b7f0030, 0x7b7f002e, 0x7b7f002b, 0x7a7f0032, 0x7a7f0030, 0x7a7f002d, 0x7a7f002b, 0x797f0030, 0x797f002e, 0x797f002b, 0x797f0029, 0x787f0030, 0x787f002d, 0x787f002b, 0x777f0032, 0x777f0030, 0x777f002d, 0x777f002b, 0x767f0031, 0x767f002f, 0x767f002c, 0x767f002a, 0x757f0031, 0x757f002f, 0x757f002c, 0x757f002a, 0x747f0030, 0x747f002d, 0x747f002b, 0x737f0032, 0x737f002f, 0x737f002c, 0x737f002a, 0x727f0030, 0x727f002d, 0x727f002b, 0x727f0029, 0x717f0030, 0x717f002d, 0x717f002b, 0x707f0031, 0x707f002f, 0x707f002c, 0x707f002a, 0x707f0027, 0x707f0025, 0x707f0023, 0x707f0021, 0x707f001f, 0x707f001d, 0x707f001c, 0x707f001a, 0x707f0019, 0x707f0017, 0x707f0016, 0x707f0015, 0x707f0014, 0x707f0012, 0x707f0012, 0x707f0011, 0x707f0010, 0x707f000f, 0x707f000e, 0x707f000d, 0x707f000d, 0x707f000c, 0x707f000b, 0x707f000a, 0x707f000a, 0x707f0009, 0x707f0008, 0x707f0008, 0x707f0008, 0x707f0008, 0x707f0007, 0x707f0007, 0x707f0006, 0x707f0006, 0x707f0006, 0x707f0005, 0x707f0005, 0x707f0005, 0x707f0004, 0x707f0004, 0x707f0004, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0003, 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0002, 0x707f0001, 0x707f0001, 0x707f0001, 0x707f0001, 0x707f0001, 0x707f0001, 0x707f0001, }; const int8_t bwn_ntab_papd_pga_gain_delta_ipa_2g[] = { -114, -108, -98, -91, -84, -78, -70, -62, -54, -46, -39, -31, -23, -15, -8, 0 }; /* Extracted from MMIO dump of 6.30.223.248 * Entries: 0, 15, 17, 21, 24, 26, 27, 29, 30 were guessed */ static const int16_t bwn_ntab_rf_pwr_offset_2057_rev9_2g[] = { -133, -133, -107, -92, -81, -73, -66, -61, -56, -52, -48, -44, -41, -37, -34, -31, -28, -25, -22, -19, -17, -14, -12, -10, -9, -7, -5, -4, -3, -2, -1, 0, }; /* Extracted from MMIO dump of 6.30.223.248 */ static const int16_t bwn_ntab_rf_pwr_offset_2057_rev9_5g[] = { -101, -94, -86, -79, -72, -65, -57, -50, -42, -35, -28, -21, -16, -9, -4, 0, }; /* Extracted from MMIO dump of 6.30.223.248 * Entries: 0, 26, 28, 29, 30, 31 were guessed */ static const int16_t bwn_ntab_rf_pwr_offset_2057_rev14_2g[] = { -111, -111, -111, -84, -70, -59, -52, -45, -40, -36, -32, -29, -26, -23, -21, -18, -16, -15, -13, -11, -10, -8, -7, -6, -5, -4, -4, -3, -3, -2, -2, -1, }; const uint16_t tbl_iqcal_gainparams[2][9][8] = { { { 0x000, 0, 0, 2, 0x69, 0x69, 0x69, 0x69 }, { 0x700, 7, 0, 0, 0x69, 0x69, 0x69, 0x69 }, { 0x710, 7, 1, 0, 0x68, 0x68, 0x68, 0x68 }, { 0x720, 7, 2, 0, 0x67, 0x67, 0x67, 0x67 }, { 0x730, 7, 3, 0, 0x66, 0x66, 0x66, 0x66 }, { 0x740, 7, 4, 0, 0x65, 0x65, 0x65, 0x65 }, { 0x741, 7, 4, 1, 0x65, 0x65, 0x65, 0x65 }, { 0x742, 7, 4, 2, 0x65, 0x65, 0x65, 0x65 }, { 0x743, 7, 4, 3, 0x65, 0x65, 0x65, 0x65 } }, { { 0x000, 7, 0, 0, 0x79, 0x79, 0x79, 0x79 }, { 0x700, 7, 0, 0, 0x79, 0x79, 0x79, 0x79 }, { 0x710, 7, 1, 0, 0x79, 0x79, 0x79, 0x79 }, { 0x720, 7, 2, 0, 0x78, 0x78, 0x78, 0x78 }, { 0x730, 7, 3, 0, 0x78, 0x78, 0x78, 0x78 }, { 0x740, 7, 4, 0, 0x78, 0x78, 0x78, 0x78 }, { 0x741, 7, 4, 1, 0x78, 0x78, 0x78, 0x78 }, { 0x742, 7, 4, 2, 0x78, 0x78, 0x78, 0x78 }, { 0x743, 7, 4, 3, 0x78, 0x78, 0x78, 0x78 } } }; const struct bwn_nphy_txiqcal_ladder ladder_lo[] = { { 3, 0 }, { 4, 0 }, { 6, 0 }, { 9, 0 }, { 13, 0 }, { 18, 0 }, { 25, 0 }, { 25, 1 }, { 25, 2 }, { 25, 3 }, { 25, 4 }, { 25, 5 }, { 25, 6 }, { 25, 7 }, { 35, 7 }, { 50, 7 }, { 71, 7 }, { 100, 7 } }; const struct bwn_nphy_txiqcal_ladder ladder_iq[] = { { 3, 0 }, { 4, 0 }, { 6, 0 }, { 9, 0 }, { 13, 0 }, { 18, 0 }, { 25, 0 }, { 35, 0 }, { 50, 0 }, { 71, 0 }, { 100, 0 }, { 100, 1 }, { 100, 2 }, { 100, 3 }, { 100, 4 }, { 100, 5 }, { 100, 6 }, { 100, 7 } }; const uint16_t loscale[] = { 256, 256, 271, 271, 287, 256, 256, 271, 271, 287, 287, 304, 304, 256, 256, 271, 271, 287, 287, 304, 304, 322, 322, 341, 341, 362, 362, 383, 383, 256, 256, 271, 271, 287, 287, 304, 304, 322, 322, 256, 256, 271, 271, 287, 287, 304, 304, 322, 322, 341, 341, 362, 362, 256, 256, 271, 271, 287, 287, 304, 304, 322, 322, 256, 256, 271, 271, 287, 287, 304, 304, 322, 322, 341, 341, 362, 362, 256, 256, 271, 271, 287, 287, 304, 304, 322, 322, 341, 341, 362, 362, 383, 383, 406, 406, 430, 430, 455, 455, 482, 482, 511, 511, 541, 541, 573, 573, 607, 607, 643, 643, 681, 681, 722, 722, 764, 764, 810, 810, 858, 858, 908, 908, 962, 962, 1019, 1019, 256 }; const uint16_t tbl_tx_iqlo_cal_loft_ladder_40[] = { 0x0200, 0x0300, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1201, 0x1202, 0x1203, 0x1204, 0x1205, 0x1206, 0x1207, 0x1907, 0x2307, 0x3207, 0x4707 }; const uint16_t tbl_tx_iqlo_cal_loft_ladder_20[] = { 0x0300, 0x0500, 0x0700, 0x0900, 0x0d00, 0x1100, 0x1900, 0x1901, 0x1902, 0x1903, 0x1904, 0x1905, 0x1906, 0x1907, 0x2407, 0x3207, 0x4607, 0x6407 }; const uint16_t tbl_tx_iqlo_cal_iqimb_ladder_40[] = { 0x0100, 0x0200, 0x0400, 0x0700, 0x0900, 0x0c00, 0x1200, 0x1900, 0x2300, 0x3200, 0x4700, 0x4701, 0x4702, 0x4703, 0x4704, 0x4705, 0x4706, 0x4707 }; const uint16_t tbl_tx_iqlo_cal_iqimb_ladder_20[] = { 0x0200, 0x0300, 0x0600, 0x0900, 0x0d00, 0x1100, 0x1900, 0x2400, 0x3200, 0x4600, 0x6400, 0x6401, 0x6402, 0x6403, 0x6404, 0x6405, 0x6406, 0x6407 }; const uint16_t tbl_tx_iqlo_cal_startcoefs_nphyrev3[BWN_NTAB_TX_IQLO_CAL_STARTCOEFS_REV3] = { }; const uint16_t tbl_tx_iqlo_cal_startcoefs[BWN_NTAB_TX_IQLO_CAL_STARTCOEFS] = { }; const uint16_t tbl_tx_iqlo_cal_cmds_recal_nphyrev3[] = { 0x8423, 0x8323, 0x8073, 0x8256, 0x8045, 0x8223, 0x9423, 0x9323, 0x9073, 0x9256, 0x9045, 0x9223 }; const uint16_t tbl_tx_iqlo_cal_cmds_recal[] = { 0x8101, 0x8253, 0x8053, 0x8234, 0x8034, 0x9101, 0x9253, 0x9053, 0x9234, 0x9034 }; const uint16_t tbl_tx_iqlo_cal_cmds_fullcal[] = { 0x8123, 0x8264, 0x8086, 0x8245, 0x8056, 0x9123, 0x9264, 0x9086, 0x9245, 0x9056 }; const uint16_t tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { 0x8434, 0x8334, 0x8084, 0x8267, 0x8056, 0x8234, 0x9434, 0x9334, 0x9084, 0x9267, 0x9056, 0x9234 }; const int16_t tbl_tx_filter_coef_rev4[7][15] = { { -377, 137, -407, 208, -1527, 956, 93, 186, 93, 230, -44, 230, 201, -191, 201 }, { -77, 20, -98, 49, -93, 60, 56, 111, 56, 26, -5, 26, 34, -32, 34 }, { -360, 164, -376, 164, -1533, 576, 308, -314, 308, 121, -73, 121, 91, 124, 91 }, { -295, 200, -363, 142, -1391, 826, 151, 301, 151, 151, 301, 151, 602, -752, 602 }, { -92, 58, -96, 49, -104, 44, 17, 35, 17, 12, 25, 12, 13, 27, 13 }, { -375, 136, -399, 209, -1479, 949, 130, 260, 130, 230, -44, 230, 201, -191, 201 }, { 0xed9, 0xc8, 0xe95, 0x8e, 0xa91, 0x33a, 0x97, 0x12d, 0x97, 0x97, 0x12d, 0x97, 0x25a, 0xd10, 0x25a } }; /* addr0, addr1, bmask, shift */ const struct bwn_nphy_rf_control_override_rev2 tbl_rf_control_override_rev2[] = { { 0x78, 0x78, 0x0038, 3 }, /* for field == 0x0002 (fls == 2) */ { 0x7A, 0x7D, 0x0001, 0 }, /* for field == 0x0004 (fls == 3) */ { 0x7A, 0x7D, 0x0002, 1 }, /* for field == 0x0008 (fls == 4) */ { 0x7A, 0x7D, 0x0004, 2 }, /* for field == 0x0010 (fls == 5) */ { 0x7A, 0x7D, 0x0030, 4 }, /* for field == 0x0020 (fls == 6) */ { 0x7A, 0x7D, 0x00C0, 6 }, /* for field == 0x0040 (fls == 7) */ { 0x7A, 0x7D, 0x0100, 8 }, /* for field == 0x0080 (fls == 8) */ { 0x7A, 0x7D, 0x0200, 9 }, /* for field == 0x0100 (fls == 9) */ { 0x78, 0x78, 0x0004, 2 }, /* for field == 0x0200 (fls == 10) */ { 0x7B, 0x7E, 0x01FF, 0 }, /* for field == 0x0400 (fls == 11) */ { 0x7C, 0x7F, 0x01FF, 0 }, /* for field == 0x0800 (fls == 12) */ { 0x78, 0x78, 0x0100, 8 }, /* for field == 0x1000 (fls == 13) */ { 0x78, 0x78, 0x0200, 9 }, /* for field == 0x2000 (fls == 14) */ { 0x78, 0x78, 0xF000, 12 } /* for field == 0x4000 (fls == 15) */ }; /* val_mask, val_shift, en_addr0, val_addr0, en_addr1, val_addr1 */ const struct bwn_nphy_rf_control_override_rev3 tbl_rf_control_override_rev3[] = { { 0x8000, 15, 0xE5, 0xF9, 0xE6, 0xFB }, /* field == 0x0001 (fls 1) */ { 0x0001, 0, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0002 (fls 2) */ { 0x0002, 1, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0004 (fls 3) */ { 0x0004, 2, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0008 (fls 4) */ { 0x0010, 4, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0010 (fls 5) */ { 0x0020, 5, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0020 (fls 6) */ { 0x0040, 6, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0040 (fls 7) */ { 0x0080, 7, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0080 (fls 8) */ { 0x0100, 8, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0100 (fls 9) */ { 0x0007, 0, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0200 (fls 10) */ { 0x0070, 4, 0xE7, 0xF8, 0xEC, 0xFA }, /* field == 0x0400 (fls 11) */ { 0xE000, 13, 0xE7, 0x7A, 0xEC, 0x7D }, /* field == 0x0800 (fls 12) */ { 0xFFFF, 0, 0xE7, 0x7B, 0xEC, 0x7E }, /* field == 0x1000 (fls 13) */ { 0xFFFF, 0, 0xE7, 0x7C, 0xEC, 0x7F }, /* field == 0x2000 (fls 14) */ { 0x00C0, 6, 0xE7, 0xF9, 0xEC, 0xFB } /* field == 0x4000 (fls 15) */ }; /* field, val_addr_core0, val_addr_core1, val_mask, val_shift */ static const struct bwn_nphy_rf_control_override_rev7 tbl_rf_control_override_rev7_over0[] = { { 0x0004, 0x07A, 0x07D, 0x0002, 1 }, { 0x0008, 0x07A, 0x07D, 0x0004, 2 }, { 0x0010, 0x07A, 0x07D, 0x0010, 4 }, { 0x0020, 0x07A, 0x07D, 0x0020, 5 }, { 0x0040, 0x07A, 0x07D, 0x0040, 6 }, { 0x0080, 0x07A, 0x07D, 0x0080, 7 }, { 0x0400, 0x0F8, 0x0FA, 0x0070, 4 }, { 0x0800, 0x07B, 0x07E, 0xFFFF, 0 }, { 0x1000, 0x07C, 0x07F, 0xFFFF, 0 }, { 0x6000, 0x348, 0x349, 0x00FF, 0 }, { 0x2000, 0x348, 0x349, 0x000F, 0 }, }; /* field, val_addr_core0, val_addr_core1, val_mask, val_shift */ static const struct bwn_nphy_rf_control_override_rev7 tbl_rf_control_override_rev7_over1[] = { { 0x0002, 0x340, 0x341, 0x0002, 1 }, { 0x0008, 0x340, 0x341, 0x0008, 3 }, { 0x0020, 0x340, 0x341, 0x0020, 5 }, { 0x0010, 0x340, 0x341, 0x0010, 4 }, { 0x0004, 0x340, 0x341, 0x0004, 2 }, { 0x0080, 0x340, 0x341, 0x0700, 8 }, { 0x0800, 0x340, 0x341, 0x4000, 14 }, { 0x0400, 0x340, 0x341, 0x2000, 13 }, { 0x0200, 0x340, 0x341, 0x0800, 12 }, { 0x0100, 0x340, 0x341, 0x0100, 11 }, { 0x0040, 0x340, 0x341, 0x0040, 6 }, { 0x0001, 0x340, 0x341, 0x0001, 0 }, }; /* field, val_addr_core0, val_addr_core1, val_mask, val_shift */ static const struct bwn_nphy_rf_control_override_rev7 tbl_rf_control_override_rev7_over2[] = { { 0x0008, 0x344, 0x345, 0x0008, 3 }, { 0x0002, 0x344, 0x345, 0x0002, 1 }, { 0x0001, 0x344, 0x345, 0x0001, 0 }, { 0x0004, 0x344, 0x345, 0x0004, 2 }, { 0x0010, 0x344, 0x345, 0x0010, 4 }, }; static struct bwn_nphy_gain_ctl_workaround_entry nphy_gain_ctl_wa_phy6_radio11_ghz2 = { { 10, 14, 19, 27 }, { -5, 6, 10, 15 }, { 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, 0x427E, { 0x413F, 0x413F, 0x413F, 0x413F }, 0x007E, 0x0066, 0x1074, 0x18, 0x18, 0x18, 0x01D0, 0x5, }; static struct bwn_nphy_gain_ctl_workaround_entry nphy_gain_ctl_workaround[2][4] = { { /* 2GHz */ { /* PHY rev 3 */ { 7, 11, 16, 23 }, { -5, 6, 10, 14 }, { 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, 0x627E, { 0x613F, 0x613F, 0x613F, 0x613F }, 0x107E, 0x0066, 0x0074, 0x18, 0x18, 0x18, 0x020D, 0x5, }, { /* PHY rev 4 */ { 8, 12, 17, 25 }, { -5, 6, 10, 14 }, { 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, 0x527E, { 0x513F, 0x513F, 0x513F, 0x513F }, 0x007E, 0x0066, 0x0074, 0x18, 0x18, 0x18, 0x01A1, 0x5, }, { /* PHY rev 5 */ { 9, 13, 18, 26 }, { -3, 7, 11, 16 }, { 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, 0x427E, /* invalid for external LNA! */ { 0x413F, 0x413F, 0x413F, 0x413F }, /* invalid for external LNA! */ 0x1076, 0x0066, 0x0000, /* low is invalid (the last one) */ 0x18, 0x18, 0x18, 0x01D0, 0x9, }, { /* PHY rev 6+ */ { 8, 13, 18, 25 }, { -5, 6, 10, 14 }, { 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA, 0xA }, { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, 0x527E, /* invalid for external LNA! */ { 0x513F, 0x513F, 0x513F, 0x513F }, /* invalid for external LNA! */ 0x007E, 0x0066, 0x0000, /* low is invalid (the last one) */ 0x18, 0x18, 0x18, 0x01D0, 0x5, }, }, { /* 5GHz */ { /* PHY rev 3 */ { 7, 11, 17, 23 }, { -6, 2, 6, 10 }, { 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13 }, { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, 0x52DE, { 0x516F, 0x516F, 0x516F, 0x516F }, 0x00DE, 0x00CA, 0x00CC, 0x1E, 0x1E, 0x1E, 0x01A1, 25, }, { /* PHY rev 4 */ { 8, 12, 18, 23 }, { -5, 2, 6, 10 }, { 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD }, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, 0x629E, { 0x614F, 0x614F, 0x614F, 0x614F }, 0x029E, 0x1084, 0x0086, 0x24, 0x24, 0x24, 0x0107, 25, }, { /* PHY rev 5 */ { 6, 10, 16, 21 }, { -7, 0, 4, 8 }, { 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD }, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, 0x729E, { 0x714F, 0x714F, 0x714F, 0x714F }, 0x029E, 0x2084, 0x2086, 0x24, 0x24, 0x24, 0x00A9, 25, }, { /* PHY rev 6+ */ { 6, 10, 16, 21 }, { -7, 0, 4, 8 }, { 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD, 0xD }, { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }, 0x729E, { 0x714F, 0x714F, 0x714F, 0x714F }, 0x029E, 0x2084, 0x2086, 0x24, 0x24, 0x24, /* low is invalid for radio rev 11! */ 0x00F0, 25, }, }, }; static inline void assert_ntab_array_sizes(void) { #undef check #define check(table, size) \ CTASSERT(nitems(bwn_ntab_##table) == BWN_NTAB_##size##_SIZE) check(adjustpower0, C0_ADJPLT); check(adjustpower1, C1_ADJPLT); check(bdi, BDI); check(channelest, CHANEST); check(estimatepowerlt0, C0_ESTPLT); check(estimatepowerlt1, C1_ESTPLT); check(framelookup, FRAMELT); check(framestruct, FRAMESTRUCT); check(gainctl0, C0_GAINCTL); check(gainctl1, C1_GAINCTL); check(intlevel, INTLEVEL); check(iqlt0, C0_IQLT); check(iqlt1, C1_IQLT); check(loftlt0, C0_LOFEEDTH); check(loftlt1, C1_LOFEEDTH); check(mcs, MCS); check(noisevar10, NOISEVAR10); check(noisevar11, NOISEVAR11); check(pilot, PILOT); check(pilotlt, PILOTLT); check(tdi20a0, TDI20A0); check(tdi20a1, TDI20A1); check(tdi40a0, TDI40A0); check(tdi40a1, TDI40A1); check(tdtrn, TDTRN); check(tmap, TMAP); #undef check } uint32_t bwn_ntab_read(struct bwn_mac *mac, uint32_t offset) { uint32_t type, value; type = offset & BWN_NTAB_TYPEMASK; offset &= ~BWN_NTAB_TYPEMASK; KASSERT(offset <= 0xFFFF, ("%s: invalid offset (%d)\n", __func__, offset)); switch (type) { case BWN_NTAB_8BIT: BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); value = BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO) & 0xFF; break; case BWN_NTAB_16BIT: BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); value = BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO); break; case BWN_NTAB_32BIT: BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); value = BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO); value |= BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATAHI) << 16; break; default: KASSERT(0, ("%s: invalid type", __func__)); value = 0; } return value; } void bwn_ntab_read_bulk(struct bwn_mac *mac, uint32_t offset, unsigned int nr_elements, void *_data) { struct bwn_softc *sc = mac->mac_sc; uint32_t type; uint8_t *data = _data; unsigned int i; type = offset & BWN_NTAB_TYPEMASK; offset &= ~BWN_NTAB_TYPEMASK; KASSERT(offset <= 0xFFFF, ("%s: invalid offset (%d)\n", __func__, offset)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); for (i = 0; i < nr_elements; i++) { /* Auto increment broken + caching issue on BCM43224? */ if (sc->sc_cid.chip_id == BHND_CHIPID_BCM43224 && bhnd_get_hwrev(sc->sc_dev) == 1) { BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset + i); } switch (type) { case BWN_NTAB_8BIT: *data = BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO) & 0xFF; data++; break; case BWN_NTAB_16BIT: *((uint16_t *)data) = BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO); data += 2; break; case BWN_NTAB_32BIT: *((uint32_t *)data) = BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO); *((uint32_t *)data) |= BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATAHI) << 16; data += 4; break; default: KASSERT(0, ("%s: called; invalid type (%d)\n", __func__, type)); } } } void bwn_ntab_write(struct bwn_mac *mac, uint32_t offset, uint32_t value) { - uint32_t type, orig; + uint32_t type; +#ifdef INVARIANTS + uint32_t orig; +#endif type = offset & BWN_NTAB_TYPEMASK; +#ifdef INVARIANTS orig = offset; +#endif offset &= 0xFFFF; switch (type) { case BWN_NTAB_8BIT: KASSERT(value <= 0xFF, ("%s: 8bit: invalid value (%d) (0x%08x)\n", __func__, value, orig)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, value); break; case BWN_NTAB_16BIT: KASSERT(value <= 0xFFFF, ("%s: 8bit: invalid value (%d) (0x%08x)\n", __func__, value, orig)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, value); break; case BWN_NTAB_32BIT: BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATAHI, value >> 16); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, value & 0xFFFF); break; default: KASSERT(0, ("%s: called; invalid type (%d)\n", __func__, type)); } return; /* Some compiletime assertions... */ assert_ntab_array_sizes(); } void bwn_ntab_write_bulk(struct bwn_mac *mac, uint32_t offset, unsigned int nr_elements, const void *_data) { struct bwn_softc *sc = mac->mac_sc; uint32_t type, value; +#ifdef INVARIANTS uint32_t orig; +#endif const uint8_t *data = _data; unsigned int i; type = offset & BWN_NTAB_TYPEMASK; +#ifdef INVARIANTS orig = offset; +#endif offset &= ~BWN_NTAB_TYPEMASK; KASSERT(offset <= 0xFFFF, ("%s: invalid offset (%d)\n", __func__, offset)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset); for (i = 0; i < nr_elements; i++) { /* Auto increment broken + caching issue on BCM43224? */ if ((offset >> 10) == 9 && sc->sc_cid.chip_id == BHND_CHIPID_BCM43224 && bhnd_get_hwrev(sc->sc_dev) == 1) { BWN_PHY_READ(mac, BWN_NPHY_TABLE_DATALO); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_ADDR, offset + i); } switch (type) { case BWN_NTAB_8BIT: value = *data; data++; KASSERT(value <= 0xFF, ("%s: 8bit: invalid value (%d) (0x%08x)\n", __func__, value, orig)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, value); break; case BWN_NTAB_16BIT: value = *((const uint16_t *)data); data += 2; KASSERT(value <= 0xFFFF, ("%s: 16bit: invalid value (%d) (0x%08x)\n", __func__, value, orig)); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, value); break; case BWN_NTAB_32BIT: value = *((const uint32_t *)data); data += 4; BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATAHI, value >> 16); BWN_PHY_WRITE(mac, BWN_NPHY_TABLE_DATALO, value & 0xFFFF); break; default: KASSERT(0, ("%s: invalid type (%d)\n", __func__, type)); } } } #define ntab_upload(mac, offset, data) do { \ bwn_ntab_write_bulk(mac, offset, nitems(data), data); \ } while (0) static void bwn_nphy_tables_init_shared_lut(struct bwn_mac *mac) { ntab_upload(mac, BWN_NTAB_C0_ESTPLT_R3, bwn_ntab_estimatepowerlt0_r3); ntab_upload(mac, BWN_NTAB_C1_ESTPLT_R3, bwn_ntab_estimatepowerlt1_r3); ntab_upload(mac, BWN_NTAB_C0_ADJPLT_R3, bwn_ntab_adjustpower0_r3); ntab_upload(mac, BWN_NTAB_C1_ADJPLT_R3, bwn_ntab_adjustpower1_r3); ntab_upload(mac, BWN_NTAB_C0_GAINCTL_R3, bwn_ntab_gainctl0_r3); ntab_upload(mac, BWN_NTAB_C1_GAINCTL_R3, bwn_ntab_gainctl1_r3); ntab_upload(mac, BWN_NTAB_C0_IQLT_R3, bwn_ntab_iqlt0_r3); ntab_upload(mac, BWN_NTAB_C1_IQLT_R3, bwn_ntab_iqlt1_r3); ntab_upload(mac, BWN_NTAB_C0_LOFEEDTH_R3, bwn_ntab_loftlt0_r3); ntab_upload(mac, BWN_NTAB_C1_LOFEEDTH_R3, bwn_ntab_loftlt1_r3); } static int bwn_nphy_tables_get_antswlut(struct bwn_mac *mac, uint8_t *antswlut) { struct ieee80211com *ic = &mac->mac_sc->sc_ic; struct bwn_softc *sc = mac->mac_sc; const char *antswlut_var; int error; if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) antswlut_var = BHND_NVAR_ANTSWCTL5G; else antswlut_var = BHND_NVAR_ANTSWCTL2G; error = bhnd_nvram_getvar_uint8(sc->sc_dev, antswlut_var, antswlut); if (error) BWN_ERRPRINTF(mac->mac_sc, "NVRAM variable %s unreadable: %d", antswlut_var, error); return (error); } static void bwn_nphy_tables_init_rev7_volatile(struct bwn_mac *mac) { int core, error, offset, i; uint8_t antswlut; const int antswlut0_offsets[] = { 0, 4, 8, }; /* Offsets for values */ const uint8_t antswlut0_values[][3] = { { 0x2, 0x12, 0x8 }, /* Core 0 */ { 0x2, 0x18, 0x2 }, /* Core 1 */ }; if ((error = bwn_nphy_tables_get_antswlut(mac, &antswlut))) return; switch (antswlut) { case 0: for (core = 0; core < 2; core++) { for (i = 0; i < nitems(antswlut0_values[0]); i++) { offset = core ? 0x20 : 0x00; offset += antswlut0_offsets[i]; bwn_ntab_write(mac, BWN_NTAB8(9, offset), antswlut0_values[core][i]); } } break; default: BWN_ERRPRINTF(mac->mac_sc, "Unsupported antswlut: %d\n", antswlut); break; } } static void bwn_nphy_tables_init_rev16(struct bwn_mac *mac) { /* Static tables */ if (mac->mac_phy.phy_do_full_init) { ntab_upload(mac, BWN_NTAB_NOISEVAR_R7, bwn_ntab_noisevar_r7); bwn_nphy_tables_init_shared_lut(mac); } /* Volatile tables */ bwn_nphy_tables_init_rev7_volatile(mac); } static void bwn_nphy_tables_init_rev7(struct bwn_mac *mac) { /* Static tables */ if (mac->mac_phy.phy_do_full_init) { ntab_upload(mac, BWN_NTAB_FRAMESTRUCT_R3, bwn_ntab_framestruct_r3); ntab_upload(mac, BWN_NTAB_PILOT_R3, bwn_ntab_pilot_r3); ntab_upload(mac, BWN_NTAB_TMAP_R7, bwn_ntab_tmap_r7); ntab_upload(mac, BWN_NTAB_INTLEVEL_R3, bwn_ntab_intlevel_r3); ntab_upload(mac, BWN_NTAB_TDTRN_R3, bwn_ntab_tdtrn_r3); ntab_upload(mac, BWN_NTAB_NOISEVAR_R7, bwn_ntab_noisevar_r7); ntab_upload(mac, BWN_NTAB_MCS_R3, bwn_ntab_mcs_r3); ntab_upload(mac, BWN_NTAB_TDI20A0_R3, bwn_ntab_tdi20a0_r3); ntab_upload(mac, BWN_NTAB_TDI20A1_R3, bwn_ntab_tdi20a1_r3); ntab_upload(mac, BWN_NTAB_TDI40A0_R3, bwn_ntab_tdi40a0_r3); ntab_upload(mac, BWN_NTAB_TDI40A1_R3, bwn_ntab_tdi40a1_r3); ntab_upload(mac, BWN_NTAB_PILOTLT_R3, bwn_ntab_pilotlt_r3); ntab_upload(mac, BWN_NTAB_CHANEST_R3, bwn_ntab_channelest_r3); ntab_upload(mac, BWN_NTAB_FRAMELT_R3, bwn_ntab_framelookup_r3); bwn_nphy_tables_init_shared_lut(mac); } /* Volatile tables */ bwn_nphy_tables_init_rev7_volatile(mac); } static void bwn_nphy_tables_init_rev3(struct bwn_mac *mac) { int error; uint8_t antswlut; if ((error = bwn_nphy_tables_get_antswlut(mac, &antswlut))) return; /* Static tables */ if (mac->mac_phy.phy_do_full_init) { ntab_upload(mac, BWN_NTAB_FRAMESTRUCT_R3, bwn_ntab_framestruct_r3); ntab_upload(mac, BWN_NTAB_PILOT_R3, bwn_ntab_pilot_r3); ntab_upload(mac, BWN_NTAB_TMAP_R3, bwn_ntab_tmap_r3); ntab_upload(mac, BWN_NTAB_INTLEVEL_R3, bwn_ntab_intlevel_r3); ntab_upload(mac, BWN_NTAB_TDTRN_R3, bwn_ntab_tdtrn_r3); ntab_upload(mac, BWN_NTAB_NOISEVAR_R3, bwn_ntab_noisevar_r3); ntab_upload(mac, BWN_NTAB_MCS_R3, bwn_ntab_mcs_r3); ntab_upload(mac, BWN_NTAB_TDI20A0_R3, bwn_ntab_tdi20a0_r3); ntab_upload(mac, BWN_NTAB_TDI20A1_R3, bwn_ntab_tdi20a1_r3); ntab_upload(mac, BWN_NTAB_TDI40A0_R3, bwn_ntab_tdi40a0_r3); ntab_upload(mac, BWN_NTAB_TDI40A1_R3, bwn_ntab_tdi40a1_r3); ntab_upload(mac, BWN_NTAB_PILOTLT_R3, bwn_ntab_pilotlt_r3); ntab_upload(mac, BWN_NTAB_CHANEST_R3, bwn_ntab_channelest_r3); ntab_upload(mac, BWN_NTAB_FRAMELT_R3, bwn_ntab_framelookup_r3); bwn_nphy_tables_init_shared_lut(mac); } /* Volatile tables */ if (antswlut < nitems(bwn_ntab_antswctl_r3)) ntab_upload(mac, BWN_NTAB_ANT_SW_CTL_R3, bwn_ntab_antswctl_r3[antswlut]); else KASSERT(0, ("%s: antswlut out of bounds (%d)\n", __func__, antswlut)); } static void bwn_nphy_tables_init_rev0(struct bwn_mac *mac) { /* Static tables */ if (mac->mac_phy.phy_do_full_init) { ntab_upload(mac, BWN_NTAB_FRAMESTRUCT, bwn_ntab_framestruct); ntab_upload(mac, BWN_NTAB_FRAMELT, bwn_ntab_framelookup); ntab_upload(mac, BWN_NTAB_TMAP, bwn_ntab_tmap); ntab_upload(mac, BWN_NTAB_TDTRN, bwn_ntab_tdtrn); ntab_upload(mac, BWN_NTAB_INTLEVEL, bwn_ntab_intlevel); ntab_upload(mac, BWN_NTAB_PILOT, bwn_ntab_pilot); ntab_upload(mac, BWN_NTAB_TDI20A0, bwn_ntab_tdi20a0); ntab_upload(mac, BWN_NTAB_TDI20A1, bwn_ntab_tdi20a1); ntab_upload(mac, BWN_NTAB_TDI40A0, bwn_ntab_tdi40a0); ntab_upload(mac, BWN_NTAB_TDI40A1, bwn_ntab_tdi40a1); ntab_upload(mac, BWN_NTAB_CHANEST, bwn_ntab_channelest); ntab_upload(mac, BWN_NTAB_MCS, bwn_ntab_mcs); ntab_upload(mac, BWN_NTAB_NOISEVAR10, bwn_ntab_noisevar10); ntab_upload(mac, BWN_NTAB_NOISEVAR11, bwn_ntab_noisevar11); } /* Volatile tables */ ntab_upload(mac, BWN_NTAB_BDI, bwn_ntab_bdi); ntab_upload(mac, BWN_NTAB_PILOTLT, bwn_ntab_pilotlt); ntab_upload(mac, BWN_NTAB_C0_GAINCTL, bwn_ntab_gainctl0); ntab_upload(mac, BWN_NTAB_C1_GAINCTL, bwn_ntab_gainctl1); ntab_upload(mac, BWN_NTAB_C0_ESTPLT, bwn_ntab_estimatepowerlt0); ntab_upload(mac, BWN_NTAB_C1_ESTPLT, bwn_ntab_estimatepowerlt1); ntab_upload(mac, BWN_NTAB_C0_ADJPLT, bwn_ntab_adjustpower0); ntab_upload(mac, BWN_NTAB_C1_ADJPLT, bwn_ntab_adjustpower1); ntab_upload(mac, BWN_NTAB_C0_IQLT, bwn_ntab_iqlt0); ntab_upload(mac, BWN_NTAB_C1_IQLT, bwn_ntab_iqlt1); ntab_upload(mac, BWN_NTAB_C0_LOFEEDTH, bwn_ntab_loftlt0); ntab_upload(mac, BWN_NTAB_C1_LOFEEDTH, bwn_ntab_loftlt1); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/InitTables */ void bwn_nphy_tables_init(struct bwn_mac *mac) { if (mac->mac_phy.rev >= 16) bwn_nphy_tables_init_rev16(mac); else if (mac->mac_phy.rev >= 7) bwn_nphy_tables_init_rev7(mac); else if (mac->mac_phy.rev >= 3) bwn_nphy_tables_init_rev3(mac); else bwn_nphy_tables_init_rev0(mac); } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */ static const uint32_t *bwn_nphy_get_ipa_gain_table(struct bwn_mac *mac) { struct bwn_softc *sc = mac->mac_sc; struct ieee80211com *ic = &mac->mac_sc->sc_ic; struct bwn_phy *phy = &mac->mac_phy; if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) { switch (phy->rev) { case 17: if (phy->rf_rev == 14) return bwn_ntab_tx_gain_ipa_2057_rev14_2g; break; case 16: if (phy->rf_rev == 9) return bwn_ntab_tx_gain_ipa_2057_rev9_2g; break; case 8: if (phy->rf_rev == 5) return bwn_ntab_tx_gain_ipa_2057_rev5_2g; break; case 6: if (sc->sc_cid.chip_id == BHND_CHIPID_BCM47162) return bwn_ntab_tx_gain_ipa_rev5_2g; return bwn_ntab_tx_gain_ipa_rev6_2g; case 5: return bwn_ntab_tx_gain_ipa_rev5_2g; case 4: case 3: return bwn_ntab_tx_gain_ipa_rev3_2g; } BWN_ERRPRINTF(mac->mac_sc, "No 2GHz IPA gain table available for this device\n"); return NULL; } else { switch (phy->rev) { case 16: if (phy->rf_rev == 9) return bwn_ntab_tx_gain_ipa_2057_rev9_5g; break; case 3 ... 6: return bwn_ntab_tx_gain_ipa_rev3_5g; } BWN_ERRPRINTF(mac->mac_sc, "No 5GHz IPA gain table available for this device\n"); return NULL; } } const uint32_t *bwn_nphy_get_tx_gain_table(struct bwn_mac *mac) { struct ieee80211com *ic = &mac->mac_sc->sc_ic; struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; int error, is_5ghz; uint8_t extpa_gain; /* XXX ideally we'd have is2, is5, etc */ is_5ghz = !! IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan); if (mac->mac_phy.rev < 3) return bwn_ntab_tx_gain_rev0_1_2; /* rev 3+ */ if ((mac->mac_phy.phy_n->ipa2g_on && is_5ghz == 0) || (mac->mac_phy.phy_n->ipa5g_on && is_5ghz == 1)) { return bwn_nphy_get_ipa_gain_table(mac); } else if (is_5ghz == 1) { switch (phy->rev) { case 6: case 5: return bwn_ntab_tx_gain_epa_rev5_5g; case 4: error = bhnd_nvram_getvar_uint8(sc->sc_dev, BHND_NVAR_EXTPAGAIN5G, &extpa_gain); if (error) { BWN_ERRPRINTF(mac->mac_sc, "Error reading EPA " "gain configuration (%s) from NVRAM: %d\n", BHND_NVAR_EXTPAGAIN5G, error); return (NULL); } return (extpa_gain == 3) ? bwn_ntab_tx_gain_epa_rev4_5g : bwn_ntab_tx_gain_epa_rev4_hi_pwr_5g; case 3: return bwn_ntab_tx_gain_epa_rev3_5g; default: BWN_ERRPRINTF(mac->mac_sc, "No 5GHz EPA gain table available for this device\n"); return NULL; } } else { switch (phy->rev) { case 6: case 5: error = bhnd_nvram_getvar_uint8(sc->sc_dev, BHND_NVAR_EXTPAGAIN2G, &extpa_gain); if (error) { BWN_ERRPRINTF(mac->mac_sc, "Error reading EPA " "gain configuration (%s) from NVRAM: %d\n", BHND_NVAR_EXTPAGAIN2G, error); return (NULL); } if (extpa_gain == 3) return bwn_ntab_tx_gain_epa_rev3_hi_pwr_2g; /* fall through */ case 4: case 3: return bwn_ntab_tx_gain_epa_rev3_2g; default: BWN_ERRPRINTF(mac->mac_sc, "No 2GHz EPA gain table available for this device\n"); return NULL; } } } const int16_t *bwn_ntab_get_rf_pwr_offset_table(struct bwn_mac *mac) { struct ieee80211com *ic = &mac->mac_sc->sc_ic; struct bwn_phy *phy = &mac->mac_phy; if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) { switch (phy->rev) { case 17: if (phy->rf_rev == 14) return bwn_ntab_rf_pwr_offset_2057_rev14_2g; break; case 16: if (phy->rf_rev == 9) return bwn_ntab_rf_pwr_offset_2057_rev9_2g; break; } BWN_ERRPRINTF(mac->mac_sc, "No 2GHz RF power table available for this device\n"); return NULL; } else { switch (phy->rev) { case 16: if (phy->rf_rev == 9) return bwn_ntab_rf_pwr_offset_2057_rev9_5g; break; } BWN_ERRPRINTF(mac->mac_sc, "No 5GHz RF power table available for this device\n"); return NULL; } } struct bwn_nphy_gain_ctl_workaround_entry *bwn_nphy_get_gain_ctl_workaround_ent( struct bwn_mac *mac, bool ghz5, bool ext_lna) { struct ieee80211com *ic = &mac->mac_sc->sc_ic; struct bwn_softc *sc = mac->mac_sc; struct bwn_phy *phy = &mac->mac_phy; struct bwn_nphy_gain_ctl_workaround_entry *e; uint8_t phy_idx; if (!ghz5 && mac->mac_phy.rev >= 6 && mac->mac_phy.rf_rev == 11) return &nphy_gain_ctl_wa_phy6_radio11_ghz2; KASSERT(mac->mac_phy.rev >= 3, ("%s: called; too early phy rev (%d)\n", __func__, mac->mac_phy.rev)); if (mac->mac_phy.rev >= 6) phy_idx = 3; else if (mac->mac_phy.rev == 5) phy_idx = 2; else if (mac->mac_phy.rev == 4) phy_idx = 1; else phy_idx = 0; e = &nphy_gain_ctl_workaround[ghz5][phy_idx]; /* Some workarounds to the workarounds... */ if (!ghz5) { uint8_t tr_iso; int error; error = bhnd_nvram_getvar_uint8(sc->sc_dev, BHND_NVAR_TRISO2G, &tr_iso); BWN_ERRPRINTF(mac->mac_sc, "Error reading %s from NVRAM: %d\n", BHND_NVAR_TRISO2G, error); if (tr_iso > 7) tr_iso = 3; if (phy->rev >= 6) { static const int gain_data[] = { 0x106a, 0x106c, 0x1074, 0x107c, 0x007e, 0x107e, 0x207e, 0x307e, }; e->cliplo_gain = gain_data[tr_iso]; } else if (phy->rev == 5) { static const int gain_data[] = { 0x0062, 0x0064, 0x006a, 0x106a, 0x106c, 0x1074, 0x107c, 0x207c, }; e->cliplo_gain = gain_data[tr_iso]; } if (phy->rev >= 5 && ext_lna) { e->rfseq_init[0] &= ~0x4000; e->rfseq_init[1] &= ~0x4000; e->rfseq_init[2] &= ~0x4000; e->rfseq_init[3] &= ~0x4000; e->init_gain &= ~0x4000; } } else { if (phy->rev >= 6) { /* XXX 40MHz HT only? No static-40MHz? */ if (phy->rf_rev == 11 && IEEE80211_IS_CHAN_HT40(ic->ic_curchan)) e->crsminu = 0x2d; } else if (phy->rev == 4 && ext_lna) { e->rfseq_init[0] &= ~0x4000; e->rfseq_init[1] &= ~0x4000; e->rfseq_init[2] &= ~0x4000; e->rfseq_init[3] &= ~0x4000; e->init_gain &= ~0x4000; e->rfseq_init[0] |= 0x1000; e->rfseq_init[1] |= 0x1000; e->rfseq_init[2] |= 0x1000; e->rfseq_init[3] |= 0x1000; e->init_gain |= 0x1000; } } return e; } const struct bwn_nphy_rf_control_override_rev7 * bwn_nphy_get_rf_ctl_over_rev7(struct bwn_mac *mac, uint16_t field, uint8_t override) { const struct bwn_nphy_rf_control_override_rev7 *e; uint8_t size, i; switch (override) { case 0: e = tbl_rf_control_override_rev7_over0; size = nitems(tbl_rf_control_override_rev7_over0); break; case 1: e = tbl_rf_control_override_rev7_over1; size = nitems(tbl_rf_control_override_rev7_over1); break; case 2: e = tbl_rf_control_override_rev7_over2; size = nitems(tbl_rf_control_override_rev7_over2); break; default: BWN_ERRPRINTF(mac->mac_sc, "Invalid override value %d\n", override); return NULL; } for (i = 0; i < size; i++) { if (e[i].field == field) return &e[i]; } return NULL; }