diff --git a/mt7603.h b/mt7603.h index 2e644748..a33ae961 100644 --- a/mt7603.h +++ b/mt7603.h @@ -74,6 +74,8 @@ struct mt7603_dev { u8 rx_chains; u8 tx_chains; + u8 rssi_offset[3]; + struct mt7603_mcu mcu; struct mt76_queue q_rx; struct mt76_queue q_tx[__MT_TXQ_MAX]; diff --git a/mt7603_core.c b/mt7603_core.c index b45c4098..bec23644 100644 --- a/mt7603_core.c +++ b/mt7603_core.c @@ -12,6 +12,7 @@ */ #include "mt7603.h" +#include "mt7603_eeprom.h" void mt7603_set_irq_mask(struct mt7603_dev *dev, u32 clear, u32 set) { @@ -76,6 +77,7 @@ u32 mt7603_reg_map(struct mt7603_dev *dev, u32 addr) int mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def) { + u8 *rssi_data = (u8 *) dev->mt76.eeprom.data; int idx, ret; u8 bw = MT_BW_20; @@ -88,7 +90,16 @@ int mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def) if (ret) return ret; - idx = def->chan->band == IEEE80211_BAND_5GHZ; + if (def->chan->band == IEEE80211_BAND_5GHZ) { + idx = 1; + rssi_data += MT_EE_RSSI_OFFSET_5G; + } else { + idx = 0; + rssi_data += MT_EE_RSSI_OFFSET_2G; + } + + memcpy(dev->rssi_offset, rssi_data, sizeof(dev->rssi_offset)); + idx |= (def->chan - mt76_hw(dev)->wiphy->bands[def->chan->band]->channels) << 1; mt76_set(dev, MT_WF_RMAC_CH_FREQ, idx); mt7603_mac_start(dev); diff --git a/mt7603_eeprom.h b/mt7603_eeprom.h index 3c33e2a8..ae46eb12 100644 --- a/mt7603_eeprom.h +++ b/mt7603_eeprom.h @@ -26,7 +26,9 @@ enum mt7603_eeprom_field { MT_EE_XTAL_TRIM_1 = 0x03a, + MT_EE_RSSI_OFFSET_2G = 0x046, MT_EE_WIFI_RF_SETTING = 0x048, + MT_EE_RSSI_OFFSET_5G = 0x04a, MT_EE_TX_POWER_DELTA_BW40 = 0x050, MT_EE_TX_POWER_DELTA_BW80 = 0x052, diff --git a/mt7603_mac.c b/mt7603_mac.c index e9835325..93f0ebbe 100644 --- a/mt7603_mac.c +++ b/mt7603_mac.c @@ -215,8 +215,15 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb) MT76_GET(MT_RXV1_HT_STBC, rxd[0]); status->rate_idx = i; - rxd += 6; + status->chains = BIT(0) | BIT(1); + status->chain_signal[0] = MT76_GET(MT_RXV4_IB_RSSI0, rxd[3]) + + dev->rssi_offset[0]; + status->chain_signal[1] = MT76_GET(MT_RXV4_IB_RSSI1, rxd[3]) + + dev->rssi_offset[1]; + status->signal = max(status->chain_signal[0], status->chain_signal[1]); + + rxd += 6; if ((u8 *) rxd - skb->data >= skb->len) return -EINVAL; }