Lines Matching +full:40 +full:- +full:bit

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /* Copyright(c) 2018-2019 Realtek Corporation
15 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_next_rssi_state()
16 u8 tol = chip->rssi_tolerance; in rtw_coex_next_rssi_state()
38 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_limited_tx()
39 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_limited_tx()
40 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_limited_tx()
43 if (!chip->scbd_support) in rtw_coex_limited_tx()
47 if (coex_stat->wl_tx_limit_en == tx_limit_en && in rtw_coex_limited_tx()
48 coex_stat->wl_ampdu_limit_en == ampdu_limit_en) in rtw_coex_limited_tx()
51 if (!coex_stat->wl_tx_limit_en) { in rtw_coex_limited_tx()
52 coex_stat->darfrc = rtw_read32(rtwdev, REG_DARFRC); in rtw_coex_limited_tx()
53 coex_stat->darfrch = rtw_read32(rtwdev, REG_DARFRCH); in rtw_coex_limited_tx()
54 coex_stat->retry_limit = rtw_read16(rtwdev, REG_RETRY_LIMIT); in rtw_coex_limited_tx()
57 if (!coex_stat->wl_ampdu_limit_en) in rtw_coex_limited_tx()
58 coex_stat->ampdu_max_time = in rtw_coex_limited_tx()
61 coex_stat->wl_tx_limit_en = tx_limit_en; in rtw_coex_limited_tx()
62 coex_stat->wl_ampdu_limit_en = ampdu_limit_en; in rtw_coex_limited_tx()
88 rtw_write16(rtwdev, REG_RETRY_LIMIT, coex_stat->retry_limit); in rtw_coex_limited_tx()
89 rtw_write32(rtwdev, REG_DARFRC, coex_stat->darfrc); in rtw_coex_limited_tx()
90 rtw_write32(rtwdev, REG_DARFRCH, coex_stat->darfrch); in rtw_coex_limited_tx()
97 coex_stat->ampdu_max_time); in rtw_coex_limited_tx()
102 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_limited_wl()
103 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_limited_wl()
104 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_limited_wl()
108 if (coex->under_5g || in rtw_coex_limited_wl()
109 coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { in rtw_coex_limited_wl()
113 if (coex_stat->bt_hid_exist || coex_stat->bt_hfp_exist || in rtw_coex_limited_wl()
114 coex_stat->bt_hid_pair_num > 0) in rtw_coex_limited_wl()
123 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_wl_ccklock_action()
124 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_wl_ccklock_action()
127 if (coex->stop_dm) in rtw_coex_wl_ccklock_action()
132 if (coex_stat->tdma_timer_base == 3 && coex_stat->wl_slot_extend) { in rtw_coex_wl_ccklock_action()
135 coex_stat->wl_slot_extend = false; in rtw_coex_wl_ccklock_action()
136 coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; in rtw_coex_wl_ccklock_action()
140 if (coex_stat->wl_slot_extend && coex_stat->wl_force_lps_ctrl && in rtw_coex_wl_ccklock_action()
141 !coex_stat->wl_cck_lock_ever) { in rtw_coex_wl_ccklock_action()
142 if (coex_stat->wl_fw_dbg_info[7] <= 5) in rtw_coex_wl_ccklock_action()
143 coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND]++; in rtw_coex_wl_ccklock_action()
145 coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; in rtw_coex_wl_ccklock_action()
147 if (coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] == 7) { in rtw_coex_wl_ccklock_action()
150 coex_stat->wl_slot_extend = false; in rtw_coex_wl_ccklock_action()
151 coex_stat->cnt_wl[COEX_CNT_WL_5MS_NOEXTEND] = 0; in rtw_coex_wl_ccklock_action()
153 } else if (!coex_stat->wl_slot_extend && coex_stat->wl_cck_lock) { in rtw_coex_wl_ccklock_action()
156 coex_stat->wl_slot_extend = true; in rtw_coex_wl_ccklock_action()
162 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_wl_ccklock_detect()
163 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_wl_ccklock_detect()
166 coex_stat->wl_cck_lock = false; in rtw_coex_wl_ccklock_detect()
167 coex_stat->wl_cck_lock_pre = false; in rtw_coex_wl_ccklock_detect()
168 coex_stat->wl_cck_lock_ever = false; in rtw_coex_wl_ccklock_detect()
173 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_wl_noisy_detect()
174 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_wl_noisy_detect()
175 struct rtw_dm_info *dm_info = &rtwdev->dm_info; in rtw_coex_wl_noisy_detect()
179 cnt_cck = dm_info->cck_ok_cnt + dm_info->cck_err_cnt; in rtw_coex_wl_noisy_detect()
181 if (!coex_stat->wl_gl_busy) { in rtw_coex_wl_noisy_detect()
183 if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY2] < 5) in rtw_coex_wl_noisy_detect()
184 coex_stat->cnt_wl[COEX_CNT_WL_NOISY2]++; in rtw_coex_wl_noisy_detect()
186 if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY2] == 5) { in rtw_coex_wl_noisy_detect()
187 coex_stat->cnt_wl[COEX_CNT_WL_NOISY0] = 0; in rtw_coex_wl_noisy_detect()
188 coex_stat->cnt_wl[COEX_CNT_WL_NOISY1] = 0; in rtw_coex_wl_noisy_detect()
191 if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY0] < 5) in rtw_coex_wl_noisy_detect()
192 coex_stat->cnt_wl[COEX_CNT_WL_NOISY0]++; in rtw_coex_wl_noisy_detect()
194 if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY0] == 5) { in rtw_coex_wl_noisy_detect()
195 coex_stat->cnt_wl[COEX_CNT_WL_NOISY1] = 0; in rtw_coex_wl_noisy_detect()
196 coex_stat->cnt_wl[COEX_CNT_WL_NOISY2] = 0; in rtw_coex_wl_noisy_detect()
199 if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY1] < 5) in rtw_coex_wl_noisy_detect()
200 coex_stat->cnt_wl[COEX_CNT_WL_NOISY1]++; in rtw_coex_wl_noisy_detect()
202 if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY1] == 5) { in rtw_coex_wl_noisy_detect()
203 coex_stat->cnt_wl[COEX_CNT_WL_NOISY0] = 0; in rtw_coex_wl_noisy_detect()
204 coex_stat->cnt_wl[COEX_CNT_WL_NOISY2] = 0; in rtw_coex_wl_noisy_detect()
208 if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY2] == 5) in rtw_coex_wl_noisy_detect()
209 coex_stat->wl_noisy_level = 2; in rtw_coex_wl_noisy_detect()
210 else if (coex_stat->cnt_wl[COEX_CNT_WL_NOISY1] == 5) in rtw_coex_wl_noisy_detect()
211 coex_stat->wl_noisy_level = 1; in rtw_coex_wl_noisy_detect()
213 coex_stat->wl_noisy_level = 0; in rtw_coex_wl_noisy_detect()
219 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_tdma_timer_base()
220 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_tdma_timer_base()
223 if (coex_stat->tdma_timer_base == type) in rtw_coex_tdma_timer_base()
226 coex_stat->tdma_timer_base = type; in rtw_coex_tdma_timer_base()
230 if (type == 3) /* 4-slot */ in rtw_coex_tdma_timer_base()
231 para[1] = PARA1_H2C69_TDMA_4SLOT; /* 4-slot */ in rtw_coex_tdma_timer_base()
232 else /* 2-slot */ in rtw_coex_tdma_timer_base()
237 /* no 5ms_wl_slot_extend for 4-slot mode */ in rtw_coex_tdma_timer_base()
238 if (coex_stat->tdma_timer_base == 3) in rtw_coex_tdma_timer_base()
250 rtw_write8_mask(rtwdev, addr, BIT(bitmap), data); in rtw_coex_set_wl_pri_mask()
255 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_write_scbd()
256 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_write_scbd()
257 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_write_scbd()
260 if (!chip->scbd_support) in rtw_coex_write_scbd()
263 val |= coex_stat->score_board; in rtw_coex_write_scbd()
268 if (!chip->new_scbd10_def && (bitpos & COEX_SCBD_FIX2M)) { in rtw_coex_write_scbd()
280 if (val != coex_stat->score_board) { in rtw_coex_write_scbd()
281 coex_stat->score_board = val; in rtw_coex_write_scbd()
290 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_read_scbd()
292 if (!chip->scbd_support) in rtw_coex_read_scbd()
300 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_check_rfk()
301 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_check_rfk()
302 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_check_rfk()
303 struct rtw_coex_rfe *coex_rfe = &coex->rfe; in rtw_coex_check_rfk()
308 if (coex_rfe->wlg_at_btg && chip->scbd_support && in rtw_coex_check_rfk()
309 coex_stat->bt_iqk_state != 0xff) { in rtw_coex_check_rfk()
325 coex_stat->bt_iqk_state = 0xff; in rtw_coex_check_rfk()
331 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_query_bt_info()
332 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_query_bt_info()
334 if (coex_stat->bt_disabled) in rtw_coex_query_bt_info()
342 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_monitor_bt_enable()
343 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_monitor_bt_enable()
344 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_monitor_bt_enable()
345 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_monitor_bt_enable()
349 if (chip->scbd_support) { in rtw_coex_monitor_bt_enable()
354 if (coex_stat->bt_disabled != bt_disabled) { in rtw_coex_monitor_bt_enable()
355 rtw_dbg(rtwdev, RTW_DBG_COEX, "coex: BT state changed (%d) -> (%d)\n", in rtw_coex_monitor_bt_enable()
356 coex_stat->bt_disabled, bt_disabled); in rtw_coex_monitor_bt_enable()
358 coex_stat->bt_disabled = bt_disabled; in rtw_coex_monitor_bt_enable()
359 coex_stat->bt_ble_scan_type = 0; in rtw_coex_monitor_bt_enable()
360 coex_dm->cur_bt_lna_lvl = 0; in rtw_coex_monitor_bt_enable()
363 if (!coex_stat->bt_disabled) { in rtw_coex_monitor_bt_enable()
364 coex_stat->bt_reenable = true; in rtw_coex_monitor_bt_enable()
365 ieee80211_queue_delayed_work(rtwdev->hw, in rtw_coex_monitor_bt_enable()
366 &coex->bt_reenable_work, 15 * HZ); in rtw_coex_monitor_bt_enable()
368 coex_stat->bt_mailbox_reply = false; in rtw_coex_monitor_bt_enable()
369 coex_stat->bt_reenable = false; in rtw_coex_monitor_bt_enable()
375 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_update_wl_link_info()
376 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_update_wl_link_info()
377 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_update_wl_link_info()
378 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_update_wl_link_info()
379 struct rtw_traffic_stats *stats = &rtwdev->stats; in rtw_coex_update_wl_link_info()
388 scan = test_bit(RTW_FLAG_SCANNING, rtwdev->flags); in rtw_coex_update_wl_link_info()
389 coex_stat->wl_connected = !!rtwdev->sta_cnt; in rtw_coex_update_wl_link_info()
391 wl_busy = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); in rtw_coex_update_wl_link_info()
392 if (wl_busy != coex_stat->wl_gl_busy) { in rtw_coex_update_wl_link_info()
394 coex_stat->wl_gl_busy = true; in rtw_coex_update_wl_link_info()
396 ieee80211_queue_delayed_work(rtwdev->hw, in rtw_coex_update_wl_link_info()
397 &coex->wl_remain_work, in rtw_coex_update_wl_link_info()
401 if (stats->tx_throughput > stats->rx_throughput) in rtw_coex_update_wl_link_info()
402 coex_stat->wl_tput_dir = COEX_WL_TPUT_TX; in rtw_coex_update_wl_link_info()
404 coex_stat->wl_tput_dir = COEX_WL_TPUT_RX; in rtw_coex_update_wl_link_info()
408 coex_stat->wl_linkscan_proc = true; in rtw_coex_update_wl_link_info()
410 coex_stat->wl_linkscan_proc = false; in rtw_coex_update_wl_link_info()
415 rssi_state = coex_dm->wl_rssi_state[i]; in rtw_coex_update_wl_link_info()
416 rssi_step = chip->wl_rssi_step[i]; in rtw_coex_update_wl_link_info()
417 rssi = rtwdev->dm_info.min_rssi; in rtw_coex_update_wl_link_info()
420 coex_dm->wl_rssi_state[i] = rssi_state; in rtw_coex_update_wl_link_info()
437 if (rtwdev->hal.current_band_type == RTW_BAND_5G) in rtw_coex_update_wl_link_info()
444 coex->under_5g = is_5G; in rtw_coex_update_wl_link_info()
452 pkt_offset = *((u32 *)resp->cb); in get_payload_from_coex_resp()
453 c2h = (struct rtw_c2h_cmd *)(resp->data + pkt_offset); in get_payload_from_coex_resp()
455 return c2h->payload; in get_payload_from_coex_resp()
460 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_info_response()
466 skb_queue_tail(&coex->queue, skb); in rtw_coex_info_response()
467 wake_up(&coex->wait); in rtw_coex_info_response()
473 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_info_request()
476 mutex_lock(&coex->mutex); in rtw_coex_info_request()
480 if (!wait_event_timeout(coex->wait, !skb_queue_empty(&coex->queue), in rtw_coex_info_request()
486 skb_resp = skb_dequeue(&coex->queue); in rtw_coex_info_request()
493 mutex_unlock(&coex->mutex); in rtw_coex_info_request()
540 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_update_bt_link_info()
541 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_update_bt_link_info()
542 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_update_bt_link_info()
543 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_update_bt_link_info()
551 rssi_state = coex_dm->bt_rssi_state[i]; in rtw_coex_update_bt_link_info()
552 rssi_step = chip->bt_rssi_step[i]; in rtw_coex_update_bt_link_info()
553 rssi = coex_stat->bt_rssi; in rtw_coex_update_bt_link_info()
556 coex_dm->bt_rssi_state[i] = rssi_state; in rtw_coex_update_bt_link_info()
560 rssi_state = coex_dm->wl_rssi_state[i]; in rtw_coex_update_bt_link_info()
561 rssi_step = chip->wl_rssi_step[i]; in rtw_coex_update_bt_link_info()
562 rssi = rtwdev->dm_info.min_rssi; in rtw_coex_update_bt_link_info()
565 coex_dm->wl_rssi_state[i] = rssi_state; in rtw_coex_update_bt_link_info()
568 if (coex_stat->bt_ble_scan_en && in rtw_coex_update_bt_link_info()
569 coex_stat->cnt_bt[COEX_CNT_BT_INFOUPDATE] % 3 == 0) { in rtw_coex_update_bt_link_info()
573 coex_stat->bt_ble_scan_type = scan_type; in rtw_coex_update_bt_link_info()
574 if ((coex_stat->bt_ble_scan_type & 0x1) == 0x1) in rtw_coex_update_bt_link_info()
575 coex_stat->bt_init_scan = true; in rtw_coex_update_bt_link_info()
577 coex_stat->bt_init_scan = false; in rtw_coex_update_bt_link_info()
581 coex_stat->bt_profile_num = 0; in rtw_coex_update_bt_link_info()
584 if (!(coex_stat->bt_info_lb2 & COEX_INFO_CONNECTION)) { in rtw_coex_update_bt_link_info()
585 coex_stat->bt_link_exist = false; in rtw_coex_update_bt_link_info()
586 coex_stat->bt_pan_exist = false; in rtw_coex_update_bt_link_info()
587 coex_stat->bt_a2dp_exist = false; in rtw_coex_update_bt_link_info()
588 coex_stat->bt_hid_exist = false; in rtw_coex_update_bt_link_info()
589 coex_stat->bt_hfp_exist = false; in rtw_coex_update_bt_link_info()
592 coex_stat->bt_link_exist = true; in rtw_coex_update_bt_link_info()
593 if (coex_stat->bt_info_lb2 & COEX_INFO_FTP) { in rtw_coex_update_bt_link_info()
594 coex_stat->bt_pan_exist = true; in rtw_coex_update_bt_link_info()
595 coex_stat->bt_profile_num++; in rtw_coex_update_bt_link_info()
597 coex_stat->bt_pan_exist = false; in rtw_coex_update_bt_link_info()
600 if (coex_stat->bt_info_lb2 & COEX_INFO_A2DP) { in rtw_coex_update_bt_link_info()
601 coex_stat->bt_a2dp_exist = true; in rtw_coex_update_bt_link_info()
602 coex_stat->bt_profile_num++; in rtw_coex_update_bt_link_info()
604 coex_stat->bt_a2dp_exist = false; in rtw_coex_update_bt_link_info()
607 if (coex_stat->bt_info_lb2 & COEX_INFO_HID) { in rtw_coex_update_bt_link_info()
608 coex_stat->bt_hid_exist = true; in rtw_coex_update_bt_link_info()
609 coex_stat->bt_profile_num++; in rtw_coex_update_bt_link_info()
611 coex_stat->bt_hid_exist = false; in rtw_coex_update_bt_link_info()
614 if (coex_stat->bt_info_lb2 & COEX_INFO_SCO_ESCO) { in rtw_coex_update_bt_link_info()
615 coex_stat->bt_hfp_exist = true; in rtw_coex_update_bt_link_info()
616 coex_stat->bt_profile_num++; in rtw_coex_update_bt_link_info()
618 coex_stat->bt_hfp_exist = false; in rtw_coex_update_bt_link_info()
622 if (coex_stat->bt_info_lb2 & COEX_INFO_INQ_PAGE) { in rtw_coex_update_bt_link_info()
623 coex_dm->bt_status = COEX_BTSTATUS_INQ_PAGE; in rtw_coex_update_bt_link_info()
624 } else if (!(coex_stat->bt_info_lb2 & COEX_INFO_CONNECTION)) { in rtw_coex_update_bt_link_info()
625 coex_dm->bt_status = COEX_BTSTATUS_NCON_IDLE; in rtw_coex_update_bt_link_info()
626 } else if (coex_stat->bt_info_lb2 == COEX_INFO_CONNECTION) { in rtw_coex_update_bt_link_info()
627 coex_dm->bt_status = COEX_BTSTATUS_CON_IDLE; in rtw_coex_update_bt_link_info()
628 } else if ((coex_stat->bt_info_lb2 & COEX_INFO_SCO_ESCO) || in rtw_coex_update_bt_link_info()
629 (coex_stat->bt_info_lb2 & COEX_INFO_SCO_BUSY)) { in rtw_coex_update_bt_link_info()
630 if (coex_stat->bt_info_lb2 & COEX_INFO_ACL_BUSY) in rtw_coex_update_bt_link_info()
631 coex_dm->bt_status = COEX_BTSTATUS_ACL_SCO_BUSY; in rtw_coex_update_bt_link_info()
633 coex_dm->bt_status = COEX_BTSTATUS_SCO_BUSY; in rtw_coex_update_bt_link_info()
634 } else if (coex_stat->bt_info_lb2 & COEX_INFO_ACL_BUSY) { in rtw_coex_update_bt_link_info()
635 coex_dm->bt_status = COEX_BTSTATUS_ACL_BUSY; in rtw_coex_update_bt_link_info()
637 coex_dm->bt_status = COEX_BTSTATUS_MAX; in rtw_coex_update_bt_link_info()
640 coex_stat->cnt_bt[COEX_CNT_BT_INFOUPDATE]++; in rtw_coex_update_bt_link_info()
642 rtw_dbg(rtwdev, RTW_DBG_COEX, "coex: bt status(%d)\n", coex_dm->bt_status); in rtw_coex_update_bt_link_info()
647 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_update_wl_ch_info()
648 struct rtw_coex_dm *coex_dm = &rtwdev->coex.dm; in rtw_coex_update_wl_ch_info()
649 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_update_wl_ch_info()
655 bw = rtwdev->hal.current_band_width; in rtw_coex_update_wl_ch_info()
658 center_chan = rtwdev->hal.current_channel; in rtw_coex_update_wl_ch_info()
660 if (center_chan == 0 || (efuse->share_ant && center_chan <= 14)) { in rtw_coex_update_wl_ch_info()
666 bw = chip->bt_afh_span_bw40; in rtw_coex_update_wl_ch_info()
668 bw = chip->bt_afh_span_bw20; in rtw_coex_update_wl_ch_info()
669 } else if (chip->afh_5g_num > 1) { in rtw_coex_update_wl_ch_info()
670 for (i = 0; i < chip->afh_5g_num; i++) { in rtw_coex_update_wl_ch_info()
671 if (center_chan == chip->afh_5g[i].wl_5g_ch) { in rtw_coex_update_wl_ch_info()
673 center_chan = chip->afh_5g[i].bt_skip_ch; in rtw_coex_update_wl_ch_info()
674 bw = chip->afh_5g[i].bt_skip_span; in rtw_coex_update_wl_ch_info()
680 coex_dm->wl_ch_info[0] = link; in rtw_coex_update_wl_ch_info()
681 coex_dm->wl_ch_info[1] = center_chan; in rtw_coex_update_wl_ch_info()
682 coex_dm->wl_ch_info[2] = bw; in rtw_coex_update_wl_ch_info()
689 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_set_bt_tx_power()
690 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_set_bt_tx_power()
692 if (bt_pwr_dec_lvl == coex_dm->cur_bt_pwr_lvl) in rtw_coex_set_bt_tx_power()
695 coex_dm->cur_bt_pwr_lvl = bt_pwr_dec_lvl; in rtw_coex_set_bt_tx_power()
702 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_set_bt_rx_gain()
703 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_set_bt_rx_gain()
705 if (bt_lna_lvl == coex_dm->cur_bt_lna_lvl) in rtw_coex_set_bt_rx_gain()
708 coex_dm->cur_bt_lna_lvl = bt_lna_lvl; in rtw_coex_set_bt_rx_gain()
722 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_set_rf_para()
723 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_set_rf_para()
726 if (coex->freerun && coex_stat->wl_noisy_level <= 1) in rtw_coex_set_rf_para()
764 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_coex_ctrl_owner()
765 const struct rtw_hw_reg *btg_reg = chip->btg_reg; in rtw_coex_coex_ctrl_owner()
770 rtw_write8_set(rtwdev, btg_reg->addr, btg_reg->mask); in rtw_coex_coex_ctrl_owner()
774 rtw_write8_clr(rtwdev, btg_reg->addr, btg_reg->mask); in rtw_coex_coex_ctrl_owner()
800 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_table()
801 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_table()
802 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_table()
803 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_table()
805 coex_dm->cur_table = type; in rtw_coex_table()
807 if (efuse->share_ant) { in rtw_coex_table()
808 if (type < chip->table_sant_num) in rtw_coex_table()
810 chip->table_sant[type].bt, in rtw_coex_table()
811 chip->table_sant[type].wl); in rtw_coex_table()
813 type = type - 100; in rtw_coex_table()
814 if (type < chip->table_nsant_num) in rtw_coex_table()
816 chip->table_nsant[type].bt, in rtw_coex_table()
817 chip->table_nsant[type].wl); in rtw_coex_table()
823 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_ignore_wlan_act()
825 if (coex->stop_dm) in rtw_coex_ignore_wlan_act()
834 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_power_save_state()
835 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_power_save_state()
838 lps_mode = rtwdev->lps_conf.mode; in rtw_coex_power_save_state()
843 coex_stat->wl_force_lps_ctrl = false; in rtw_coex_power_save_state()
848 coex_stat->wl_force_lps_ctrl = true; in rtw_coex_power_save_state()
862 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_set_tdma()
863 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_set_tdma()
864 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_set_tdma()
868 if (ap_enable && (byte1 & BIT(4) && !(byte1 & BIT(5)))) { in rtw_coex_set_tdma()
869 byte1 &= ~BIT(4); in rtw_coex_set_tdma()
870 byte1 |= BIT(5); in rtw_coex_set_tdma()
872 byte5 |= BIT(5); in rtw_coex_set_tdma()
873 byte5 &= ~BIT(6); in rtw_coex_set_tdma()
877 } else if (byte1 & BIT(4) && !(byte1 & BIT(5))) { in rtw_coex_set_tdma()
878 if (chip->pstdma_type == COEX_PSTDMA_FORCE_LPSOFF) in rtw_coex_set_tdma()
888 coex_dm->ps_tdma_para[0] = byte1; in rtw_coex_set_tdma()
889 coex_dm->ps_tdma_para[1] = byte2; in rtw_coex_set_tdma()
890 coex_dm->ps_tdma_para[2] = byte3; in rtw_coex_set_tdma()
891 coex_dm->ps_tdma_para[3] = byte4; in rtw_coex_set_tdma()
892 coex_dm->ps_tdma_para[4] = byte5; in rtw_coex_set_tdma()
899 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_tdma()
900 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_tdma()
901 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_tdma()
902 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_tdma()
903 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_tdma()
908 if (tcase & TDMA_4SLOT)/* 4-slot (50ms) mode */ in rtw_coex_tdma()
918 if (turn_on == coex_dm->cur_ps_tdma_on && in rtw_coex_tdma()
919 type == coex_dm->cur_ps_tdma) { in rtw_coex_tdma()
928 wl_busy = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); in rtw_coex_tdma()
930 if ((coex_stat->bt_a2dp_exist && in rtw_coex_tdma()
931 (coex_stat->bt_inq_remain || coex_stat->bt_multi_link)) || in rtw_coex_tdma()
937 if (efuse->share_ant) { in rtw_coex_tdma()
938 if (type < chip->tdma_sant_num) in rtw_coex_tdma()
940 chip->tdma_sant[type].para[0], in rtw_coex_tdma()
941 chip->tdma_sant[type].para[1], in rtw_coex_tdma()
942 chip->tdma_sant[type].para[2], in rtw_coex_tdma()
943 chip->tdma_sant[type].para[3], in rtw_coex_tdma()
944 chip->tdma_sant[type].para[4]); in rtw_coex_tdma()
946 n = type - 100; in rtw_coex_tdma()
947 if (n < chip->tdma_nsant_num) in rtw_coex_tdma()
949 chip->tdma_nsant[n].para[0], in rtw_coex_tdma()
950 chip->tdma_nsant[n].para[1], in rtw_coex_tdma()
951 chip->tdma_nsant[n].para[2], in rtw_coex_tdma()
952 chip->tdma_nsant[n].para[3], in rtw_coex_tdma()
953 chip->tdma_nsant[n].para[4]); in rtw_coex_tdma()
957 coex_dm->cur_ps_tdma_on = turn_on; in rtw_coex_tdma()
958 coex_dm->cur_ps_tdma = type; in rtw_coex_tdma()
965 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_set_ant_path()
966 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_set_ant_path()
967 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_set_ant_path()
971 if (!force && coex_dm->cur_ant_pos_type == phase) in rtw_coex_set_ant_path()
974 coex_dm->cur_ant_pos_type = phase; in rtw_coex_set_ant_path()
981 /* set path control owner to BT at power-on */ in rtw_coex_set_ant_path()
982 if (coex_stat->bt_disabled) in rtw_coex_set_ant_path()
991 if (coex_stat->bt_disabled) { in rtw_coex_set_ant_path()
1094 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_algorithm()
1095 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_algorithm()
1099 if (coex_stat->bt_hfp_exist) in rtw_coex_algorithm()
1101 if (coex_stat->bt_hid_exist) in rtw_coex_algorithm()
1103 if (coex_stat->bt_a2dp_exist) in rtw_coex_algorithm()
1105 if (coex_stat->bt_pan_exist) in rtw_coex_algorithm()
1138 if (coex_stat->bt_multi_link) { in rtw_coex_algorithm()
1139 if (coex_stat->bt_hid_pair_num > 0) in rtw_coex_algorithm()
1157 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_coex_all_off()
1158 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_coex_all_off()
1161 if (efuse->share_ant) { in rtw_coex_action_coex_all_off()
1162 /* Shared-Ant */ in rtw_coex_action_coex_all_off()
1166 /* Non-Shared-Ant */ in rtw_coex_action_coex_all_off()
1171 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_coex_all_off()
1178 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_freerun()
1179 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_freerun()
1180 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_action_freerun()
1181 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_freerun()
1182 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_freerun()
1185 if (efuse->share_ant) in rtw_coex_action_freerun()
1188 coex->freerun = true; in rtw_coex_action_freerun()
1190 if (coex_stat->wl_connected) in rtw_coex_action_freerun()
1197 if (COEX_RSSI_HIGH(coex_dm->wl_rssi_state[0])) in rtw_coex_action_freerun()
1199 else if (COEX_RSSI_HIGH(coex_dm->wl_rssi_state[1])) in rtw_coex_action_freerun()
1201 else if (COEX_RSSI_HIGH(coex_dm->wl_rssi_state[2])) in rtw_coex_action_freerun()
1206 if (level > chip->wl_rf_para_num - 1) in rtw_coex_action_freerun()
1207 level = chip->wl_rf_para_num - 1; in rtw_coex_action_freerun()
1209 if (coex_stat->wl_tput_dir == COEX_WL_TPUT_TX) in rtw_coex_action_freerun()
1210 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_tx[level]); in rtw_coex_action_freerun()
1212 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[level]); in rtw_coex_action_freerun()
1220 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_whql_test()
1221 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_whql_test()
1224 if (efuse->share_ant) { in rtw_coex_action_bt_whql_test()
1225 /* Shared-Ant */ in rtw_coex_action_bt_whql_test()
1229 /* Non-Shared-Ant */ in rtw_coex_action_bt_whql_test()
1235 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_whql_test()
1242 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_relink()
1243 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_relink()
1246 if (efuse->share_ant) { in rtw_coex_action_bt_relink()
1247 /* Shared-Ant */ in rtw_coex_action_bt_relink()
1251 /* Non-Shared-Ant */ in rtw_coex_action_bt_relink()
1257 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_relink()
1264 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_idle()
1265 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_idle()
1266 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_action_bt_idle()
1267 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_idle()
1268 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_idle()
1269 struct rtw_coex_rfe *coex_rfe = &coex->rfe; in rtw_coex_action_bt_idle()
1272 if (coex_rfe->ant_switch_with_bt && in rtw_coex_action_bt_idle()
1273 coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { in rtw_coex_action_bt_idle()
1274 if (efuse->share_ant && in rtw_coex_action_bt_idle()
1275 COEX_RSSI_HIGH(coex_dm->wl_rssi_state[1])) { in rtw_coex_action_bt_idle()
1278 } else if (!efuse->share_ant) { in rtw_coex_action_bt_idle()
1293 if (efuse->share_ant) { in rtw_coex_action_bt_idle()
1294 /* Shared-Ant */ in rtw_coex_action_bt_idle()
1295 if (!coex_stat->wl_gl_busy) { in rtw_coex_action_bt_idle()
1298 } else if (coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { in rtw_coex_action_bt_idle()
1306 /* Non-Shared-Ant */ in rtw_coex_action_bt_idle()
1307 if (!coex_stat->wl_gl_busy) { in rtw_coex_action_bt_idle()
1310 } else if ((coex_stat->bt_ble_scan_type & 0x2) && in rtw_coex_action_bt_idle()
1311 coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE) { in rtw_coex_action_bt_idle()
1320 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_idle()
1327 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_inquiry()
1328 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_inquiry()
1329 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_inquiry()
1330 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_inquiry()
1335 if (coex_stat->wl_linkscan_proc || coex_stat->wl_hi_pri_task1 || in rtw_coex_action_bt_inquiry()
1336 coex_stat->wl_hi_pri_task2) in rtw_coex_action_bt_inquiry()
1339 if (efuse->share_ant) { in rtw_coex_action_bt_inquiry()
1340 /* Shared-Ant */ in rtw_coex_action_bt_inquiry()
1343 if (coex_stat->bt_profile_num > 0) in rtw_coex_action_bt_inquiry()
1345 else if (coex_stat->wl_hi_pri_task1) in rtw_coex_action_bt_inquiry()
1347 else if (!coex_stat->bt_page) in rtw_coex_action_bt_inquiry()
1351 } else if (coex_stat->wl_gl_busy) { in rtw_coex_action_bt_inquiry()
1352 if (coex_stat->bt_profile_num == 0) { in rtw_coex_action_bt_inquiry()
1355 } else if (coex_stat->bt_profile_num == 1 && in rtw_coex_action_bt_inquiry()
1356 !coex_stat->bt_a2dp_exist) { in rtw_coex_action_bt_inquiry()
1365 } else if (coex_stat->wl_connected) { in rtw_coex_action_bt_inquiry()
1373 /* Non_Shared-Ant */ in rtw_coex_action_bt_inquiry()
1376 if (coex_stat->bt_a2dp_exist && in rtw_coex_action_bt_inquiry()
1377 !coex_stat->bt_pan_exist) in rtw_coex_action_bt_inquiry()
1379 else if (coex_stat->wl_hi_pri_task1) in rtw_coex_action_bt_inquiry()
1381 else if (!coex_stat->bt_page) in rtw_coex_action_bt_inquiry()
1385 } else if (coex_stat->wl_gl_busy) { in rtw_coex_action_bt_inquiry()
1388 } else if (coex_stat->wl_connected) { in rtw_coex_action_bt_inquiry()
1398 wl_hi_pri, coex_stat->bt_page); in rtw_coex_action_bt_inquiry()
1401 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_inquiry()
1408 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_hfp()
1409 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_hfp()
1410 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_hfp()
1411 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_hfp()
1414 if (efuse->share_ant) { in rtw_coex_action_bt_hfp()
1415 /* Shared-Ant */ in rtw_coex_action_bt_hfp()
1416 if (coex_stat->bt_multi_link) { in rtw_coex_action_bt_hfp()
1424 /* Non-Shared-Ant */ in rtw_coex_action_bt_hfp()
1425 if (coex_stat->bt_multi_link) { in rtw_coex_action_bt_hfp()
1435 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_hfp()
1442 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_hid()
1443 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_hid()
1444 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_hid()
1445 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_hid()
1449 wl_bw = rtwdev->hal.current_band_width; in rtw_coex_action_bt_hid()
1451 if (efuse->share_ant) { in rtw_coex_action_bt_hid()
1452 /* Shared-Ant */ in rtw_coex_action_bt_hid()
1453 if (coex_stat->bt_ble_exist) { in rtw_coex_action_bt_hid()
1455 if (!coex_stat->wl_gl_busy) in rtw_coex_action_bt_hid()
1460 if (coex_stat->bt_a2dp_active || wl_bw == 0) in rtw_coex_action_bt_hid()
1462 else if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_hid()
1467 if (coex_stat->bt_a2dp_active || wl_bw == 0) { in rtw_coex_action_bt_hid()
1472 if (coex_stat->bt_418_hid_exist && in rtw_coex_action_bt_hid()
1473 coex_stat->wl_gl_busy) in rtw_coex_action_bt_hid()
1481 /* Non-Shared-Ant */ in rtw_coex_action_bt_hid()
1482 if (coex_stat->bt_a2dp_active) { in rtw_coex_action_bt_hid()
1485 } else if (coex_stat->bt_ble_exist) { in rtw_coex_action_bt_hid()
1489 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_hid()
1500 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_hid()
1507 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_a2dp()
1508 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_a2dp()
1509 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_action_bt_a2dp()
1510 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_a2dp()
1511 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_a2dp()
1515 if (efuse->share_ant) { in rtw_coex_action_bt_a2dp()
1516 /* Shared-Ant */ in rtw_coex_action_bt_a2dp()
1519 if (coex_stat->wl_gl_busy && coex_stat->wl_noisy_level == 0) in rtw_coex_action_bt_a2dp()
1524 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_a2dp()
1529 /* Non-Shared-Ant */ in rtw_coex_action_bt_a2dp()
1532 if (COEX_RSSI_HIGH(coex_dm->wl_rssi_state[1])) in rtw_coex_action_bt_a2dp()
1539 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_a2dp()
1546 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_a2dpsink()
1547 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_a2dpsink()
1548 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_a2dpsink()
1549 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_a2dpsink()
1553 if (efuse->share_ant) { /* Shared-Ant */ in rtw_coex_action_bt_a2dpsink()
1557 } else if (coex_stat->wl_gl_busy) { in rtw_coex_action_bt_a2dpsink()
1564 } else { /* Non-Shared-Ant */ in rtw_coex_action_bt_a2dpsink()
1575 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_a2dpsink()
1582 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_pan()
1583 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_pan()
1584 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_pan()
1585 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_pan()
1588 if (efuse->share_ant) { in rtw_coex_action_bt_pan()
1589 /* Shared-Ant */ in rtw_coex_action_bt_pan()
1590 if (coex_stat->wl_gl_busy && coex_stat->wl_noisy_level == 0) in rtw_coex_action_bt_pan()
1595 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_pan()
1600 /* Non-Shared-Ant */ in rtw_coex_action_bt_pan()
1603 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_pan()
1610 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_pan()
1617 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_a2dp_hid()
1618 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_a2dp_hid()
1619 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_action_bt_a2dp_hid()
1620 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_a2dp_hid()
1621 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_a2dp_hid()
1625 if (efuse->share_ant) { in rtw_coex_action_bt_a2dp_hid()
1626 /* Shared-Ant */ in rtw_coex_action_bt_a2dp_hid()
1629 if (coex_stat->bt_ble_exist) in rtw_coex_action_bt_a2dp_hid()
1634 if (coex_stat->wl_gl_busy) { in rtw_coex_action_bt_a2dp_hid()
1640 /* Non-Shared-Ant */ in rtw_coex_action_bt_a2dp_hid()
1641 if (coex_stat->bt_ble_exist) in rtw_coex_action_bt_a2dp_hid()
1646 if (COEX_RSSI_HIGH(coex_dm->wl_rssi_state[1])) in rtw_coex_action_bt_a2dp_hid()
1653 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_a2dp_hid()
1660 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_a2dp_pan()
1661 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_a2dp_pan()
1662 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_a2dp_pan()
1663 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_a2dp_pan()
1666 if (efuse->share_ant) { in rtw_coex_action_bt_a2dp_pan()
1667 /* Shared-Ant */ in rtw_coex_action_bt_a2dp_pan()
1668 if (coex_stat->wl_gl_busy && in rtw_coex_action_bt_a2dp_pan()
1669 coex_stat->wl_noisy_level == 0) in rtw_coex_action_bt_a2dp_pan()
1674 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_a2dp_pan()
1679 /* Non-Shared-Ant */ in rtw_coex_action_bt_a2dp_pan()
1682 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_a2dp_pan()
1689 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_a2dp_pan()
1696 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_pan_hid()
1697 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_pan_hid()
1698 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_pan_hid()
1699 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_pan_hid()
1702 if (efuse->share_ant) { in rtw_coex_action_bt_pan_hid()
1703 /* Shared-Ant */ in rtw_coex_action_bt_pan_hid()
1706 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_pan_hid()
1711 /* Non-Shared-Ant */ in rtw_coex_action_bt_pan_hid()
1714 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_pan_hid()
1721 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_pan_hid()
1728 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_bt_a2dp_pan_hid()
1729 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_bt_a2dp_pan_hid()
1730 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_bt_a2dp_pan_hid()
1731 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_bt_a2dp_pan_hid()
1734 if (efuse->share_ant) { in rtw_coex_action_bt_a2dp_pan_hid()
1735 /* Shared-Ant */ in rtw_coex_action_bt_a2dp_pan_hid()
1738 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_a2dp_pan_hid()
1743 /* Non-Shared-Ant */ in rtw_coex_action_bt_a2dp_pan_hid()
1746 if (coex_stat->wl_gl_busy) in rtw_coex_action_bt_a2dp_pan_hid()
1753 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_bt_a2dp_pan_hid()
1760 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_wl_under5g()
1761 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_wl_under5g()
1766 if (efuse->share_ant) { in rtw_coex_action_wl_under5g()
1767 /* Shared-Ant */ in rtw_coex_action_wl_under5g()
1771 /* Non-Shared-Ant */ in rtw_coex_action_wl_under5g()
1777 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_wl_under5g()
1784 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_wl_only()
1785 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_wl_only()
1788 if (efuse->share_ant) { in rtw_coex_action_wl_only()
1789 /* Shared-Ant */ in rtw_coex_action_wl_only()
1793 /* Non-Shared-Ant */ in rtw_coex_action_wl_only()
1799 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_wl_only()
1806 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_wl_native_lps()
1807 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_wl_native_lps()
1808 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_wl_native_lps()
1811 if (coex->under_5g) in rtw_coex_action_wl_native_lps()
1814 if (efuse->share_ant) { in rtw_coex_action_wl_native_lps()
1815 /* Shared-Ant */ in rtw_coex_action_wl_native_lps()
1819 /* Non-Shared-Ant */ in rtw_coex_action_wl_native_lps()
1825 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_wl_native_lps()
1832 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_wl_linkscan()
1833 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_wl_linkscan()
1834 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_wl_linkscan()
1835 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_wl_linkscan()
1839 if (efuse->share_ant) { in rtw_coex_action_wl_linkscan()
1840 /* Shared-Ant */ in rtw_coex_action_wl_linkscan()
1841 if (coex_stat->bt_a2dp_exist) { in rtw_coex_action_wl_linkscan()
1850 /* Non-Shared-Ant */ in rtw_coex_action_wl_linkscan()
1851 if (coex_stat->bt_a2dp_exist) { in rtw_coex_action_wl_linkscan()
1861 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_wl_linkscan()
1868 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_wl_not_connected()
1869 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_action_wl_not_connected()
1872 if (efuse->share_ant) { in rtw_coex_action_wl_not_connected()
1873 /* Shared-Ant */ in rtw_coex_action_wl_not_connected()
1877 /* Non-Shared-Ant */ in rtw_coex_action_wl_not_connected()
1883 rtw_coex_set_rf_para(rtwdev, chip->wl_rf_para_rx[0]); in rtw_coex_action_wl_not_connected()
1890 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_action_wl_connected()
1891 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_action_wl_connected()
1892 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_action_wl_connected()
1893 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_action_wl_connected()
1896 /* Non-Shared-Ant */ in rtw_coex_action_wl_connected()
1897 if (!efuse->share_ant && coex_stat->wl_gl_busy && in rtw_coex_action_wl_connected()
1898 COEX_RSSI_HIGH(coex_dm->wl_rssi_state[3]) && in rtw_coex_action_wl_connected()
1899 COEX_RSSI_HIGH(coex_dm->bt_rssi_state[0])) { in rtw_coex_action_wl_connected()
1914 if (coex_stat->bt_a2dp_sink) in rtw_coex_action_wl_connected()
1943 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_run_coex()
1944 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_run_coex()
1945 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_run_coex()
1947 lockdep_assert_held(&rtwdev->mutex); in rtw_coex_run_coex()
1949 if (!test_bit(RTW_FLAG_RUNNING, rtwdev->flags)) in rtw_coex_run_coex()
1952 coex_dm->reason = reason; in rtw_coex_run_coex()
1959 if (coex->stop_dm) in rtw_coex_run_coex()
1962 if (coex_stat->wl_under_ips) in rtw_coex_run_coex()
1965 if (coex->freeze && coex_dm->reason == COEX_RSN_BTINFO && in rtw_coex_run_coex()
1966 !coex_stat->bt_setup_link) in rtw_coex_run_coex()
1969 coex_stat->cnt_wl[COEX_CNT_WL_COEXRUN]++; in rtw_coex_run_coex()
1970 coex->freerun = false; in rtw_coex_run_coex()
1972 /* Pure-5G Coex Process */ in rtw_coex_run_coex()
1973 if (coex->under_5g) { in rtw_coex_run_coex()
1974 coex_stat->wl_coex_mode = COEX_WLINK_5G; in rtw_coex_run_coex()
1979 coex_stat->wl_coex_mode = COEX_WLINK_2G1PORT; in rtw_coex_run_coex()
1981 if (coex_stat->bt_disabled) { in rtw_coex_run_coex()
1986 if (coex_stat->wl_under_lps && !coex_stat->wl_force_lps_ctrl) { in rtw_coex_run_coex()
1991 if (coex_stat->bt_whck_test) { in rtw_coex_run_coex()
1996 if (coex_stat->bt_setup_link) { in rtw_coex_run_coex()
2001 if (coex_stat->bt_inq_page) { in rtw_coex_run_coex()
2006 if ((coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE || in rtw_coex_run_coex()
2007 coex_dm->bt_status == COEX_BTSTATUS_CON_IDLE) && in rtw_coex_run_coex()
2008 coex_stat->wl_connected) { in rtw_coex_run_coex()
2013 if (coex_stat->wl_linkscan_proc) { in rtw_coex_run_coex()
2018 if (coex_stat->wl_connected) in rtw_coex_run_coex()
2030 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_init_coex_var()
2031 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_init_coex_var()
2032 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_init_coex_var()
2039 coex_stat->cnt_wl[i] = 0; in rtw_coex_init_coex_var()
2042 coex_stat->cnt_bt[i] = 0; in rtw_coex_init_coex_var()
2044 for (i = 0; i < ARRAY_SIZE(coex_dm->bt_rssi_state); i++) in rtw_coex_init_coex_var()
2045 coex_dm->bt_rssi_state[i] = COEX_RSSI_STATE_LOW; in rtw_coex_init_coex_var()
2047 for (i = 0; i < ARRAY_SIZE(coex_dm->wl_rssi_state); i++) in rtw_coex_init_coex_var()
2048 coex_dm->wl_rssi_state[i] = COEX_RSSI_STATE_LOW; in rtw_coex_init_coex_var()
2050 coex_stat->wl_coex_mode = COEX_WLINK_MAX; in rtw_coex_init_coex_var()
2055 struct rtw_coex *coex = &rtwdev->coex; in __rtw_coex_init_hw_config()
2062 /* set Tx response = Hi-Pri (ex: Transmitting ACK,BA,CTS) */ in __rtw_coex_init_hw_config()
2065 /* set Tx beacon = Hi-Pri */ in __rtw_coex_init_hw_config()
2068 /* set Tx beacon queue = Hi-Pri */ in __rtw_coex_init_hw_config()
2072 if (coex->wl_rf_off) { in __rtw_coex_init_hw_config()
2075 coex->stop_dm = true; in __rtw_coex_init_hw_config()
2080 coex->stop_dm = true; in __rtw_coex_init_hw_config()
2085 coex->stop_dm = false; in __rtw_coex_init_hw_config()
2086 coex->freeze = true; in __rtw_coex_init_hw_config()
2097 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_power_on_setting()
2099 coex->stop_dm = true; in rtw_coex_power_on_setting()
2100 coex->wl_rf_off = false; in rtw_coex_power_on_setting()
2103 rtw_write8_set(rtwdev, REG_SYS_FUNC_EN, BIT(0) | BIT(1)); in rtw_coex_power_on_setting()
2122 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_ips_notify()
2123 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_ips_notify()
2125 if (coex->stop_dm) in rtw_coex_ips_notify()
2129 coex_stat->wl_under_ips = true; in rtw_coex_ips_notify()
2143 coex_stat->wl_under_ips = false; in rtw_coex_ips_notify()
2149 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_lps_notify()
2150 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_lps_notify()
2152 if (coex->stop_dm) in rtw_coex_lps_notify()
2156 coex_stat->wl_under_lps = true; in rtw_coex_lps_notify()
2158 if (coex_stat->wl_force_lps_ctrl) { in rtw_coex_lps_notify()
2159 /* for ps-tdma */ in rtw_coex_lps_notify()
2168 coex_stat->wl_under_lps = false; in rtw_coex_lps_notify()
2173 if (!coex_stat->wl_force_lps_ctrl) in rtw_coex_lps_notify()
2180 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_scan_notify()
2181 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_scan_notify()
2183 if (coex->stop_dm) in rtw_coex_scan_notify()
2186 coex->freeze = false; in rtw_coex_scan_notify()
2196 coex_stat->wl_hi_pri_task2 = true; in rtw_coex_scan_notify()
2202 coex_stat->wl_hi_pri_task2 = false; in rtw_coex_scan_notify()
2209 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_switchband_notify()
2211 if (coex->stop_dm) in rtw_coex_switchband_notify()
2224 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_connect_notify()
2225 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_connect_notify()
2227 if (coex->stop_dm) in rtw_coex_connect_notify()
2240 coex_stat->wl_hi_pri_task1 = true; in rtw_coex_connect_notify()
2241 coex_stat->cnt_wl[COEX_CNT_WL_CONNPKT] = 2; in rtw_coex_connect_notify()
2251 coex->freeze = true; in rtw_coex_connect_notify()
2252 ieee80211_queue_delayed_work(rtwdev->hw, &coex->defreeze_work, in rtw_coex_connect_notify()
2255 coex_stat->wl_hi_pri_task1 = false; in rtw_coex_connect_notify()
2256 coex->freeze = false; in rtw_coex_connect_notify()
2264 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_media_status_notify()
2265 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_media_status_notify()
2268 if (coex->stop_dm) in rtw_coex_media_status_notify()
2289 coex_stat->wl_slot_extend = true; in rtw_coex_media_status_notify()
2304 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_bt_info_notify()
2305 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_bt_info_notify()
2306 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_bt_info_notify()
2316 coex_stat->bt_iqk_state = buf[1]; in rtw_coex_bt_info_notify()
2317 if (coex_stat->bt_iqk_state == 1) in rtw_coex_bt_info_notify()
2318 coex_stat->cnt_bt[COEX_CNT_BT_IQK]++; in rtw_coex_bt_info_notify()
2319 else if (coex_stat->bt_iqk_state == 2) in rtw_coex_bt_info_notify()
2320 coex_stat->cnt_bt[COEX_CNT_BT_IQKFAIL]++; in rtw_coex_bt_info_notify()
2327 if (coex_stat->bt_disabled != coex_stat->bt_disabled_pre) { in rtw_coex_bt_info_notify()
2328 coex_stat->bt_disabled_pre = coex_stat->bt_disabled; in rtw_coex_bt_info_notify()
2336 if (coex_stat->bt_disabled) { in rtw_coex_bt_info_notify()
2337 coex_stat->bt_disabled = false; in rtw_coex_bt_info_notify()
2338 coex_stat->bt_reenable = true; in rtw_coex_bt_info_notify()
2339 ieee80211_queue_delayed_work(rtwdev->hw, in rtw_coex_bt_info_notify()
2340 &coex->bt_reenable_work, in rtw_coex_bt_info_notify()
2347 coex_stat->bt_info_c2h[rsp_source][i] = buf[i]; in rtw_coex_bt_info_notify()
2359 if (coex_stat->bt_info_c2h[rsp_source][1] == coex_stat->bt_info_lb2 && in rtw_coex_bt_info_notify()
2360 coex_stat->bt_info_c2h[rsp_source][2] == coex_stat->bt_info_lb3 && in rtw_coex_bt_info_notify()
2361 coex_stat->bt_info_c2h[rsp_source][3] == coex_stat->bt_info_hb0 && in rtw_coex_bt_info_notify()
2362 coex_stat->bt_info_c2h[rsp_source][4] == coex_stat->bt_info_hb1 && in rtw_coex_bt_info_notify()
2363 coex_stat->bt_info_c2h[rsp_source][5] == coex_stat->bt_info_hb2 && in rtw_coex_bt_info_notify()
2364 coex_stat->bt_info_c2h[rsp_source][6] == coex_stat->bt_info_hb3) in rtw_coex_bt_info_notify()
2367 coex_stat->bt_info_lb2 = coex_stat->bt_info_c2h[rsp_source][1]; in rtw_coex_bt_info_notify()
2368 coex_stat->bt_info_lb3 = coex_stat->bt_info_c2h[rsp_source][2]; in rtw_coex_bt_info_notify()
2369 coex_stat->bt_info_hb0 = coex_stat->bt_info_c2h[rsp_source][3]; in rtw_coex_bt_info_notify()
2370 coex_stat->bt_info_hb1 = coex_stat->bt_info_c2h[rsp_source][4]; in rtw_coex_bt_info_notify()
2371 coex_stat->bt_info_hb2 = coex_stat->bt_info_c2h[rsp_source][5]; in rtw_coex_bt_info_notify()
2372 coex_stat->bt_info_hb3 = coex_stat->bt_info_c2h[rsp_source][6]; in rtw_coex_bt_info_notify()
2375 coex_stat->bt_whck_test = (coex_stat->bt_info_lb2 == 0xff); in rtw_coex_bt_info_notify()
2377 inq_page = ((coex_stat->bt_info_lb2 & BIT(2)) == BIT(2)); in rtw_coex_bt_info_notify()
2379 if (inq_page != coex_stat->bt_inq_page) { in rtw_coex_bt_info_notify()
2380 cancel_delayed_work_sync(&coex->bt_remain_work); in rtw_coex_bt_info_notify()
2381 coex_stat->bt_inq_page = inq_page; in rtw_coex_bt_info_notify()
2384 coex_stat->bt_inq_remain = true; in rtw_coex_bt_info_notify()
2386 ieee80211_queue_delayed_work(rtwdev->hw, in rtw_coex_bt_info_notify()
2387 &coex->bt_remain_work, in rtw_coex_bt_info_notify()
2390 coex_stat->bt_acl_busy = ((coex_stat->bt_info_lb2 & BIT(3)) == BIT(3)); in rtw_coex_bt_info_notify()
2391 coex_stat->cnt_bt[COEX_CNT_BT_RETRY] = coex_stat->bt_info_lb3 & 0xf; in rtw_coex_bt_info_notify()
2392 if (coex_stat->cnt_bt[COEX_CNT_BT_RETRY] >= 1) in rtw_coex_bt_info_notify()
2393 coex_stat->cnt_bt[COEX_CNT_BT_POPEVENT]++; in rtw_coex_bt_info_notify()
2395 coex_stat->bt_fix_2M = ((coex_stat->bt_info_lb3 & BIT(4)) == BIT(4)); in rtw_coex_bt_info_notify()
2396 coex_stat->bt_inq = ((coex_stat->bt_info_lb3 & BIT(5)) == BIT(5)); in rtw_coex_bt_info_notify()
2397 if (coex_stat->bt_inq) in rtw_coex_bt_info_notify()
2398 coex_stat->cnt_bt[COEX_CNT_BT_INQ]++; in rtw_coex_bt_info_notify()
2400 coex_stat->bt_page = ((coex_stat->bt_info_lb3 & BIT(7)) == BIT(7)); in rtw_coex_bt_info_notify()
2401 if (coex_stat->bt_page) { in rtw_coex_bt_info_notify()
2402 coex_stat->cnt_bt[COEX_CNT_BT_PAGE]++; in rtw_coex_bt_info_notify()
2403 if (coex_stat->wl_linkscan_proc || in rtw_coex_bt_info_notify()
2404 coex_stat->wl_hi_pri_task1 || in rtw_coex_bt_info_notify()
2405 coex_stat->wl_hi_pri_task2 || coex_stat->wl_gl_busy) in rtw_coex_bt_info_notify()
2413 /* unit: % (value-100 to translate to unit: dBm in coex info) */ in rtw_coex_bt_info_notify()
2414 if (chip->bt_rssi_type == COEX_BTRSSI_RATIO) { in rtw_coex_bt_info_notify()
2415 coex_stat->bt_rssi = coex_stat->bt_info_hb0 * 2 + 10; in rtw_coex_bt_info_notify()
2416 } else { /* original unit: dbm -> unit: % -> value-100 in coex info */ in rtw_coex_bt_info_notify()
2417 if (coex_stat->bt_info_hb0 <= 127) in rtw_coex_bt_info_notify()
2418 coex_stat->bt_rssi = 100; in rtw_coex_bt_info_notify()
2419 else if (256 - coex_stat->bt_info_hb0 <= 100) in rtw_coex_bt_info_notify()
2420 coex_stat->bt_rssi = 100 - (256 - coex_stat->bt_info_hb0); in rtw_coex_bt_info_notify()
2422 coex_stat->bt_rssi = 0; in rtw_coex_bt_info_notify()
2425 coex_stat->bt_ble_exist = ((coex_stat->bt_info_hb1 & BIT(0)) == BIT(0)); in rtw_coex_bt_info_notify()
2426 if (coex_stat->bt_info_hb1 & BIT(1)) in rtw_coex_bt_info_notify()
2427 coex_stat->cnt_bt[COEX_CNT_BT_REINIT]++; in rtw_coex_bt_info_notify()
2429 if (coex_stat->bt_info_hb1 & BIT(2)) { in rtw_coex_bt_info_notify()
2430 coex_stat->cnt_bt[COEX_CNT_BT_SETUPLINK]++; in rtw_coex_bt_info_notify()
2431 coex_stat->bt_setup_link = true; in rtw_coex_bt_info_notify()
2432 if (coex_stat->bt_reenable) in rtw_coex_bt_info_notify()
2437 ieee80211_queue_delayed_work(rtwdev->hw, in rtw_coex_bt_info_notify()
2438 &coex->bt_relink_work, in rtw_coex_bt_info_notify()
2442 if (coex_stat->bt_info_hb1 & BIT(3)) in rtw_coex_bt_info_notify()
2443 coex_stat->cnt_bt[COEX_CNT_BT_IGNWLANACT]++; in rtw_coex_bt_info_notify()
2445 coex_stat->bt_ble_voice = ((coex_stat->bt_info_hb1 & BIT(4)) == BIT(4)); in rtw_coex_bt_info_notify()
2446 coex_stat->bt_ble_scan_en = ((coex_stat->bt_info_hb1 & BIT(5)) == BIT(5)); in rtw_coex_bt_info_notify()
2447 if (coex_stat->bt_info_hb1 & BIT(6)) in rtw_coex_bt_info_notify()
2448 coex_stat->cnt_bt[COEX_CNT_BT_ROLESWITCH]++; in rtw_coex_bt_info_notify()
2450 coex_stat->bt_multi_link = ((coex_stat->bt_info_hb1 & BIT(7)) == BIT(7)); in rtw_coex_bt_info_notify()
2452 if ((coex_stat->bt_info_hb1 & BIT(1))) { in rtw_coex_bt_info_notify()
2453 if (coex_stat->wl_connected) in rtw_coex_bt_info_notify()
2461 if ((coex_stat->bt_info_hb1 & BIT(3)) && in rtw_coex_bt_info_notify()
2462 (!(coex_stat->bt_info_hb1 & BIT(2)))) in rtw_coex_bt_info_notify()
2465 coex_stat->bt_opp_exist = ((coex_stat->bt_info_hb2 & BIT(0)) == BIT(0)); in rtw_coex_bt_info_notify()
2466 if (coex_stat->bt_info_hb2 & BIT(1)) in rtw_coex_bt_info_notify()
2467 coex_stat->cnt_bt[COEX_CNT_BT_AFHUPDATE]++; in rtw_coex_bt_info_notify()
2469 coex_stat->bt_a2dp_active = (coex_stat->bt_info_hb2 & BIT(2)) == BIT(2); in rtw_coex_bt_info_notify()
2470 coex_stat->bt_slave = ((coex_stat->bt_info_hb2 & BIT(3)) == BIT(3)); in rtw_coex_bt_info_notify()
2471 coex_stat->bt_hid_slot = (coex_stat->bt_info_hb2 & 0x30) >> 4; in rtw_coex_bt_info_notify()
2472 coex_stat->bt_hid_pair_num = (coex_stat->bt_info_hb2 & 0xc0) >> 6; in rtw_coex_bt_info_notify()
2473 if (coex_stat->bt_hid_pair_num > 0 && coex_stat->bt_hid_slot >= 2) in rtw_coex_bt_info_notify()
2474 coex_stat->bt_418_hid_exist = true; in rtw_coex_bt_info_notify()
2475 else if (coex_stat->bt_hid_pair_num == 0) in rtw_coex_bt_info_notify()
2476 coex_stat->bt_418_hid_exist = false; in rtw_coex_bt_info_notify()
2478 if ((coex_stat->bt_info_lb2 & 0x49) == 0x49) in rtw_coex_bt_info_notify()
2479 coex_stat->bt_a2dp_bitpool = (coex_stat->bt_info_hb3 & 0x7f); in rtw_coex_bt_info_notify()
2481 coex_stat->bt_a2dp_bitpool = 0; in rtw_coex_bt_info_notify()
2483 coex_stat->bt_a2dp_sink = ((coex_stat->bt_info_hb3 & BIT(7)) == BIT(7)); in rtw_coex_bt_info_notify()
2491 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_wl_fwdbginfo_notify()
2492 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_wl_fwdbginfo_notify()
2503 val = coex_stat->wl_fw_dbg_info_pre[i]; in rtw_coex_wl_fwdbginfo_notify()
2505 coex_stat->wl_fw_dbg_info[i] = buf[i] - val; in rtw_coex_wl_fwdbginfo_notify()
2507 coex_stat->wl_fw_dbg_info[i] = val - buf[i]; in rtw_coex_wl_fwdbginfo_notify()
2509 coex_stat->wl_fw_dbg_info_pre[i] = buf[i]; in rtw_coex_wl_fwdbginfo_notify()
2512 coex_stat->cnt_wl[COEX_CNT_WL_FW_NOTIFY]++; in rtw_coex_wl_fwdbginfo_notify()
2519 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_wl_status_change_notify()
2521 if (coex->stop_dm) in rtw_coex_wl_status_change_notify()
2531 struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; in rtw_coex_bt_relink_work()
2533 mutex_lock(&rtwdev->mutex); in rtw_coex_bt_relink_work()
2534 coex_stat->bt_setup_link = false; in rtw_coex_bt_relink_work()
2536 mutex_unlock(&rtwdev->mutex); in rtw_coex_bt_relink_work()
2543 struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; in rtw_coex_bt_reenable_work()
2545 mutex_lock(&rtwdev->mutex); in rtw_coex_bt_reenable_work()
2546 coex_stat->bt_reenable = false; in rtw_coex_bt_reenable_work()
2547 mutex_unlock(&rtwdev->mutex); in rtw_coex_bt_reenable_work()
2554 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_defreeze_work()
2555 struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; in rtw_coex_defreeze_work()
2557 mutex_lock(&rtwdev->mutex); in rtw_coex_defreeze_work()
2558 coex->freeze = false; in rtw_coex_defreeze_work()
2559 coex_stat->wl_hi_pri_task1 = false; in rtw_coex_defreeze_work()
2561 mutex_unlock(&rtwdev->mutex); in rtw_coex_defreeze_work()
2568 struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; in rtw_coex_wl_remain_work()
2570 mutex_lock(&rtwdev->mutex); in rtw_coex_wl_remain_work()
2571 coex_stat->wl_gl_busy = test_bit(RTW_FLAG_BUSY_TRAFFIC, rtwdev->flags); in rtw_coex_wl_remain_work()
2573 mutex_unlock(&rtwdev->mutex); in rtw_coex_wl_remain_work()
2580 struct rtw_coex_stat *coex_stat = &rtwdev->coex.stat; in rtw_coex_bt_remain_work()
2582 mutex_lock(&rtwdev->mutex); in rtw_coex_bt_remain_work()
2583 coex_stat->bt_inq_remain = coex_stat->bt_inq_page; in rtw_coex_bt_remain_work()
2585 mutex_unlock(&rtwdev->mutex); in rtw_coex_bt_remain_work()
2640 if (INFO_SIZE - n <= 0) in rtw_coex_addr_info()
2643 switch (reg->domain) { in rtw_coex_addr_info()
2662 ffs = __ffs(reg->mask); in rtw_coex_addr_info()
2663 fls = __fls(reg->mask); in rtw_coex_addr_info()
2666 return scnprintf(addr_info + n, INFO_SIZE - n, "%s%s%x", in rtw_coex_addr_info()
2667 sep, rf_prefix, reg->addr); in rtw_coex_addr_info()
2669 return scnprintf(addr_info + n, INFO_SIZE - n, "%s%s%x[%d]", in rtw_coex_addr_info()
2670 sep, rf_prefix, reg->addr, ffs); in rtw_coex_addr_info()
2672 return scnprintf(addr_info + n, INFO_SIZE - n, "%s%s%x[%d:%d]", in rtw_coex_addr_info()
2673 sep, rf_prefix, reg->addr, fls, ffs); in rtw_coex_addr_info()
2683 if (INFO_SIZE - n <= 0) in rtw_coex_val_info()
2686 switch (reg->domain) { in rtw_coex_val_info()
2688 return scnprintf(val_info + n, INFO_SIZE - n, "%s0x%x", sep, in rtw_coex_val_info()
2689 rtw_read32_mask(rtwdev, reg->addr, reg->mask)); in rtw_coex_val_info()
2691 return scnprintf(val_info + n, INFO_SIZE - n, "%s0x%x", sep, in rtw_coex_val_info()
2692 rtw_read16_mask(rtwdev, reg->addr, reg->mask)); in rtw_coex_val_info()
2694 return scnprintf(val_info + n, INFO_SIZE - n, "%s0x%x", sep, in rtw_coex_val_info()
2695 rtw_read8_mask(rtwdev, reg->addr, reg->mask)); in rtw_coex_val_info()
2707 return scnprintf(val_info + n, INFO_SIZE - n, "%s0x%x", sep, in rtw_coex_val_info()
2708 rtw_read_rf(rtwdev, rf_path, reg->addr, reg->mask)); in rtw_coex_val_info()
2713 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_set_coexinfo_hw()
2721 for (i = 0; i < chip->coex_info_hw_regs_num; i++) { in rtw_coex_set_coexinfo_hw()
2722 reg = &chip->coex_info_hw_regs[i]; in rtw_coex_set_coexinfo_hw()
2727 if (reg->domain == RTW_REG_DOMAIN_NL) { in rtw_coex_set_coexinfo_hw()
2728 seq_printf(m, "%-40s = %s\n", addr_info, val_info); in rtw_coex_set_coexinfo_hw()
2735 seq_printf(m, "%-40s = %s\n", addr_info, val_info); in rtw_coex_set_coexinfo_hw()
2834 struct rtw_vif *rtwvif = sta_iter_data->rtwvif; in rtw_coex_sta_stat_iter()
2835 struct rtw_sta_info *si = (struct rtw_sta_info *)sta->drv_priv; in rtw_coex_sta_stat_iter()
2836 struct seq_file *m = sta_iter_data->file; in rtw_coex_sta_stat_iter()
2840 if (si->vif != vif) in rtw_coex_sta_stat_iter()
2843 rssi = ewma_rssi_read(&si->avg_rssi); in rtw_coex_sta_stat_iter()
2844 seq_printf(m, "\tPeer %3d\n", si->mac_id); in rtw_coex_sta_stat_iter()
2845 seq_printf(m, "\t\t%-24s = %d\n", "RSSI", rssi); in rtw_coex_sta_stat_iter()
2846 seq_printf(m, "\t\t%-24s = %d\n", "BW mode", si->bw_mode); in rtw_coex_sta_stat_iter()
2859 struct rtw_dev *rtwdev = vif_iter_data->rtwdev; in rtw_coex_vif_stat_iter()
2860 struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv; in rtw_coex_vif_stat_iter()
2861 struct seq_file *m = vif_iter_data->file; in rtw_coex_vif_stat_iter()
2862 struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; in rtw_coex_vif_stat_iter()
2864 seq_printf(m, "Iface on Port (%d)\n", rtwvif->port); in rtw_coex_vif_stat_iter()
2865 seq_printf(m, "\t%-32s = %d\n", in rtw_coex_vif_stat_iter()
2866 "Beacon interval", bss_conf->beacon_int); in rtw_coex_vif_stat_iter()
2867 seq_printf(m, "\t%-32s = %d\n", in rtw_coex_vif_stat_iter()
2868 "Network Type", rtwvif->net_type); in rtw_coex_vif_stat_iter()
2878 struct rtw_chip_info *chip = rtwdev->chip; in rtw_coex_display_coex_info()
2879 struct rtw_dm_info *dm_info = &rtwdev->dm_info; in rtw_coex_display_coex_info()
2880 struct rtw_coex *coex = &rtwdev->coex; in rtw_coex_display_coex_info()
2881 struct rtw_coex_stat *coex_stat = &coex->stat; in rtw_coex_display_coex_info()
2882 struct rtw_coex_dm *coex_dm = &coex->dm; in rtw_coex_display_coex_info()
2883 struct rtw_hal *hal = &rtwdev->hal; in rtw_coex_display_coex_info()
2884 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_coex_display_coex_info()
2885 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_coex_display_coex_info()
2887 u8 reason = coex_dm->reason; in rtw_coex_display_coex_info()
2896 score_board_WB = coex_stat->score_board; in rtw_coex_display_coex_info()
2909 if (!coex_stat->bt_disabled && !coex_stat->bt_mailbox_reply) { in rtw_coex_display_coex_info()
2911 &coex_stat->bt_supported_version); in rtw_coex_display_coex_info()
2912 rtw_coex_get_bt_patch_version(rtwdev, &coex_stat->patch_ver); in rtw_coex_display_coex_info()
2914 &coex_stat->bt_supported_feature); in rtw_coex_display_coex_info()
2915 rtw_coex_get_bt_reg(rtwdev, 3, 0xae, &coex_stat->bt_reg_vendor_ae); in rtw_coex_display_coex_info()
2916 rtw_coex_get_bt_reg(rtwdev, 3, 0xac, &coex_stat->bt_reg_vendor_ac); in rtw_coex_display_coex_info()
2918 if (coex_stat->patch_ver != 0) in rtw_coex_display_coex_info()
2919 coex_stat->bt_mailbox_reply = true; in rtw_coex_display_coex_info()
2923 seq_printf(m, "\t\tBT Coexist info %x\n", chip->id); in rtw_coex_display_coex_info()
2925 seq_printf(m, "%-40s = %s/ %d\n", in rtw_coex_display_coex_info()
2927 efuse->share_ant ? "Shared" : "Non-Shared", in rtw_coex_display_coex_info()
2928 efuse->rfe_option); in rtw_coex_display_coex_info()
2929 seq_printf(m, "%-40s = %08x/ 0x%02x/ 0x%08x %s\n", in rtw_coex_display_coex_info()
2931 chip->coex_para_ver, chip->bt_desired_ver, in rtw_coex_display_coex_info()
2932 coex_stat->bt_supported_version, in rtw_coex_display_coex_info()
2933 coex_stat->bt_disabled ? "(BT disabled)" : in rtw_coex_display_coex_info()
2934 coex_stat->bt_supported_version >= chip->bt_desired_ver ? in rtw_coex_display_coex_info()
2936 seq_printf(m, "%-40s = %s/ %u/ %d\n", in rtw_coex_display_coex_info()
2938 coex_stat->bt_slave ? "Slave" : "Master", in rtw_coex_display_coex_info()
2939 coex_stat->cnt_bt[COEX_CNT_BT_ROLESWITCH], in rtw_coex_display_coex_info()
2940 coex_dm->ignore_wl_act); in rtw_coex_display_coex_info()
2941 seq_printf(m, "%-40s = %u.%u/ 0x%x/ %c\n", in rtw_coex_display_coex_info()
2943 fw->version, fw->sub_version, in rtw_coex_display_coex_info()
2944 coex_stat->patch_ver, coex_stat->kt_ver + 65); in rtw_coex_display_coex_info()
2945 seq_printf(m, "%-40s = %u/ %u/ %u/ ch-(%u)\n", in rtw_coex_display_coex_info()
2947 coex_dm->wl_ch_info[0], coex_dm->wl_ch_info[1], in rtw_coex_display_coex_info()
2948 coex_dm->wl_ch_info[2], hal->current_channel); in rtw_coex_display_coex_info()
2953 seq_printf(m, "%-40s = %s/ %ddBm/ %u/ %u\n", in rtw_coex_display_coex_info()
2955 coex_dm->bt_status == COEX_BTSTATUS_NCON_IDLE ? "non-conn" : in rtw_coex_display_coex_info()
2956 coex_dm->bt_status == COEX_BTSTATUS_CON_IDLE ? "conn-idle" : "busy", in rtw_coex_display_coex_info()
2957 coex_stat->bt_rssi - 100, in rtw_coex_display_coex_info()
2958 coex_stat->cnt_bt[COEX_CNT_BT_RETRY], in rtw_coex_display_coex_info()
2959 coex_stat->cnt_bt[COEX_CNT_BT_POPEVENT]); in rtw_coex_display_coex_info()
2960 seq_printf(m, "%-40s = %s%s%s%s%s (multi-link %d)\n", in rtw_coex_display_coex_info()
2962 coex_stat->bt_a2dp_exist ? (coex_stat->bt_a2dp_sink ? in rtw_coex_display_coex_info()
2964 coex_stat->bt_hfp_exist ? "HFP," : "", in rtw_coex_display_coex_info()
2965 coex_stat->bt_hid_exist ? in rtw_coex_display_coex_info()
2966 (coex_stat->bt_ble_exist ? "HID(RCU)," : in rtw_coex_display_coex_info()
2967 coex_stat->bt_hid_slot >= 2 ? "HID(4/18)" : in rtw_coex_display_coex_info()
2969 coex_stat->bt_pan_exist ? coex_stat->bt_opp_exist ? in rtw_coex_display_coex_info()
2971 coex_stat->bt_ble_voice ? "Voice," : "", in rtw_coex_display_coex_info()
2972 coex_stat->bt_multi_link); in rtw_coex_display_coex_info()
2973 seq_printf(m, "%-40s = %u/ %u/ %u/ 0x%08x\n", in rtw_coex_display_coex_info()
2975 coex_stat->cnt_bt[COEX_CNT_BT_REINIT], in rtw_coex_display_coex_info()
2976 coex_stat->cnt_bt[COEX_CNT_BT_SETUPLINK], in rtw_coex_display_coex_info()
2977 coex_stat->cnt_bt[COEX_CNT_BT_IGNWLANACT], in rtw_coex_display_coex_info()
2978 coex_stat->bt_supported_feature); in rtw_coex_display_coex_info()
2979 seq_printf(m, "%-40s = %u/ %u/ %u/ %u\n", in rtw_coex_display_coex_info()
2981 coex_stat->cnt_bt[COEX_CNT_BT_PAGE], in rtw_coex_display_coex_info()
2982 coex_stat->cnt_bt[COEX_CNT_BT_INQ], in rtw_coex_display_coex_info()
2983 coex_stat->cnt_bt[COEX_CNT_BT_IQK], in rtw_coex_display_coex_info()
2984 coex_stat->cnt_bt[COEX_CNT_BT_IQKFAIL]); in rtw_coex_display_coex_info()
2985 seq_printf(m, "%-40s = 0x%04x/ 0x%04x/ 0x%04x/ 0x%04x\n", in rtw_coex_display_coex_info()
2986 "0xae/ 0xac/ score board (W->B)/ (B->W)", in rtw_coex_display_coex_info()
2987 coex_stat->bt_reg_vendor_ae, in rtw_coex_display_coex_info()
2988 coex_stat->bt_reg_vendor_ac, in rtw_coex_display_coex_info()
2990 seq_printf(m, "%-40s = %u/%u, %u/%u\n", in rtw_coex_display_coex_info()
2991 "Hi-Pri TX/RX, Lo-Pri TX/RX", in rtw_coex_display_coex_info()
2995 seq_printf(m, "%-40s = %7ph\n", in rtw_coex_display_coex_info()
2997 coex_stat->bt_info_c2h[i]); in rtw_coex_display_coex_info()
3002 seq_printf(m, "%-40s = %d\n", in rtw_coex_display_coex_info()
3003 "Scanning", test_bit(RTW_FLAG_SCANNING, rtwdev->flags)); in rtw_coex_display_coex_info()
3004 seq_printf(m, "%-40s = %u/ TX %d Mbps/ RX %d Mbps\n", in rtw_coex_display_coex_info()
3006 coex_stat->wl_gl_busy, in rtw_coex_display_coex_info()
3007 rtwdev->stats.tx_throughput, rtwdev->stats.rx_throughput); in rtw_coex_display_coex_info()
3008 seq_printf(m, "%-40s = %u/ %u/ %u\n", in rtw_coex_display_coex_info()
3010 test_bit(RTW_FLAG_INACTIVE_PS, rtwdev->flags), in rtw_coex_display_coex_info()
3011 test_bit(RTW_FLAG_LEISURE_PS_DEEP, rtwdev->flags), in rtw_coex_display_coex_info()
3012 rtwdev->lps_conf.mode); in rtw_coex_display_coex_info()
3021 seq_printf(m, "%-40s = %5ph (case-%d)\n", in rtw_coex_display_coex_info()
3023 coex_dm->ps_tdma_para, coex_dm->cur_ps_tdma); in rtw_coex_display_coex_info()
3024 seq_printf(m, "%-40s = %d\n", in rtw_coex_display_coex_info()
3025 "Timer base", coex_stat->tdma_timer_base); in rtw_coex_display_coex_info()
3026 seq_printf(m, "%-40s = %d/ 0x%08x/ 0x%08x/ 0x%08x\n", in rtw_coex_display_coex_info()
3028 coex_dm->cur_table, wl_reg_6c0, wl_reg_6c4, wl_reg_6c8); in rtw_coex_display_coex_info()
3029 seq_printf(m, "%-40s = 0x%08x/ 0x%08x/ reason (%s)\n", in rtw_coex_display_coex_info()
3032 seq_printf(m, "%-40s = %u/ %u/ %u/ %u/ %u\n", in rtw_coex_display_coex_info()
3034 coex_stat->wl_fw_dbg_info[1], coex_stat->wl_fw_dbg_info[2], in rtw_coex_display_coex_info()
3035 coex_stat->wl_fw_dbg_info[3], coex_stat->wl_fw_dbg_info[4], in rtw_coex_display_coex_info()
3036 coex_stat->wl_fw_dbg_info[5]); in rtw_coex_display_coex_info()
3037 seq_printf(m, "%-40s = %u/ %u/ %s/ %u\n", in rtw_coex_display_coex_info()
3039 coex_stat->wl_fw_dbg_info[6], in rtw_coex_display_coex_info()
3040 coex_stat->wl_fw_dbg_info[7], in rtw_coex_display_coex_info()
3041 coex_stat->wl_slot_extend ? "Yes" : "No", in rtw_coex_display_coex_info()
3042 coex_stat->cnt_wl[COEX_CNT_WL_FW_NOTIFY]); in rtw_coex_display_coex_info()
3047 seq_printf(m, "%-40s = %s/ %s\n", in rtw_coex_display_coex_info()
3049 lte_coex & BIT(7) ? "ON" : "OFF", in rtw_coex_display_coex_info()
3050 sys_lte & BIT(2) ? "WL" : "BT"); in rtw_coex_display_coex_info()
3051 seq_printf(m, "%-40s = RF:%s_BB:%s/ RF:%s_BB:%s/ %s\n", in rtw_coex_display_coex_info()
3053 lte_coex & BIT(12) ? "SW" : "HW", in rtw_coex_display_coex_info()
3054 lte_coex & BIT(8) ? "SW" : "HW", in rtw_coex_display_coex_info()
3055 lte_coex & BIT(14) ? "SW" : "HW", in rtw_coex_display_coex_info()
3056 lte_coex & BIT(10) ? "SW" : "HW", in rtw_coex_display_coex_info()
3057 sys_lte & BIT(3) ? "On" : "Off"); in rtw_coex_display_coex_info()
3058 seq_printf(m, "%-40s = %lu/ %lu\n", in rtw_coex_display_coex_info()
3060 (bt_coex & BIT(2)) >> 2, (bt_coex & BIT(3)) >> 3); in rtw_coex_display_coex_info()
3061 seq_printf(m, "%-40s = %u/ %u/ %u/ %u\n", in rtw_coex_display_coex_info()
3063 dm_info->cck_ok_cnt, dm_info->ofdm_ok_cnt, in rtw_coex_display_coex_info()
3064 dm_info->ht_ok_cnt, dm_info->vht_ok_cnt); in rtw_coex_display_coex_info()
3065 seq_printf(m, "%-40s = %u/ %u/ %u/ %u\n", in rtw_coex_display_coex_info()
3067 dm_info->cck_err_cnt, dm_info->ofdm_err_cnt, in rtw_coex_display_coex_info()
3068 dm_info->ht_err_cnt, dm_info->vht_err_cnt); in rtw_coex_display_coex_info()
3069 seq_printf(m, "%-40s = %s/ %s/ %s/ %u\n", in rtw_coex_display_coex_info()
3071 coex_stat->wl_hi_pri_task1 ? "Y" : "N", in rtw_coex_display_coex_info()
3072 coex_stat->wl_cck_lock ? "Y" : "N", in rtw_coex_display_coex_info()
3073 coex_stat->wl_cck_lock_ever ? "Y" : "N", in rtw_coex_display_coex_info()
3074 coex_stat->wl_noisy_level); in rtw_coex_display_coex_info()