Commit 5dff21ee authored by Felix Fietkau's avatar Felix Fietkau
Browse files

mt76: mt7615: add eeprom support for MT7622



When sending EEPROM data to the MCU, MT7622 uses a longer buffer

Co-developed-by: default avatarShayne Chen <shayne.chen@mediatek.com>
Co-developed-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent cdad4874
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ static int mt7615_check_eeprom(struct mt76_dev *dev)

	switch (val) {
	case 0x7615:
	case 0x7622:
		return 0;
	default:
		return -EINVAL;
+2 −1
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@ enum mt7615_eeprom_field {
	MT_EE_TX2_5G_G0_TARGET_POWER =		0x142,
	MT_EE_TX3_5G_G0_TARGET_POWER =		0x16a,

	__MT_EE_MAX =				0x3bf
	MT7615_EE_MAX =				0x3bf,
	MT7622_EE_MAX =				0x3db,
};

#define MT_EE_NIC_CONF_TX_MASK			GENMASK(7, 4)
+11 −6
Original line number Diff line number Diff line
@@ -621,18 +621,23 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev)
		__le16 len;
	} __packed req_hdr = {
		.buffer_mode = 1,
		.len = cpu_to_le16(__MT_EE_MAX - MT_EE_NIC_CONF_0),
	};
	int ret, len = sizeof(req_hdr) + __MT_EE_MAX - MT_EE_NIC_CONF_0;
	int ret, len, eep_len;
	u8 *req, *eep = (u8 *)dev->mt76.eeprom.data;

	if (is_mt7622(&dev->mt76))
		eep_len = MT7622_EE_MAX - MT_EE_NIC_CONF_0;
	else
		eep_len = MT7615_EE_MAX - MT_EE_NIC_CONF_0;

	len = sizeof(req_hdr) + eep_len;
	req = kzalloc(len, GFP_KERNEL);
	if (!req)
		return -ENOMEM;

	req_hdr.len = cpu_to_le16(eep_len);
	memcpy(req, &req_hdr, sizeof(req_hdr));
	memcpy(req + sizeof(req_hdr), eep + MT_EE_NIC_CONF_0,
	       __MT_EE_MAX - MT_EE_NIC_CONF_0);
	memcpy(req + sizeof(req_hdr), eep + MT_EE_NIC_CONF_0, eep_len);

	ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE,
				  req, len, true);
@@ -1285,7 +1290,7 @@ int mt7615_mcu_set_tx_power(struct mt7615_phy *phy)
	};
	s8 tx_power;

	len = sizeof(req_hdr) + __MT_EE_MAX - MT_EE_NIC_CONF_0;
	len = sizeof(req_hdr) + MT7615_EE_MAX - MT_EE_NIC_CONF_0;
	req = kzalloc(len, GFP_KERNEL);
	if (!req)
		return -ENOMEM;
@@ -1293,7 +1298,7 @@ int mt7615_mcu_set_tx_power(struct mt7615_phy *phy)
	memcpy(req, &req_hdr, sizeof(req_hdr));
	data = req + sizeof(req_hdr);
	memcpy(data, eep + MT_EE_NIC_CONF_0,
	       __MT_EE_MAX - MT_EE_NIC_CONF_0);
	       MT7615_EE_MAX - MT_EE_NIC_CONF_0);

	tx_power = hw->conf.power_level * 2;
	switch (n_chains) {