From patchwork Tue Jan 21 14:13:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11344009 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CC966C1 for ; Tue, 21 Jan 2020 14:13:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B51F217F4 for ; Tue, 21 Jan 2020 14:13:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="M7dOuynC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729346AbgAUON5 (ORCPT ); Tue, 21 Jan 2020 09:13:57 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:52943 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729300AbgAUON4 (ORCPT ); Tue, 21 Jan 2020 09:13:56 -0500 X-UUID: cc872b21e6974122a7c1faed90e62134-20200121 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=v+wcGDsO7LzhLYd0t7yY8jTM7GyhTanF/p5aGuMf2uY=; b=M7dOuynClHVnt635uLeS5o8Mfj1VwIESUyTXExnKPoaZoIA+EwCPnTJza3URKsFqOoRWwddCXI0vL60920Aiw7VCqGXRLU2HCX9yPagb5WgF29S4MVuA9iwpu1AF+QkvRdHTBJic1w6uvpuiwoH7i6qqcEWHxwq/4zb2+rJSoqM=; X-UUID: cc872b21e6974122a7c1faed90e62134-20200121 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 386455802; Tue, 21 Jan 2020 22:13:51 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 21 Jan 2020 22:12:18 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 21 Jan 2020 22:13:30 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , Roy Luo , Sean Wang , , , Ryder Lee Subject: [PATCH 4/7] mt76: mt7615: adjust command flow for firmware v2 Date: Tue, 21 Jan 2020 22:13:39 +0800 Message-ID: <48e1baba8a4d87dc6c081189034f78447d65bf14.1579237414.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 X-TM-SNTS-SMTP: 2B03C0DA28A1CC07F7DDAEF4D85FBDFC6E7BE8B28A39E7767ABA05FED6B601882000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add fw_version in mt7615_dev to adapt new firmware version. Signed-off-by: Ryder Lee Signed-off-by: Shayne Chen Tested-by: Sean Wang --- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 16 ++++++++++++---- .../net/wireless/mediatek/mt76/mt7615/mt7615.h | 5 +++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 6bef0dcb83b7..c055949b289c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -491,6 +491,11 @@ static int mt7615_load_ram(struct mt7615_dev *dev) goto out; } + if (!strncmp(hdr->fw_ver, "mtk_v2", 6)) + dev->fw_ver = MT7615_FIRMWARE_V2; + else + dev->fw_ver = MT7615_FIRMWARE_V1; + release_firmware(fw); ret = request_firmware(&fw, MT7615_FIRMWARE_CR4, dev->mt76.dev); @@ -992,18 +997,21 @@ static int mt7615_mcu_send_sta_rec(struct mt7615_dev *dev, u8 *req, u8 *wreq, u8 wlen, bool enable) { - u32 slen = wreq - req; + bool is_v1 = (dev->fw_ver == MT7615_FIRMWARE_V1) ? true : false; + u32 slen = is_v1 ? wreq - req : wreq - req + wlen; - if (!enable) { + if (is_v1 && !enable) { __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE, req, slen, true); return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE, wreq, wlen, true); + } - __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE, wreq, - wlen, true); + if (is_v1) + __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_WTBL_UPDATE, + wreq, wlen, true); return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_STA_REC_UPDATE, req, slen, true); diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index 9bd926d6963f..fa39632cd2bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -30,6 +30,9 @@ #define MT7615_FIRMWARE_N9 "mediatek/mt7615_n9.bin" #define MT7615_ROM_PATCH "mediatek/mt7615_rom_patch.bin" +#define MT7615_FIRMWARE_V1 1 +#define MT7615_FIRMWARE_V2 2 + #define MT7615_EEPROM_SIZE 1024 #define MT7615_TOKEN_SIZE 4096 @@ -144,6 +147,8 @@ struct mt7615_dev { spinlock_t token_lock; struct idr token; + + u8 fw_ver; }; enum {