Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2689057pxb; Fri, 5 Nov 2021 03:04:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRxdkXqaisYLIG9hcgJhcYUEmY3b04nU7paXHGBHWeKoWcTLl6+0KHMBuFlY6nBASdazCs X-Received: by 2002:a05:6638:410a:: with SMTP id ay10mr6919784jab.120.1636106664057; Fri, 05 Nov 2021 03:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636106664; cv=none; d=google.com; s=arc-20160816; b=DxEhXDImMM/QQHkbnkKsOQShhgjqPzRO8YHUBL289/8mA8TWcVv1SQjXXzt0VM16uv PUWFJV4Vnep8WgPx1jdV2Eq7rmdyyNGUZPqNQ32Gj58MsduRY1JTIA/hU1viJTuMYgzh ohNkKNBGQEi5/e3wbmBGgKDBCxvnfqp5YAbTJlmwhvjSorF6MhLWuE0Bsy2BMNc4EuXz UfTinaL6Bl+m6QJM8oq4WOhciIOBcvoxy1Y7C6YLV+a8mIDJ/q8ovpjOAlRvB0nw6k8P sWmWDF9wjpWRSraOYEWXtTZ0GvldX0GOHzdY81jSXjyKX/AXNQYu4gAxhfUM+9tzMAEM 6qhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=vL+p2e7O708uqzwWR8C+QXGz/tGoUyejLTy1B5rsejs=; b=A6qRVYP0peoS4N0kOw0fWU0+kPw85s1cIX9XjKpMjjURykwE+rVdAbvR3kCIwi4sK6 s2HjUDSFpSizSbndh/2a7H4WkIpsSwNHbLrjXiED0EvBaPtJ4ltgV+f/DVj2hq8sHtQy RlEnGSvEop1zdf66eXWfasukUkgyaHSIWSqI0V+rYYEcNhU8qEOIvrEGw/lT0Jxdz4YG p4w9rU7V6dvqICBPyvYFdkORM891IM8YEEco6R2eQv9qayV9y0Yk9D4fywxwo3iLr0g5 REyybvM703rok2bIdLLlTByTEU4OP5sGFdpisAutg6w1FQSPzPzX4v5U7wFQNvzLAmYA IXrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si16038143jaj.98.2021.11.05.03.04.15; Fri, 05 Nov 2021 03:04:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233048AbhKEKFL (ORCPT + 67 others); Fri, 5 Nov 2021 06:05:11 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:49030 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S233027AbhKEKFI (ORCPT ); Fri, 5 Nov 2021 06:05:08 -0400 X-UUID: 1209db54a6dd4900b0e862750f52e046-20211105 X-UUID: 1209db54a6dd4900b0e862750f52e046-20211105 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1511216972; Fri, 05 Nov 2021 18:02:25 +0800 Received: from MTKMBS34N1.mediatek.inc (172.27.4.172) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 5 Nov 2021 18:02:25 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS34N1.mediatek.inc (172.27.4.172) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 5 Nov 2021 18:02:19 +0800 Received: from mcddlt001.gcn.mediatek.inc (10.19.240.15) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 5 Nov 2021 18:02:18 +0800 From: Bo Jiao To: Felix Fietkau CC: linux-wireless , Ryder Lee , Xing Song , Sujuan Chen , Shayne Chen , "Evelyn Tsai" , linux-mediatek , Bo Jiao Subject: [PATCH v2 10/11] mt76: mt7915: add mt7916 calibrated data support Date: Fri, 5 Nov 2021 18:02:09 +0800 Message-ID: <6fa6d5d9b581af5a6b8c627ebd39ed429240e3eb.1636105953.git.Bo.Jiao@mediatek.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Bo Jiao Adjust proper eeprom size and add default calibrated data support for mt7916. Co-developed-by: Shayne Chen Signed-off-by: Shayne Chen Co-developed-by: Sujuan Chen Signed-off-by: Sujuan Chen Signed-off-by: Bo Jiao Reviewed-by: Ryder Lee --- drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 11 ++++++++--- drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 7 ++++--- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 8 ++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c index 40dcbeb..6aa749b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c @@ -35,6 +35,7 @@ static int mt7915_check_eeprom(struct mt7915_dev *dev) switch (val) { case 0x7915: + case 0x7916: return 0; default: return -EINVAL; @@ -52,6 +53,9 @@ mt7915_eeprom_load_default(struct mt7915_dev *dev) if (dev->dbdc_support) default_bin = MT7915_EEPROM_DEFAULT_DBDC; + if (!is_mt7915(&dev->mt76)) + default_bin = MT7916_EEPROM_DEFAULT; + ret = request_firmware(&fw, default_bin, dev->mt76.dev); if (ret) return ret; @@ -62,7 +66,7 @@ mt7915_eeprom_load_default(struct mt7915_dev *dev) goto out; } - memcpy(eeprom, fw->data, MT7915_EEPROM_SIZE); + memcpy(eeprom, fw->data, mt7915_eeprom_size(dev)); dev->flash_mode = true; out: @@ -74,8 +78,9 @@ out: static int mt7915_eeprom_load(struct mt7915_dev *dev) { int ret; + u16 eeprom_size = mt7915_eeprom_size(dev); - ret = mt76_eeprom_init(&dev->mt76, MT7915_EEPROM_SIZE); + ret = mt76_eeprom_init(&dev->mt76, eeprom_size); if (ret < 0) return ret; @@ -91,7 +96,7 @@ static int mt7915_eeprom_load(struct mt7915_dev *dev) return -EINVAL; /* read eeprom data from efuse */ - block_num = DIV_ROUND_UP(MT7915_EEPROM_SIZE, + block_num = DIV_ROUND_UP(eeprom_size, MT7915_EEPROM_BLOCK_SIZE); for (i = 0; i < block_num; i++) mt7915_mcu_get_eeprom(dev, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index dee5aee..20dd2d9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -3551,7 +3551,8 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev) #define PAGE_IDX_MASK GENMASK(4, 2) #define PER_PAGE_SIZE 0x400 struct mt7915_mcu_eeprom req = { .buffer_mode = EE_MODE_BUFFER }; - u8 total = DIV_ROUND_UP(MT7915_EEPROM_SIZE, PER_PAGE_SIZE); + u16 eeprom_size = mt7915_eeprom_size(dev); + u8 total = DIV_ROUND_UP(eeprom_size, PER_PAGE_SIZE); u8 *eep = (u8 *)dev->mt76.eeprom.data; int eep_len; int i; @@ -3560,8 +3561,8 @@ static int mt7915_mcu_set_eeprom_flash(struct mt7915_dev *dev) struct sk_buff *skb; int ret; - if (i == total - 1 && !!(MT7915_EEPROM_SIZE % PER_PAGE_SIZE)) - eep_len = MT7915_EEPROM_SIZE % PER_PAGE_SIZE; + if (i == total - 1 && !!(eeprom_size % PER_PAGE_SIZE)) + eep_len = eeprom_size % PER_PAGE_SIZE; else eep_len = PER_PAGE_SIZE; diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index e8fbe69..4cc2666 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -37,8 +37,11 @@ #define MT7915_EEPROM_DEFAULT "mediatek/mt7915_eeprom.bin" #define MT7915_EEPROM_DEFAULT_DBDC "mediatek/mt7915_eeprom_dbdc.bin" +#define MT7916_EEPROM_DEFAULT "mediatek/mt7916_eeprom.bin" #define MT7915_EEPROM_SIZE 3584 +#define MT7916_EEPROM_SIZE 4096 + #define MT7915_EEPROM_BLOCK_SIZE 16 #define MT7915_TOKEN_SIZE 8192 @@ -483,6 +486,11 @@ static inline u16 mt7915_wtbl_size(struct mt7915_dev *dev) return is_mt7915(&dev->mt76) ? MT7915_WTBL_SIZE : MT7916_WTBL_SIZE; } +static inline u16 mt7915_eeprom_size(struct mt7915_dev *dev) +{ + return is_mt7915(&dev->mt76) ? MT7915_EEPROM_SIZE : MT7916_EEPROM_SIZE; +} + void mt7915_dual_hif_set_irq_mask(struct mt7915_dev *dev, bool write_reg, u32 clear, u32 set); -- 2.18.0