Lines Matching refs:dev

13 mt76x2_phy_tssi_init_cal(struct mt76x02_dev *dev)  in mt76x2_phy_tssi_init_cal()  argument
15 struct ieee80211_channel *chan = dev->mphy.chandef.chan; in mt76x2_phy_tssi_init_cal()
18 if (!mt76x2_tssi_enabled(dev)) in mt76x2_phy_tssi_init_cal()
21 if (mt76x2_channel_silent(dev)) in mt76x2_phy_tssi_init_cal()
27 if (mt76x02_ext_pa_enabled(dev, chan->band)) in mt76x2_phy_tssi_init_cal()
30 mt76x02_mcu_calibrate(dev, MCU_CAL_TSSI, flag); in mt76x2_phy_tssi_init_cal()
31 dev->cal.tssi_cal_done = true; in mt76x2_phy_tssi_init_cal()
36 mt76x2_phy_channel_calibrate(struct mt76x02_dev *dev, bool mac_stopped) in mt76x2_phy_channel_calibrate() argument
38 struct ieee80211_channel *chan = dev->mphy.chandef.chan; in mt76x2_phy_channel_calibrate()
41 if (dev->cal.channel_cal_done) in mt76x2_phy_channel_calibrate()
44 if (mt76x2_channel_silent(dev)) in mt76x2_phy_channel_calibrate()
47 if (!dev->cal.tssi_cal_done) in mt76x2_phy_channel_calibrate()
48 mt76x2_phy_tssi_init_cal(dev); in mt76x2_phy_channel_calibrate()
51 mt76x2_mac_stop(dev, false); in mt76x2_phy_channel_calibrate()
54 mt76x02_mcu_calibrate(dev, MCU_CAL_LC, 0); in mt76x2_phy_channel_calibrate()
56 mt76x02_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz); in mt76x2_phy_channel_calibrate()
57 mt76x02_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz); in mt76x2_phy_channel_calibrate()
58 mt76x02_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz); in mt76x2_phy_channel_calibrate()
59 mt76x02_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0); in mt76x2_phy_channel_calibrate()
60 mt76x02_mcu_calibrate(dev, MCU_CAL_TX_SHAPING, 0); in mt76x2_phy_channel_calibrate()
63 mt76x2_mac_resume(dev); in mt76x2_phy_channel_calibrate()
65 mt76x2_apply_gain_adj(dev); in mt76x2_phy_channel_calibrate()
66 mt76x02_edcca_init(dev); in mt76x2_phy_channel_calibrate()
68 dev->cal.channel_cal_done = true; in mt76x2_phy_channel_calibrate()
71 void mt76x2_phy_set_antenna(struct mt76x02_dev *dev) in mt76x2_phy_set_antenna() argument
75 val = mt76_rr(dev, MT_BBP(AGC, 0)); in mt76x2_phy_set_antenna()
77 switch (dev->mphy.antenna_mask) { in mt76x2_phy_set_antenna()
80 mt76_clear(dev, MT_BBP(IBI, 9), BIT(11)); in mt76x2_phy_set_antenna()
81 mt76_clear(dev, MT_BBP(TXBE, 5), 3); in mt76x2_phy_set_antenna()
82 mt76_rmw_field(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_TXANT, 0x3); in mt76x2_phy_set_antenna()
83 mt76_rmw_field(dev, MT_BBP(CORE, 32), GENMASK(21, 20), 2); in mt76x2_phy_set_antenna()
85 mt76_rmw_field(dev, MT_BBP(CORE, 33), GENMASK(12, 9), 4); in mt76x2_phy_set_antenna()
91 mt76_clear(dev, MT_BBP(IBI, 9), BIT(11)); in mt76x2_phy_set_antenna()
92 mt76_rmw_field(dev, MT_BBP(TXBE, 5), 3, 1); in mt76x2_phy_set_antenna()
93 mt76_rmw_field(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_TXANT, 0xc); in mt76x2_phy_set_antenna()
94 mt76_rmw_field(dev, MT_BBP(CORE, 32), GENMASK(21, 20), 1); in mt76x2_phy_set_antenna()
96 mt76_rmw_field(dev, MT_BBP(CORE, 33), GENMASK(12, 9), 1); in mt76x2_phy_set_antenna()
104 mt76_set(dev, MT_BBP(IBI, 9), BIT(11)); in mt76x2_phy_set_antenna()
105 mt76_set(dev, MT_BBP(TXBE, 5), 3); in mt76x2_phy_set_antenna()
106 mt76_rmw_field(dev, MT_TX_PIN_CFG, MT_TX_PIN_CFG_TXANT, 0xf); in mt76x2_phy_set_antenna()
107 mt76_clear(dev, MT_BBP(CORE, 32), GENMASK(21, 20)); in mt76x2_phy_set_antenna()
108 mt76_clear(dev, MT_BBP(CORE, 33), GENMASK(12, 9)); in mt76x2_phy_set_antenna()
114 mt76_wr(dev, MT_BBP(AGC, 0), val); in mt76x2_phy_set_antenna()
117 int mt76x2_phy_set_channel(struct mt76x02_dev *dev, in mt76x2_phy_set_channel() argument
121 bool scan = test_bit(MT76_SCANNING, &dev->mphy.state); in mt76x2_phy_set_channel()
152 dev->cal.channel_cal_done = false; in mt76x2_phy_set_channel()
184 mt76x2_read_rx_gain(dev); in mt76x2_phy_set_channel()
185 mt76x2_phy_set_txpower_regs(dev, band); in mt76x2_phy_set_channel()
186 mt76x2_configure_tx_delay(dev, band, bw); in mt76x2_phy_set_channel()
187 mt76x2_phy_set_txpower(dev); in mt76x2_phy_set_channel()
189 mt76x02_phy_set_band(dev, chan->band, ch_group_index & 1); in mt76x2_phy_set_channel()
190 mt76x02_phy_set_bw(dev, chandef->width, ch_group_index); in mt76x2_phy_set_channel()
192 mt76_rmw(dev, MT_EXT_CCA_CFG, in mt76x2_phy_set_channel()
200 ret = mt76x2_mcu_set_channel(dev, channel, bw, bw_index, scan); in mt76x2_phy_set_channel()
204 mt76x2_mcu_init_gain(dev, channel, dev->cal.rx.mcu_gain, true); in mt76x2_phy_set_channel()
206 mt76x2_phy_set_antenna(dev); in mt76x2_phy_set_channel()
209 if (mt76xx_rev(dev) >= MT76XX_REV_E3) in mt76x2_phy_set_channel()
210 mt76_set(dev, MT_BBP(RXO, 13), BIT(10)); in mt76x2_phy_set_channel()
212 if (!dev->cal.init_cal_done) { in mt76x2_phy_set_channel()
213 u8 val = mt76x02_eeprom_get(dev, MT_EE_BT_RCAL_RESULT); in mt76x2_phy_set_channel()
216 mt76x02_mcu_calibrate(dev, MCU_CAL_R, 0); in mt76x2_phy_set_channel()
219 mt76x02_mcu_calibrate(dev, MCU_CAL_RXDCOC, channel); in mt76x2_phy_set_channel()
222 if (!dev->cal.init_cal_done) in mt76x2_phy_set_channel()
223 mt76x02_mcu_calibrate(dev, MCU_CAL_RC, 0); in mt76x2_phy_set_channel()
225 dev->cal.init_cal_done = true; in mt76x2_phy_set_channel()
227 mt76_wr(dev, MT_BBP(AGC, 61), 0xFF64A4E2); in mt76x2_phy_set_channel()
228 mt76_wr(dev, MT_BBP(AGC, 7), 0x08081010); in mt76x2_phy_set_channel()
229 mt76_wr(dev, MT_BBP(AGC, 11), 0x00000404); in mt76x2_phy_set_channel()
230 mt76_wr(dev, MT_BBP(AGC, 2), 0x00007070); in mt76x2_phy_set_channel()
231 mt76_wr(dev, MT_TXOP_CTRL_CFG, 0x04101B3F); in mt76x2_phy_set_channel()
236 mt76x2_phy_channel_calibrate(dev, true); in mt76x2_phy_set_channel()
237 mt76x02_init_agc_gain(dev); in mt76x2_phy_set_channel()
240 if (mt76x2_tssi_enabled(dev)) { in mt76x2_phy_set_channel()
241 mt76_rmw_field(dev, MT_TX_ALC_CFG_1, MT_TX_ALC_CFG_1_TEMP_COMP, in mt76x2_phy_set_channel()
243 mt76_rmw_field(dev, MT_TX_ALC_CFG_2, MT_TX_ALC_CFG_2_TEMP_COMP, in mt76x2_phy_set_channel()
247 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work, in mt76x2_phy_set_channel()
254 mt76x2_phy_temp_compensate(struct mt76x02_dev *dev) in mt76x2_phy_temp_compensate() argument
259 if (mt76x2_get_temp_comp(dev, &t)) in mt76x2_phy_temp_compensate()
262 temp = mt76_get_field(dev, MT_TEMP_SENSOR, MT_TEMP_SENSOR_VAL); in mt76x2_phy_temp_compensate()
265 dev->cal.temp = temp; in mt76x2_phy_temp_compensate()
275 mt76_rmw_field(dev, MT_TX_ALC_CFG_1, MT_TX_ALC_CFG_1_TEMP_COMP, in mt76x2_phy_temp_compensate()
277 mt76_rmw_field(dev, MT_TX_ALC_CFG_2, MT_TX_ALC_CFG_2_TEMP_COMP, in mt76x2_phy_temp_compensate()
283 struct mt76x02_dev *dev; in mt76x2_phy_calibrate() local
285 dev = container_of(work, struct mt76x02_dev, cal_work.work); in mt76x2_phy_calibrate()
287 mutex_lock(&dev->mt76.mutex); in mt76x2_phy_calibrate()
289 mt76x2_phy_channel_calibrate(dev, false); in mt76x2_phy_calibrate()
290 mt76x2_phy_tssi_compensate(dev); in mt76x2_phy_calibrate()
291 mt76x2_phy_temp_compensate(dev); in mt76x2_phy_calibrate()
292 mt76x2_phy_update_channel_gain(dev); in mt76x2_phy_calibrate()
294 mutex_unlock(&dev->mt76.mutex); in mt76x2_phy_calibrate()
296 ieee80211_queue_delayed_work(mt76_hw(dev), &dev->cal_work, in mt76x2_phy_calibrate()
300 int mt76x2_phy_start(struct mt76x02_dev *dev) in mt76x2_phy_start() argument
304 ret = mt76x02_mcu_set_radio_state(dev, true); in mt76x2_phy_start()
308 mt76x2_mcu_load_cr(dev, MT_RF_BBP_CR, 0, 0); in mt76x2_phy_start()