Skip to content

Commit f28eab6

Browse files
Ping-Ke ShihKalle Valo
authored andcommitted
wifi: rtw89: mac: add to access efuse for WiFi 7 chips
MAC address, hardware type, calibration values and etc are stored in efuse, so we read them at probe stage and use them as capabilities to register hardware. There are two physical efuse -- one is the main efuse for digital hardware part, and the other is for analog part. Because they are very similar, we only describe the main efuse below. The main efuse is split into two regions -- one is for logic map, and the other is for physical map. For both regions, we use the same method to read data, but need additional parser to get logic map. To allow reading operation, we need to convert power state to active, and turn to idle state after reading. For WiFi 7 chips, we introduce efuse blocks to define feature group easier, and these blocks are discontinue. For example, RF block is from 0x1_0000 ~ 0x1_0240, and the next block PCIE_SDIO is starting from 0x2_0000. Comparing to old one used by WiFi 6 chips, there is only single one logic map, it would be a little hard to add an new field to a group if we don't reserve a room in advance. The relationship between efuse, region and block is shown as below: (logical map) +------------+ +---------------+ +-----------------+ | main efuse | | region 1 | | block 0x1_0000~ | | (digital) | |(to logcal map)| +-----------------+ | | | | => +-----------------+ | | => | | | block 0x2_0000~ | | | | | +-----------------+ | | |---------------| : | | | region 2 | +------------+ +---------------+ +------------+ +-----------------+ | 2nd efuse | ======================> | block 0x7_0000~ | | (analog) | +-----------------+ +------------+ The parser converting from raw data to logic map is to decode block page, block page offset, and word_en bits. Each word_en bit indicates two following bytes as data of logic map, so total four word_en bits can represent eight bytes. Thus, block page offset is 8-byte alignment. The layout of a tuple is shown as below +--------+--------+--------+--------+--------+--------+ | fixed 3 byte header | | | | | | | | | | [19:17] block_page | | | ... | | [16:4] block_page_offset| | | | | [3:0] word_en | ^ | ^ | | +----|---+--------+--------+---|----+----|---+--------+ | | | +-------------------------+---------+ a word_en bit indicates two bytes as data For example, block_page = 0x3 block_page_offset = 0x80 (must 8-byte alignment) word_en = 0x6 (b'0110; 0 means data is presented) following 4 bytes = 34 56 78 90 Then, 0x3_0080 = 34 56 0x3_0086 = 78 90 A special block page is RTW89_EFUSE_BLOCK_ADIE (7) that uses different but similar format, because its real efuse size is smaller than main efuse. Signed-off-by: Ping-Ke Shih <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 88e6a92 commit f28eab6

File tree

11 files changed

+552
-6
lines changed

11 files changed

+552
-6
lines changed

drivers/net/wireless/realtek/rtw89/core.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct rtw89_dev;
1616
struct rtw89_pci_info;
1717
struct rtw89_mac_gen_def;
1818
struct rtw89_phy_gen_def;
19+
struct rtw89_efuse_block_cfg;
1920

2021
extern const struct ieee80211_ops rtw89_ops;
2122

@@ -2777,6 +2778,20 @@ enum rtw89_rx_frame_type {
27772778
RTW89_RX_TYPE_RSVD = 3,
27782779
};
27792780

2781+
enum rtw89_efuse_block {
2782+
RTW89_EFUSE_BLOCK_SYS = 0,
2783+
RTW89_EFUSE_BLOCK_RF = 1,
2784+
RTW89_EFUSE_BLOCK_HCI_DIG_PCIE_SDIO = 2,
2785+
RTW89_EFUSE_BLOCK_HCI_DIG_USB = 3,
2786+
RTW89_EFUSE_BLOCK_HCI_PHY_PCIE = 4,
2787+
RTW89_EFUSE_BLOCK_HCI_PHY_USB3 = 5,
2788+
RTW89_EFUSE_BLOCK_HCI_PHY_USB2 = 6,
2789+
RTW89_EFUSE_BLOCK_ADIE = 7,
2790+
2791+
RTW89_EFUSE_BLOCK_NUM,
2792+
RTW89_EFUSE_BLOCK_IGNORE,
2793+
};
2794+
27802795
struct rtw89_ra_info {
27812796
u8 is_dis_ra:1;
27822797
/* Bit0 : CCK
@@ -3119,7 +3134,8 @@ struct rtw89_chip_ops {
31193134
const struct rtw89_chan *chan,
31203135
enum rtw89_mac_idx mac_idx,
31213136
enum rtw89_phy_idx phy_idx);
3122-
int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map);
3137+
int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map,
3138+
enum rtw89_efuse_block block);
31233139
int (*read_phycap)(struct rtw89_dev *rtwdev, u8 *phycap_map);
31243140
void (*fem_setup)(struct rtw89_dev *rtwdev);
31253141
void (*rfe_gpio)(struct rtw89_dev *rtwdev);
@@ -3655,6 +3671,7 @@ struct rtw89_chip_info {
36553671
u32 dav_log_efuse_size;
36563672
u32 phycap_addr;
36573673
u32 phycap_size;
3674+
const struct rtw89_efuse_block_cfg *efuse_blocks;
36583675

36593676
const struct rtw89_pwr_cfg * const *pwr_on_seq;
36603677
const struct rtw89_pwr_cfg * const *pwr_off_seq;

drivers/net/wireless/realtek/rtw89/efuse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ int rtw89_parse_efuse_map_ax(struct rtw89_dev *rtwdev)
291291

292292
rtw89_hex_dump(rtwdev, RTW89_DBG_FW, "log_map: ", log_map, full_log_size);
293293

294-
ret = rtwdev->chip->ops->read_efuse(rtwdev, log_map);
294+
ret = rtwdev->chip->ops->read_efuse(rtwdev, log_map, RTW89_EFUSE_BLOCK_IGNORE);
295295
if (ret) {
296296
rtw89_warn(rtwdev, "failed to read efuse map\n");
297297
goto out_free;

drivers/net/wireless/realtek/rtw89/efuse.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,21 @@
77

88
#include "core.h"
99

10+
#define RTW89_EFUSE_BLOCK_ID_MASK GENMASK(31, 16)
11+
#define RTW89_EFUSE_BLOCK_SIZE_MASK GENMASK(15, 0)
12+
#define RTW89_EFUSE_MAX_BLOCK_SIZE 0x10000
13+
14+
struct rtw89_efuse_block_cfg {
15+
u32 offset;
16+
u32 size;
17+
};
18+
1019
int rtw89_parse_efuse_map_ax(struct rtw89_dev *rtwdev);
1120
int rtw89_parse_phycap_map_ax(struct rtw89_dev *rtwdev);
1221
int rtw89_cnv_efuse_state_ax(struct rtw89_dev *rtwdev, bool idle);
22+
int rtw89_parse_efuse_map_be(struct rtw89_dev *rtwdev);
23+
int rtw89_parse_phycap_map_be(struct rtw89_dev *rtwdev);
24+
int rtw89_cnv_efuse_state_be(struct rtw89_dev *rtwdev, bool idle);
1325
int rtw89_read_efuse_ver(struct rtw89_dev *rtwdev, u8 *efv);
1426

1527
#endif

0 commit comments

Comments
 (0)