xref: /openbmc/linux/drivers/net/wireless/realtek/rtw89/rtw8852b.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
108484e1fSPing-Ke Shih /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
208484e1fSPing-Ke Shih /* Copyright(c) 2019-2022  Realtek Corporation
308484e1fSPing-Ke Shih  */
408484e1fSPing-Ke Shih 
508484e1fSPing-Ke Shih #ifndef __RTW89_8852B_H__
608484e1fSPing-Ke Shih #define __RTW89_8852B_H__
708484e1fSPing-Ke Shih 
808484e1fSPing-Ke Shih #include "core.h"
908484e1fSPing-Ke Shih 
1008484e1fSPing-Ke Shih #define RF_PATH_NUM_8852B 2
1108484e1fSPing-Ke Shih #define BB_PATH_NUM_8852B 2
1208484e1fSPing-Ke Shih 
13*572fd2abSPing-Ke Shih enum rtw8852b_pmac_mode {
14*572fd2abSPing-Ke Shih 	NONE_TEST,
15*572fd2abSPing-Ke Shih 	PKTS_TX,
16*572fd2abSPing-Ke Shih 	PKTS_RX,
17*572fd2abSPing-Ke Shih 	CONT_TX
18*572fd2abSPing-Ke Shih };
19*572fd2abSPing-Ke Shih 
20132dc4feSPing-Ke Shih struct rtw8852b_u_efuse {
21132dc4feSPing-Ke Shih 	u8 rsvd[0x88];
22132dc4feSPing-Ke Shih 	u8 mac_addr[ETH_ALEN];
23132dc4feSPing-Ke Shih };
24132dc4feSPing-Ke Shih 
25132dc4feSPing-Ke Shih struct rtw8852b_e_efuse {
26132dc4feSPing-Ke Shih 	u8 mac_addr[ETH_ALEN];
27132dc4feSPing-Ke Shih };
28132dc4feSPing-Ke Shih 
29132dc4feSPing-Ke Shih struct rtw8852b_tssi_offset {
30132dc4feSPing-Ke Shih 	u8 cck_tssi[TSSI_CCK_CH_GROUP_NUM];
31132dc4feSPing-Ke Shih 	u8 bw40_tssi[TSSI_MCS_2G_CH_GROUP_NUM];
32132dc4feSPing-Ke Shih 	u8 rsvd[7];
33132dc4feSPing-Ke Shih 	u8 bw40_1s_tssi_5g[TSSI_MCS_5G_CH_GROUP_NUM];
34132dc4feSPing-Ke Shih } __packed;
35132dc4feSPing-Ke Shih 
36132dc4feSPing-Ke Shih struct rtw8852b_efuse {
37132dc4feSPing-Ke Shih 	u8 rsvd[0x210];
38132dc4feSPing-Ke Shih 	struct rtw8852b_tssi_offset path_a_tssi;
39132dc4feSPing-Ke Shih 	u8 rsvd1[10];
40132dc4feSPing-Ke Shih 	struct rtw8852b_tssi_offset path_b_tssi;
41132dc4feSPing-Ke Shih 	u8 rsvd2[94];
42132dc4feSPing-Ke Shih 	u8 channel_plan;
43132dc4feSPing-Ke Shih 	u8 xtal_k;
44132dc4feSPing-Ke Shih 	u8 rsvd3;
45132dc4feSPing-Ke Shih 	u8 iqk_lck;
46132dc4feSPing-Ke Shih 	u8 rsvd4[5];
47132dc4feSPing-Ke Shih 	u8 reg_setting:2;
48132dc4feSPing-Ke Shih 	u8 tx_diversity:1;
49132dc4feSPing-Ke Shih 	u8 rx_diversity:2;
50132dc4feSPing-Ke Shih 	u8 ac_mode:1;
51132dc4feSPing-Ke Shih 	u8 module_type:2;
52132dc4feSPing-Ke Shih 	u8 rsvd5;
53132dc4feSPing-Ke Shih 	u8 shared_ant:1;
54132dc4feSPing-Ke Shih 	u8 coex_type:3;
55132dc4feSPing-Ke Shih 	u8 ant_iso:1;
56132dc4feSPing-Ke Shih 	u8 radio_on_off:1;
57132dc4feSPing-Ke Shih 	u8 rsvd6:2;
58132dc4feSPing-Ke Shih 	u8 eeprom_version;
59132dc4feSPing-Ke Shih 	u8 customer_id;
60132dc4feSPing-Ke Shih 	u8 tx_bb_swing_2g;
61132dc4feSPing-Ke Shih 	u8 tx_bb_swing_5g;
62132dc4feSPing-Ke Shih 	u8 tx_cali_pwr_trk_mode;
63132dc4feSPing-Ke Shih 	u8 trx_path_selection;
64132dc4feSPing-Ke Shih 	u8 rfe_type;
65132dc4feSPing-Ke Shih 	u8 country_code[2];
66132dc4feSPing-Ke Shih 	u8 rsvd7[3];
67132dc4feSPing-Ke Shih 	u8 path_a_therm;
68132dc4feSPing-Ke Shih 	u8 path_b_therm;
69132dc4feSPing-Ke Shih 	u8 rsvd8[2];
70132dc4feSPing-Ke Shih 	u8 rx_gain_2g_ofdm;
71132dc4feSPing-Ke Shih 	u8 rsvd9;
72132dc4feSPing-Ke Shih 	u8 rx_gain_2g_cck;
73132dc4feSPing-Ke Shih 	u8 rsvd10;
74132dc4feSPing-Ke Shih 	u8 rx_gain_5g_low;
75132dc4feSPing-Ke Shih 	u8 rsvd11;
76132dc4feSPing-Ke Shih 	u8 rx_gain_5g_mid;
77132dc4feSPing-Ke Shih 	u8 rsvd12;
78132dc4feSPing-Ke Shih 	u8 rx_gain_5g_high;
79132dc4feSPing-Ke Shih 	u8 rsvd13[35];
80132dc4feSPing-Ke Shih 	u8 path_a_cck_pwr_idx[6];
81132dc4feSPing-Ke Shih 	u8 path_a_bw40_1tx_pwr_idx[5];
82132dc4feSPing-Ke Shih 	u8 path_a_ofdm_1tx_pwr_idx_diff:4;
83132dc4feSPing-Ke Shih 	u8 path_a_bw20_1tx_pwr_idx_diff:4;
84132dc4feSPing-Ke Shih 	u8 path_a_bw20_2tx_pwr_idx_diff:4;
85132dc4feSPing-Ke Shih 	u8 path_a_bw40_2tx_pwr_idx_diff:4;
86132dc4feSPing-Ke Shih 	u8 path_a_cck_2tx_pwr_idx_diff:4;
87132dc4feSPing-Ke Shih 	u8 path_a_ofdm_2tx_pwr_idx_diff:4;
88132dc4feSPing-Ke Shih 	u8 rsvd14[0xf2];
89132dc4feSPing-Ke Shih 	union {
90132dc4feSPing-Ke Shih 		struct rtw8852b_u_efuse u;
91132dc4feSPing-Ke Shih 		struct rtw8852b_e_efuse e;
92132dc4feSPing-Ke Shih 	};
93132dc4feSPing-Ke Shih } __packed;
94132dc4feSPing-Ke Shih 
95*572fd2abSPing-Ke Shih struct rtw8852b_bb_pmac_info {
96*572fd2abSPing-Ke Shih 	u8 en_pmac_tx:1;
97*572fd2abSPing-Ke Shih 	u8 is_cck:1;
98*572fd2abSPing-Ke Shih 	u8 mode:3;
99*572fd2abSPing-Ke Shih 	u8 rsvd:3;
100*572fd2abSPing-Ke Shih 	u16 tx_cnt;
101*572fd2abSPing-Ke Shih 	u16 period;
102*572fd2abSPing-Ke Shih 	u16 tx_time;
103*572fd2abSPing-Ke Shih 	u8 duty_cycle;
104*572fd2abSPing-Ke Shih };
105*572fd2abSPing-Ke Shih 
106*572fd2abSPing-Ke Shih struct rtw8852b_bb_tssi_bak {
107*572fd2abSPing-Ke Shih 	u8 tx_path;
108*572fd2abSPing-Ke Shih 	u8 rx_path;
109*572fd2abSPing-Ke Shih 	u32 p0_rfmode;
110*572fd2abSPing-Ke Shih 	u32 p0_rfmode_ftm;
111*572fd2abSPing-Ke Shih 	u32 p1_rfmode;
112*572fd2abSPing-Ke Shih 	u32 p1_rfmode_ftm;
113*572fd2abSPing-Ke Shih 	s16 tx_pwr; /* S9 */
114*572fd2abSPing-Ke Shih };
115*572fd2abSPing-Ke Shih 
1169695dc2eSPing-Ke Shih extern const struct rtw89_chip_info rtw8852b_chip_info;
1179695dc2eSPing-Ke Shih 
118*572fd2abSPing-Ke Shih void rtw8852b_bb_set_plcp_tx(struct rtw89_dev *rtwdev);
119*572fd2abSPing-Ke Shih void rtw8852b_bb_set_pmac_tx(struct rtw89_dev *rtwdev,
120*572fd2abSPing-Ke Shih 			     struct rtw8852b_bb_pmac_info *tx_info,
121*572fd2abSPing-Ke Shih 			     enum rtw89_phy_idx idx);
122*572fd2abSPing-Ke Shih void rtw8852b_bb_set_pmac_pkt_tx(struct rtw89_dev *rtwdev, u8 enable,
123*572fd2abSPing-Ke Shih 				 u16 tx_cnt, u16 period, u16 tx_time,
124*572fd2abSPing-Ke Shih 				 enum rtw89_phy_idx idx);
125*572fd2abSPing-Ke Shih void rtw8852b_bb_set_power(struct rtw89_dev *rtwdev, s16 pwr_dbm,
126*572fd2abSPing-Ke Shih 			   enum rtw89_phy_idx idx);
127*572fd2abSPing-Ke Shih void rtw8852b_bb_cfg_tx_path(struct rtw89_dev *rtwdev, u8 tx_path);
1288915a256SPing-Ke Shih void rtw8852b_bb_ctrl_rx_path(struct rtw89_dev *rtwdev,
1298915a256SPing-Ke Shih 			      enum rtw89_rf_path_bit rx_path);
130*572fd2abSPing-Ke Shih void rtw8852b_bb_tx_mode_switch(struct rtw89_dev *rtwdev,
131*572fd2abSPing-Ke Shih 				enum rtw89_phy_idx idx, u8 mode);
132*572fd2abSPing-Ke Shih void rtw8852b_bb_backup_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx idx,
133*572fd2abSPing-Ke Shih 			     struct rtw8852b_bb_tssi_bak *bak);
134*572fd2abSPing-Ke Shih void rtw8852b_bb_restore_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx idx,
135*572fd2abSPing-Ke Shih 			      const struct rtw8852b_bb_tssi_bak *bak);
1368915a256SPing-Ke Shih 
13708484e1fSPing-Ke Shih #endif
138