Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wifi: mt76: mt7996: support mt7996 2+3+3 variant #907

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mt7996/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ static char *mt7996_eeprom_name(struct mt7996_dev *dev)
{
switch (mt76_chip(&dev->mt76)) {
case 0x7990:
if (dev->var_type == MT7996_VAR_TYPE_233)
return MT7996_EEPROM_DEFAULT_233;
return MT7996_EEPROM_DEFAULT;
case 0x7992:
return MT7992_EEPROM_DEFAULT;
Expand Down
25 changes: 25 additions & 0 deletions mt7996/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,27 @@ static void mt7996_wed_rro_work(struct work_struct *work)
#endif
}

static int mt7996_chip_variant_init(struct mt7996_dev *dev)
{
u32 val = mt76_rr(dev, MT_PAD_GPIO);

switch (mt76_chip(&dev->mt76)) {
case 0x7990:
if (u32_get_bits(val, MT_PAD_GPIO_2ADIE_TBTC))
dev->var_type = MT7996_VAR_TYPE_233;
else
dev->var_type = MT7996_VAR_TYPE_444;
break;
case 0x7992:
dev->var_type = MT7992_VAR_TYPE_44;
break;
default:
return -EINVAL;
}

return 0;
}

static int mt7996_init_hardware(struct mt7996_dev *dev)
{
int ret, idx;
Expand All @@ -899,6 +920,10 @@ static int mt7996_init_hardware(struct mt7996_dev *dev)
INIT_LIST_HEAD(&dev->wed_rro.poll_list);
spin_lock_init(&dev->wed_rro.lock);

ret = mt7996_chip_variant_init(dev);
if (ret)
return ret;

ret = mt7996_dma_init(dev);
if (ret)
return ret;
Expand Down
9 changes: 8 additions & 1 deletion mt7996/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
_fw = MT7992_##name; \
break; \
case 0x7990: \
if ((_dev)->var_type == MT7996_VAR_TYPE_233) \
_fw = MT7996_##name##_233; \
else \
_fw = MT7996_##name; \
break; \
default: \
_fw = MT7996_##name; \
break; \
Expand Down Expand Up @@ -2851,14 +2856,16 @@ static int __mt7996_load_ram(struct mt7996_dev *dev, const char *fw_type,

static int mt7996_load_ram(struct mt7996_dev *dev)
{
const char *dsp_name;
int ret;

ret = __mt7996_load_ram(dev, "WM", fw_name(dev, FIRMWARE_WM),
MT7996_RAM_TYPE_WM);
if (ret)
return ret;

ret = __mt7996_load_ram(dev, "DSP", fw_name(dev, FIRMWARE_DSP),
dsp_name = is_mt7996(&dev->mt76) ? MT7996_FIRMWARE_DSP : MT7992_FIRMWARE_DSP;
ret = __mt7996_load_ram(dev, "DSP", dsp_name,
MT7996_RAM_TYPE_DSP);
if (ret)
return ret;
Expand Down
17 changes: 15 additions & 2 deletions mt7996/mt7996.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@
#define MT7996_FIRMWARE_DSP "mediatek/mt7996/mt7996_dsp.bin"
#define MT7996_ROM_PATCH "mediatek/mt7996/mt7996_rom_patch.bin"

#define MT7996_FIRMWARE_WA_233 "mediatek/mt7996/mt7996_wa_233.bin"
#define MT7996_FIRMWARE_WM_233 "mediatek/mt7996/mt7996_wm_233.bin"
#define MT7996_ROM_PATCH_233 "mediatek/mt7996/mt7996_rom_patch_233.bin"

#define MT7992_FIRMWARE_WA "mediatek/mt7996/mt7992_wa.bin"
#define MT7992_FIRMWARE_WM "mediatek/mt7996/mt7992_wm.bin"
#define MT7992_FIRMWARE_DSP "mediatek/mt7996/mt7992_dsp.bin"
#define MT7992_ROM_PATCH "mediatek/mt7996/mt7992_rom_patch.bin"

#define MT7996_EEPROM_DEFAULT "mediatek/mt7996/mt7996_eeprom.bin"
#define MT7996_EEPROM_DEFAULT_233 "mediatek/mt7996/mt7996_eeprom_233.bin"
#define MT7992_EEPROM_DEFAULT "mediatek/mt7996/mt7992_eeprom.bin"
#define MT7996_EEPROM_SIZE 7680
#define MT7996_EEPROM_BLOCK_SIZE 16
Expand Down Expand Up @@ -89,6 +94,14 @@ struct mt7996_sta;
struct mt7996_dfs_pulse;
struct mt7996_dfs_pattern;

enum mt7996_var_type {
MT7996_VAR_TYPE_444,
MT7996_VAR_TYPE_233,

/* mt7992 */
MT7992_VAR_TYPE_44,
};

enum mt7996_ram_type {
MT7996_RAM_TYPE_WM,
MT7996_RAM_TYPE_WA,
Expand Down Expand Up @@ -329,6 +342,7 @@ struct mt7996_dev {
spinlock_t reg_lock;

u8 wtbl_size_group;
u8 var_type;
};

enum {
Expand Down Expand Up @@ -406,8 +420,7 @@ mt7996_band_valid(struct mt7996_dev *dev, u8 band)
return band <= MT_BAND1;

/* tri-band support */
if (band <= MT_BAND2 &&
mt76_get_field(dev, MT_PAD_GPIO, MT_PAD_GPIO_ADIE_COMB) <= 1)
if (band <= MT_BAND2 && dev->var_type)
return true;

return band == MT_BAND0 || band == MT_BAND2;
Expand Down
1 change: 1 addition & 0 deletions mt7996/regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ enum offs_rev {

#define MT_PAD_GPIO 0x700056f0
#define MT_PAD_GPIO_ADIE_COMB GENMASK(16, 15)
#define MT_PAD_GPIO_2ADIE_TBTC BIT(19)

#define MT_HW_REV 0x70010204
#define MT_HW_REV1 0x8a00
Expand Down