Skip to content

Commit cfb9943

Browse files
Ping-Ke ShihKalle Valo
authored andcommitted
wifi: rtw89: mac: add flags to check if CMAC and DMAC are enabled
Before accessing CMAC and DMAC registers, we should ensure they have been powered on, so add flag to determine the state. For old chips, we read registers and check corresponding bit, but it takes extra cost to read. Signed-off-by: Ping-Ke Shih <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://msgid.link/[email protected]
1 parent f20b2b7 commit cfb9943

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4117,6 +4117,9 @@ struct rtw89_hal {
41174117

41184118
enum rtw89_flags {
41194119
RTW89_FLAG_POWERON,
4120+
RTW89_FLAG_DMAC_FUNC,
4121+
RTW89_FLAG_CMAC0_FUNC,
4122+
RTW89_FLAG_CMAC1_FUNC,
41204123
RTW89_FLAG_FW_RDY,
41214124
RTW89_FLAG_RUNNING,
41224125
RTW89_FLAG_BFEE_MON,

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ static u32 rtw89_mac_mem_read(struct rtw89_dev *rtwdev, u32 offset,
5757
return rtw89_read32(rtwdev, mac->indir_access_addr);
5858
}
5959

60-
int rtw89_mac_check_mac_en(struct rtw89_dev *rtwdev, u8 mac_idx,
61-
enum rtw89_mac_hwmod_sel sel)
60+
static int rtw89_mac_check_mac_en_ax(struct rtw89_dev *rtwdev, u8 mac_idx,
61+
enum rtw89_mac_hwmod_sel sel)
6262
{
6363
u32 val, r_val;
6464

@@ -1473,9 +1473,14 @@ static int rtw89_mac_power_switch(struct rtw89_dev *rtwdev, bool on)
14731473

14741474
if (on) {
14751475
set_bit(RTW89_FLAG_POWERON, rtwdev->flags);
1476+
set_bit(RTW89_FLAG_DMAC_FUNC, rtwdev->flags);
1477+
set_bit(RTW89_FLAG_CMAC0_FUNC, rtwdev->flags);
14761478
rtw89_write8(rtwdev, R_AX_SCOREBOARD + 3, MAC_AX_NOTIFY_TP_MAJOR);
14771479
} else {
14781480
clear_bit(RTW89_FLAG_POWERON, rtwdev->flags);
1481+
clear_bit(RTW89_FLAG_DMAC_FUNC, rtwdev->flags);
1482+
clear_bit(RTW89_FLAG_CMAC0_FUNC, rtwdev->flags);
1483+
clear_bit(RTW89_FLAG_CMAC1_FUNC, rtwdev->flags);
14791484
clear_bit(RTW89_FLAG_FW_RDY, rtwdev->flags);
14801485
rtw89_write8(rtwdev, R_AX_SCOREBOARD + 3, MAC_AX_NOTIFY_PWR_MAJOR);
14811486
rtw89_set_entity_state(rtwdev, false);
@@ -6100,6 +6105,7 @@ const struct rtw89_mac_gen_def rtw89_mac_gen_ax = {
61006105
B_AX_BFMEE_HE_NDPA_EN,
61016106
},
61026107

6108+
.check_mac_en = rtw89_mac_check_mac_en_ax,
61036109
.hci_func_en = rtw89_mac_hci_func_en_ax,
61046110
.dmac_func_pre_en = rtw89_mac_dmac_func_pre_en_ax,
61056111
.dle_func_en = dle_func_en_ax,

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,8 @@ struct rtw89_mac_gen_def {
898898
struct rtw89_reg_def muedca_ctrl;
899899
struct rtw89_reg_def bfee_ctrl;
900900

901+
int (*check_mac_en)(struct rtw89_dev *rtwdev, u8 band,
902+
enum rtw89_mac_hwmod_sel sel);
901903
void (*hci_func_en)(struct rtw89_dev *rtwdev);
902904
void (*dmac_func_pre_en)(struct rtw89_dev *rtwdev);
903905
void (*dle_func_en)(struct rtw89_dev *rtwdev, bool enable);
@@ -1044,8 +1046,15 @@ rtw89_write32_port_set(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif,
10441046
void rtw89_mac_pwr_off(struct rtw89_dev *rtwdev);
10451047
int rtw89_mac_partial_init(struct rtw89_dev *rtwdev, bool include_bb);
10461048
int rtw89_mac_init(struct rtw89_dev *rtwdev);
1049+
static inline
10471050
int rtw89_mac_check_mac_en(struct rtw89_dev *rtwdev, u8 band,
1048-
enum rtw89_mac_hwmod_sel sel);
1051+
enum rtw89_mac_hwmod_sel sel)
1052+
{
1053+
const struct rtw89_mac_gen_def *mac = rtwdev->chip->mac_def;
1054+
1055+
return mac->check_mac_en(rtwdev, band, sel);
1056+
}
1057+
10491058
int rtw89_mac_write_lte(struct rtw89_dev *rtwdev, const u32 offset, u32 val);
10501059
int rtw89_mac_read_lte(struct rtw89_dev *rtwdev, const u32 offset, u32 *val);
10511060
int rtw89_mac_dle_dfi_cfg(struct rtw89_dev *rtwdev, struct rtw89_mac_dle_dfi_ctrl *ctrl);

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ static const struct rtw89_port_reg rtw89_port_base_be = {
5757
R_BE_PORT_HGQ_WINDOW_CFG + 3},
5858
};
5959

60+
static int rtw89_mac_check_mac_en_be(struct rtw89_dev *rtwdev, u8 mac_idx,
61+
enum rtw89_mac_hwmod_sel sel)
62+
{
63+
if (sel == RTW89_DMAC_SEL &&
64+
test_bit(RTW89_FLAG_DMAC_FUNC, rtwdev->flags))
65+
return 0;
66+
if (sel == RTW89_CMAC_SEL && mac_idx == RTW89_MAC_0 &&
67+
test_bit(RTW89_FLAG_CMAC0_FUNC, rtwdev->flags))
68+
return 0;
69+
if (sel == RTW89_CMAC_SEL && mac_idx == RTW89_MAC_1 &&
70+
test_bit(RTW89_FLAG_CMAC1_FUNC, rtwdev->flags))
71+
return 0;
72+
73+
return -EFAULT;
74+
}
75+
6076
static void hfc_get_mix_info_be(struct rtw89_dev *rtwdev)
6177
{
6278
struct rtw89_hfc_param *param = &rtwdev->mac.hfc_param;
@@ -1145,6 +1161,7 @@ const struct rtw89_mac_gen_def rtw89_mac_gen_be = {
11451161
B_BE_BFMEE_HE_NDPA_EN | B_BE_BFMEE_EHT_NDPA_EN,
11461162
},
11471163

1164+
.check_mac_en = rtw89_mac_check_mac_en_be,
11481165
.hci_func_en = rtw89_mac_hci_func_en_be,
11491166
.dmac_func_pre_en = rtw89_mac_dmac_func_pre_en_be,
11501167
.dle_func_en = dle_func_en_be,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ static int rtw8922a_pwr_on_func(struct rtw89_dev *rtwdev)
257257
B_BE_H_AXIDMA_EN | B_BE_DMAC_MLO_EN | B_BE_PLRLS_EN |
258258
B_BE_P_AXIDMA_EN | B_BE_DLE_DATACPUIO_EN | B_BE_LTR_CTL_EN);
259259

260+
set_bit(RTW89_FLAG_DMAC_FUNC, rtwdev->flags);
261+
260262
rtw89_write32_set(rtwdev, R_BE_CMAC_SHARE_FUNC_EN,
261263
B_BE_CMAC_SHARE_EN | B_BE_RESPBA_EN | B_BE_ADDRSRCH_EN |
262264
B_BE_BTCOEX_EN);
@@ -266,6 +268,8 @@ static int rtw8922a_pwr_on_func(struct rtw89_dev *rtwdev)
266268
B_BE_PTCLTOP_EN | B_BE_SCHEDULER_EN | B_BE_TMAC_EN |
267269
B_BE_RMAC_EN | B_BE_TXTIME_EN | B_BE_RESP_PKTCTL_EN);
268270

271+
set_bit(RTW89_FLAG_CMAC0_FUNC, rtwdev->flags);
272+
269273
rtw89_write32_set(rtwdev, R_BE_FEN_RST_ENABLE, B_BE_FEN_BB_IP_RSTN |
270274
B_BE_FEN_BBPLAT_RSTB);
271275

0 commit comments

Comments
 (0)