1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2018-2019 Realtek Corporation
8 /* BT profile map bit definition */
10 #define BPM_HID BIT(1)
11 #define BPM_A2DP BIT(2)
12 #define BPM_PAN BIT(3)
14 #define COEX_RESP_ACK_BY_WL_FW 0x1
15 #define COEX_REQUEST_TIMEOUT msecs_to_jiffies(10)
17 #define COEX_MIN_DELAY 10 /* delay unit in ms */
18 #define COEX_RFK_TIMEOUT 600 /* RFK timeout in ms */
20 #define COEX_RF_OFF 0x0
21 #define COEX_RF_ON 0x1
23 #define COEX_H2C69_WL_LEAKAP 0xc
24 #define PARA1_H2C69_DIS_5MS 0x1
25 #define PARA1_H2C69_EN_5MS 0x0
27 #define COEX_H2C69_TDMA_SLOT 0xb
28 #define PARA1_H2C69_TDMA_4SLOT 0xc1
29 #define PARA1_H2C69_TDMA_2SLOT 0x1
31 #define TDMA_4SLOT BIT(8)
33 #define COEX_RSSI_STEP 4
34 #define COEX_RSSI_HIGH(rssi) \
35 ({ typeof(rssi) __rssi__ = rssi; \
36 (__rssi__ == COEX_RSSI_STATE_HIGH || \
37 __rssi__ == COEX_RSSI_STATE_STAY_HIGH ? true : false); })
39 #define COEX_RSSI_MEDIUM(rssi) \
40 ({ typeof(rssi) __rssi__ = rssi; \
41 (__rssi__ == COEX_RSSI_STATE_MEDIUM || \
42 __rssi__ == COEX_RSSI_STATE_STAY_MEDIUM ? true : false); })
44 #define COEX_RSSI_LOW(rssi) \
45 ({ typeof(rssi) __rssi__ = rssi; \
46 (__rssi__ == COEX_RSSI_STATE_LOW || \
47 __rssi__ == COEX_RSSI_STATE_STAY_LOW ? true : false); })
49 #define GET_COEX_RESP_BT_SUPP_VER(payload) \
50 le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(39, 32))
51 #define GET_COEX_RESP_BT_SUPP_FEAT(payload) \
52 le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(39, 24))
53 #define GET_COEX_RESP_BT_PATCH_VER(payload) \
54 le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(55, 24))
55 #define GET_COEX_RESP_BT_REG_VAL(payload) \
56 le64_get_bits(*((__le64 *)(payload)), GENMASK_ULL(39, 24))
57 #define GET_COEX_RESP_BT_SCAN_TYPE(payload) \
58 le64_get_bits(*((__le64 *)(payload)), GENMASK(31, 24))
60 enum coex_mp_info_op
{
61 BT_MP_INFO_OP_PATCH_VER
= 0x00,
62 BT_MP_INFO_OP_READ_REG
= 0x11,
63 BT_MP_INFO_OP_SUPP_FEAT
= 0x2a,
64 BT_MP_INFO_OP_SUPP_VER
= 0x2b,
65 BT_MP_INFO_OP_SCAN_TYPE
= 0x2d,
66 BT_MP_INFO_OP_LNA_CONSTRAINT
= 0x32,
69 enum coex_set_ant_phase
{
77 COEX_SET_ANT_2G_FREERUN
,
83 COEX_RSN_2GSCANSTART
= 0,
84 COEX_RSN_5GSCANSTART
= 1,
85 COEX_RSN_SCANFINISH
= 2,
86 COEX_RSN_2GSWITCHBAND
= 3,
87 COEX_RSN_5GSWITCHBAND
= 4,
88 COEX_RSN_2GCONSTART
= 5,
89 COEX_RSN_5GCONSTART
= 6,
90 COEX_RSN_2GCONFINISH
= 7,
91 COEX_RSN_5GCONFINISH
= 8,
93 COEX_RSN_5GMEDIA
= 10,
94 COEX_RSN_MEDIADISCON
= 11,
97 COEX_RSN_WLSTATUS
= 14,
102 enum coex_lte_coex_table_type
{
107 enum coex_gnt_setup_state
{
108 COEX_GNT_SET_HW_PTA
= 0x0,
109 COEX_GNT_SET_SW_LOW
= 0x1,
110 COEX_GNT_SET_SW_HIGH
= 0x3,
113 enum coex_ext_ant_switch_pos_type
{
117 COEX_SWITCH_TO_NOCARE
,
118 COEX_SWITCH_TO_WLG_BT
,
123 enum coex_ext_ant_switch_ctrl_type
{
124 COEX_SWITCH_CTRL_BY_BBSW
,
125 COEX_SWITCH_CTRL_BY_PTA
,
126 COEX_SWITCH_CTRL_BY_ANTDIV
,
127 COEX_SWITCH_CTRL_BY_MAC
,
128 COEX_SWITCH_CTRL_BY_BT
,
129 COEX_SWITCH_CTRL_BY_FW
,
134 enum coex_algorithm
{
135 COEX_ALGO_NOPROFILE
= 0,
140 COEX_ALGO_A2DP_HID
= 5,
141 COEX_ALGO_A2DP_PAN
= 6,
142 COEX_ALGO_PAN_HID
= 7,
143 COEX_ALGO_A2DP_PAN_HID
= 8,
148 enum coex_wl_link_mode
{
149 COEX_WLINK_2G1PORT
= 0x0,
154 enum coex_wl2bt_scoreboard
{
155 COEX_SCBD_ACTIVE
= BIT(0),
156 COEX_SCBD_ONOFF
= BIT(1),
157 COEX_SCBD_SCAN
= BIT(2),
158 COEX_SCBD_UNDERTEST
= BIT(3),
159 COEX_SCBD_RXGAIN
= BIT(4),
160 COEX_SCBD_BT_RFK
= BIT(5),
161 COEX_SCBD_WLBUSY
= BIT(6),
162 COEX_SCBD_EXTFEM
= BIT(8),
163 COEX_SCBD_TDMA
= BIT(9),
164 COEX_SCBD_FIX2M
= BIT(10),
165 COEX_SCBD_ALL
= GENMASK(15, 0),
168 enum coex_power_save_type
{
169 COEX_PS_WIFI_NATIVE
= 0,
174 enum coex_rssi_state
{
175 COEX_RSSI_STATE_HIGH
,
176 COEX_RSSI_STATE_MEDIUM
,
178 COEX_RSSI_STATE_STAY_HIGH
,
179 COEX_RSSI_STATE_STAY_MEDIUM
,
180 COEX_RSSI_STATE_STAY_LOW
,
183 enum coex_notify_type_ips
{
184 COEX_IPS_LEAVE
= 0x0,
185 COEX_IPS_ENTER
= 0x1,
188 enum coex_notify_type_lps
{
189 COEX_LPS_DISABLE
= 0x0,
190 COEX_LPS_ENABLE
= 0x1,
193 enum coex_notify_type_scan
{
200 enum coex_notify_type_switchband
{
204 COEX_SWITCH_TO_24G_NOFORSCAN
,
207 enum coex_notify_type_associate
{
208 COEX_ASSOCIATE_FINISH
,
209 COEX_ASSOCIATE_START
,
210 COEX_ASSOCIATE_5G_FINISH
,
211 COEX_ASSOCIATE_5G_START
,
214 enum coex_notify_type_media_status
{
215 COEX_MEDIA_DISCONNECT
,
217 COEX_MEDIA_CONNECT_5G
,
220 enum coex_bt_status
{
221 COEX_BTSTATUS_NCON_IDLE
= 0,
222 COEX_BTSTATUS_CON_IDLE
= 1,
223 COEX_BTSTATUS_INQ_PAGE
= 2,
224 COEX_BTSTATUS_ACL_BUSY
= 3,
225 COEX_BTSTATUS_SCO_BUSY
= 4,
226 COEX_BTSTATUS_ACL_SCO_BUSY
= 5,
231 enum coex_wl_tput_dir
{
232 COEX_WL_TPUT_TX
= 0x0,
233 COEX_WL_TPUT_RX
= 0x1,
237 enum coex_wl_priority_mask
{
238 COEX_WLPRI_RX_RSP
= 2,
239 COEX_WLPRI_TX_RSP
= 3,
240 COEX_WLPRI_TX_BEACON
= 4,
241 COEX_WLPRI_TX_OFDM
= 11,
242 COEX_WLPRI_TX_CCK
= 12,
243 COEX_WLPRI_TX_BEACONQ
= 27,
244 COEX_WLPRI_RX_CCK
= 28,
245 COEX_WLPRI_RX_OFDM
= 29,
249 enum coex_commom_chip_setup
{
250 COEX_CSETUP_INIT_HW
= 0x0,
251 COEX_CSETUP_ANT_SWITCH
= 0x1,
252 COEX_CSETUP_GNT_FIX
= 0x2,
253 COEX_CSETUP_GNT_DEBUG
= 0x3,
254 COEX_CSETUP_RFE_TYPE
= 0x4,
255 COEX_CSETUP_COEXINFO_HW
= 0x5,
256 COEX_CSETUP_WL_TX_POWER
= 0x6,
257 COEX_CSETUP_WL_RX_GAIN
= 0x7,
258 COEX_CSETUP_WLAN_ACT_IPS
= 0x8,
262 enum coex_indirect_reg_type
{
263 COEX_INDIRECT_1700
= 0x0,
264 COEX_INDIRECT_7C0
= 0x1,
268 enum coex_pstdma_type
{
269 COEX_PSTDMA_FORCE_LPSOFF
= 0x0,
270 COEX_PSTDMA_FORCE_LPSON
= 0x1,
274 enum coex_btrssi_type
{
275 COEX_BTRSSI_RATIO
= 0x0,
276 COEX_BTRSSI_DBM
= 0x1,
280 struct coex_table_para
{
285 struct coex_tdma_para
{
289 struct coex_5g_afh_map
{
295 struct coex_rf_para
{
302 static inline void rtw_coex_set_init(struct rtw_dev
*rtwdev
)
304 struct rtw_chip_info
*chip
= rtwdev
->chip
;
306 chip
->ops
->coex_set_init(rtwdev
);
310 void rtw_coex_set_ant_switch(struct rtw_dev
*rtwdev
, u8 ctrl_type
, u8 pos_type
)
312 struct rtw_chip_info
*chip
= rtwdev
->chip
;
314 if (!chip
->ops
->coex_set_ant_switch
)
317 chip
->ops
->coex_set_ant_switch(rtwdev
, ctrl_type
, pos_type
);
320 static inline void rtw_coex_set_gnt_fix(struct rtw_dev
*rtwdev
)
322 struct rtw_chip_info
*chip
= rtwdev
->chip
;
324 chip
->ops
->coex_set_gnt_fix(rtwdev
);
327 static inline void rtw_coex_set_gnt_debug(struct rtw_dev
*rtwdev
)
329 struct rtw_chip_info
*chip
= rtwdev
->chip
;
331 chip
->ops
->coex_set_gnt_debug(rtwdev
);
334 static inline void rtw_coex_set_rfe_type(struct rtw_dev
*rtwdev
)
336 struct rtw_chip_info
*chip
= rtwdev
->chip
;
338 chip
->ops
->coex_set_rfe_type(rtwdev
);
341 static inline void rtw_coex_set_wl_tx_power(struct rtw_dev
*rtwdev
, u8 wl_pwr
)
343 struct rtw_chip_info
*chip
= rtwdev
->chip
;
345 chip
->ops
->coex_set_wl_tx_power(rtwdev
, wl_pwr
);
349 void rtw_coex_set_wl_rx_gain(struct rtw_dev
*rtwdev
, bool low_gain
)
351 struct rtw_chip_info
*chip
= rtwdev
->chip
;
353 chip
->ops
->coex_set_wl_rx_gain(rtwdev
, low_gain
);
356 void rtw_coex_info_response(struct rtw_dev
*rtwdev
, struct sk_buff
*skb
);
357 u32
rtw_coex_read_indirect_reg(struct rtw_dev
*rtwdev
, u16 addr
);
358 void rtw_coex_write_indirect_reg(struct rtw_dev
*rtwdev
, u16 addr
,
360 void rtw_coex_write_scbd(struct rtw_dev
*rtwdev
, u16 bitpos
, bool set
);
362 void rtw_coex_bt_relink_work(struct work_struct
*work
);
363 void rtw_coex_bt_reenable_work(struct work_struct
*work
);
364 void rtw_coex_defreeze_work(struct work_struct
*work
);
366 void rtw_coex_power_on_setting(struct rtw_dev
*rtwdev
);
367 void rtw_coex_init_hw_config(struct rtw_dev
*rtwdev
, bool wifi_only
);
368 void rtw_coex_ips_notify(struct rtw_dev
*rtwdev
, u8 type
);
369 void rtw_coex_lps_notify(struct rtw_dev
*rtwdev
, u8 type
);
370 void rtw_coex_scan_notify(struct rtw_dev
*rtwdev
, u8 type
);
371 void rtw_coex_connect_notify(struct rtw_dev
*rtwdev
, u8 action
);
372 void rtw_coex_media_status_notify(struct rtw_dev
*rtwdev
, u8 status
);
373 void rtw_coex_bt_info_notify(struct rtw_dev
*rtwdev
, u8
*buf
, u8 len
);
374 void rtw_coex_wl_fwdbginfo_notify(struct rtw_dev
*rtwdev
, u8
*buf
, u8 length
);
375 void rtw_coex_switchband_notify(struct rtw_dev
*rtwdev
, u8 type
);
376 void rtw_coex_wl_status_change_notify(struct rtw_dev
*rtwdev
);
378 void rtw_coex_display_coex_info(struct rtw_dev
*rtwdev
, struct seq_file
*m
);