Exemplo n.º 1
0
void mt76_stop_hardware(struct mt76_dev *dev)
{
	cancel_delayed_work_sync(&dev->cal_work);
	cancel_delayed_work_sync(&dev->mac_work);
	mt76_mcu_set_radio_state(dev, false);
	mt76_mac_stop(dev, false);
}
Exemplo n.º 2
0
Arquivo: phy.c Projeto: jhbsz/mt76
static void
mt76_phy_channel_calibrate(struct mt76_dev *dev, bool mac_stopped)
{
	struct ieee80211_channel *chan = dev->chandef.chan;
	bool is_5ghz = chan->band == IEEE80211_BAND_5GHZ;

	if (dev->cal.channel_cal_done)
		return;

	if (mt76_channel_silent(dev))
		return;

	if (!dev->cal.tssi_cal_done)
		mt76_phy_tssi_init_cal(dev);

	if (!mac_stopped)
		mt76_mac_stop(dev, false);

	if (is_5ghz)
		mt76_mcu_calibrate(dev, MCU_CAL_LC, 0);

	mt76_mcu_calibrate(dev, MCU_CAL_TX_LOFT, is_5ghz);
	mt76_mcu_calibrate(dev, MCU_CAL_TXIQ, is_5ghz);
	mt76_mcu_calibrate(dev, MCU_CAL_RXIQC_FI, is_5ghz);
	mt76_mcu_calibrate(dev, MCU_CAL_TEMP_SENSOR, 0);

	if (!mac_stopped)
		mt76_mac_resume(dev);

	mt76_apply_gain_adj(dev);

	dev->cal.channel_cal_done = true;
}
Exemplo n.º 3
0
int mt76_init_hardware(struct mt76_dev *dev)
{
	static const u16 beacon_offsets[16] = {
		/* 1024 byte per beacon */
		0xc000,
		0xc400,
		0xc800,
		0xcc00,
		0xd000,
		0xd400,
		0xd800,
		0xdc00,

		/* BSS idx 8-15 not used for beacons */
		0xc000,
		0xc000,
		0xc000,
		0xc000,
		0xc000,
		0xc000,
		0xc000,
		0xc000,
	};
	u32 val;
	int ret;

	dev->beacon_offsets = beacon_offsets;
	tasklet_init(&dev->pre_tbtt_tasklet, mt76_pre_tbtt_tasklet,
		     (unsigned long) dev);

	dev->chainmask = 0x202;

	val = mt76_rr(dev, MT_WPDMA_GLO_CFG);
	val &= MT_WPDMA_GLO_CFG_DMA_BURST_SIZE |
	       MT_WPDMA_GLO_CFG_BIG_ENDIAN |
	       MT_WPDMA_GLO_CFG_HDR_SEG_LEN;
	val |= MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE;
	mt76_wr(dev, MT_WPDMA_GLO_CFG, val);

	mt76_reset_wlan(dev, true);
	mt76_power_on(dev);

	ret = mt76_eeprom_init(dev);
	if (ret)
		return ret;

	ret = mt76_mac_reset(dev, true);
	if (ret)
		return ret;

	ret = mt76_dma_init(dev);
	if (ret)
		return ret;

	set_bit(MT76_STATE_INITIALIZED, &dev->state);
	ret = mt76_mac_start(dev);
	if (ret)
		return ret;

	ret = mt76_mcu_init(dev);
	if (ret)
		return ret;

	mt76_mac_stop(dev, false);
	dev->rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);

	return 0;
}