mt76: mt7615: add mt7663e support to mt7615_mcu_set_eeprom
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 17 Mar 2020 16:41:24 +0000 (17:41 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 17 Mar 2020 16:47:57 +0000 (17:47 +0100)
Extend mt7615_mcu_set_eeprom routine in order to be reused
adding mt7663e support to mt7615 driver

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c

index 18c7301521b7102914e87b4d7843b3eda10ff8da..8a2a64b7fcd36ceede5e96936e73a4bc18d41dee 100644 (file)
@@ -18,11 +18,13 @@ enum mt7615_eeprom_field {
        MT_EE_TX1_5G_G0_TARGET_POWER =          0x098,
        MT_EE_EXT_PA_2G_TARGET_POWER =          0x0f2,
        MT_EE_EXT_PA_5G_TARGET_POWER =          0x0f3,
+       MT7663_EE_TX0_2G_TARGET_POWER =         0x123,
        MT_EE_TX2_5G_G0_TARGET_POWER =          0x142,
        MT_EE_TX3_5G_G0_TARGET_POWER =          0x16a,
 
        MT7615_EE_MAX =                         0x3bf,
        MT7622_EE_MAX =                         0x3db,
+       MT7663_EE_MAX =                         0x400,
 };
 
 #define MT_EE_NIC_CONF_TX_MASK                 GENMASK(7, 4)
index 9d044f23340ed23f24c0e4c8d844770c8f2f1fdd..e73cd3cb014ad5433fef2fe6dacf9f9ce0da8c8b 100644 (file)
@@ -1539,19 +1539,30 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev)
 {
        struct {
                u8 buffer_mode;
-               u8 pad;
+               u8 content_format;
                __le16 len;
        } __packed req_hdr = {
                .buffer_mode = 1,
        };
        u8 *eep = (u8 *)dev->mt76.eeprom.data;
        struct sk_buff *skb;
-       int eep_len;
+       int eep_len, offset;
 
-       if (is_mt7622(&dev->mt76))
+       switch (mt76_chip(&dev->mt76)) {
+       case 0x7622:
                eep_len = MT7622_EE_MAX - MT_EE_NIC_CONF_0;
-       else
+               offset = MT_EE_NIC_CONF_0;
+               break;
+       case 0x7663:
+               eep_len = MT7663_EE_MAX - MT_EE_CHIP_ID;
+               req_hdr.content_format = 1;
+               offset = MT_EE_CHIP_ID;
+               break;
+       default:
                eep_len = MT7615_EE_MAX - MT_EE_NIC_CONF_0;
+               offset = MT_EE_NIC_CONF_0;
+               break;
+       }
 
        req_hdr.len = cpu_to_le16(eep_len);
 
@@ -1560,7 +1571,7 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev)
                return -ENOMEM;
 
        skb_put_data(skb, &req_hdr, sizeof(req_hdr));
-       skb_put_data(skb, eep + MT_EE_NIC_CONF_0, eep_len);
+       skb_put_data(skb, eep + offset, eep_len);
 
        return __mt76_mcu_skb_send_msg(&dev->mt76, skb,
                                       MCU_EXT_CMD_EFUSE_BUFFER_MODE, true);