Lines Matching full:ab

814 static inline struct ath11k_pdev *ath11k_core_get_single_pdev(struct ath11k_base *ab)  in ath11k_core_get_single_pdev()  argument
816 WARN_ON(!ab->hw_params.single_pdev_only); in ath11k_core_get_single_pdev()
818 return &ab->pdevs[0]; in ath11k_core_get_single_pdev()
867 bool ath11k_core_coldboot_cal_support(struct ath11k_base *ab) in ath11k_core_coldboot_cal_support() argument
873 return ab->hw_params.coldboot_cal_ftm; in ath11k_core_coldboot_cal_support()
876 return ab->hw_params.coldboot_cal_mm; in ath11k_core_coldboot_cal_support()
879 int ath11k_core_suspend(struct ath11k_base *ab) in ath11k_core_suspend() argument
885 if (!ab->hw_params.supports_suspend) in ath11k_core_suspend()
891 pdev = ath11k_core_get_single_pdev(ab); in ath11k_core_suspend()
896 ret = ath11k_dp_rx_pktlog_stop(ab, true); in ath11k_core_suspend()
898 ath11k_warn(ab, "failed to stop dp rx (and timer) pktlog during suspend: %d\n", in ath11k_core_suspend()
905 ath11k_warn(ab, "failed to wait tx complete: %d\n", ret); in ath11k_core_suspend()
909 ret = ath11k_wow_enable(ab); in ath11k_core_suspend()
911 ath11k_warn(ab, "failed to enable wow during suspend: %d\n", ret); in ath11k_core_suspend()
915 ret = ath11k_dp_rx_pktlog_stop(ab, false); in ath11k_core_suspend()
917 ath11k_warn(ab, "failed to stop dp rx pktlog during suspend: %d\n", in ath11k_core_suspend()
922 ath11k_ce_stop_shadow_timers(ab); in ath11k_core_suspend()
923 ath11k_dp_stop_shadow_timers(ab); in ath11k_core_suspend()
925 ath11k_hif_irq_disable(ab); in ath11k_core_suspend()
926 ath11k_hif_ce_irq_disable(ab); in ath11k_core_suspend()
928 ret = ath11k_hif_suspend(ab); in ath11k_core_suspend()
930 ath11k_warn(ab, "failed to suspend hif: %d\n", ret); in ath11k_core_suspend()
938 int ath11k_core_resume(struct ath11k_base *ab) in ath11k_core_resume() argument
944 if (!ab->hw_params.supports_suspend) in ath11k_core_resume()
950 pdev = ath11k_core_get_single_pdev(ab); in ath11k_core_resume()
955 ret = ath11k_hif_resume(ab); in ath11k_core_resume()
957 ath11k_warn(ab, "failed to resume hif during resume: %d\n", ret); in ath11k_core_resume()
961 ath11k_hif_ce_irq_enable(ab); in ath11k_core_resume()
962 ath11k_hif_irq_enable(ab); in ath11k_core_resume()
964 ret = ath11k_dp_rx_pktlog_start(ab); in ath11k_core_resume()
966 ath11k_warn(ab, "failed to start rx pktlog during resume: %d\n", in ath11k_core_resume()
971 ret = ath11k_wow_wakeup(ab); in ath11k_core_resume()
973 ath11k_warn(ab, "failed to wakeup wow during resume: %d\n", ret); in ath11k_core_resume()
983 struct ath11k_base *ab = data; in ath11k_core_check_cc_code_bdfext() local
990 if (ab->qmi.target.bdf_ext[0] != '\0') in ath11k_core_check_cc_code_bdfext()
997 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_check_cc_code_bdfext()
1003 spin_lock_bh(&ab->base_lock); in ath11k_core_check_cc_code_bdfext()
1007 ab->new_alpha2[0] = (smbios->cc_code >> 8) & 0xff; in ath11k_core_check_cc_code_bdfext()
1008 ab->new_alpha2[1] = smbios->cc_code & 0xff; in ath11k_core_check_cc_code_bdfext()
1009 ath11k_dbg(ab, ATH11K_DBG_BOOT, "smbios cc_code %c%c\n", in ath11k_core_check_cc_code_bdfext()
1010 ab->new_alpha2[0], ab->new_alpha2[1]); in ath11k_core_check_cc_code_bdfext()
1013 ab->new_alpha2[0] = '0'; in ath11k_core_check_cc_code_bdfext()
1014 ab->new_alpha2[1] = '0'; in ath11k_core_check_cc_code_bdfext()
1015 ath11k_dbg(ab, ATH11K_DBG_BOOT, "smbios worldwide regdomain\n"); in ath11k_core_check_cc_code_bdfext()
1018 ath11k_dbg(ab, ATH11K_DBG_BOOT, "ignore smbios country code setting %d\n", in ath11k_core_check_cc_code_bdfext()
1023 spin_unlock_bh(&ab->base_lock); in ath11k_core_check_cc_code_bdfext()
1026 ath11k_dbg(ab, ATH11K_DBG_BOOT, "bdf variant name not found.\n"); in ath11k_core_check_cc_code_bdfext()
1032 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_check_cc_code_bdfext()
1038 strlen(smbios->bdf_ext), sizeof(ab->qmi.target.bdf_ext)); in ath11k_core_check_cc_code_bdfext()
1041 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_check_cc_code_bdfext()
1048 copied = strscpy(ab->qmi.target.bdf_ext, smbios->bdf_ext + strlen(magic), in ath11k_core_check_cc_code_bdfext()
1049 sizeof(ab->qmi.target.bdf_ext)); in ath11k_core_check_cc_code_bdfext()
1051 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_check_cc_code_bdfext()
1056 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_check_cc_code_bdfext()
1058 ATH11K_SMBIOS_BDF_EXT_TYPE, ab->qmi.target.bdf_ext); in ath11k_core_check_cc_code_bdfext()
1061 int ath11k_core_check_smbios(struct ath11k_base *ab) in ath11k_core_check_smbios() argument
1063 ab->qmi.target.bdf_ext[0] = '\0'; in ath11k_core_check_smbios()
1064 dmi_walk(ath11k_core_check_cc_code_bdfext, ab); in ath11k_core_check_smbios()
1066 if (ab->qmi.target.bdf_ext[0] == '\0') in ath11k_core_check_smbios()
1072 int ath11k_core_check_dt(struct ath11k_base *ab) in ath11k_core_check_dt() argument
1074 size_t max_len = sizeof(ab->qmi.target.bdf_ext); in ath11k_core_check_dt()
1078 node = ab->dev->of_node; in ath11k_core_check_dt()
1087 if (strscpy(ab->qmi.target.bdf_ext, variant, max_len) < 0) in ath11k_core_check_dt()
1088 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_check_dt()
1101 static int __ath11k_core_create_board_name(struct ath11k_base *ab, char *name, in __ath11k_core_create_board_name() argument
1105 /* strlen(',variant=') + strlen(ab->qmi.target.bdf_ext) */ in __ath11k_core_create_board_name()
1108 if (with_variant && ab->qmi.target.bdf_ext[0] != '\0') in __ath11k_core_create_board_name()
1110 ab->qmi.target.bdf_ext); in __ath11k_core_create_board_name()
1112 switch (ab->id.bdf_search) { in __ath11k_core_create_board_name()
1118 ath11k_bus_str(ab->hif.bus), in __ath11k_core_create_board_name()
1119 ab->id.vendor, ab->id.device, in __ath11k_core_create_board_name()
1120 ab->id.subsystem_vendor, in __ath11k_core_create_board_name()
1121 ab->id.subsystem_device, in __ath11k_core_create_board_name()
1122 ab->qmi.target.chip_id, in __ath11k_core_create_board_name()
1123 ab->qmi.target.board_id, in __ath11k_core_create_board_name()
1129 ath11k_bus_str(ab->hif.bus)); in __ath11k_core_create_board_name()
1134 ath11k_bus_str(ab->hif.bus), in __ath11k_core_create_board_name()
1135 ab->qmi.target.chip_id); in __ath11k_core_create_board_name()
1142 ath11k_bus_str(ab->hif.bus), in __ath11k_core_create_board_name()
1143 ab->qmi.target.chip_id, in __ath11k_core_create_board_name()
1144 ab->qmi.target.board_id, variant); in __ath11k_core_create_board_name()
1148 ath11k_dbg(ab, ATH11K_DBG_BOOT, "using board name '%s'\n", name); in __ath11k_core_create_board_name()
1153 static int ath11k_core_create_board_name(struct ath11k_base *ab, char *name, in ath11k_core_create_board_name() argument
1156 return __ath11k_core_create_board_name(ab, name, name_len, true, in ath11k_core_create_board_name()
1160 static int ath11k_core_create_fallback_board_name(struct ath11k_base *ab, char *name, in ath11k_core_create_fallback_board_name() argument
1163 return __ath11k_core_create_board_name(ab, name, name_len, false, in ath11k_core_create_fallback_board_name()
1167 static int ath11k_core_create_bus_type_board_name(struct ath11k_base *ab, char *name, in ath11k_core_create_bus_type_board_name() argument
1170 return __ath11k_core_create_board_name(ab, name, name_len, false, in ath11k_core_create_bus_type_board_name()
1174 static int ath11k_core_create_chip_id_board_name(struct ath11k_base *ab, char *name, in ath11k_core_create_chip_id_board_name() argument
1177 return __ath11k_core_create_board_name(ab, name, name_len, false, in ath11k_core_create_chip_id_board_name()
1181 const struct firmware *ath11k_core_firmware_request(struct ath11k_base *ab, in ath11k_core_firmware_request() argument
1191 ath11k_core_create_firmware_path(ab, file, path, sizeof(path)); in ath11k_core_firmware_request()
1193 ret = firmware_request_nowarn(&fw, path, ab->dev); in ath11k_core_firmware_request()
1197 ath11k_dbg(ab, ATH11K_DBG_BOOT, "firmware request %s size %zu\n", in ath11k_core_firmware_request()
1203 void ath11k_core_free_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd) in ath11k_core_free_bdf() argument
1211 static int ath11k_core_parse_bd_ie_board(struct ath11k_base *ab, in ath11k_core_parse_bd_ie_board() argument
1238 ath11k_err(ab, "invalid %s length: %zu < %zu\n", in ath11k_core_parse_bd_ie_board()
1246 ath11k_dbg_dump(ab, ATH11K_DBG_BOOT, "board name", "", in ath11k_core_parse_bd_ie_board()
1257 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_parse_bd_ie_board()
1266 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_parse_bd_ie_board()
1277 ath11k_warn(ab, "unknown %s id found: %d\n", in ath11k_core_parse_bd_ie_board()
1296 static int ath11k_core_fetch_board_data_api_n(struct ath11k_base *ab, in ath11k_core_fetch_board_data_api_n() argument
1313 bd->fw = ath11k_core_firmware_request(ab, filename); in ath11k_core_fetch_board_data_api_n()
1321 ath11k_core_create_firmware_path(ab, filename, in ath11k_core_fetch_board_data_api_n()
1327 ath11k_err(ab, "failed to find magic value in %s, file too short: %zu\n", in ath11k_core_fetch_board_data_api_n()
1334 ath11k_err(ab, "found invalid board magic\n"); in ath11k_core_fetch_board_data_api_n()
1342 ath11k_err(ab, "failed: %s too small to contain board data, len: %zu\n", in ath11k_core_fetch_board_data_api_n()
1360 ath11k_err(ab, "invalid length for board ie_id %d ie_len %zu len %zu\n", in ath11k_core_fetch_board_data_api_n()
1367 ret = ath11k_core_parse_bd_ie_board(ab, bd, data, in ath11k_core_fetch_board_data_api_n()
1392 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_fetch_board_data_api_n()
1403 ath11k_core_free_bdf(ab, bd); in ath11k_core_fetch_board_data_api_n()
1407 int ath11k_core_fetch_board_data_api_1(struct ath11k_base *ab, in ath11k_core_fetch_board_data_api_1() argument
1411 bd->fw = ath11k_core_firmware_request(ab, name); in ath11k_core_fetch_board_data_api_1()
1423 int ath11k_core_fetch_bdf(struct ath11k_base *ab, struct ath11k_board_data *bd) in ath11k_core_fetch_bdf() argument
1437 ret = ath11k_core_create_board_name(ab, boardname, BOARD_NAME_SIZE); in ath11k_core_fetch_bdf()
1439 ath11k_err(ab, "failed to create board name: %d", ret); in ath11k_core_fetch_bdf()
1444 ret = ath11k_core_fetch_board_data_api_n(ab, bd, boardname, in ath11k_core_fetch_bdf()
1457 ret = ath11k_core_create_fallback_board_name(ab, fallback_boardname, in ath11k_core_fetch_bdf()
1460 ath11k_err(ab, "failed to create fallback board name: %d", ret); in ath11k_core_fetch_bdf()
1464 ret = ath11k_core_fetch_board_data_api_n(ab, bd, fallback_boardname, in ath11k_core_fetch_bdf()
1477 ret = ath11k_core_create_chip_id_board_name(ab, chip_id_boardname, in ath11k_core_fetch_bdf()
1480 ath11k_err(ab, "failed to create chip id board name: %d", ret); in ath11k_core_fetch_bdf()
1484 ret = ath11k_core_fetch_board_data_api_n(ab, bd, chip_id_boardname, in ath11k_core_fetch_bdf()
1493 ret = ath11k_core_fetch_board_data_api_1(ab, bd, ATH11K_DEFAULT_BOARD_FILE); in ath11k_core_fetch_bdf()
1495 ath11k_core_create_firmware_path(ab, filename, in ath11k_core_fetch_bdf()
1497 ath11k_err(ab, "failed to fetch board data for %s from %s\n", in ath11k_core_fetch_bdf()
1500 ath11k_err(ab, "failed to fetch board data for %s from %s\n", in ath11k_core_fetch_bdf()
1503 ath11k_err(ab, "failed to fetch board data for %s from %s\n", in ath11k_core_fetch_bdf()
1506 ath11k_err(ab, "failed to fetch board.bin from %s\n", in ath11k_core_fetch_bdf()
1507 ab->hw_params.fw.dir); in ath11k_core_fetch_bdf()
1516 ath11k_dbg(ab, ATH11K_DBG_BOOT, "using board api %d\n", bd_api); in ath11k_core_fetch_bdf()
1521 int ath11k_core_fetch_regdb(struct ath11k_base *ab, struct ath11k_board_data *bd) in ath11k_core_fetch_regdb() argument
1526 ret = ath11k_core_create_board_name(ab, boardname, BOARD_NAME_SIZE); in ath11k_core_fetch_regdb()
1528 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_fetch_regdb()
1533 ret = ath11k_core_fetch_board_data_api_n(ab, bd, boardname, in ath11k_core_fetch_regdb()
1540 ret = ath11k_core_create_bus_type_board_name(ab, default_boardname, in ath11k_core_fetch_regdb()
1543 ath11k_dbg(ab, ATH11K_DBG_BOOT, in ath11k_core_fetch_regdb()
1548 ret = ath11k_core_fetch_board_data_api_n(ab, bd, default_boardname, in ath11k_core_fetch_regdb()
1555 ret = ath11k_core_fetch_board_data_api_1(ab, bd, ATH11K_REGDB_FILE_NAME); in ath11k_core_fetch_regdb()
1557 ath11k_dbg(ab, ATH11K_DBG_BOOT, "failed to fetch %s from %s\n", in ath11k_core_fetch_regdb()
1558 ATH11K_REGDB_FILE_NAME, ab->hw_params.fw.dir); in ath11k_core_fetch_regdb()
1562 ath11k_dbg(ab, ATH11K_DBG_BOOT, "fetched regdb\n"); in ath11k_core_fetch_regdb()
1567 static void ath11k_core_stop(struct ath11k_base *ab) in ath11k_core_stop() argument
1569 if (!test_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags)) in ath11k_core_stop()
1570 ath11k_qmi_firmware_stop(ab); in ath11k_core_stop()
1572 ath11k_hif_stop(ab); in ath11k_core_stop()
1573 ath11k_wmi_detach(ab); in ath11k_core_stop()
1574 ath11k_dp_pdev_reo_cleanup(ab); in ath11k_core_stop()
1579 static int ath11k_core_soc_create(struct ath11k_base *ab) in ath11k_core_soc_create() argument
1584 ab->fw_mode = ATH11K_FIRMWARE_MODE_FTM; in ath11k_core_soc_create()
1585 ath11k_info(ab, "Booting in factory test mode\n"); in ath11k_core_soc_create()
1588 ret = ath11k_qmi_init_service(ab); in ath11k_core_soc_create()
1590 ath11k_err(ab, "failed to initialize qmi :%d\n", ret); in ath11k_core_soc_create()
1594 ret = ath11k_debugfs_soc_create(ab); in ath11k_core_soc_create()
1596 ath11k_err(ab, "failed to create ath11k debugfs\n"); in ath11k_core_soc_create()
1600 ret = ath11k_hif_power_up(ab); in ath11k_core_soc_create()
1602 ath11k_err(ab, "failed to power up :%d\n", ret); in ath11k_core_soc_create()
1609 ath11k_debugfs_soc_destroy(ab); in ath11k_core_soc_create()
1611 ath11k_qmi_deinit_service(ab); in ath11k_core_soc_create()
1615 static void ath11k_core_soc_destroy(struct ath11k_base *ab) in ath11k_core_soc_destroy() argument
1617 ath11k_debugfs_soc_destroy(ab); in ath11k_core_soc_destroy()
1618 ath11k_dp_free(ab); in ath11k_core_soc_destroy()
1619 ath11k_reg_free(ab); in ath11k_core_soc_destroy()
1620 ath11k_qmi_deinit_service(ab); in ath11k_core_soc_destroy()
1623 static int ath11k_core_pdev_create(struct ath11k_base *ab) in ath11k_core_pdev_create() argument
1627 ret = ath11k_debugfs_pdev_create(ab); in ath11k_core_pdev_create()
1629 ath11k_err(ab, "failed to create core pdev debugfs: %d\n", ret); in ath11k_core_pdev_create()
1633 ret = ath11k_dp_pdev_alloc(ab); in ath11k_core_pdev_create()
1635 ath11k_err(ab, "failed to attach DP pdev: %d\n", ret); in ath11k_core_pdev_create()
1639 ret = ath11k_mac_register(ab); in ath11k_core_pdev_create()
1641 ath11k_err(ab, "failed register the radio with mac80211: %d\n", ret); in ath11k_core_pdev_create()
1645 ret = ath11k_thermal_register(ab); in ath11k_core_pdev_create()
1647 ath11k_err(ab, "could not register thermal device: %d\n", in ath11k_core_pdev_create()
1652 ret = ath11k_spectral_init(ab); in ath11k_core_pdev_create()
1654 ath11k_err(ab, "failed to init spectral %d\n", ret); in ath11k_core_pdev_create()
1661 ath11k_thermal_unregister(ab); in ath11k_core_pdev_create()
1663 ath11k_mac_unregister(ab); in ath11k_core_pdev_create()
1665 ath11k_dp_pdev_free(ab); in ath11k_core_pdev_create()
1667 ath11k_debugfs_pdev_destroy(ab); in ath11k_core_pdev_create()
1672 static void ath11k_core_pdev_destroy(struct ath11k_base *ab) in ath11k_core_pdev_destroy() argument
1674 ath11k_spectral_deinit(ab); in ath11k_core_pdev_destroy()
1675 ath11k_thermal_unregister(ab); in ath11k_core_pdev_destroy()
1676 ath11k_mac_unregister(ab); in ath11k_core_pdev_destroy()
1677 ath11k_hif_irq_disable(ab); in ath11k_core_pdev_destroy()
1678 ath11k_dp_pdev_free(ab); in ath11k_core_pdev_destroy()
1679 ath11k_debugfs_pdev_destroy(ab); in ath11k_core_pdev_destroy()
1682 static int ath11k_core_start(struct ath11k_base *ab) in ath11k_core_start() argument
1686 ret = ath11k_wmi_attach(ab); in ath11k_core_start()
1688 ath11k_err(ab, "failed to attach wmi: %d\n", ret); in ath11k_core_start()
1692 ret = ath11k_htc_init(ab); in ath11k_core_start()
1694 ath11k_err(ab, "failed to init htc: %d\n", ret); in ath11k_core_start()
1698 ret = ath11k_hif_start(ab); in ath11k_core_start()
1700 ath11k_err(ab, "failed to start HIF: %d\n", ret); in ath11k_core_start()
1704 ret = ath11k_htc_wait_target(&ab->htc); in ath11k_core_start()
1706 ath11k_err(ab, "failed to connect to HTC: %d\n", ret); in ath11k_core_start()
1710 ret = ath11k_dp_htt_connect(&ab->dp); in ath11k_core_start()
1712 ath11k_err(ab, "failed to connect to HTT: %d\n", ret); in ath11k_core_start()
1716 ret = ath11k_wmi_connect(ab); in ath11k_core_start()
1718 ath11k_err(ab, "failed to connect wmi: %d\n", ret); in ath11k_core_start()
1722 ret = ath11k_htc_start(&ab->htc); in ath11k_core_start()
1724 ath11k_err(ab, "failed to start HTC: %d\n", ret); in ath11k_core_start()
1728 ret = ath11k_wmi_wait_for_service_ready(ab); in ath11k_core_start()
1730 ath11k_err(ab, "failed to receive wmi service ready event: %d\n", in ath11k_core_start()
1735 ret = ath11k_mac_allocate(ab); in ath11k_core_start()
1737 ath11k_err(ab, "failed to create new hw device with mac80211 :%d\n", in ath11k_core_start()
1742 ath11k_dp_pdev_pre_alloc(ab); in ath11k_core_start()
1744 ret = ath11k_dp_pdev_reo_setup(ab); in ath11k_core_start()
1746 ath11k_err(ab, "failed to initialize reo destination rings: %d\n", ret); in ath11k_core_start()
1750 ret = ath11k_wmi_cmd_init(ab); in ath11k_core_start()
1752 ath11k_err(ab, "failed to send wmi init cmd: %d\n", ret); in ath11k_core_start()
1756 ret = ath11k_wmi_wait_for_unified_ready(ab); in ath11k_core_start()
1758 ath11k_err(ab, "failed to receive wmi unified ready event: %d\n", in ath11k_core_start()
1764 if (ab->hw_params.single_pdev_only && ab->hw_params.num_rxdma_per_pdev > 1) { in ath11k_core_start()
1765 ret = ath11k_wmi_set_hw_mode(ab, WMI_HOST_HW_MODE_DBS); in ath11k_core_start()
1767 ath11k_err(ab, "failed to send dbs mode: %d\n", ret); in ath11k_core_start()
1772 ret = ath11k_dp_tx_htt_h2t_ver_req_msg(ab); in ath11k_core_start()
1774 ath11k_err(ab, "failed to send htt version request message: %d\n", in ath11k_core_start()
1782 ath11k_dp_pdev_reo_cleanup(ab); in ath11k_core_start()
1784 ath11k_mac_destroy(ab); in ath11k_core_start()
1786 ath11k_hif_stop(ab); in ath11k_core_start()
1788 ath11k_wmi_detach(ab); in ath11k_core_start()
1793 static int ath11k_core_start_firmware(struct ath11k_base *ab, in ath11k_core_start_firmware() argument
1798 ath11k_ce_get_shadow_config(ab, &ab->qmi.ce_cfg.shadow_reg_v2, in ath11k_core_start_firmware()
1799 &ab->qmi.ce_cfg.shadow_reg_v2_len); in ath11k_core_start_firmware()
1801 ret = ath11k_qmi_firmware_start(ab, mode); in ath11k_core_start_firmware()
1803 ath11k_err(ab, "failed to send firmware start: %d\n", ret); in ath11k_core_start_firmware()
1810 int ath11k_core_qmi_firmware_ready(struct ath11k_base *ab) in ath11k_core_qmi_firmware_ready() argument
1814 ret = ath11k_core_start_firmware(ab, ab->fw_mode); in ath11k_core_qmi_firmware_ready()
1816 ath11k_err(ab, "failed to start firmware: %d\n", ret); in ath11k_core_qmi_firmware_ready()
1820 ret = ath11k_ce_init_pipes(ab); in ath11k_core_qmi_firmware_ready()
1822 ath11k_err(ab, "failed to initialize CE: %d\n", ret); in ath11k_core_qmi_firmware_ready()
1826 ret = ath11k_dp_alloc(ab); in ath11k_core_qmi_firmware_ready()
1828 ath11k_err(ab, "failed to init DP: %d\n", ret); in ath11k_core_qmi_firmware_ready()
1834 set_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags); in ath11k_core_qmi_firmware_ready()
1835 set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags); in ath11k_core_qmi_firmware_ready()
1838 clear_bit(ATH11K_FLAG_HW_CRYPTO_DISABLED, &ab->dev_flags); in ath11k_core_qmi_firmware_ready()
1839 clear_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags); in ath11k_core_qmi_firmware_ready()
1842 ath11k_info(ab, "invalid crypto_mode: %d\n", ath11k_crypto_mode); in ath11k_core_qmi_firmware_ready()
1847 set_bit(ATH11K_FLAG_RAW_MODE, &ab->dev_flags); in ath11k_core_qmi_firmware_ready()
1849 mutex_lock(&ab->core_lock); in ath11k_core_qmi_firmware_ready()
1850 ret = ath11k_core_start(ab); in ath11k_core_qmi_firmware_ready()
1852 ath11k_err(ab, "failed to start core: %d\n", ret); in ath11k_core_qmi_firmware_ready()
1856 ret = ath11k_core_pdev_create(ab); in ath11k_core_qmi_firmware_ready()
1858 ath11k_err(ab, "failed to create pdev core: %d\n", ret); in ath11k_core_qmi_firmware_ready()
1861 ath11k_hif_irq_enable(ab); in ath11k_core_qmi_firmware_ready()
1862 mutex_unlock(&ab->core_lock); in ath11k_core_qmi_firmware_ready()
1867 ath11k_core_stop(ab); in ath11k_core_qmi_firmware_ready()
1868 ath11k_mac_destroy(ab); in ath11k_core_qmi_firmware_ready()
1870 ath11k_dp_free(ab); in ath11k_core_qmi_firmware_ready()
1871 mutex_unlock(&ab->core_lock); in ath11k_core_qmi_firmware_ready()
1873 ath11k_qmi_firmware_stop(ab); in ath11k_core_qmi_firmware_ready()
1878 static int ath11k_core_reconfigure_on_crash(struct ath11k_base *ab) in ath11k_core_reconfigure_on_crash() argument
1882 mutex_lock(&ab->core_lock); in ath11k_core_reconfigure_on_crash()
1883 ath11k_thermal_unregister(ab); in ath11k_core_reconfigure_on_crash()
1884 ath11k_dp_pdev_free(ab); in ath11k_core_reconfigure_on_crash()
1885 ath11k_spectral_deinit(ab); in ath11k_core_reconfigure_on_crash()
1886 ath11k_ce_cleanup_pipes(ab); in ath11k_core_reconfigure_on_crash()
1887 ath11k_wmi_detach(ab); in ath11k_core_reconfigure_on_crash()
1888 ath11k_dp_pdev_reo_cleanup(ab); in ath11k_core_reconfigure_on_crash()
1889 mutex_unlock(&ab->core_lock); in ath11k_core_reconfigure_on_crash()
1891 ath11k_dp_free(ab); in ath11k_core_reconfigure_on_crash()
1892 ath11k_hal_srng_deinit(ab); in ath11k_core_reconfigure_on_crash()
1894 ab->free_vdev_map = (1LL << (ab->num_radios * TARGET_NUM_VDEVS(ab))) - 1; in ath11k_core_reconfigure_on_crash()
1896 ret = ath11k_hal_srng_init(ab); in ath11k_core_reconfigure_on_crash()
1900 clear_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags); in ath11k_core_reconfigure_on_crash()
1902 ret = ath11k_core_qmi_firmware_ready(ab); in ath11k_core_reconfigure_on_crash()
1906 clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); in ath11k_core_reconfigure_on_crash()
1911 ath11k_hal_srng_deinit(ab); in ath11k_core_reconfigure_on_crash()
1917 struct ath11k_base *ab = ar->ab; in ath11k_core_halt() local
1928 cancel_work_sync(&ab->update_11d_work); in ath11k_core_halt()
1930 rcu_assign_pointer(ab->pdevs_active[ar->pdev_idx], NULL); in ath11k_core_halt()
1938 struct ath11k_base *ab = container_of(work, struct ath11k_base, update_11d_work); in ath11k_update_11d() local
1943 for (i = 0; i < ab->num_radios; i++) { in ath11k_update_11d()
1944 pdev = &ab->pdevs[i]; in ath11k_update_11d()
1947 spin_lock_bh(&ab->base_lock); in ath11k_update_11d()
1948 memcpy(&ar->alpha2, &ab->new_alpha2, 2); in ath11k_update_11d()
1949 spin_unlock_bh(&ab->base_lock); in ath11k_update_11d()
1951 ath11k_dbg(ab, ATH11K_DBG_WMI, "update 11d new cc %c%c for pdev %d\n", in ath11k_update_11d()
1956 ath11k_warn(ar->ab, in ath11k_update_11d()
1962 void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab) in ath11k_core_pre_reconfigure_recovery() argument
1968 spin_lock_bh(&ab->base_lock); in ath11k_core_pre_reconfigure_recovery()
1969 ab->stats.fw_crash_counter++; in ath11k_core_pre_reconfigure_recovery()
1970 spin_unlock_bh(&ab->base_lock); in ath11k_core_pre_reconfigure_recovery()
1972 for (i = 0; i < ab->num_radios; i++) { in ath11k_core_pre_reconfigure_recovery()
1973 pdev = &ab->pdevs[i]; in ath11k_core_pre_reconfigure_recovery()
2005 wake_up(&ab->wmi_ab.tx_credits_wq); in ath11k_core_pre_reconfigure_recovery()
2006 wake_up(&ab->peer_mapping_wq); in ath11k_core_pre_reconfigure_recovery()
2008 reinit_completion(&ab->driver_recovery); in ath11k_core_pre_reconfigure_recovery()
2011 static void ath11k_core_post_reconfigure_recovery(struct ath11k_base *ab) in ath11k_core_post_reconfigure_recovery() argument
2017 for (i = 0; i < ab->num_radios; i++) { in ath11k_core_post_reconfigure_recovery()
2018 pdev = &ab->pdevs[i]; in ath11k_core_post_reconfigure_recovery()
2032 ath11k_warn(ab, in ath11k_core_post_reconfigure_recovery()
2042 ath11k_warn(ab, in ath11k_core_post_reconfigure_recovery()
2046 ath11k_dbg(ab, ATH11K_DBG_TESTMODE, in ath11k_core_post_reconfigure_recovery()
2053 complete(&ab->driver_recovery); in ath11k_core_post_reconfigure_recovery()
2058 struct ath11k_base *ab = container_of(work, struct ath11k_base, restart_work); in ath11k_core_restart() local
2061 ret = ath11k_core_reconfigure_on_crash(ab); in ath11k_core_restart()
2063 ath11k_err(ab, "failed to reconfigure driver on crash recovery\n"); in ath11k_core_restart()
2067 if (ab->is_reset) in ath11k_core_restart()
2068 complete_all(&ab->reconfigure_complete); in ath11k_core_restart()
2070 if (!ab->is_reset) in ath11k_core_restart()
2071 ath11k_core_post_reconfigure_recovery(ab); in ath11k_core_restart()
2076 struct ath11k_base *ab = container_of(work, struct ath11k_base, reset_work); in ath11k_core_reset() local
2080 if (!(test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))) { in ath11k_core_reset()
2081 ath11k_warn(ab, "ignore reset dev flags 0x%lx\n", ab->dev_flags); in ath11k_core_reset()
2088 fail_cont_count = atomic_read(&ab->fail_cont_count); in ath11k_core_reset()
2094 time_before(jiffies, ab->reset_fail_timeout)) in ath11k_core_reset()
2097 reset_count = atomic_inc_return(&ab->reset_count); in ath11k_core_reset()
2104 ath11k_warn(ab, "already resetting count %d\n", reset_count); in ath11k_core_reset()
2106 reinit_completion(&ab->reset_complete); in ath11k_core_reset()
2107 time_left = wait_for_completion_timeout(&ab->reset_complete, in ath11k_core_reset()
2111 ath11k_dbg(ab, ATH11K_DBG_BOOT, "to skip reset\n"); in ath11k_core_reset()
2112 atomic_dec(&ab->reset_count); in ath11k_core_reset()
2116 ab->reset_fail_timeout = jiffies + ATH11K_RESET_FAIL_TIMEOUT_HZ; in ath11k_core_reset()
2118 atomic_inc(&ab->fail_cont_count); in ath11k_core_reset()
2121 ath11k_dbg(ab, ATH11K_DBG_BOOT, "reset starting\n"); in ath11k_core_reset()
2123 ab->is_reset = true; in ath11k_core_reset()
2124 atomic_set(&ab->recovery_count, 0); in ath11k_core_reset()
2125 reinit_completion(&ab->recovery_start); in ath11k_core_reset()
2126 atomic_set(&ab->recovery_start_count, 0); in ath11k_core_reset()
2128 ath11k_core_pre_reconfigure_recovery(ab); in ath11k_core_reset()
2130 reinit_completion(&ab->reconfigure_complete); in ath11k_core_reset()
2131 ath11k_core_post_reconfigure_recovery(ab); in ath11k_core_reset()
2133 ath11k_dbg(ab, ATH11K_DBG_BOOT, "waiting recovery start...\n"); in ath11k_core_reset()
2135 time_left = wait_for_completion_timeout(&ab->recovery_start, in ath11k_core_reset()
2138 ath11k_hif_irq_disable(ab); in ath11k_core_reset()
2139 ath11k_hif_ce_irq_disable(ab); in ath11k_core_reset()
2141 ath11k_hif_power_down(ab); in ath11k_core_reset()
2142 ath11k_hif_power_up(ab); in ath11k_core_reset()
2144 ath11k_dbg(ab, ATH11K_DBG_BOOT, "reset started\n"); in ath11k_core_reset()
2147 static int ath11k_init_hw_params(struct ath11k_base *ab) in ath11k_init_hw_params() argument
2155 if (hw_params->hw_rev == ab->hw_rev) in ath11k_init_hw_params()
2160 ath11k_err(ab, "Unsupported hardware version: 0x%x\n", ab->hw_rev); in ath11k_init_hw_params()
2164 ab->hw_params = *hw_params; in ath11k_init_hw_params()
2166 ath11k_info(ab, "%s\n", ab->hw_params.name); in ath11k_init_hw_params()
2171 int ath11k_core_pre_init(struct ath11k_base *ab) in ath11k_core_pre_init() argument
2175 ret = ath11k_init_hw_params(ab); in ath11k_core_pre_init()
2177 ath11k_err(ab, "failed to get hw params: %d\n", ret); in ath11k_core_pre_init()
2181 ret = ath11k_fw_pre_init(ab); in ath11k_core_pre_init()
2183 ath11k_err(ab, "failed to pre init firmware: %d", ret); in ath11k_core_pre_init()
2191 int ath11k_core_init(struct ath11k_base *ab) in ath11k_core_init() argument
2195 ret = ath11k_core_soc_create(ab); in ath11k_core_init()
2197 ath11k_err(ab, "failed to create soc core: %d\n", ret); in ath11k_core_init()
2205 void ath11k_core_deinit(struct ath11k_base *ab) in ath11k_core_deinit() argument
2207 mutex_lock(&ab->core_lock); in ath11k_core_deinit()
2209 ath11k_core_pdev_destroy(ab); in ath11k_core_deinit()
2210 ath11k_core_stop(ab); in ath11k_core_deinit()
2212 mutex_unlock(&ab->core_lock); in ath11k_core_deinit()
2214 ath11k_hif_power_down(ab); in ath11k_core_deinit()
2215 ath11k_mac_destroy(ab); in ath11k_core_deinit()
2216 ath11k_core_soc_destroy(ab); in ath11k_core_deinit()
2217 ath11k_fw_destroy(ab); in ath11k_core_deinit()
2221 void ath11k_core_free(struct ath11k_base *ab) in ath11k_core_free() argument
2223 destroy_workqueue(ab->workqueue_aux); in ath11k_core_free()
2224 destroy_workqueue(ab->workqueue); in ath11k_core_free()
2226 kfree(ab); in ath11k_core_free()
2233 struct ath11k_base *ab; in ath11k_core_alloc() local
2235 ab = kzalloc(sizeof(*ab) + priv_size, GFP_KERNEL); in ath11k_core_alloc()
2236 if (!ab) in ath11k_core_alloc()
2239 init_completion(&ab->driver_recovery); in ath11k_core_alloc()
2241 ab->workqueue = create_singlethread_workqueue("ath11k_wq"); in ath11k_core_alloc()
2242 if (!ab->workqueue) in ath11k_core_alloc()
2245 ab->workqueue_aux = create_singlethread_workqueue("ath11k_aux_wq"); in ath11k_core_alloc()
2246 if (!ab->workqueue_aux) in ath11k_core_alloc()
2249 mutex_init(&ab->core_lock); in ath11k_core_alloc()
2250 mutex_init(&ab->tbl_mtx_lock); in ath11k_core_alloc()
2251 spin_lock_init(&ab->base_lock); in ath11k_core_alloc()
2252 mutex_init(&ab->vdev_id_11d_lock); in ath11k_core_alloc()
2253 init_completion(&ab->reset_complete); in ath11k_core_alloc()
2254 init_completion(&ab->reconfigure_complete); in ath11k_core_alloc()
2255 init_completion(&ab->recovery_start); in ath11k_core_alloc()
2257 INIT_LIST_HEAD(&ab->peers); in ath11k_core_alloc()
2258 init_waitqueue_head(&ab->peer_mapping_wq); in ath11k_core_alloc()
2259 init_waitqueue_head(&ab->wmi_ab.tx_credits_wq); in ath11k_core_alloc()
2260 init_waitqueue_head(&ab->qmi.cold_boot_waitq); in ath11k_core_alloc()
2261 INIT_WORK(&ab->restart_work, ath11k_core_restart); in ath11k_core_alloc()
2262 INIT_WORK(&ab->update_11d_work, ath11k_update_11d); in ath11k_core_alloc()
2263 INIT_WORK(&ab->reset_work, ath11k_core_reset); in ath11k_core_alloc()
2264 timer_setup(&ab->rx_replenish_retry, ath11k_ce_rx_replenish_retry, 0); in ath11k_core_alloc()
2265 init_completion(&ab->htc_suspend); in ath11k_core_alloc()
2266 init_completion(&ab->wow.wakeup_completed); in ath11k_core_alloc()
2268 ab->dev = dev; in ath11k_core_alloc()
2269 ab->hif.bus = bus; in ath11k_core_alloc()
2271 return ab; in ath11k_core_alloc()
2274 destroy_workqueue(ab->workqueue); in ath11k_core_alloc()
2276 kfree(ab); in ath11k_core_alloc()