Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1830530ybl; Thu, 30 Jan 2020 06:47:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwptuvFkxB6J6KOInB3T4xr3S5OyBcdQMcxVvYjrm4rPFq81I/Unf2bw++j7ezLjPVjNz/W X-Received: by 2002:aca:90f:: with SMTP id 15mr3138956oij.18.1580395667577; Thu, 30 Jan 2020 06:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580395667; cv=none; d=google.com; s=arc-20160816; b=v/F/d09hDEwNzuzHpz7ib0QXWfS9JFbh6N3UFsRV3ubX7+4nJa/NWnrMdAgsmMSiBX 5AYrMLwfkmlVKZUetXNCsiRhZ7lH2KLCqnk159RtU2qDY/8ChuhI0OJr+70GMA4GI+ra Uu7am431t5byyBO2NVswEqB40xsj8/nfSXOGn0uKaautNYT/PaTVNPEuEHRbzJrLD+ft alYDa5NG38WRYN10JhduR1ETndBdKrVhOsVwviTx5MFaGbWi+XCd3+b1Lg7rXTZK/WsI QHR0beVvPYp8VfWU+IoBK0+sGJqILAfbBS5eKG+68nh82E7Rx8AFsCeMqiaBKs8fY+hU 0Nag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=MzMtSuJdT+mp6u132QBZeSGfkmn+kvDDEAbc7SCMzIg=; b=KdFHWQT5UM7x9BWP7u5CuMEz8iUaFP8vwWTuTkys9sbYhvvWwn8wq5CvJ/fcWyycho L/3dJLTxY8x34d2VXS1q/kXuArmnwtY9dlvEZp2xREZ/Ko2ODTzoPCHrah2/VfbCPRV2 oUIng7TWGTYv0TurcbPNKnxzuEHtlOwTUAEEn1r6EWaoIaACpIe0WK6LPbah+wmCu+Nc Pzh5F5xleaKbo88e3CJenWy61M+a1zBx7XFQqSaUM49ahFm+xE/VJKHFY7/RVFle0ea5 nTN10oHj2dLhBFhXpVa5SgzKD7PBpUAvQOpHSgTo4v9evQkcideZvHVYiNn6PlHX+Ni6 aYXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=CT8ykGhW; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si3325550otq.250.2020.01.30.06.47.35; Thu, 30 Jan 2020 06:47:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=CT8ykGhW; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727338AbgA3Or0 (ORCPT + 99 others); Thu, 30 Jan 2020 09:47:26 -0500 Received: from nbd.name ([46.4.11.11]:57448 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727263AbgA3OrW (ORCPT ); Thu, 30 Jan 2020 09:47:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=MzMtSuJdT+mp6u132QBZeSGfkmn+kvDDEAbc7SCMzIg=; b=CT8ykGhWSu96TqY5AjGPcBhBhs KCZYWiAZ5FHigDLNUJ956xC0+jffeS1bfSgtR7M6ytOB+wgwjpO9t+OjjesSF8cKvezNg/dmxiT6Y uWFFXMgFRDoVYDhKtFU8IyYZqodSjHjWvkNIApz+tFXWf8HIb7jDXj+arOIcpnZ2wuxI=; Received: from [178.162.209.135] (helo=maeck.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ixB6G-0001Vl-JN for linux-wireless@vger.kernel.org; Thu, 30 Jan 2020 15:47:20 +0100 Received: by maeck.local (Postfix, from userid 501) id EEA7C7AE4694; Thu, 30 Jan 2020 15:47:18 +0100 (CET) From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 08/15] mt76: mt7615: add eeprom support for MT7622 Date: Thu, 30 Jan 2020 15:47:11 +0100 Message-Id: <20200130144718.14298-8-nbd@nbd.name> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200130144718.14298-1-nbd@nbd.name> References: <20200130144718.14298-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When sending EEPROM data to the MCU, MT7622 uses a longer buffer Co-developed-by: Shayne Chen Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7615/eeprom.c | 1 + .../net/wireless/mediatek/mt76/mt7615/eeprom.h | 3 ++- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 17 +++++++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c index e4dcfa531a24..3c3570332366 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c @@ -84,6 +84,7 @@ static int mt7615_check_eeprom(struct mt76_dev *dev) switch (val) { case 0x7615: + case 0x7622: return 0; default: return -EINVAL; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h index c3bc69ac210e..18c7301521b7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h @@ -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) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 2352e7687790..e51e584bf81f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -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) { -- 2.24.0