From 97e65131440ccae916e76323251b80cafdfc9006 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 25 Aug 2020 07:03:37 +0200 Subject: [PATCH] mt76: mt7603: check for single-stream EEPROM configuration Some devices using MT7628 or MT7603 have only one antenna chain connected. Detect these using the EEPROM rx/tx path settings Reported-by: Qin Wei Signed-off-by: Felix Fietkau --- mt7603/eeprom.h | 3 +++ mt7603/init.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mt7603/eeprom.h b/mt7603/eeprom.h index b893facf..4687d6dc 100644 --- a/mt7603/eeprom.h +++ b/mt7603/eeprom.h @@ -85,4 +85,7 @@ enum mt7603_eeprom_source { MT_EE_SRC_FLASH, }; +#define MT_EE_NIC_CONF_0_RX_PATH GENMASK(3, 0) +#define MT_EE_NIC_CONF_0_TX_PATH GENMASK(7, 4) + #endif diff --git a/mt7603/init.c b/mt7603/init.c index 94196599..43dbabcc 100644 --- a/mt7603/init.c +++ b/mt7603/init.c @@ -510,11 +510,17 @@ mt7603_init_txpower(struct mt7603_dev *dev, } } +static inline bool is_mt7688(struct mt7603_dev *dev) +{ + return mt76_rr(dev, MT_EFUSE_BASE + 0x64) & BIT(4); +} + int mt7603_register_device(struct mt7603_dev *dev) { struct mt76_bus_ops *bus_ops; struct ieee80211_hw *hw = mt76_hw(dev); struct wiphy *wiphy = hw->wiphy; + u8 *eeprom = (u8 *)dev->mt76.eeprom.data; int ret; dev->bus_ops = dev->mt76.bus; @@ -536,9 +542,11 @@ int mt7603_register_device(struct mt7603_dev *dev) tasklet_init(&dev->mt76.pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet, (unsigned long)dev); - /* Check for 7688, which only has 1SS */ + /* Check for 1SS devices */ dev->mphy.antenna_mask = 3; - if (mt76_rr(dev, MT_EFUSE_BASE + 0x64) & BIT(4)) + if (FIELD_GET(MT_EE_NIC_CONF_0_RX_PATH, eeprom[MT_EE_NIC_CONF_0]) == 1 || + FIELD_GET(MT_EE_NIC_CONF_0_TX_PATH, eeprom[MT_EE_NIC_CONF_0]) == 1 || + is_mt7688(dev)) dev->mphy.antenna_mask = 1; dev->slottime = 9;