]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mt76: mt7615: select wifi band according to eeprom
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 17 May 2019 21:32:56 +0000 (23:32 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 27 Jun 2019 10:58:13 +0000 (12:58 +0200)
Select supported band according to the value read from
eeprom mtd/otp partition

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h

index 1712f66520a81f98ebdb1961a0d205f4ddb5c4b0..714590878d658c0171bad80736e58e693a65e559 100644 (file)
@@ -90,6 +90,26 @@ static int mt7615_check_eeprom(struct mt76_dev *dev)
        }
 }
 
+static void mt7615_eeprom_parse_hw_cap(struct mt7615_dev *dev)
+{
+       u8 val, *eeprom = dev->mt76.eeprom.data;
+
+       val = FIELD_GET(MT_EE_NIC_WIFI_CONF_BAND_SEL,
+                       eeprom[MT_EE_WIFI_CONF]);
+       switch (val) {
+       case MT_EE_5GHZ:
+               dev->mt76.cap.has_5ghz = true;
+               break;
+       case MT_EE_2GHZ:
+               dev->mt76.cap.has_2ghz = true;
+               break;
+       default:
+               dev->mt76.cap.has_2ghz = true;
+               dev->mt76.cap.has_5ghz = true;
+               break;
+       }
+}
+
 int mt7615_eeprom_init(struct mt7615_dev *dev)
 {
        int ret;
@@ -103,9 +123,7 @@ int mt7615_eeprom_init(struct mt7615_dev *dev)
                memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data,
                       MT7615_EEPROM_SIZE);
 
-       dev->mt76.cap.has_2ghz = true;
-       dev->mt76.cap.has_5ghz = true;
-
+       mt7615_eeprom_parse_hw_cap(dev);
        memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
               ETH_ALEN);
 
index a4cf166881717e6da5ffac969d4079acf849a7d7..b422e395d6ee7ef737fa68224528c91b18c59da2 100644 (file)
@@ -11,8 +11,17 @@ enum mt7615_eeprom_field {
        MT_EE_VERSION =                         0x002,
        MT_EE_MAC_ADDR =                        0x004,
        MT_EE_NIC_CONF_0 =                      0x034,
+       MT_EE_WIFI_CONF =                       0x03e,
 
        __MT_EE_MAX =                           0x3bf
 };
 
+#define MT_EE_NIC_WIFI_CONF_BAND_SEL           GENMASK(5, 4)
+enum mt7615_eeprom_band {
+       MT_EE_DUAL_BAND,
+       MT_EE_5GHZ,
+       MT_EE_2GHZ,
+       MT_EE_DBDC,
+};
+
 #endif