Lines Matching refs:rtwdev

150 	struct rtw_dev *rtwdev = container_of(work, struct rtw_dev,  in rtw_watch_dog_work()  local
153 bool busy_traffic = rtw_flag_check(rtwdev, RTW_FLAG_BUSY_TRAFFIC); in rtw_watch_dog_work()
155 if (!rtw_flag_check(rtwdev, RTW_FLAG_RUNNING)) in rtw_watch_dog_work()
158 ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work, in rtw_watch_dog_work()
161 if (rtwdev->stats.tx_cnt > 100 || rtwdev->stats.rx_cnt > 100) in rtw_watch_dog_work()
162 rtw_flag_set(rtwdev, RTW_FLAG_BUSY_TRAFFIC); in rtw_watch_dog_work()
164 rtw_flag_clear(rtwdev, RTW_FLAG_BUSY_TRAFFIC); in rtw_watch_dog_work()
166 if (busy_traffic != rtw_flag_check(rtwdev, RTW_FLAG_BUSY_TRAFFIC)) in rtw_watch_dog_work()
167 rtw_coex_wl_status_change_notify(rtwdev); in rtw_watch_dog_work()
170 rtwdev->stats.tx_unicast = 0; in rtw_watch_dog_work()
171 rtwdev->stats.rx_unicast = 0; in rtw_watch_dog_work()
172 rtwdev->stats.tx_cnt = 0; in rtw_watch_dog_work()
173 rtwdev->stats.rx_cnt = 0; in rtw_watch_dog_work()
176 rtw_iterate_vifs_atomic(rtwdev, rtw_vif_watch_dog_iter, &data); in rtw_watch_dog_work()
184 rtw_enter_lps(rtwdev, data.rtwvif); in rtw_watch_dog_work()
186 if (rtw_flag_check(rtwdev, RTW_FLAG_SCANNING)) in rtw_watch_dog_work()
189 rtw_phy_dynamic_mechanism(rtwdev); in rtw_watch_dog_work()
191 rtwdev->watch_dog_cnt++; in rtw_watch_dog_work()
196 struct rtw_dev *rtwdev = container_of(work, struct rtw_dev, c2h_work); in rtw_c2h_work() local
199 skb_queue_walk_safe(&rtwdev->c2h_queue, skb, tmp) { in rtw_c2h_work()
200 skb_unlink(skb, &rtwdev->c2h_queue); in rtw_c2h_work()
201 rtw_fw_c2h_cmd_handle(rtwdev, skb); in rtw_c2h_work()
285 void rtw_set_channel(struct rtw_dev *rtwdev) in rtw_set_channel() argument
287 struct ieee80211_hw *hw = rtwdev->hw; in rtw_set_channel()
288 struct rtw_hal *hal = &rtwdev->hal; in rtw_set_channel()
289 struct rtw_chip_info *chip = rtwdev->chip; in rtw_set_channel()
309 chip->ops->set_channel(rtwdev, center_chan, bandwidth, primary_chan_idx); in rtw_set_channel()
312 rtw_coex_switchband_notify(rtwdev, COEX_SWITCH_TO_5G); in rtw_set_channel()
314 if (rtw_flag_check(rtwdev, RTW_FLAG_SCANNING)) in rtw_set_channel()
315 rtw_coex_switchband_notify(rtwdev, COEX_SWITCH_TO_24G); in rtw_set_channel()
317 rtw_coex_switchband_notify(rtwdev, COEX_SWITCH_TO_24G_NOFORSCAN); in rtw_set_channel()
320 rtw_phy_set_tx_power_level(rtwdev, center_chan); in rtw_set_channel()
323 static void rtw_vif_write_addr(struct rtw_dev *rtwdev, u32 start, u8 *addr) in rtw_vif_write_addr() argument
328 rtw_write8(rtwdev, start + i, addr[i]); in rtw_vif_write_addr()
331 void rtw_vif_port_config(struct rtw_dev *rtwdev, in rtw_vif_port_config() argument
339 rtw_vif_write_addr(rtwdev, addr, rtwvif->mac_addr); in rtw_vif_port_config()
343 rtw_vif_write_addr(rtwdev, addr, rtwvif->bssid); in rtw_vif_port_config()
348 rtw_write32_mask(rtwdev, addr, mask, rtwvif->net_type); in rtw_vif_port_config()
353 rtw_write32_mask(rtwdev, addr, mask, rtwvif->aid); in rtw_vif_port_config()
358 rtw_write8_mask(rtwdev, addr, mask, rtwvif->bcn_ctrl); in rtw_vif_port_config()
382 static void rtw_hw_config_rf_ant_num(struct rtw_dev *rtwdev, u8 hw_ant_num) in rtw_hw_config_rf_ant_num() argument
384 struct rtw_hal *hal = &rtwdev->hal; in rtw_hw_config_rf_ant_num()
532 void rtw_update_sta_info(struct rtw_dev *rtwdev, struct rtw_sta_info *si) in rtw_update_sta_info() argument
535 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_update_sta_info()
536 struct rtw_hal *hal = &rtwdev->hal; in rtw_update_sta_info()
599 rtw_err(rtwdev, "Unknown band type\n"); in rtw_update_sta_info()
656 rtw_fw_send_ra_info(rtwdev, si); in rtw_update_sta_info()
659 static int rtw_power_on(struct rtw_dev *rtwdev) in rtw_power_on() argument
661 struct rtw_chip_info *chip = rtwdev->chip; in rtw_power_on()
662 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_power_on()
666 ret = rtw_hci_setup(rtwdev); in rtw_power_on()
668 rtw_err(rtwdev, "failed to setup hci\n"); in rtw_power_on()
673 ret = rtw_mac_power_on(rtwdev); in rtw_power_on()
675 rtw_err(rtwdev, "failed to power on mac\n"); in rtw_power_on()
682 rtw_err(rtwdev, "failed to load firmware\n"); in rtw_power_on()
686 ret = rtw_download_firmware(rtwdev, fw); in rtw_power_on()
688 rtw_err(rtwdev, "failed to download firmware\n"); in rtw_power_on()
693 ret = rtw_mac_init(rtwdev); in rtw_power_on()
695 rtw_err(rtwdev, "failed to configure mac\n"); in rtw_power_on()
699 chip->ops->phy_set_param(rtwdev); in rtw_power_on()
701 ret = rtw_hci_start(rtwdev); in rtw_power_on()
703 rtw_err(rtwdev, "failed to start hci\n"); in rtw_power_on()
708 rtw_fw_send_general_info(rtwdev); in rtw_power_on()
709 rtw_fw_send_phydm_info(rtwdev); in rtw_power_on()
711 wifi_only = !rtwdev->efuse.btcoex; in rtw_power_on()
712 rtw_coex_power_on_setting(rtwdev); in rtw_power_on()
713 rtw_coex_init_hw_config(rtwdev, wifi_only); in rtw_power_on()
718 rtw_mac_power_off(rtwdev); in rtw_power_on()
724 int rtw_core_start(struct rtw_dev *rtwdev) in rtw_core_start() argument
728 ret = rtw_power_on(rtwdev); in rtw_core_start()
732 rtw_sec_enable_sec_engine(rtwdev); in rtw_core_start()
735 rtw_write32(rtwdev, REG_RCR, rtwdev->hal.rcr); in rtw_core_start()
737 ieee80211_queue_delayed_work(rtwdev->hw, &rtwdev->watch_dog_work, in rtw_core_start()
740 rtw_flag_set(rtwdev, RTW_FLAG_RUNNING); in rtw_core_start()
745 static void rtw_power_off(struct rtw_dev *rtwdev) in rtw_power_off() argument
747 rtwdev->hci.ops->stop(rtwdev); in rtw_power_off()
748 rtw_mac_power_off(rtwdev); in rtw_power_off()
751 void rtw_core_stop(struct rtw_dev *rtwdev) in rtw_core_stop() argument
753 struct rtw_coex *coex = &rtwdev->coex; in rtw_core_stop()
755 rtw_flag_clear(rtwdev, RTW_FLAG_RUNNING); in rtw_core_stop()
756 rtw_flag_clear(rtwdev, RTW_FLAG_FW_RUNNING); in rtw_core_stop()
758 cancel_delayed_work_sync(&rtwdev->watch_dog_work); in rtw_core_stop()
763 rtw_power_off(rtwdev); in rtw_core_stop()
766 static void rtw_init_ht_cap(struct rtw_dev *rtwdev, in rtw_init_ht_cap() argument
769 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_init_ht_cap()
797 static void rtw_init_vht_cap(struct rtw_dev *rtwdev, in rtw_init_vht_cap() argument
800 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_init_vht_cap()
841 struct rtw_dev *rtwdev = hw->priv; in rtw_set_supported_band() local
849 rtw_init_ht_cap(rtwdev, &sband->ht_cap); in rtw_set_supported_band()
858 rtw_init_ht_cap(rtwdev, &sband->ht_cap); in rtw_set_supported_band()
860 rtw_init_vht_cap(rtwdev, &sband->vht_cap); in rtw_set_supported_band()
867 rtw_err(rtwdev, "failed to set supported band\n"); in rtw_set_supported_band()
880 struct rtw_dev *rtwdev = context; in rtw_load_firmware_cb() local
881 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_load_firmware_cb()
884 rtw_err(rtwdev, "failed to request firmware\n"); in rtw_load_firmware_cb()
890 static int rtw_load_firmware(struct rtw_dev *rtwdev, const char *fw_name) in rtw_load_firmware() argument
892 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_load_firmware()
897 ret = request_firmware_nowait(THIS_MODULE, true, fw_name, rtwdev->dev, in rtw_load_firmware()
898 GFP_KERNEL, rtwdev, rtw_load_firmware_cb); in rtw_load_firmware()
900 rtw_err(rtwdev, "async firmware request failed\n"); in rtw_load_firmware()
907 static int rtw_chip_parameter_setup(struct rtw_dev *rtwdev) in rtw_chip_parameter_setup() argument
909 struct rtw_chip_info *chip = rtwdev->chip; in rtw_chip_parameter_setup()
910 struct rtw_hal *hal = &rtwdev->hal; in rtw_chip_parameter_setup()
911 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_chip_parameter_setup()
914 switch (rtw_hci_type(rtwdev)) { in rtw_chip_parameter_setup()
916 rtwdev->hci.rpwm_addr = 0x03d9; in rtw_chip_parameter_setup()
919 rtw_err(rtwdev, "unsupported hci type\n"); in rtw_chip_parameter_setup()
923 hal->chip_version = rtw_read32(rtwdev, REG_SYS_CFG1); in rtw_chip_parameter_setup()
949 rtwdev->hal.rcr |= BIT_VHT_DACK; in rtw_chip_parameter_setup()
954 static int rtw_chip_efuse_enable(struct rtw_dev *rtwdev) in rtw_chip_efuse_enable() argument
956 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_chip_efuse_enable()
959 ret = rtw_hci_setup(rtwdev); in rtw_chip_efuse_enable()
961 rtw_err(rtwdev, "failed to setup hci\n"); in rtw_chip_efuse_enable()
965 ret = rtw_mac_power_on(rtwdev); in rtw_chip_efuse_enable()
967 rtw_err(rtwdev, "failed to power on mac\n"); in rtw_chip_efuse_enable()
971 rtw_write8(rtwdev, REG_C2HEVT, C2H_HW_FEATURE_DUMP); in rtw_chip_efuse_enable()
976 rtw_err(rtwdev, "failed to load firmware\n"); in rtw_chip_efuse_enable()
980 ret = rtw_download_firmware(rtwdev, fw); in rtw_chip_efuse_enable()
982 rtw_err(rtwdev, "failed to download firmware\n"); in rtw_chip_efuse_enable()
989 rtw_mac_power_off(rtwdev); in rtw_chip_efuse_enable()
995 static int rtw_dump_hw_feature(struct rtw_dev *rtwdev) in rtw_dump_hw_feature() argument
997 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_dump_hw_feature()
1003 id = rtw_read8(rtwdev, REG_C2HEVT); in rtw_dump_hw_feature()
1005 rtw_err(rtwdev, "failed to read hw feature report\n"); in rtw_dump_hw_feature()
1010 hw_feature[i] = rtw_read8(rtwdev, REG_C2HEVT + 2 + i); in rtw_dump_hw_feature()
1012 rtw_write8(rtwdev, REG_C2HEVT, 0); in rtw_dump_hw_feature()
1021 rtw_hw_config_rf_ant_num(rtwdev, efuse->hw_cap.ant_num); in rtw_dump_hw_feature()
1024 efuse->hw_cap.nss = rtwdev->hal.rf_path_num; in rtw_dump_hw_feature()
1026 rtw_dbg(rtwdev, RTW_DBG_EFUSE, in rtw_dump_hw_feature()
1034 static void rtw_chip_efuse_disable(struct rtw_dev *rtwdev) in rtw_chip_efuse_disable() argument
1036 rtw_hci_stop(rtwdev); in rtw_chip_efuse_disable()
1037 rtw_mac_power_off(rtwdev); in rtw_chip_efuse_disable()
1040 static int rtw_chip_efuse_info_setup(struct rtw_dev *rtwdev) in rtw_chip_efuse_info_setup() argument
1042 struct rtw_efuse *efuse = &rtwdev->efuse; in rtw_chip_efuse_info_setup()
1045 mutex_lock(&rtwdev->mutex); in rtw_chip_efuse_info_setup()
1048 ret = rtw_chip_efuse_enable(rtwdev); in rtw_chip_efuse_info_setup()
1052 ret = rtw_parse_efuse_map(rtwdev); in rtw_chip_efuse_info_setup()
1056 ret = rtw_dump_hw_feature(rtwdev); in rtw_chip_efuse_info_setup()
1060 ret = rtw_check_supported_rfe(rtwdev); in rtw_chip_efuse_info_setup()
1089 rtw_chip_efuse_disable(rtwdev); in rtw_chip_efuse_info_setup()
1092 mutex_unlock(&rtwdev->mutex); in rtw_chip_efuse_info_setup()
1096 static int rtw_chip_board_info_setup(struct rtw_dev *rtwdev) in rtw_chip_board_info_setup() argument
1098 struct rtw_hal *hal = &rtwdev->hal; in rtw_chip_board_info_setup()
1099 const struct rtw_rfe_def *rfe_def = rtw_get_rfe_def(rtwdev); in rtw_chip_board_info_setup()
1104 rtw_phy_setup_phy_cond(rtwdev, 0); in rtw_chip_board_info_setup()
1106 rtw_phy_init_tx_power(rtwdev); in rtw_chip_board_info_setup()
1107 rtw_load_table(rtwdev, rfe_def->phy_pg_tbl); in rtw_chip_board_info_setup()
1108 rtw_load_table(rtwdev, rfe_def->txpwr_lmt_tbl); in rtw_chip_board_info_setup()
1115 int rtw_chip_info_setup(struct rtw_dev *rtwdev) in rtw_chip_info_setup() argument
1119 ret = rtw_chip_parameter_setup(rtwdev); in rtw_chip_info_setup()
1121 rtw_err(rtwdev, "failed to setup chip parameters\n"); in rtw_chip_info_setup()
1125 ret = rtw_chip_efuse_info_setup(rtwdev); in rtw_chip_info_setup()
1127 rtw_err(rtwdev, "failed to setup chip efuse info\n"); in rtw_chip_info_setup()
1131 ret = rtw_chip_board_info_setup(rtwdev); in rtw_chip_info_setup()
1133 rtw_err(rtwdev, "failed to setup chip board info\n"); in rtw_chip_info_setup()
1144 int rtw_core_init(struct rtw_dev *rtwdev) in rtw_core_init() argument
1146 struct rtw_coex *coex = &rtwdev->coex; in rtw_core_init()
1149 INIT_LIST_HEAD(&rtwdev->rsvd_page_list); in rtw_core_init()
1151 timer_setup(&rtwdev->tx_report.purge_timer, in rtw_core_init()
1154 INIT_DELAYED_WORK(&rtwdev->watch_dog_work, rtw_watch_dog_work); in rtw_core_init()
1155 INIT_DELAYED_WORK(&rtwdev->lps_work, rtw_lps_work); in rtw_core_init()
1159 INIT_WORK(&rtwdev->c2h_work, rtw_c2h_work); in rtw_core_init()
1160 skb_queue_head_init(&rtwdev->c2h_queue); in rtw_core_init()
1161 skb_queue_head_init(&rtwdev->coex.queue); in rtw_core_init()
1162 skb_queue_head_init(&rtwdev->tx_report.queue); in rtw_core_init()
1164 spin_lock_init(&rtwdev->dm_lock); in rtw_core_init()
1165 spin_lock_init(&rtwdev->rf_lock); in rtw_core_init()
1166 spin_lock_init(&rtwdev->h2c.lock); in rtw_core_init()
1167 spin_lock_init(&rtwdev->tx_report.q_lock); in rtw_core_init()
1169 mutex_init(&rtwdev->mutex); in rtw_core_init()
1170 mutex_init(&rtwdev->coex.mutex); in rtw_core_init()
1171 mutex_init(&rtwdev->hal.tx_power_mutex); in rtw_core_init()
1173 init_waitqueue_head(&rtwdev->coex.wait); in rtw_core_init()
1175 rtwdev->sec.total_cam_num = 32; in rtw_core_init()
1176 rtwdev->hal.current_channel = 1; in rtw_core_init()
1177 set_bit(RTW_BC_MC_MACID, rtwdev->mac_id_map); in rtw_core_init()
1179 mutex_lock(&rtwdev->mutex); in rtw_core_init()
1180 rtw_add_rsvd_page(rtwdev, RSVD_BEACON, false); in rtw_core_init()
1181 mutex_unlock(&rtwdev->mutex); in rtw_core_init()
1184 rtwdev->hal.rcr = BIT_APP_FCS | BIT_APP_MIC | BIT_APP_ICV | in rtw_core_init()
1188 ret = rtw_load_firmware(rtwdev, rtwdev->chip->fw_name); in rtw_core_init()
1190 rtw_warn(rtwdev, "no firmware loaded\n"); in rtw_core_init()
1198 void rtw_core_deinit(struct rtw_dev *rtwdev) in rtw_core_deinit() argument
1200 struct rtw_fw_state *fw = &rtwdev->fw; in rtw_core_deinit()
1207 spin_lock_irqsave(&rtwdev->tx_report.q_lock, flags); in rtw_core_deinit()
1208 skb_queue_purge(&rtwdev->tx_report.queue); in rtw_core_deinit()
1209 spin_unlock_irqrestore(&rtwdev->tx_report.q_lock, flags); in rtw_core_deinit()
1211 list_for_each_entry_safe(rsvd_pkt, tmp, &rtwdev->rsvd_page_list, list) { in rtw_core_deinit()
1216 mutex_destroy(&rtwdev->mutex); in rtw_core_deinit()
1217 mutex_destroy(&rtwdev->coex.mutex); in rtw_core_deinit()
1218 mutex_destroy(&rtwdev->hal.tx_power_mutex); in rtw_core_deinit()
1222 int rtw_register_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw) in rtw_register_hw() argument
1228 max_tx_headroom = rtwdev->chip->tx_pkt_desc_sz; in rtw_register_hw()
1255 rtw_set_supported_band(hw, rtwdev->chip); in rtw_register_hw()
1256 SET_IEEE80211_PERM_ADDR(hw, rtwdev->efuse.addr); in rtw_register_hw()
1258 rtw_regd_init(rtwdev, rtw_regd_notifier); in rtw_register_hw()
1262 rtw_err(rtwdev, "failed to register hw\n"); in rtw_register_hw()
1266 if (regulatory_hint(hw->wiphy, rtwdev->regd.alpha2)) in rtw_register_hw()
1267 rtw_err(rtwdev, "regulatory_hint fail\n"); in rtw_register_hw()
1269 rtw_debugfs_init(rtwdev); in rtw_register_hw()
1275 void rtw_unregister_hw(struct rtw_dev *rtwdev, struct ieee80211_hw *hw) in rtw_unregister_hw() argument
1277 struct rtw_chip_info *chip = rtwdev->chip; in rtw_unregister_hw()