From patchwork Fri Feb 21 00:07:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 216442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBB0BC11D00 for ; Fri, 21 Feb 2020 00:08:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B424B222C4 for ; Fri, 21 Feb 2020 00:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582243693; bh=7+18sp25jTYgLmeUI9KTxSL/+oFBGmYyxBuYYLoCKzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=WjAaLlvpRXBDfrXLZ0POZy5wVjX/w/46gjxkYY7WUj1PDWTQKMCUL4gC/9kuVcoXn EhUyGGkrZggr8nzauaMzSFaEpW9c2iWzl90c9QNhcz/SQyJ/4ACY0tIOLXiZ/FGVuF F215IaUcN/lVDxTQ93EAxAJRmYnrSduwqG7+kGCM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729456AbgBUAIN (ORCPT ); Thu, 20 Feb 2020 19:08:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:38712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729373AbgBUAIM (ORCPT ); Thu, 20 Feb 2020 19:08:12 -0500 Received: from localhost.localdomain (unknown [151.48.137.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 112382071E; Fri, 21 Feb 2020 00:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582243692; bh=7+18sp25jTYgLmeUI9KTxSL/+oFBGmYyxBuYYLoCKzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EWk6w7Z5YEMH3Vl4DDfAjhUzlMo4fIzVY6rR0NNt+Nwb6wpHLs5O5qlB/2yvBhxqB eLdbXhhtGEPMpwSrx6P3YqTVGIE3NeFdrjExhL0j/NBe6fAspQ5Oqd0kB5qY/5DtwO Xm9eFNiyAds9Jbp270HFzkc/nO4fHunOGtmf2mJs= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, sean.wang@mediatek.com, ryder.lee@mediatek.com Subject: [PATCH 5/8] mt76: mt7615: add mt7663e support to mt7615_mcu_set_eeprom Date: Fri, 21 Feb 2020 01:07:32 +0100 Message-Id: X-Mailer: git-send-email 2.24.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Extend mt7615_mcu_set_eeprom routine in order to be reused adding mt7663e support to mt7615 driver Co-developed-by: Sean Wang Signed-off-by: Sean Wang Co-developed-by: Ryder Lee Signed-off-by: Ryder Lee Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7615/eeprom.h | 2 ++ .../net/wireless/mediatek/mt76/mt7615/mcu.c | 21 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h index 18c7301521b7..8a2a64b7fcd3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h @@ -18,11 +18,13 @@ enum mt7615_eeprom_field { MT_EE_TX1_5G_G0_TARGET_POWER = 0x098, MT_EE_EXT_PA_2G_TARGET_POWER = 0x0f2, MT_EE_EXT_PA_5G_TARGET_POWER = 0x0f3, + MT7663_EE_TX0_2G_TARGET_POWER = 0x123, MT_EE_TX2_5G_G0_TARGET_POWER = 0x142, MT_EE_TX3_5G_G0_TARGET_POWER = 0x16a, MT7615_EE_MAX = 0x3bf, MT7622_EE_MAX = 0x3db, + MT7663_EE_MAX = 0x400, }; #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 a244585d78df..fbf892750e2c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -731,18 +731,29 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev) { struct { u8 buffer_mode; - u8 pad; + u8 content_format; __le16 len; } __packed req_hdr = { .buffer_mode = 1, }; - int ret, len, eep_len; + int ret, len, eep_len, offset; u8 *req, *eep = (u8 *)dev->mt76.eeprom.data; - if (is_mt7622(&dev->mt76)) + switch (mt76_chip(&dev->mt76)) { + case 0x7622: eep_len = MT7622_EE_MAX - MT_EE_NIC_CONF_0; - else + offset = MT_EE_NIC_CONF_0; + break; + case 0x7663: + eep_len = MT7663_EE_MAX - MT_EE_CHIP_ID; + req_hdr.content_format = 1; + offset = MT_EE_CHIP_ID; + break; + default: eep_len = MT7615_EE_MAX - MT_EE_NIC_CONF_0; + offset = MT_EE_NIC_CONF_0; + break; + } len = sizeof(req_hdr) + eep_len; req = kzalloc(len, GFP_KERNEL); @@ -751,7 +762,7 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev) 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, eep_len); + memcpy(req + sizeof(req_hdr), eep + offset, eep_len); ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE, req, len, true);