Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3280131ybz; Sun, 19 Apr 2020 22:53:01 -0700 (PDT) X-Google-Smtp-Source: APiQypIH5KfSIwWHSD/yy8cbT6cSc2XlCTmstJo5mvem9dlINvi+FePFrJnV1w9h6nsirY9okmZ1 X-Received: by 2002:a50:9d83:: with SMTP id w3mr12882900ede.23.1587361981662; Sun, 19 Apr 2020 22:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587361981; cv=none; d=google.com; s=arc-20160816; b=Plgveheq1uv4Nae5LbZ/pcAaTqU6S6RTj5cO3pyzvuS7LwpgQFnXJB5Szd7vnc2XgA SYGsAYOlWA7epp+HN5LD8ZvLJkTZ2Vrcl+U8qoA2EOlL20JgWlqj5QKZa6PUtm6HPYcN U2GSww1kqC6+KfWzI+kmnmjV8kQ26yl58T4l65MDb63rCrW+9X5xHg+KmKkxPc7XtmRi bloacLMjT+FMqbMUXiz5TgrILOnYf3fTrpb3uZXaZCehewUHKFbZ/aztYZKYNycS28A9 ryopFVeZ2lQ/JDxrBMZ+k4Bi5N4AKs3z2VvXi3LN4Oda7sDyomLKg0+fsICWkkbLxWM9 C4UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:authenticated-by; bh=29Icn7OPx0dRJtWgsQ9bRj7KJlla3RnC9X3+GnhYXMQ=; b=khMtYPXShdGOEdjrgo6hNQ0ZRRNffBXsEQDpjHWp2jq2sSdqyEdzaN/a/Eci33sfrF hree/xuitEdjS/4qoFhIGEJfDKRUC2Wds1UHIONX3XM5RDFPDDDxqhkiwNBtilC2Bpnr SwBWAAE6cpkK9wwbH8+XD0mZbB2UjYySLLujflGtbYaACkN36LhvI/As8CPrF1nfxfMK isDCBU82EE9UjdDyTa7eOMrKqcCcT95pXsRhj+tR2QgzEHFOnoGBMeE8cDjyblI2FioN z8V42Tfpnt/MSkVebwBlEXorHVUmZaPm4fcGtKWiv2HHbSPlXvBkrIcXrgius7VlONVi wlXA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si5774732ejx.386.2020.04.19.22.52.38; Sun, 19 Apr 2020 22:53:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726081AbgDTFvP (ORCPT + 99 others); Mon, 20 Apr 2020 01:51:15 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:42171 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbgDTFvP (ORCPT ); Mon, 20 Apr 2020 01:51:15 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.69 with qID 03K5p9Zg9001143, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexmb06.realtek.com.tw[172.21.6.99]) by rtits2.realtek.com.tw (8.15.2/2.66/5.86) with ESMTPS id 03K5p9Zg9001143 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 20 Apr 2020 13:51:09 +0800 Received: from RTEXMB04.realtek.com.tw (172.21.6.97) by RTEXMB06.realtek.com.tw (172.21.6.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Mon, 20 Apr 2020 13:51:09 +0800 Received: from localhost.localdomain (172.21.68.128) by RTEXMB04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Mon, 20 Apr 2020 13:51:08 +0800 From: To: CC: , Subject: [PATCH v2 8/8] rtw88: 8723d: Add read_efuse to recognize efuse info from map Date: Mon, 20 Apr 2020 13:50:54 +0800 Message-ID: <20200420055054.14592-9-yhchuang@realtek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420055054.14592-1-yhchuang@realtek.com> References: <20200420055054.14592-1-yhchuang@realtek.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.68.128] X-ClientProxiedBy: RTEXMB03.realtek.com.tw (172.21.6.96) To RTEXMB04.realtek.com.tw (172.21.6.97) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ping-Ke Shih The logical efuse map is decoded from physical map by parsing the header format of the physical map. And each different type of chips has different logical efuse layout. So add the logical map's layout for parsing the efuse contents. Signed-off-by: Ping-Ke Shih Signed-off-by: Yan-Hsuan Chuang --- drivers/net/wireless/realtek/rtw88/rtw8723d.c | 43 +++++++++++++++++++ drivers/net/wireless/realtek/rtw88/rtw8723d.h | 39 +++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c index 756454d69fad..c25cabbab64d 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c @@ -14,6 +14,48 @@ #include "reg.h" #include "debug.h" +static void rtw8723de_efuse_parsing(struct rtw_efuse *efuse, + struct rtw8723d_efuse *map) +{ + ether_addr_copy(efuse->addr, map->e.mac_addr); +} + +static int rtw8723d_read_efuse(struct rtw_dev *rtwdev, u8 *log_map) +{ + struct rtw_efuse *efuse = &rtwdev->efuse; + struct rtw8723d_efuse *map; + int i; + + map = (struct rtw8723d_efuse *)log_map; + + efuse->rfe_option = 0; + efuse->rf_board_option = map->rf_board_option; + efuse->crystal_cap = map->xtal_k; + efuse->pa_type_2g = map->pa_type; + efuse->lna_type_2g = map->lna_type_2g[0]; + efuse->channel_plan = map->channel_plan; + efuse->country_code[0] = map->country_code[0]; + efuse->country_code[1] = map->country_code[1]; + efuse->bt_setting = map->rf_bt_setting; + efuse->regd = map->rf_board_option & 0x7; + efuse->thermal_meter[0] = map->thermal_meter; + efuse->thermal_meter_k = map->thermal_meter; + + for (i = 0; i < 4; i++) + efuse->txpwr_idx_table[i] = map->txpwr_idx_table[i]; + + switch (rtw_hci_type(rtwdev)) { + case RTW_HCI_TYPE_PCIE: + rtw8723de_efuse_parsing(efuse, map); + break; + default: + /* unsupported now */ + return -ENOTSUPP; + } + + return 0; +} + static void rtw8723d_cfg_ldo25(struct rtw_dev *rtwdev, bool enable) { u8 ldo_pwr; @@ -41,6 +83,7 @@ static void rtw8723d_efuse_grant(struct rtw_dev *rtwdev, bool on) } static struct rtw_chip_ops rtw8723d_ops = { + .read_efuse = rtw8723d_read_efuse, .read_rf = rtw_phy_read_rf_sipi, .write_rf = rtw_phy_write_rf_reg_sipi, .set_antenna = NULL, diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h b/drivers/net/wireless/realtek/rtw88/rtw8723d.h index 0b784cfc34c6..1939d9897a26 100644 --- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h +++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h @@ -5,4 +5,43 @@ #ifndef __RTW8723D_H__ #define __RTW8723D_H__ +struct rtw8723de_efuse { + u8 mac_addr[ETH_ALEN]; /* 0xd0 */ + u8 vender_id[2]; + u8 device_id[2]; + u8 sub_vender_id[2]; + u8 sub_device_id[2]; +}; + +struct rtw8723d_efuse { + __le16 rtl_id; + u8 rsvd[2]; + u8 afe; + u8 rsvd1[11]; + + /* power index for four RF paths */ + struct rtw_txpwr_idx txpwr_idx_table[4]; + + u8 channel_plan; /* 0xb8 */ + u8 xtal_k; + u8 thermal_meter; + u8 iqk_lck; + u8 pa_type; /* 0xbc */ + u8 lna_type_2g[2]; /* 0xbd */ + u8 lna_type_5g[2]; + u8 rf_board_option; + u8 rf_feature_option; + u8 rf_bt_setting; + u8 eeprom_version; + u8 eeprom_customer_id; + u8 tx_bb_swing_setting_2g; + u8 res_c7; + u8 tx_pwr_calibrate_rate; + u8 rf_antenna_option; /* 0xc9 */ + u8 rfe_option; + u8 country_code[2]; + u8 res[3]; + struct rtw8723de_efuse e; +}; + #endif -- 2.17.1