mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-12 18:35:35 -04:00
wifi: mt76: mt7915: set correct background radar capability
Some of the variants do not support background radar, so add a helper to report background radar capability. For mt7916, only the variant of 5G 2T2R + 1R supports background radar. Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> Reviewed-by: Shayne Chen <shayne.chen@mediatek.com> Link: https://patch.msgid.link/20250320015909.3948612-1-StanleyYP.Wang@mediatek.com Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
committed by
Felix Fietkau
parent
8d63161d2e
commit
888208d1cc
@@ -445,6 +445,11 @@ mt7915_rdd_monitor(struct seq_file *s, void *data)
|
||||
|
||||
mutex_lock(&dev->mt76.mutex);
|
||||
|
||||
if (!mt7915_eeprom_has_background_radar(dev)) {
|
||||
seq_puts(s, "no background radar capability\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!cfg80211_chandef_valid(chandef)) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
|
||||
@@ -147,7 +147,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev)
|
||||
/* read eeprom data from efuse */
|
||||
block_num = DIV_ROUND_UP(eeprom_size, eeprom_blk_size);
|
||||
for (i = 0; i < block_num; i++) {
|
||||
ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size);
|
||||
ret = mt7915_mcu_get_eeprom(dev, i * eeprom_blk_size, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
@@ -361,6 +361,37 @@ s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band)
|
||||
return val & MT_EE_RATE_DELTA_SIGN ? delta : -delta;
|
||||
}
|
||||
|
||||
bool
|
||||
mt7915_eeprom_has_background_radar(struct mt7915_dev *dev)
|
||||
{
|
||||
u8 val, buf[MT7915_EEPROM_BLOCK_SIZE];
|
||||
u8 band_sel, tx_path, rx_path;
|
||||
int offs = MT_EE_WIFI_CONF + 1;
|
||||
|
||||
switch (mt76_chip(&dev->mt76)) {
|
||||
case 0x7915:
|
||||
return true;
|
||||
case 0x7906:
|
||||
/* read efuse to check background radar capability */
|
||||
if (mt7915_mcu_get_eeprom(dev, offs, buf))
|
||||
break;
|
||||
|
||||
val = buf[offs % MT7915_EEPROM_BLOCK_SIZE];
|
||||
band_sel = u8_get_bits(val, MT_EE_WIFI_CONF0_BAND_SEL);
|
||||
tx_path = u8_get_bits(val, MT_EE_WIFI_CONF0_TX_PATH);
|
||||
rx_path = u8_get_bits(val, MT_EE_WIFI_CONF0_RX_PATH);
|
||||
|
||||
return (band_sel == MT_EE_V2_BAND_SEL_5GHZ &&
|
||||
tx_path == rx_path && rx_path == 2);
|
||||
case 0x7981:
|
||||
case 0x7986:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const u8 mt7915_sku_group_len[] = {
|
||||
[SKU_CCK] = 4,
|
||||
[SKU_OFDM] = 8,
|
||||
|
||||
@@ -55,6 +55,7 @@ enum mt7915_eeprom_field {
|
||||
#define MT_EE_CAL_DPD_SIZE_V2_7981 (102 * MT_EE_CAL_UNIT) /* no 6g dpd data */
|
||||
|
||||
#define MT_EE_WIFI_CONF0_TX_PATH GENMASK(2, 0)
|
||||
#define MT_EE_WIFI_CONF0_RX_PATH GENMASK(5, 3)
|
||||
#define MT_EE_WIFI_CONF0_BAND_SEL GENMASK(7, 6)
|
||||
#define MT_EE_WIFI_CONF1_BAND_SEL GENMASK(7, 6)
|
||||
#define MT_EE_WIFI_CONF_STREAM_NUM GENMASK(7, 5)
|
||||
|
||||
@@ -392,9 +392,10 @@ mt7915_init_wiphy(struct mt7915_phy *phy)
|
||||
if (!is_mt7915(&dev->mt76))
|
||||
wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_STA_TX_PWR);
|
||||
|
||||
if (!mdev->dev->of_node ||
|
||||
!of_property_read_bool(mdev->dev->of_node,
|
||||
"mediatek,disable-radar-background"))
|
||||
if (mt7915_eeprom_has_background_radar(phy->dev) &&
|
||||
(!mdev->dev->of_node ||
|
||||
!of_property_read_bool(mdev->dev->of_node,
|
||||
"mediatek,disable-radar-background")))
|
||||
wiphy_ext_feature_set(wiphy,
|
||||
NL80211_EXT_FEATURE_RADAR_BACKGROUND);
|
||||
|
||||
|
||||
@@ -2859,7 +2859,7 @@ int mt7915_mcu_set_eeprom(struct mt7915_dev *dev)
|
||||
&req, sizeof(req), true);
|
||||
}
|
||||
|
||||
int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
|
||||
int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf)
|
||||
{
|
||||
struct mt7915_mcu_eeprom_info req = {
|
||||
.addr = cpu_to_le32(round_down(offset,
|
||||
@@ -2867,8 +2867,8 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
|
||||
};
|
||||
struct mt7915_mcu_eeprom_info *res;
|
||||
struct sk_buff *skb;
|
||||
u8 *buf = read_buf;
|
||||
int ret;
|
||||
u8 *buf;
|
||||
|
||||
ret = mt76_mcu_send_and_get_msg(&dev->mt76,
|
||||
MCU_EXT_QUERY(EFUSE_ACCESS),
|
||||
@@ -2877,8 +2877,10 @@ int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset)
|
||||
return ret;
|
||||
|
||||
res = (struct mt7915_mcu_eeprom_info *)skb->data;
|
||||
buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
|
||||
if (!buf)
|
||||
buf = dev->mt76.eeprom.data + le32_to_cpu(res->addr);
|
||||
memcpy(buf, res->data, MT7915_EEPROM_BLOCK_SIZE);
|
||||
|
||||
dev_kfree_skb(skb);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -425,6 +425,7 @@ int mt7915_eeprom_get_target_power(struct mt7915_dev *dev,
|
||||
struct ieee80211_channel *chan,
|
||||
u8 chain_idx);
|
||||
s8 mt7915_eeprom_get_power_delta(struct mt7915_dev *dev, int band);
|
||||
bool mt7915_eeprom_has_background_radar(struct mt7915_dev *dev);
|
||||
int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2);
|
||||
void mt7915_dma_prefetch(struct mt7915_dev *dev);
|
||||
void mt7915_dma_cleanup(struct mt7915_dev *dev);
|
||||
@@ -473,7 +474,7 @@ int mt7915_mcu_set_fixed_rate_ctrl(struct mt7915_dev *dev,
|
||||
struct ieee80211_sta *sta,
|
||||
void *data, u32 field);
|
||||
int mt7915_mcu_set_eeprom(struct mt7915_dev *dev);
|
||||
int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset);
|
||||
int mt7915_mcu_get_eeprom(struct mt7915_dev *dev, u32 offset, u8 *read_buf);
|
||||
int mt7915_mcu_get_eeprom_free_block(struct mt7915_dev *dev, u8 *block_num);
|
||||
int mt7915_mcu_set_mac(struct mt7915_dev *dev, int band, bool enable,
|
||||
bool hdr_trans);
|
||||
|
||||
Reference in New Issue
Block a user