Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1b8ee35 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Felix Fietkau
Browse files

mt76x02: run calibration after scanning



If we are associated and scanning is performed, sw_scan_complete callback
is done after we get back to operating channel, so we do not perform
queue cal work. Fix this queue cal work from sw_scan_complete().

On mt76x0 we have to restore gain in MT_BBP(AGC, 8) register after
scanning, as it was multiple times modified by channel switch code.
So queue cal work without any delay to set AGC gain value.

Similar like in mt76x2 init AGC gain only when set operating channel
and just check before queuing cal work in sw_scan_complete() if
initialization was already done.

Fixes: bbd10586 ("mt76x0: phy: do not run calibration during channel switch")
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent c6950536
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1004,13 +1004,13 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev,


	mt76x0_read_rx_gain(dev);
	mt76x0_read_rx_gain(dev);
	mt76x0_phy_set_chan_bbp_params(dev, rf_bw_band);
	mt76x0_phy_set_chan_bbp_params(dev, rf_bw_band);
	mt76x02_init_agc_gain(dev);


	/* enable vco */
	/* enable vco */
	mt76x0_rf_set(dev, MT_RF(0, 4), BIT(7));
	mt76x0_rf_set(dev, MT_RF(0, 4), BIT(7));
	if (scan)
	if (scan)
		return 0;
		return 0;


	mt76x02_init_agc_gain(dev);
	mt76x0_phy_calibrate(dev, false);
	mt76x0_phy_calibrate(dev, false);
	mt76x0_phy_set_txpower(dev);
	mt76x0_phy_set_txpower(dev);


+1 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ struct mt76x02_calibration {
	bool tssi_comp_pending;
	bool tssi_comp_pending;
	bool dpd_cal_done;
	bool dpd_cal_done;
	bool channel_cal_done;
	bool channel_cal_done;
	bool gain_init_done;


	int tssi_target;
	int tssi_target;
	s8 tssi_dc;
	s8 tssi_dc;
+1 −0
Original line number Original line Diff line number Diff line
@@ -254,5 +254,6 @@ void mt76x02_init_agc_gain(struct mt76x02_dev *dev)
	memcpy(dev->cal.agc_gain_cur, dev->cal.agc_gain_init,
	memcpy(dev->cal.agc_gain_cur, dev->cal.agc_gain_init,
	       sizeof(dev->cal.agc_gain_cur));
	       sizeof(dev->cal.agc_gain_cur));
	dev->cal.low_gain = -1;
	dev->cal.low_gain = -1;
	dev->cal.gain_init_done = true;
}
}
EXPORT_SYMBOL_GPL(mt76x02_init_agc_gain);
EXPORT_SYMBOL_GPL(mt76x02_init_agc_gain);
+3 −0
Original line number Original line Diff line number Diff line
@@ -554,6 +554,9 @@ void mt76x02_sw_scan_complete(struct ieee80211_hw *hw,
	clear_bit(MT76_SCANNING, &dev->mt76.state);
	clear_bit(MT76_SCANNING, &dev->mt76.state);
	if (mt76_is_mmio(dev))
	if (mt76_is_mmio(dev))
		tasklet_enable(&dev->pre_tbtt_tasklet);
		tasklet_enable(&dev->pre_tbtt_tasklet);

	if (dev->cal.gain_init_done)
		ieee80211_queue_delayed_work(hw, &dev->cal_work, 0);
}
}
EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);
EXPORT_SYMBOL_GPL(mt76x02_sw_scan_complete);