Lines Matching refs:ab
1707 static int ath11k_qmi_host_cap_send(struct ath11k_base *ab) in ath11k_qmi_host_cap_send() argument
1719 req.mem_cfg_mode = ab->qmi.target_mem_mode; in ath11k_qmi_host_cap_send()
1724 if (ab->hw_params.m3_fw_support) { in ath11k_qmi_host_cap_send()
1737 req.cal_done = ab->qmi.cal_done; in ath11k_qmi_host_cap_send()
1739 if (ab->hw_params.internal_sleep_clock) { in ath11k_qmi_host_cap_send()
1753 if (ab->hw_params.global_reset) in ath11k_qmi_host_cap_send()
1758 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi host cap request\n"); in ath11k_qmi_host_cap_send()
1760 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_host_cap_send()
1765 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_host_cap_send()
1771 ath11k_warn(ab, "failed to send host capability request: %d\n", ret); in ath11k_qmi_host_cap_send()
1780 ath11k_warn(ab, "host capability request failed: %d %d\n", in ath11k_qmi_host_cap_send()
1790 static int ath11k_qmi_fw_ind_register_send(struct ath11k_base *ab) in ath11k_qmi_fw_ind_register_send() argument
1794 struct qmi_handle *handle = &ab->qmi.handle; in ath11k_qmi_fw_ind_register_send()
1824 if (!ab->hw_params.fixed_fw_mem) { in ath11k_qmi_fw_ind_register_send()
1836 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi indication register request\n"); in ath11k_qmi_fw_ind_register_send()
1838 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_fw_ind_register_send()
1844 ath11k_warn(ab, "failed to send indication register request: %d\n", in ath11k_qmi_fw_ind_register_send()
1851 ath11k_warn(ab, "failed to register fw indication: %d\n", ret); in ath11k_qmi_fw_ind_register_send()
1856 ath11k_warn(ab, "firmware indication register request failed: %d %d\n", in ath11k_qmi_fw_ind_register_send()
1869 static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab) in ath11k_qmi_respond_fw_mem_request() argument
1888 if (!(ab->hw_params.fixed_mem_region || in ath11k_qmi_respond_fw_mem_request()
1889 test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) && in ath11k_qmi_respond_fw_mem_request()
1890 ab->qmi.target_mem_delayed) { in ath11k_qmi_respond_fw_mem_request()
1892 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n", in ath11k_qmi_respond_fw_mem_request()
1893 ab->qmi.mem_seg_count); in ath11k_qmi_respond_fw_mem_request()
1897 req->mem_seg_len = ab->qmi.mem_seg_count; in ath11k_qmi_respond_fw_mem_request()
1900 req->mem_seg[i].addr = ab->qmi.target_mem[i].paddr; in ath11k_qmi_respond_fw_mem_request()
1901 req->mem_seg[i].size = ab->qmi.target_mem[i].size; in ath11k_qmi_respond_fw_mem_request()
1902 req->mem_seg[i].type = ab->qmi.target_mem[i].type; in ath11k_qmi_respond_fw_mem_request()
1903 ath11k_dbg(ab, ATH11K_DBG_QMI, in ath11k_qmi_respond_fw_mem_request()
1905 &ab->qmi.target_mem[i].paddr, in ath11k_qmi_respond_fw_mem_request()
1906 ab->qmi.target_mem[i].size, in ath11k_qmi_respond_fw_mem_request()
1907 ab->qmi.target_mem[i].type); in ath11k_qmi_respond_fw_mem_request()
1911 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_respond_fw_mem_request()
1916 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi respond memory request delayed %i\n", in ath11k_qmi_respond_fw_mem_request()
1919 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_respond_fw_mem_request()
1925 ath11k_warn(ab, "failed to respond qmi memory request: %d\n", in ath11k_qmi_respond_fw_mem_request()
1932 ath11k_warn(ab, "failed to wait qmi memory request: %d\n", ret); in ath11k_qmi_respond_fw_mem_request()
1943 ath11k_warn(ab, "qmi respond memory request failed: %d %d\n", in ath11k_qmi_respond_fw_mem_request()
1953 static void ath11k_qmi_free_target_mem_chunk(struct ath11k_base *ab) in ath11k_qmi_free_target_mem_chunk() argument
1957 for (i = 0; i < ab->qmi.mem_seg_count; i++) { in ath11k_qmi_free_target_mem_chunk()
1958 if ((ab->hw_params.fixed_mem_region || in ath11k_qmi_free_target_mem_chunk()
1959 test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) && in ath11k_qmi_free_target_mem_chunk()
1960 ab->qmi.target_mem[i].iaddr) in ath11k_qmi_free_target_mem_chunk()
1961 iounmap(ab->qmi.target_mem[i].iaddr); in ath11k_qmi_free_target_mem_chunk()
1963 if (!ab->qmi.target_mem[i].vaddr) in ath11k_qmi_free_target_mem_chunk()
1966 dma_free_coherent(ab->dev, in ath11k_qmi_free_target_mem_chunk()
1967 ab->qmi.target_mem[i].size, in ath11k_qmi_free_target_mem_chunk()
1968 ab->qmi.target_mem[i].vaddr, in ath11k_qmi_free_target_mem_chunk()
1969 ab->qmi.target_mem[i].paddr); in ath11k_qmi_free_target_mem_chunk()
1970 ab->qmi.target_mem[i].vaddr = NULL; in ath11k_qmi_free_target_mem_chunk()
1974 static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab) in ath11k_qmi_alloc_target_mem_chunk() argument
1979 ab->qmi.target_mem_delayed = false; in ath11k_qmi_alloc_target_mem_chunk()
1981 for (i = 0; i < ab->qmi.mem_seg_count; i++) { in ath11k_qmi_alloc_target_mem_chunk()
1982 chunk = &ab->qmi.target_mem[i]; in ath11k_qmi_alloc_target_mem_chunk()
1993 dma_free_coherent(ab->dev, chunk->size, in ath11k_qmi_alloc_target_mem_chunk()
1998 chunk->vaddr = dma_alloc_coherent(ab->dev, in ath11k_qmi_alloc_target_mem_chunk()
2003 if (ab->qmi.mem_seg_count <= ATH11K_QMI_FW_MEM_REQ_SEGMENT_CNT) { in ath11k_qmi_alloc_target_mem_chunk()
2004 ath11k_dbg(ab, ATH11K_DBG_QMI, in ath11k_qmi_alloc_target_mem_chunk()
2008 ath11k_qmi_free_target_mem_chunk(ab); in ath11k_qmi_alloc_target_mem_chunk()
2009 ab->qmi.target_mem_delayed = true; in ath11k_qmi_alloc_target_mem_chunk()
2013 ath11k_err(ab, "failed to allocate dma memory for qmi (%d B type %u)\n", in ath11k_qmi_alloc_target_mem_chunk()
2025 static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab) in ath11k_qmi_assign_target_mem_chunk() argument
2027 struct device *dev = ab->dev; in ath11k_qmi_assign_target_mem_chunk()
2033 for (i = 0, idx = 0; i < ab->qmi.mem_seg_count; i++) { in ath11k_qmi_assign_target_mem_chunk()
2034 switch (ab->qmi.target_mem[i].type) { in ath11k_qmi_assign_target_mem_chunk()
2038 ath11k_dbg(ab, ATH11K_DBG_QMI, in ath11k_qmi_assign_target_mem_chunk()
2046 ath11k_dbg(ab, ATH11K_DBG_QMI, in ath11k_qmi_assign_target_mem_chunk()
2051 if (res.end - res.start + 1 < ab->qmi.target_mem[i].size) { in ath11k_qmi_assign_target_mem_chunk()
2052 ath11k_dbg(ab, ATH11K_DBG_QMI, in ath11k_qmi_assign_target_mem_chunk()
2057 ab->qmi.target_mem[idx].paddr = res.start; in ath11k_qmi_assign_target_mem_chunk()
2058 ab->qmi.target_mem[idx].iaddr = in ath11k_qmi_assign_target_mem_chunk()
2059 ioremap(ab->qmi.target_mem[idx].paddr, in ath11k_qmi_assign_target_mem_chunk()
2060 ab->qmi.target_mem[i].size); in ath11k_qmi_assign_target_mem_chunk()
2061 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2062 host_ddr_sz = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2063 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; in ath11k_qmi_assign_target_mem_chunk()
2067 ab->qmi.target_mem[idx].paddr = ab->hw_params.bdf_addr; in ath11k_qmi_assign_target_mem_chunk()
2068 ab->qmi.target_mem[idx].vaddr = NULL; in ath11k_qmi_assign_target_mem_chunk()
2069 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2070 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; in ath11k_qmi_assign_target_mem_chunk()
2074 if (ab->qmi.target_mem[i].size > ATH11K_QMI_CALDB_SIZE) { in ath11k_qmi_assign_target_mem_chunk()
2075 ath11k_warn(ab, "qmi mem size is low to load caldata\n"); in ath11k_qmi_assign_target_mem_chunk()
2079 if (ath11k_cold_boot_cal && ab->hw_params.cold_boot_calib) { in ath11k_qmi_assign_target_mem_chunk()
2081 ab->qmi.target_mem[idx].paddr = in ath11k_qmi_assign_target_mem_chunk()
2083 ab->qmi.target_mem[idx].iaddr = in ath11k_qmi_assign_target_mem_chunk()
2084 ioremap(ab->qmi.target_mem[idx].paddr, in ath11k_qmi_assign_target_mem_chunk()
2085 ab->qmi.target_mem[i].size); in ath11k_qmi_assign_target_mem_chunk()
2087 ab->qmi.target_mem[idx].paddr = in ath11k_qmi_assign_target_mem_chunk()
2091 ab->qmi.target_mem[idx].paddr = 0; in ath11k_qmi_assign_target_mem_chunk()
2092 ab->qmi.target_mem[idx].vaddr = NULL; in ath11k_qmi_assign_target_mem_chunk()
2094 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2095 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; in ath11k_qmi_assign_target_mem_chunk()
2099 ath11k_warn(ab, "qmi ignore invalid mem req type %d\n", in ath11k_qmi_assign_target_mem_chunk()
2100 ab->qmi.target_mem[i].type); in ath11k_qmi_assign_target_mem_chunk()
2104 ab->qmi.mem_seg_count = idx; in ath11k_qmi_assign_target_mem_chunk()
2109 static int ath11k_qmi_request_device_info(struct ath11k_base *ab) in ath11k_qmi_request_device_info() argument
2118 if (!ab->hw_params.hybrid_bus_type) in ath11k_qmi_request_device_info()
2121 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_request_device_info()
2126 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_request_device_info()
2132 ath11k_warn(ab, "failed to send qmi target device info request: %d\n", in ath11k_qmi_request_device_info()
2139 ath11k_warn(ab, "failed to wait qmi target device info request: %d\n", in ath11k_qmi_request_device_info()
2145 ath11k_warn(ab, "qmi device info request failed: %d %d\n", in ath11k_qmi_request_device_info()
2152 ath11k_warn(ab, "qmi device info response invalid: %d %d\n", in ath11k_qmi_request_device_info()
2160 ath11k_warn(ab, "qmi device info invalid address and size: %llu %u\n", in ath11k_qmi_request_device_info()
2166 bar_addr_va = devm_ioremap(ab->dev, resp.bar_addr, resp.bar_size); in ath11k_qmi_request_device_info()
2169 ath11k_warn(ab, "qmi device info ioremap failed\n"); in ath11k_qmi_request_device_info()
2170 ab->mem_len = 0; in ath11k_qmi_request_device_info()
2175 ab->mem = bar_addr_va; in ath11k_qmi_request_device_info()
2176 ab->mem_len = resp.bar_size; in ath11k_qmi_request_device_info()
2183 static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) in ath11k_qmi_request_target_cap() argument
2196 ret = qmi_txn_init(&ab->qmi.handle, &txn, qmi_wlanfw_cap_resp_msg_v01_ei, in ath11k_qmi_request_target_cap()
2201 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi target cap request\n"); in ath11k_qmi_request_target_cap()
2203 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_request_target_cap()
2209 ath11k_warn(ab, "failed to send qmi cap request: %d\n", in ath11k_qmi_request_target_cap()
2216 ath11k_warn(ab, "failed to wait qmi cap request: %d\n", ret); in ath11k_qmi_request_target_cap()
2221 ath11k_warn(ab, "qmi cap request failed: %d %d\n", in ath11k_qmi_request_target_cap()
2228 ab->qmi.target.chip_id = resp.chip_info.chip_id; in ath11k_qmi_request_target_cap()
2229 ab->qmi.target.chip_family = resp.chip_info.chip_family; in ath11k_qmi_request_target_cap()
2233 ab->qmi.target.board_id = resp.board_info.board_id; in ath11k_qmi_request_target_cap()
2235 ab->qmi.target.board_id = 0xFF; in ath11k_qmi_request_target_cap()
2238 ab->qmi.target.soc_id = resp.soc_info.soc_id; in ath11k_qmi_request_target_cap()
2241 ab->qmi.target.fw_version = resp.fw_version_info.fw_version; in ath11k_qmi_request_target_cap()
2242 strscpy(ab->qmi.target.fw_build_timestamp, in ath11k_qmi_request_target_cap()
2244 sizeof(ab->qmi.target.fw_build_timestamp)); in ath11k_qmi_request_target_cap()
2248 strscpy(ab->qmi.target.fw_build_id, resp.fw_build_id, in ath11k_qmi_request_target_cap()
2249 sizeof(ab->qmi.target.fw_build_id)); in ath11k_qmi_request_target_cap()
2252 ab->qmi.target.eeprom_caldata = in ath11k_qmi_request_target_cap()
2254 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cal data supported from eeprom\n"); in ath11k_qmi_request_target_cap()
2257 fw_build_id = ab->qmi.target.fw_build_id; in ath11k_qmi_request_target_cap()
2262 ath11k_info(ab, "chip_id 0x%x chip_family 0x%x board_id 0x%x soc_id 0x%x\n", in ath11k_qmi_request_target_cap()
2263 ab->qmi.target.chip_id, ab->qmi.target.chip_family, in ath11k_qmi_request_target_cap()
2264 ab->qmi.target.board_id, ab->qmi.target.soc_id); in ath11k_qmi_request_target_cap()
2266 ath11k_info(ab, "fw_version 0x%x fw_build_timestamp %s fw_build_id %s", in ath11k_qmi_request_target_cap()
2267 ab->qmi.target.fw_version, in ath11k_qmi_request_target_cap()
2268 ab->qmi.target.fw_build_timestamp, in ath11k_qmi_request_target_cap()
2271 r = ath11k_core_check_smbios(ab); in ath11k_qmi_request_target_cap()
2273 ath11k_dbg(ab, ATH11K_DBG_QMI, "SMBIOS bdf variant name not set.\n"); in ath11k_qmi_request_target_cap()
2275 r = ath11k_core_check_dt(ab); in ath11k_qmi_request_target_cap()
2277 ath11k_dbg(ab, ATH11K_DBG_QMI, "DT bdf variant name not set.\n"); in ath11k_qmi_request_target_cap()
2283 static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab, in ath11k_qmi_load_file_target_mem() argument
2300 if (ab->hw_params.fixed_bdf_addr) { in ath11k_qmi_load_file_target_mem()
2301 bdf_addr = ioremap(ab->hw_params.bdf_addr, ab->hw_params.fw.board_size); in ath11k_qmi_load_file_target_mem()
2303 ath11k_warn(ab, "qmi ioremap error for bdf_addr\n"); in ath11k_qmi_load_file_target_mem()
2312 req->file_id = ab->qmi.target.board_id; in ath11k_qmi_load_file_target_mem()
2329 if (ab->hw_params.fixed_bdf_addr || in ath11k_qmi_load_file_target_mem()
2338 if (ab->hw_params.fixed_bdf_addr) { in ath11k_qmi_load_file_target_mem()
2340 bdf_addr += ab->hw_params.fw.cal_offset; in ath11k_qmi_load_file_target_mem()
2345 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_load_file_target_mem()
2351 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi bdf download req fixed addr type %d\n", in ath11k_qmi_load_file_target_mem()
2354 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_load_file_target_mem()
2365 ath11k_warn(ab, "failed to wait board file download request: %d\n", in ath11k_qmi_load_file_target_mem()
2371 ath11k_warn(ab, "board file download request failed: %d %d\n", in ath11k_qmi_load_file_target_mem()
2377 if (ab->hw_params.fixed_bdf_addr || in ath11k_qmi_load_file_target_mem()
2384 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi bdf download request remaining %i\n", in ath11k_qmi_load_file_target_mem()
2390 if (ab->hw_params.fixed_bdf_addr) in ath11k_qmi_load_file_target_mem()
2399 static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab, in ath11k_qmi_load_bdf_qmi() argument
2402 struct device *dev = ab->dev; in ath11k_qmi_load_bdf_qmi()
2413 ret = ath11k_core_fetch_regdb(ab, &bd); in ath11k_qmi_load_bdf_qmi()
2415 ret = ath11k_core_fetch_bdf(ab, &bd); in ath11k_qmi_load_bdf_qmi()
2417 ath11k_warn(ab, "qmi failed to fetch board file: %d\n", ret); in ath11k_qmi_load_bdf_qmi()
2430 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi bdf_type %d\n", bdf_type); in ath11k_qmi_load_bdf_qmi()
2432 fw_size = min_t(u32, ab->hw_params.fw.board_size, bd.len); in ath11k_qmi_load_bdf_qmi()
2434 ret = ath11k_qmi_load_file_target_mem(ab, bd.data, fw_size, bdf_type); in ath11k_qmi_load_bdf_qmi()
2436 ath11k_warn(ab, "qmi failed to load bdf file\n"); in ath11k_qmi_load_bdf_qmi()
2444 if (ab->qmi.target.eeprom_caldata) { in ath11k_qmi_load_bdf_qmi()
2453 ath11k_bus_str(ab->hif.bus), dev_name(dev)); in ath11k_qmi_load_bdf_qmi()
2454 fw_entry = ath11k_core_firmware_request(ab, filename); in ath11k_qmi_load_bdf_qmi()
2458 fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE); in ath11k_qmi_load_bdf_qmi()
2461 ath11k_warn(ab, in ath11k_qmi_load_bdf_qmi()
2467 fw_size = min_t(u32, ab->hw_params.fw.board_size, fw_entry->size); in ath11k_qmi_load_bdf_qmi()
2471 ret = ath11k_qmi_load_file_target_mem(ab, tmp, fw_size, file_type); in ath11k_qmi_load_bdf_qmi()
2473 ath11k_warn(ab, "qmi failed to load caldata\n"); in ath11k_qmi_load_bdf_qmi()
2477 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi caldata type: %u\n", file_type); in ath11k_qmi_load_bdf_qmi()
2480 if (!ab->qmi.target.eeprom_caldata) in ath11k_qmi_load_bdf_qmi()
2483 ath11k_core_free_bdf(ab, &bd); in ath11k_qmi_load_bdf_qmi()
2484 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi BDF download sequence completed\n"); in ath11k_qmi_load_bdf_qmi()
2489 static int ath11k_qmi_m3_load(struct ath11k_base *ab) in ath11k_qmi_m3_load() argument
2491 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath11k_qmi_m3_load()
2496 fw = ath11k_core_firmware_request(ab, ATH11K_M3_FILE); in ath11k_qmi_m3_load()
2499 ath11k_core_create_firmware_path(ab, ATH11K_M3_FILE, in ath11k_qmi_m3_load()
2501 ath11k_err(ab, "failed to load %s: %d\n", path, ret); in ath11k_qmi_m3_load()
2508 m3_mem->vaddr = dma_alloc_coherent(ab->dev, in ath11k_qmi_m3_load()
2512 ath11k_err(ab, "failed to allocate memory for M3 with size %zu\n", in ath11k_qmi_m3_load()
2526 static void ath11k_qmi_m3_free(struct ath11k_base *ab) in ath11k_qmi_m3_free() argument
2528 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath11k_qmi_m3_free()
2530 if (!ab->hw_params.m3_fw_support || !m3_mem->vaddr) in ath11k_qmi_m3_free()
2533 dma_free_coherent(ab->dev, m3_mem->size, in ath11k_qmi_m3_free()
2539 static int ath11k_qmi_wlanfw_m3_info_send(struct ath11k_base *ab) in ath11k_qmi_wlanfw_m3_info_send() argument
2541 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath11k_qmi_wlanfw_m3_info_send()
2550 if (ab->hw_params.m3_fw_support) { in ath11k_qmi_wlanfw_m3_info_send()
2551 ret = ath11k_qmi_m3_load(ab); in ath11k_qmi_wlanfw_m3_info_send()
2553 ath11k_err(ab, "failed to load m3 firmware: %d", ret); in ath11k_qmi_wlanfw_m3_info_send()
2564 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_m3_info_send()
2569 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi m3 info req\n"); in ath11k_qmi_wlanfw_m3_info_send()
2571 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_m3_info_send()
2577 ath11k_warn(ab, "failed to send m3 information request: %d\n", in ath11k_qmi_wlanfw_m3_info_send()
2584 ath11k_warn(ab, "failed to wait m3 information request: %d\n", ret); in ath11k_qmi_wlanfw_m3_info_send()
2589 ath11k_warn(ab, "m3 info request failed: %d %d\n", in ath11k_qmi_wlanfw_m3_info_send()
2598 static int ath11k_qmi_wlanfw_mode_send(struct ath11k_base *ab, in ath11k_qmi_wlanfw_mode_send() argument
2613 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_mode_send()
2618 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wlan mode req mode %d\n", mode); in ath11k_qmi_wlanfw_mode_send()
2620 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_mode_send()
2626 ath11k_warn(ab, "failed to send wlan mode request (mode %d): %d\n", in ath11k_qmi_wlanfw_mode_send()
2634 ath11k_warn(ab, "WLFW service is dis-connected\n"); in ath11k_qmi_wlanfw_mode_send()
2637 ath11k_warn(ab, "failed to wait wlan mode request (mode %d): %d\n", in ath11k_qmi_wlanfw_mode_send()
2643 ath11k_warn(ab, "wlan mode request failed (mode: %d): %d %d\n", in ath11k_qmi_wlanfw_mode_send()
2653 static int ath11k_qmi_wlanfw_wlan_cfg_send(struct ath11k_base *ab) in ath11k_qmi_wlanfw_wlan_cfg_send() argument
2662 ce_cfg = (struct ce_pipe_config *)ab->qmi.ce_cfg.tgt_ce; in ath11k_qmi_wlanfw_wlan_cfg_send()
2663 svc_cfg = (struct service_to_pipe *)ab->qmi.ce_cfg.svc_to_ce_map; in ath11k_qmi_wlanfw_wlan_cfg_send()
2677 req->tgt_cfg_len = ab->qmi.ce_cfg.tgt_ce_len; in ath11k_qmi_wlanfw_wlan_cfg_send()
2688 req->svc_cfg_len = ab->qmi.ce_cfg.svc_to_ce_map_len; in ath11k_qmi_wlanfw_wlan_cfg_send()
2697 if (ab->hw_params.supports_shadow_regs) { in ath11k_qmi_wlanfw_wlan_cfg_send()
2700 ab->qmi.ce_cfg.shadow_reg_v2_len, in ath11k_qmi_wlanfw_wlan_cfg_send()
2702 memcpy(&req->shadow_reg_v2, ab->qmi.ce_cfg.shadow_reg_v2, in ath11k_qmi_wlanfw_wlan_cfg_send()
2708 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_wlan_cfg_send()
2713 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wlan cfg req\n"); in ath11k_qmi_wlanfw_wlan_cfg_send()
2715 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_wlan_cfg_send()
2721 ath11k_warn(ab, "failed to send wlan config request: %d\n", in ath11k_qmi_wlanfw_wlan_cfg_send()
2728 ath11k_warn(ab, "failed to wait wlan config request: %d\n", ret); in ath11k_qmi_wlanfw_wlan_cfg_send()
2733 ath11k_warn(ab, "wlan config request failed: %d %d\n", in ath11k_qmi_wlanfw_wlan_cfg_send()
2744 static int ath11k_qmi_wlanfw_wlan_ini_send(struct ath11k_base *ab, bool enable) in ath11k_qmi_wlanfw_wlan_ini_send() argument
2754 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_wlan_ini_send()
2759 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_wlan_ini_send()
2764 ath11k_warn(ab, "qmi failed to send wlan ini request, err = %d\n", in ath11k_qmi_wlanfw_wlan_ini_send()
2772 ath11k_warn(ab, "qmi failed wlan ini request, err = %d\n", ret); in ath11k_qmi_wlanfw_wlan_ini_send()
2777 ath11k_warn(ab, "qmi wlan ini request failed, result: %d, err: %d\n", in ath11k_qmi_wlanfw_wlan_ini_send()
2786 void ath11k_qmi_firmware_stop(struct ath11k_base *ab) in ath11k_qmi_firmware_stop() argument
2790 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware stop\n"); in ath11k_qmi_firmware_stop()
2792 ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_OFF); in ath11k_qmi_firmware_stop()
2794 ath11k_warn(ab, "qmi failed to send wlan mode off: %d\n", ret); in ath11k_qmi_firmware_stop()
2799 int ath11k_qmi_firmware_start(struct ath11k_base *ab, in ath11k_qmi_firmware_start() argument
2804 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware start\n"); in ath11k_qmi_firmware_start()
2806 if (ab->hw_params.fw_wmi_diag_event) { in ath11k_qmi_firmware_start()
2807 ret = ath11k_qmi_wlanfw_wlan_ini_send(ab, true); in ath11k_qmi_firmware_start()
2809 ath11k_warn(ab, "qmi failed to send wlan fw ini:%d\n", ret); in ath11k_qmi_firmware_start()
2814 ret = ath11k_qmi_wlanfw_wlan_cfg_send(ab); in ath11k_qmi_firmware_start()
2816 ath11k_warn(ab, "qmi failed to send wlan cfg: %d\n", ret); in ath11k_qmi_firmware_start()
2820 ret = ath11k_qmi_wlanfw_mode_send(ab, mode); in ath11k_qmi_firmware_start()
2822 ath11k_warn(ab, "qmi failed to send wlan fw mode: %d\n", ret); in ath11k_qmi_firmware_start()
2829 static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) in ath11k_qmi_process_coldboot_calibration() argument
2834 ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT); in ath11k_qmi_process_coldboot_calibration()
2836 ath11k_warn(ab, "qmi failed to send wlan fw mode: %d\n", ret); in ath11k_qmi_process_coldboot_calibration()
2840 ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n"); in ath11k_qmi_process_coldboot_calibration()
2842 timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, in ath11k_qmi_process_coldboot_calibration()
2843 (ab->qmi.cal_done == 1), in ath11k_qmi_process_coldboot_calibration()
2846 ath11k_warn(ab, "coldboot calibration timed out\n"); in ath11k_qmi_process_coldboot_calibration()
2850 ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration done\n"); in ath11k_qmi_process_coldboot_calibration()
2880 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_event_mem_request() local
2883 ret = ath11k_qmi_respond_fw_mem_request(ab); in ath11k_qmi_event_mem_request()
2885 ath11k_warn(ab, "qmi failed to respond fw mem req: %d\n", ret); in ath11k_qmi_event_mem_request()
2894 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_event_load_bdf() local
2897 ret = ath11k_qmi_request_target_cap(ab); in ath11k_qmi_event_load_bdf()
2899 ath11k_warn(ab, "failed to request qmi target capabilities: %d\n", in ath11k_qmi_event_load_bdf()
2904 ret = ath11k_qmi_request_device_info(ab); in ath11k_qmi_event_load_bdf()
2906 ath11k_warn(ab, "failed to request qmi device info: %d\n", ret); in ath11k_qmi_event_load_bdf()
2910 if (ab->hw_params.supports_regdb) in ath11k_qmi_event_load_bdf()
2911 ath11k_qmi_load_bdf_qmi(ab, true); in ath11k_qmi_event_load_bdf()
2913 ret = ath11k_qmi_load_bdf_qmi(ab, false); in ath11k_qmi_event_load_bdf()
2915 ath11k_warn(ab, "failed to load board data file: %d\n", ret); in ath11k_qmi_event_load_bdf()
2924 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_event_server_arrive() local
2927 ret = ath11k_qmi_fw_ind_register_send(ab); in ath11k_qmi_event_server_arrive()
2929 ath11k_warn(ab, "failed to send qmi firmware indication: %d\n", in ath11k_qmi_event_server_arrive()
2934 ret = ath11k_qmi_host_cap_send(ab); in ath11k_qmi_event_server_arrive()
2936 ath11k_warn(ab, "failed to send qmi host cap: %d\n", ret); in ath11k_qmi_event_server_arrive()
2940 if (!ab->hw_params.fixed_fw_mem) in ath11k_qmi_event_server_arrive()
2945 ath11k_warn(ab, "qmi failed to download BDF:%d\n", ret); in ath11k_qmi_event_server_arrive()
2958 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_mem_request_cb() local
2962 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware request memory request\n"); in ath11k_qmi_msg_mem_request_cb()
2966 ath11k_warn(ab, "invalid memory segment length: %u\n", in ath11k_qmi_msg_mem_request_cb()
2969 ab->qmi.mem_seg_count = msg->mem_seg_len; in ath11k_qmi_msg_mem_request_cb()
2972 ab->qmi.target_mem[i].type = msg->mem_seg[i].type; in ath11k_qmi_msg_mem_request_cb()
2973 ab->qmi.target_mem[i].size = msg->mem_seg[i].size; in ath11k_qmi_msg_mem_request_cb()
2974 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi mem seg type %d size %d\n", in ath11k_qmi_msg_mem_request_cb()
2978 if (ab->hw_params.fixed_mem_region || in ath11k_qmi_msg_mem_request_cb()
2979 test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) { in ath11k_qmi_msg_mem_request_cb()
2980 ret = ath11k_qmi_assign_target_mem_chunk(ab); in ath11k_qmi_msg_mem_request_cb()
2982 ath11k_warn(ab, "failed to assign qmi target memory: %d\n", in ath11k_qmi_msg_mem_request_cb()
2987 ret = ath11k_qmi_alloc_target_mem_chunk(ab); in ath11k_qmi_msg_mem_request_cb()
2989 ath11k_warn(ab, "failed to allocate qmi target memory: %d\n", in ath11k_qmi_msg_mem_request_cb()
3004 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_mem_ready_cb() local
3006 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware memory ready indication\n"); in ath11k_qmi_msg_mem_ready_cb()
3016 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_fw_ready_cb() local
3018 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware ready\n"); in ath11k_qmi_msg_fw_ready_cb()
3020 if (!ab->qmi.cal_done) { in ath11k_qmi_msg_fw_ready_cb()
3021 ab->qmi.cal_done = 1; in ath11k_qmi_msg_fw_ready_cb()
3022 wake_up(&ab->qmi.cold_boot_waitq); in ath11k_qmi_msg_fw_ready_cb()
3035 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_cold_boot_cal_done_cb() local
3037 ab->qmi.cal_done = 1; in ath11k_qmi_msg_cold_boot_cal_done_cb()
3038 wake_up(&ab->qmi.cold_boot_waitq); in ath11k_qmi_msg_cold_boot_cal_done_cb()
3039 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cold boot calibration done\n"); in ath11k_qmi_msg_cold_boot_cal_done_cb()
3049 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_fw_init_done_cb() local
3052 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware init done\n"); in ath11k_qmi_msg_fw_init_done_cb()
3102 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_ops_new_server() local
3113 ath11k_warn(ab, "failed to connect to qmi remote service: %d\n", ret); in ath11k_qmi_ops_new_server()
3117 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wifi fw qmi service connected\n"); in ath11k_qmi_ops_new_server()
3127 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_ops_del_server() local
3129 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wifi fw del server\n"); in ath11k_qmi_ops_del_server()
3143 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_driver_event_work() local
3153 if (test_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags)) { in ath11k_qmi_driver_event_work()
3162 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3165 set_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3166 set_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3171 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3176 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3180 ret = ath11k_qmi_wlanfw_m3_info_send(ab); in ath11k_qmi_driver_event_work()
3182 ath11k_warn(ab, in ath11k_qmi_driver_event_work()
3184 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3189 clear_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3190 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) { in ath11k_qmi_driver_event_work()
3191 ath11k_hal_dump_srng_stats(ab); in ath11k_qmi_driver_event_work()
3192 queue_work(ab->workqueue, &ab->restart_work); in ath11k_qmi_driver_event_work()
3196 if (ath11k_cold_boot_cal && ab->qmi.cal_done == 0 && in ath11k_qmi_driver_event_work()
3197 ab->hw_params.cold_boot_calib) { in ath11k_qmi_driver_event_work()
3198 ath11k_qmi_process_coldboot_calibration(ab); in ath11k_qmi_driver_event_work()
3201 &ab->dev_flags); in ath11k_qmi_driver_event_work()
3202 clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3203 ret = ath11k_core_qmi_firmware_ready(ab); in ath11k_qmi_driver_event_work()
3205 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3208 set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3218 if (ab->hw_params.cbcal_restart_fw) in ath11k_qmi_driver_event_work()
3222 &ab->dev_flags); in ath11k_qmi_driver_event_work()
3223 clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3224 ath11k_core_qmi_firmware_ready(ab); in ath11k_qmi_driver_event_work()
3225 set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3231 ath11k_warn(ab, "invalid qmi event type: %d", event->type); in ath11k_qmi_driver_event_work()
3240 int ath11k_qmi_init_service(struct ath11k_base *ab) in ath11k_qmi_init_service() argument
3244 memset(&ab->qmi.target, 0, sizeof(struct target_info)); in ath11k_qmi_init_service()
3245 memset(&ab->qmi.target_mem, 0, sizeof(struct target_mem_chunk)); in ath11k_qmi_init_service()
3246 ab->qmi.ab = ab; in ath11k_qmi_init_service()
3248 ab->qmi.target_mem_mode = ab->hw_params.fw_mem_mode; in ath11k_qmi_init_service()
3249 ret = qmi_handle_init(&ab->qmi.handle, ATH11K_QMI_RESP_LEN_MAX, in ath11k_qmi_init_service()
3252 ath11k_warn(ab, "failed to initialize qmi handle: %d\n", ret); in ath11k_qmi_init_service()
3256 ab->qmi.event_wq = alloc_workqueue("ath11k_qmi_driver_event", in ath11k_qmi_init_service()
3258 if (!ab->qmi.event_wq) { in ath11k_qmi_init_service()
3259 ath11k_err(ab, "failed to allocate workqueue\n"); in ath11k_qmi_init_service()
3263 INIT_LIST_HEAD(&ab->qmi.event_list); in ath11k_qmi_init_service()
3264 spin_lock_init(&ab->qmi.event_lock); in ath11k_qmi_init_service()
3265 INIT_WORK(&ab->qmi.event_work, ath11k_qmi_driver_event_work); in ath11k_qmi_init_service()
3267 ret = qmi_add_lookup(&ab->qmi.handle, ATH11K_QMI_WLFW_SERVICE_ID_V01, in ath11k_qmi_init_service()
3269 ab->qmi.service_ins_id); in ath11k_qmi_init_service()
3271 ath11k_warn(ab, "failed to add qmi lookup: %d\n", ret); in ath11k_qmi_init_service()
3272 destroy_workqueue(ab->qmi.event_wq); in ath11k_qmi_init_service()
3279 void ath11k_qmi_deinit_service(struct ath11k_base *ab) in ath11k_qmi_deinit_service() argument
3281 qmi_handle_release(&ab->qmi.handle); in ath11k_qmi_deinit_service()
3282 cancel_work_sync(&ab->qmi.event_work); in ath11k_qmi_deinit_service()
3283 destroy_workqueue(ab->qmi.event_wq); in ath11k_qmi_deinit_service()
3284 ath11k_qmi_m3_free(ab); in ath11k_qmi_deinit_service()
3285 ath11k_qmi_free_target_mem_chunk(ab); in ath11k_qmi_deinit_service()
3289 void ath11k_qmi_free_resource(struct ath11k_base *ab) in ath11k_qmi_free_resource() argument
3291 ath11k_qmi_free_target_mem_chunk(ab); in ath11k_qmi_free_resource()
3292 ath11k_qmi_m3_free(ab); in ath11k_qmi_free_resource()