rtw88: 8723d: Add read_efuse to recognize efuse info from map
authorPing-Ke Shih <pkshih@realtek.com>
Mon, 20 Apr 2020 05:50:54 +0000 (13:50 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 21 Apr 2020 12:59:26 +0000 (15:59 +0300)
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 <pkshih@realtek.com>
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200420055054.14592-9-yhchuang@realtek.com
drivers/net/wireless/realtek/rtw88/rtw8723d.c
drivers/net/wireless/realtek/rtw88/rtw8723d.h

index 756454d..c25cabb 100644 (file)
 #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,
index 0b784cf..1939d98 100644 (file)
@@ -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