diff mbox series

[5/8] wifi: mt76: mt7996: support mt7992 eeprom loading

Message ID 20231113070619.19964-6-shayne.chen@mediatek.com
State New
Headers show
Series Add MT7992 support | expand

Commit Message

Shayne Chen Nov. 13, 2023, 7:06 a.m. UTC
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>

Add the default eeprom and 0x7992 check to mt7996_check_eeprom().
This is a preliminary patch for mt7992 chipsets support.

Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
---
 .../net/wireless/mediatek/mt76/mt7996/eeprom.c    | 15 ++++++++++++---
 .../net/wireless/mediatek/mt76/mt7996/mt7996.h    |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
index 9db7e531076d..9c3735bed50c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
@@ -12,9 +12,12 @@  static int mt7996_check_eeprom(struct mt7996_dev *dev)
 	u8 *eeprom = dev->mt76.eeprom.data;
 	u16 val = get_unaligned_le16(eeprom);
 
+#define CHECK_EEPROM_ERR(match)	(match ? 0 : -EINVAL)
 	switch (val) {
 	case 0x7990:
-		return 0;
+		return CHECK_EEPROM_ERR(is_mt7996(&dev->mt76));
+	case 0x7992:
+		return CHECK_EEPROM_ERR(is_mt7992(&dev->mt76));
 	default:
 		return -EINVAL;
 	}
@@ -22,8 +25,14 @@  static int mt7996_check_eeprom(struct mt7996_dev *dev)
 
 static char *mt7996_eeprom_name(struct mt7996_dev *dev)
 {
-	/* reserve for future variants */
-	return MT7996_EEPROM_DEFAULT;
+	switch (mt76_chip(&dev->mt76)) {
+	case 0x7990:
+		return MT7996_EEPROM_DEFAULT;
+	case 0x7992:
+		return MT7992_EEPROM_DEFAULT;
+	default:
+		return MT7996_EEPROM_DEFAULT;
+	}
 }
 
 static int
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index 87822663870f..5cdde28ce83f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -39,6 +39,7 @@ 
 #define MT7992_ROM_PATCH		"mediatek/mt7996/mt7992_rom_patch.bin"
 
 #define MT7996_EEPROM_DEFAULT		"mediatek/mt7996/mt7996_eeprom.bin"
+#define MT7992_EEPROM_DEFAULT		"mediatek/mt7996/mt7992_eeprom.bin"
 #define MT7996_EEPROM_SIZE		7680
 #define MT7996_EEPROM_BLOCK_SIZE	16
 #define MT7996_TOKEN_SIZE		16384