Lines Matching refs:rtwdev

12 static void rtw_fw_c2h_cmd_handle_ext(struct rtw_dev *rtwdev,  in rtw_fw_c2h_cmd_handle_ext()  argument
23 rtw_tx_report_handle(rtwdev, skb); in rtw_fw_c2h_cmd_handle_ext()
30 void rtw_fw_c2h_cmd_handle(struct rtw_dev *rtwdev, struct sk_buff *skb) in rtw_fw_c2h_cmd_handle() argument
40 mutex_lock(&rtwdev->mutex); in rtw_fw_c2h_cmd_handle()
44 rtw_coex_bt_info_notify(rtwdev, c2h->payload, len); in rtw_fw_c2h_cmd_handle()
47 rtw_coex_wl_fwdbginfo_notify(rtwdev, c2h->payload, len); in rtw_fw_c2h_cmd_handle()
50 rtw_fw_c2h_cmd_handle_ext(rtwdev, skb); in rtw_fw_c2h_cmd_handle()
56 mutex_unlock(&rtwdev->mutex); in rtw_fw_c2h_cmd_handle()
59 void rtw_fw_c2h_cmd_rx_irqsafe(struct rtw_dev *rtwdev, u32 pkt_offset, in rtw_fw_c2h_cmd_rx_irqsafe() argument
69 rtw_dbg(rtwdev, RTW_DBG_FW, "recv C2H, id=0x%02x, seq=0x%02x, len=%d\n", in rtw_fw_c2h_cmd_rx_irqsafe()
74 rtw_coex_info_response(rtwdev, skb); in rtw_fw_c2h_cmd_rx_irqsafe()
79 skb_queue_tail(&rtwdev->c2h_queue, skb); in rtw_fw_c2h_cmd_rx_irqsafe()
80 ieee80211_queue_work(rtwdev->hw, &rtwdev->c2h_work); in rtw_fw_c2h_cmd_rx_irqsafe()
86 static void rtw_fw_send_h2c_command(struct rtw_dev *rtwdev, in rtw_fw_send_h2c_command() argument
95 rtw_dbg(rtwdev, RTW_DBG_FW, in rtw_fw_send_h2c_command()
100 spin_lock(&rtwdev->h2c.lock); in rtw_fw_send_h2c_command()
102 box = rtwdev->h2c.last_box_num; in rtw_fw_send_h2c_command()
127 box_state = rtw_read8(rtwdev, REG_HMETFR); in rtw_fw_send_h2c_command()
131 rtw_err(rtwdev, "failed to send h2c command\n"); in rtw_fw_send_h2c_command()
136 rtw_write8(rtwdev, box_reg + idx, h2c[idx]); in rtw_fw_send_h2c_command()
138 rtw_write8(rtwdev, box_ex_reg + idx, h2c[idx + 4]); in rtw_fw_send_h2c_command()
140 if (++rtwdev->h2c.last_box_num >= 4) in rtw_fw_send_h2c_command()
141 rtwdev->h2c.last_box_num = 0; in rtw_fw_send_h2c_command()
144 spin_unlock(&rtwdev->h2c.lock); in rtw_fw_send_h2c_command()
147 static void rtw_fw_send_h2c_packet(struct rtw_dev *rtwdev, u8 *h2c_pkt) in rtw_fw_send_h2c_packet() argument
151 spin_lock(&rtwdev->h2c.lock); in rtw_fw_send_h2c_packet()
153 FW_OFFLOAD_H2C_SET_SEQ_NUM(h2c_pkt, rtwdev->h2c.seq); in rtw_fw_send_h2c_packet()
154 ret = rtw_hci_write_data_h2c(rtwdev, h2c_pkt, H2C_PKT_SIZE); in rtw_fw_send_h2c_packet()
156 rtw_err(rtwdev, "failed to send h2c packet\n"); in rtw_fw_send_h2c_packet()
157 rtwdev->h2c.seq++; in rtw_fw_send_h2c_packet()
159 spin_unlock(&rtwdev->h2c.lock); in rtw_fw_send_h2c_packet()
163 rtw_fw_send_general_info(struct rtw_dev *rtwdev) in rtw_fw_send_general_info() argument
165 struct rtw_fifo_conf *fifo = &rtwdev->fifo; in rtw_fw_send_general_info()
177 rtw_fw_send_h2c_packet(rtwdev, h2c_pkt); in rtw_fw_send_general_info()
181 rtw_fw_send_phydm_info(struct rtw_dev *rtwdev) in rtw_fw_send_phydm_info() argument
183 struct rtw_hal *hal = &rtwdev->hal; in rtw_fw_send_phydm_info()
184 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_fw_send_phydm_info()
203 rtw_fw_send_h2c_packet(rtwdev, h2c_pkt); in rtw_fw_send_phydm_info()
206 void rtw_fw_do_iqk(struct rtw_dev *rtwdev, struct rtw_iqk_para *para) in rtw_fw_do_iqk() argument
216 rtw_fw_send_h2c_packet(rtwdev, h2c_pkt); in rtw_fw_do_iqk()
219 void rtw_fw_query_bt_info(struct rtw_dev *rtwdev) in rtw_fw_query_bt_info() argument
227 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_query_bt_info()
230 void rtw_fw_wl_ch_info(struct rtw_dev *rtwdev, u8 link, u8 ch, u8 bw) in rtw_fw_wl_ch_info() argument
240 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_wl_ch_info()
243 void rtw_fw_query_bt_mp_info(struct rtw_dev *rtwdev, in rtw_fw_query_bt_mp_info() argument
256 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_query_bt_mp_info()
259 void rtw_fw_force_bt_tx_power(struct rtw_dev *rtwdev, u8 bt_pwr_dec_lvl) in rtw_fw_force_bt_tx_power() argument
268 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_force_bt_tx_power()
271 void rtw_fw_bt_ignore_wlan_action(struct rtw_dev *rtwdev, bool enable) in rtw_fw_bt_ignore_wlan_action() argument
279 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_bt_ignore_wlan_action()
282 void rtw_fw_coex_tdma_type(struct rtw_dev *rtwdev, in rtw_fw_coex_tdma_type() argument
295 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_coex_tdma_type()
298 void rtw_fw_bt_wifi_control(struct rtw_dev *rtwdev, u8 op_code, u8 *data) in rtw_fw_bt_wifi_control() argument
312 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_bt_wifi_control()
315 void rtw_fw_send_rssi_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) in rtw_fw_send_rssi_info() argument
327 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_send_rssi_info()
330 void rtw_fw_send_ra_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) in rtw_fw_send_ra_info() argument
355 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_send_ra_info()
358 void rtw_fw_media_status_report(struct rtw_dev *rtwdev, u8 mac_id, bool connect) in rtw_fw_media_status_report() argument
366 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_media_status_report()
369 void rtw_fw_set_pwr_mode(struct rtw_dev *rtwdev) in rtw_fw_set_pwr_mode() argument
371 struct rtw_lps_conf *conf = &rtwdev->lps_conf; in rtw_fw_set_pwr_mode()
383 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_fw_set_pwr_mode()
386 static u8 rtw_get_rsvd_page_location(struct rtw_dev *rtwdev, in rtw_get_rsvd_page_location() argument
392 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) { in rtw_get_rsvd_page_location()
400 void rtw_send_rsvd_page_h2c(struct rtw_dev *rtwdev) in rtw_send_rsvd_page_h2c() argument
407 location = rtw_get_rsvd_page_location(rtwdev, RSVD_PROBE_RESP); in rtw_send_rsvd_page_h2c()
409 rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_PROBE_RESP loc: %d\n", location); in rtw_send_rsvd_page_h2c()
411 location = rtw_get_rsvd_page_location(rtwdev, RSVD_PS_POLL); in rtw_send_rsvd_page_h2c()
413 rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_PS_POLL loc: %d\n", location); in rtw_send_rsvd_page_h2c()
415 location = rtw_get_rsvd_page_location(rtwdev, RSVD_NULL); in rtw_send_rsvd_page_h2c()
417 rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_NULL loc: %d\n", location); in rtw_send_rsvd_page_h2c()
419 location = rtw_get_rsvd_page_location(rtwdev, RSVD_QOS_NULL); in rtw_send_rsvd_page_h2c()
421 rtw_dbg(rtwdev, RTW_DBG_FW, "RSVD_QOS_NULL loc: %d\n", location); in rtw_send_rsvd_page_h2c()
423 rtw_fw_send_h2c_command(rtwdev, h2c_pkt); in rtw_send_rsvd_page_h2c()
477 static void rtw_fill_rsvd_page_desc(struct rtw_dev *rtwdev, struct sk_buff *skb) in rtw_fill_rsvd_page_desc() argument
480 struct rtw_chip_info *chip = rtwdev->chip; in rtw_fill_rsvd_page_desc()
484 rtw_rsvd_page_pkt_info_update(rtwdev, &pkt_info, skb); in rtw_fill_rsvd_page_desc()
495 static void rtw_rsvd_page_list_to_buf(struct rtw_dev *rtwdev, u8 page_size, in rtw_rsvd_page_list_to_buf() argument
502 rtw_fill_rsvd_page_desc(rtwdev, skb); in rtw_rsvd_page_list_to_buf()
511 void rtw_add_rsvd_page(struct rtw_dev *rtwdev, enum rtw_rsvd_packet_type type, in rtw_add_rsvd_page() argument
516 lockdep_assert_held(&rtwdev->mutex); in rtw_add_rsvd_page()
518 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) { in rtw_add_rsvd_page()
529 list_add_tail(&rsvd_pkt->list, &rtwdev->rsvd_page_list); in rtw_add_rsvd_page()
532 void rtw_reset_rsvd_page(struct rtw_dev *rtwdev) in rtw_reset_rsvd_page() argument
536 lockdep_assert_held(&rtwdev->mutex); in rtw_reset_rsvd_page()
538 list_for_each_entry_safe(rsvd_pkt, tmp, &rtwdev->rsvd_page_list, list) { in rtw_reset_rsvd_page()
546 int rtw_fw_write_data_rsvd_page(struct rtw_dev *rtwdev, u16 pg_addr, in rtw_fw_write_data_rsvd_page() argument
554 lockdep_assert_held(&rtwdev->mutex); in rtw_fw_write_data_rsvd_page()
560 rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2, pg_addr | BIT_BCN_VALID_V1); in rtw_fw_write_data_rsvd_page()
562 val = rtw_read8(rtwdev, REG_CR + 1); in rtw_fw_write_data_rsvd_page()
565 rtw_write8(rtwdev, REG_CR + 1, val); in rtw_fw_write_data_rsvd_page()
567 val = rtw_read8(rtwdev, REG_FWHW_TXQ_CTRL + 2); in rtw_fw_write_data_rsvd_page()
570 rtw_write8(rtwdev, REG_FWHW_TXQ_CTRL + 2, val); in rtw_fw_write_data_rsvd_page()
572 ret = rtw_hci_write_data_rsvd_page(rtwdev, buf, size); in rtw_fw_write_data_rsvd_page()
574 rtw_err(rtwdev, "failed to write data to rsvd page\n"); in rtw_fw_write_data_rsvd_page()
578 if (!check_hw_ready(rtwdev, REG_FIFOPAGE_CTRL_2, BIT_BCN_VALID_V1, 1)) { in rtw_fw_write_data_rsvd_page()
579 rtw_err(rtwdev, "error beacon valid\n"); in rtw_fw_write_data_rsvd_page()
584 rsvd_pg_head = rtwdev->fifo.rsvd_boundary; in rtw_fw_write_data_rsvd_page()
585 rtw_write16(rtwdev, REG_FIFOPAGE_CTRL_2, in rtw_fw_write_data_rsvd_page()
587 rtw_write8(rtwdev, REG_FWHW_TXQ_CTRL + 2, bckp[1]); in rtw_fw_write_data_rsvd_page()
588 rtw_write8(rtwdev, REG_CR + 1, bckp[0]); in rtw_fw_write_data_rsvd_page()
593 static int rtw_download_drv_rsvd_page(struct rtw_dev *rtwdev, u8 *buf, u32 size) in rtw_download_drv_rsvd_page() argument
599 pg_size = rtwdev->chip->page_size; in rtw_download_drv_rsvd_page()
601 if (pg_num > rtwdev->fifo.rsvd_drv_pg_num) in rtw_download_drv_rsvd_page()
604 pg_addr = rtwdev->fifo.rsvd_drv_addr; in rtw_download_drv_rsvd_page()
606 return rtw_fw_write_data_rsvd_page(rtwdev, pg_addr, buf, size); in rtw_download_drv_rsvd_page()
609 static u8 *rtw_build_rsvd_page(struct rtw_dev *rtwdev, in rtw_build_rsvd_page() argument
612 struct ieee80211_hw *hw = rtwdev->hw; in rtw_build_rsvd_page()
613 struct rtw_chip_info *chip = rtwdev->chip; in rtw_build_rsvd_page()
625 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) { in rtw_build_rsvd_page()
628 rtw_err(rtwdev, "fail to build rsvd packet\n"); in rtw_build_rsvd_page()
640 if (total_page > rtwdev->fifo.rsvd_drv_pg_num) { in rtw_build_rsvd_page()
641 rtw_err(rtwdev, "rsvd page over size: %d\n", total_page); in rtw_build_rsvd_page()
650 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) { in rtw_build_rsvd_page()
651 rtw_rsvd_page_list_to_buf(rtwdev, page_size, page_margin, in rtw_build_rsvd_page()
655 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) in rtw_build_rsvd_page()
661 list_for_each_entry(rsvd_pkt, &rtwdev->rsvd_page_list, list) in rtw_build_rsvd_page()
668 rtw_download_beacon(struct rtw_dev *rtwdev, struct ieee80211_vif *vif) in rtw_download_beacon() argument
670 struct ieee80211_hw *hw = rtwdev->hw; in rtw_download_beacon()
676 rtw_err(rtwdev, "failed to get beacon skb\n"); in rtw_download_beacon()
681 ret = rtw_download_drv_rsvd_page(rtwdev, skb->data, skb->len); in rtw_download_beacon()
683 rtw_err(rtwdev, "failed to download drv rsvd page\n"); in rtw_download_beacon()
691 int rtw_fw_download_rsvd_page(struct rtw_dev *rtwdev, struct ieee80211_vif *vif) in rtw_fw_download_rsvd_page() argument
697 buf = rtw_build_rsvd_page(rtwdev, vif, &size); in rtw_fw_download_rsvd_page()
699 rtw_err(rtwdev, "failed to build rsvd page pkt\n"); in rtw_fw_download_rsvd_page()
703 ret = rtw_download_drv_rsvd_page(rtwdev, buf, size); in rtw_fw_download_rsvd_page()
705 rtw_err(rtwdev, "failed to download drv rsvd page\n"); in rtw_fw_download_rsvd_page()
709 ret = rtw_download_beacon(rtwdev, vif); in rtw_fw_download_rsvd_page()
711 rtw_err(rtwdev, "failed to download beacon\n"); in rtw_fw_download_rsvd_page()
721 int rtw_dump_drv_rsvd_page(struct rtw_dev *rtwdev, in rtw_dump_drv_rsvd_page() argument
724 struct rtw_fifo_conf *fifo = &rtwdev->fifo; in rtw_dump_drv_rsvd_page()
732 rtw_warn(rtwdev, "should be 4-byte aligned\n"); in rtw_dump_drv_rsvd_page()
741 rcr = rtw_read8(rtwdev, REG_RCR + 2); in rtw_dump_drv_rsvd_page()
742 ctl = rtw_read16(rtwdev, REG_PKTBUF_DBG_CTRL) & 0xf000; in rtw_dump_drv_rsvd_page()
745 rtw_write8(rtwdev, REG_RCR, rcr | BIT(3)); in rtw_dump_drv_rsvd_page()
748 rtw_write16(rtwdev, REG_PKTBUF_DBG_CTRL, start_pg | ctl); in rtw_dump_drv_rsvd_page()
752 buf[idx++] = rtw_read32(rtwdev, i); in rtw_dump_drv_rsvd_page()
763 rtw_write16(rtwdev, REG_PKTBUF_DBG_CTRL, ctl); in rtw_dump_drv_rsvd_page()
764 rtw_write8(rtwdev, REG_RCR + 2, rcr); in rtw_dump_drv_rsvd_page()