static void mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped) { struct ieee80211_channel *chan = dev->mt76.chandef.chan; bool is_5ghz = chan->band == NL80211_BAND_5GHZ; if (dev->cal.channel_cal_done) return; if (mt76x2_channel_silent(dev)) return; if (!dev->cal.tssi_cal_done) mt76x2_phy_tssi_init_cal(dev); if (!mac_stopped) mt76x2_mac_stop(dev, false); if (is_5ghz) mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0); mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz); mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz); mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz); mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0); mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0); if (!mac_stopped) mt76x2_mac_resume(dev); mt76x2_apply_gain_adj(dev); dev->cal.channel_cal_done = true; }
static void mt76x2u_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *info, u32 changed) { struct mt76x02_dev *dev = hw->priv; mutex_lock(&dev->mt76.mutex); if (changed & BSS_CHANGED_ASSOC) { mt76x2u_phy_channel_calibrate(dev); mt76x2_apply_gain_adj(dev); } if (changed & BSS_CHANGED_BSSID) { mt76_wr(dev, MT_MAC_BSSID_DW0, get_unaligned_le32(info->bssid)); mt76_wr(dev, MT_MAC_BSSID_DW1, get_unaligned_le16(info->bssid + 4)); } mutex_unlock(&dev->mt76.mutex); }