Lines Matching full: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, "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, "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, "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, "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].prev_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->prev_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 if (!ab->qmi.target_mem[idx].iaddr) in ath11k_qmi_assign_target_mem_chunk()
2064 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2065 host_ddr_sz = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2066 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; in ath11k_qmi_assign_target_mem_chunk()
2070 ab->qmi.target_mem[idx].paddr = ab->hw_params.bdf_addr; in ath11k_qmi_assign_target_mem_chunk()
2071 ab->qmi.target_mem[idx].vaddr = NULL; in ath11k_qmi_assign_target_mem_chunk()
2072 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2073 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; in ath11k_qmi_assign_target_mem_chunk()
2077 if (ab->qmi.target_mem[i].size > ATH11K_QMI_CALDB_SIZE) { in ath11k_qmi_assign_target_mem_chunk()
2078 ath11k_warn(ab, "qmi mem size is low to load caldata\n"); in ath11k_qmi_assign_target_mem_chunk()
2082 if (ath11k_core_coldboot_cal_support(ab)) { in ath11k_qmi_assign_target_mem_chunk()
2084 ab->qmi.target_mem[idx].paddr = in ath11k_qmi_assign_target_mem_chunk()
2086 ab->qmi.target_mem[idx].iaddr = in ath11k_qmi_assign_target_mem_chunk()
2087 ioremap(ab->qmi.target_mem[idx].paddr, in ath11k_qmi_assign_target_mem_chunk()
2088 ab->qmi.target_mem[i].size); in ath11k_qmi_assign_target_mem_chunk()
2089 if (!ab->qmi.target_mem[idx].iaddr) in ath11k_qmi_assign_target_mem_chunk()
2092 ab->qmi.target_mem[idx].paddr = in ath11k_qmi_assign_target_mem_chunk()
2096 ab->qmi.target_mem[idx].paddr = 0; in ath11k_qmi_assign_target_mem_chunk()
2097 ab->qmi.target_mem[idx].vaddr = NULL; in ath11k_qmi_assign_target_mem_chunk()
2099 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size; in ath11k_qmi_assign_target_mem_chunk()
2100 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type; in ath11k_qmi_assign_target_mem_chunk()
2104 ath11k_warn(ab, "qmi ignore invalid mem req type %d\n", in ath11k_qmi_assign_target_mem_chunk()
2105 ab->qmi.target_mem[i].type); in ath11k_qmi_assign_target_mem_chunk()
2109 ab->qmi.mem_seg_count = idx; in ath11k_qmi_assign_target_mem_chunk()
2114 static int ath11k_qmi_request_device_info(struct ath11k_base *ab) in ath11k_qmi_request_device_info() argument
2123 if (!ab->hw_params.hybrid_bus_type) in ath11k_qmi_request_device_info()
2126 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_request_device_info()
2131 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_request_device_info()
2137 ath11k_warn(ab, "failed to send qmi target device info request: %d\n", in ath11k_qmi_request_device_info()
2144 ath11k_warn(ab, "failed to wait qmi target device info request: %d\n", in ath11k_qmi_request_device_info()
2150 ath11k_warn(ab, "qmi device info request failed: %d %d\n", in ath11k_qmi_request_device_info()
2157 ath11k_warn(ab, "qmi device info response invalid: %d %d\n", in ath11k_qmi_request_device_info()
2165 ath11k_warn(ab, "qmi device info invalid address and size: %llu %u\n", in ath11k_qmi_request_device_info()
2171 bar_addr_va = devm_ioremap(ab->dev, resp.bar_addr, resp.bar_size); in ath11k_qmi_request_device_info()
2174 ath11k_warn(ab, "qmi device info ioremap failed\n"); in ath11k_qmi_request_device_info()
2175 ab->mem_len = 0; in ath11k_qmi_request_device_info()
2180 ab->mem = bar_addr_va; in ath11k_qmi_request_device_info()
2181 ab->mem_len = resp.bar_size; in ath11k_qmi_request_device_info()
2188 static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) in ath11k_qmi_request_target_cap() argument
2201 ret = qmi_txn_init(&ab->qmi.handle, &txn, qmi_wlanfw_cap_resp_msg_v01_ei, in ath11k_qmi_request_target_cap()
2206 ath11k_dbg(ab, ATH11K_DBG_QMI, "target cap request\n"); in ath11k_qmi_request_target_cap()
2208 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_request_target_cap()
2214 ath11k_warn(ab, "failed to send qmi cap request: %d\n", in ath11k_qmi_request_target_cap()
2221 ath11k_warn(ab, "failed to wait qmi cap request: %d\n", ret); in ath11k_qmi_request_target_cap()
2226 ath11k_warn(ab, "qmi cap request failed: %d %d\n", in ath11k_qmi_request_target_cap()
2233 ab->qmi.target.chip_id = resp.chip_info.chip_id; in ath11k_qmi_request_target_cap()
2234 ab->qmi.target.chip_family = resp.chip_info.chip_family; in ath11k_qmi_request_target_cap()
2238 ab->qmi.target.board_id = resp.board_info.board_id; in ath11k_qmi_request_target_cap()
2240 ab->qmi.target.board_id = 0xFF; in ath11k_qmi_request_target_cap()
2243 ab->qmi.target.soc_id = resp.soc_info.soc_id; in ath11k_qmi_request_target_cap()
2246 ab->qmi.target.fw_version = resp.fw_version_info.fw_version; in ath11k_qmi_request_target_cap()
2247 strscpy(ab->qmi.target.fw_build_timestamp, in ath11k_qmi_request_target_cap()
2249 sizeof(ab->qmi.target.fw_build_timestamp)); in ath11k_qmi_request_target_cap()
2253 strscpy(ab->qmi.target.fw_build_id, resp.fw_build_id, in ath11k_qmi_request_target_cap()
2254 sizeof(ab->qmi.target.fw_build_id)); in ath11k_qmi_request_target_cap()
2257 ab->qmi.target.eeprom_caldata = in ath11k_qmi_request_target_cap()
2259 ath11k_dbg(ab, ATH11K_DBG_QMI, "cal data supported from eeprom\n"); in ath11k_qmi_request_target_cap()
2262 fw_build_id = ab->qmi.target.fw_build_id; in ath11k_qmi_request_target_cap()
2267 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()
2268 ab->qmi.target.chip_id, ab->qmi.target.chip_family, in ath11k_qmi_request_target_cap()
2269 ab->qmi.target.board_id, ab->qmi.target.soc_id); in ath11k_qmi_request_target_cap()
2271 ath11k_info(ab, "fw_version 0x%x fw_build_timestamp %s fw_build_id %s", in ath11k_qmi_request_target_cap()
2272 ab->qmi.target.fw_version, in ath11k_qmi_request_target_cap()
2273 ab->qmi.target.fw_build_timestamp, in ath11k_qmi_request_target_cap()
2276 r = ath11k_core_check_smbios(ab); in ath11k_qmi_request_target_cap()
2278 ath11k_dbg(ab, ATH11K_DBG_QMI, "SMBIOS bdf variant name not set.\n"); in ath11k_qmi_request_target_cap()
2280 r = ath11k_core_check_dt(ab); in ath11k_qmi_request_target_cap()
2282 ath11k_dbg(ab, ATH11K_DBG_QMI, "DT bdf variant name not set.\n"); in ath11k_qmi_request_target_cap()
2288 static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab, in ath11k_qmi_load_file_target_mem() argument
2305 if (ab->hw_params.fixed_bdf_addr) { in ath11k_qmi_load_file_target_mem()
2306 bdf_addr = ioremap(ab->hw_params.bdf_addr, ab->hw_params.fw.board_size); in ath11k_qmi_load_file_target_mem()
2308 ath11k_warn(ab, "qmi ioremap error for bdf_addr\n"); in ath11k_qmi_load_file_target_mem()
2317 req->file_id = ab->qmi.target.board_id; in ath11k_qmi_load_file_target_mem()
2334 if (ab->hw_params.fixed_bdf_addr || in ath11k_qmi_load_file_target_mem()
2343 if (ab->hw_params.fixed_bdf_addr) { in ath11k_qmi_load_file_target_mem()
2345 bdf_addr += ab->hw_params.fw.cal_offset; in ath11k_qmi_load_file_target_mem()
2350 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_load_file_target_mem()
2356 ath11k_dbg(ab, ATH11K_DBG_QMI, "bdf download req fixed addr type %d\n", in ath11k_qmi_load_file_target_mem()
2359 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_load_file_target_mem()
2370 ath11k_warn(ab, "failed to wait board file download request: %d\n", in ath11k_qmi_load_file_target_mem()
2376 ath11k_warn(ab, "board file download request failed: %d %d\n", in ath11k_qmi_load_file_target_mem()
2382 if (ab->hw_params.fixed_bdf_addr || in ath11k_qmi_load_file_target_mem()
2389 ath11k_dbg(ab, ATH11K_DBG_QMI, "bdf download request remaining %i\n", in ath11k_qmi_load_file_target_mem()
2395 if (ab->hw_params.fixed_bdf_addr) in ath11k_qmi_load_file_target_mem()
2404 static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab, in ath11k_qmi_load_bdf_qmi() argument
2407 struct device *dev = ab->dev; in ath11k_qmi_load_bdf_qmi()
2418 ret = ath11k_core_fetch_regdb(ab, &bd); in ath11k_qmi_load_bdf_qmi()
2420 ret = ath11k_core_fetch_bdf(ab, &bd); in ath11k_qmi_load_bdf_qmi()
2422 ath11k_warn(ab, "qmi failed to fetch board file: %d\n", ret); in ath11k_qmi_load_bdf_qmi()
2435 ath11k_dbg(ab, ATH11K_DBG_QMI, "bdf_type %d\n", bdf_type); in ath11k_qmi_load_bdf_qmi()
2437 fw_size = min_t(u32, ab->hw_params.fw.board_size, bd.len); in ath11k_qmi_load_bdf_qmi()
2439 ret = ath11k_qmi_load_file_target_mem(ab, bd.data, fw_size, bdf_type); in ath11k_qmi_load_bdf_qmi()
2441 ath11k_warn(ab, "qmi failed to load bdf file\n"); in ath11k_qmi_load_bdf_qmi()
2449 if (ab->qmi.target.eeprom_caldata) { in ath11k_qmi_load_bdf_qmi()
2458 ath11k_bus_str(ab->hif.bus), dev_name(dev)); in ath11k_qmi_load_bdf_qmi()
2459 fw_entry = ath11k_core_firmware_request(ab, filename); in ath11k_qmi_load_bdf_qmi()
2463 fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE); in ath11k_qmi_load_bdf_qmi()
2469 ath11k_info(ab, in ath11k_qmi_load_bdf_qmi()
2474 ath11k_warn(ab, in ath11k_qmi_load_bdf_qmi()
2480 fw_size = min_t(u32, ab->hw_params.fw.board_size, fw_entry->size); in ath11k_qmi_load_bdf_qmi()
2484 ret = ath11k_qmi_load_file_target_mem(ab, tmp, fw_size, file_type); in ath11k_qmi_load_bdf_qmi()
2486 ath11k_warn(ab, "qmi failed to load caldata\n"); in ath11k_qmi_load_bdf_qmi()
2490 ath11k_dbg(ab, ATH11K_DBG_QMI, "caldata type: %u\n", file_type); in ath11k_qmi_load_bdf_qmi()
2493 if (!ab->qmi.target.eeprom_caldata) in ath11k_qmi_load_bdf_qmi()
2496 ath11k_core_free_bdf(ab, &bd); in ath11k_qmi_load_bdf_qmi()
2497 ath11k_dbg(ab, ATH11K_DBG_QMI, "BDF download sequence completed\n"); in ath11k_qmi_load_bdf_qmi()
2502 static int ath11k_qmi_m3_load(struct ath11k_base *ab) in ath11k_qmi_m3_load() argument
2504 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath11k_qmi_m3_load()
2515 if (ab->fw.m3_data && ab->fw.m3_len > 0) { in ath11k_qmi_m3_load()
2517 m3_data = ab->fw.m3_data; in ath11k_qmi_m3_load()
2518 m3_len = ab->fw.m3_len; in ath11k_qmi_m3_load()
2523 fw = ath11k_core_firmware_request(ab, ATH11K_M3_FILE); in ath11k_qmi_m3_load()
2526 ath11k_core_create_firmware_path(ab, ATH11K_M3_FILE, in ath11k_qmi_m3_load()
2528 ath11k_err(ab, "failed to load %s: %d\n", path, ret); in ath11k_qmi_m3_load()
2536 m3_mem->vaddr = dma_alloc_coherent(ab->dev, in ath11k_qmi_m3_load()
2540 ath11k_err(ab, "failed to allocate memory for M3 with size %zu\n", in ath11k_qmi_m3_load()
2557 static void ath11k_qmi_m3_free(struct ath11k_base *ab) in ath11k_qmi_m3_free() argument
2559 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath11k_qmi_m3_free()
2561 if (!ab->hw_params.m3_fw_support || !m3_mem->vaddr) in ath11k_qmi_m3_free()
2564 dma_free_coherent(ab->dev, m3_mem->size, in ath11k_qmi_m3_free()
2570 static int ath11k_qmi_wlanfw_m3_info_send(struct ath11k_base *ab) in ath11k_qmi_wlanfw_m3_info_send() argument
2572 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath11k_qmi_wlanfw_m3_info_send()
2581 if (ab->hw_params.m3_fw_support) { in ath11k_qmi_wlanfw_m3_info_send()
2582 ret = ath11k_qmi_m3_load(ab); in ath11k_qmi_wlanfw_m3_info_send()
2584 ath11k_err(ab, "failed to load m3 firmware: %d", ret); in ath11k_qmi_wlanfw_m3_info_send()
2595 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_m3_info_send()
2600 ath11k_dbg(ab, ATH11K_DBG_QMI, "m3 info req\n"); in ath11k_qmi_wlanfw_m3_info_send()
2602 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_m3_info_send()
2608 ath11k_warn(ab, "failed to send m3 information request: %d\n", in ath11k_qmi_wlanfw_m3_info_send()
2615 ath11k_warn(ab, "failed to wait m3 information request: %d\n", ret); in ath11k_qmi_wlanfw_m3_info_send()
2620 ath11k_warn(ab, "m3 info request failed: %d %d\n", in ath11k_qmi_wlanfw_m3_info_send()
2629 static int ath11k_qmi_wlanfw_mode_send(struct ath11k_base *ab, in ath11k_qmi_wlanfw_mode_send() argument
2644 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_mode_send()
2649 ath11k_dbg(ab, ATH11K_DBG_QMI, "wlan mode req mode %d\n", mode); in ath11k_qmi_wlanfw_mode_send()
2651 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_mode_send()
2657 ath11k_warn(ab, "failed to send wlan mode request (mode %d): %d\n", in ath11k_qmi_wlanfw_mode_send()
2665 ath11k_warn(ab, "WLFW service is dis-connected\n"); in ath11k_qmi_wlanfw_mode_send()
2668 ath11k_warn(ab, "failed to wait wlan mode request (mode %d): %d\n", in ath11k_qmi_wlanfw_mode_send()
2674 ath11k_warn(ab, "wlan mode request failed (mode: %d): %d %d\n", in ath11k_qmi_wlanfw_mode_send()
2684 static int ath11k_qmi_wlanfw_wlan_cfg_send(struct ath11k_base *ab) in ath11k_qmi_wlanfw_wlan_cfg_send() argument
2693 ce_cfg = (struct ce_pipe_config *)ab->qmi.ce_cfg.tgt_ce; in ath11k_qmi_wlanfw_wlan_cfg_send()
2694 svc_cfg = (struct service_to_pipe *)ab->qmi.ce_cfg.svc_to_ce_map; in ath11k_qmi_wlanfw_wlan_cfg_send()
2708 req->tgt_cfg_len = ab->qmi.ce_cfg.tgt_ce_len; in ath11k_qmi_wlanfw_wlan_cfg_send()
2719 req->svc_cfg_len = ab->qmi.ce_cfg.svc_to_ce_map_len; in ath11k_qmi_wlanfw_wlan_cfg_send()
2728 if (ab->hw_params.supports_shadow_regs) { in ath11k_qmi_wlanfw_wlan_cfg_send()
2731 ab->qmi.ce_cfg.shadow_reg_v2_len, in ath11k_qmi_wlanfw_wlan_cfg_send()
2733 memcpy(&req->shadow_reg_v2, ab->qmi.ce_cfg.shadow_reg_v2, in ath11k_qmi_wlanfw_wlan_cfg_send()
2739 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_wlan_cfg_send()
2744 ath11k_dbg(ab, ATH11K_DBG_QMI, "wlan cfg req\n"); in ath11k_qmi_wlanfw_wlan_cfg_send()
2746 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_wlan_cfg_send()
2752 ath11k_warn(ab, "failed to send wlan config request: %d\n", in ath11k_qmi_wlanfw_wlan_cfg_send()
2759 ath11k_warn(ab, "failed to wait wlan config request: %d\n", ret); in ath11k_qmi_wlanfw_wlan_cfg_send()
2764 ath11k_warn(ab, "wlan config request failed: %d %d\n", in ath11k_qmi_wlanfw_wlan_cfg_send()
2775 static int ath11k_qmi_wlanfw_wlan_ini_send(struct ath11k_base *ab, bool enable) in ath11k_qmi_wlanfw_wlan_ini_send() argument
2785 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath11k_qmi_wlanfw_wlan_ini_send()
2790 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath11k_qmi_wlanfw_wlan_ini_send()
2795 ath11k_warn(ab, "qmi failed to send wlan ini request, err = %d\n", in ath11k_qmi_wlanfw_wlan_ini_send()
2803 ath11k_warn(ab, "qmi failed wlan ini request, err = %d\n", ret); in ath11k_qmi_wlanfw_wlan_ini_send()
2808 ath11k_warn(ab, "qmi wlan ini request failed, result: %d, err: %d\n", in ath11k_qmi_wlanfw_wlan_ini_send()
2817 void ath11k_qmi_firmware_stop(struct ath11k_base *ab) in ath11k_qmi_firmware_stop() argument
2821 ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware stop\n"); in ath11k_qmi_firmware_stop()
2823 ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_OFF); in ath11k_qmi_firmware_stop()
2825 ath11k_warn(ab, "qmi failed to send wlan mode off: %d\n", ret); in ath11k_qmi_firmware_stop()
2830 int ath11k_qmi_firmware_start(struct ath11k_base *ab, in ath11k_qmi_firmware_start() argument
2835 ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware start\n"); in ath11k_qmi_firmware_start()
2837 if (ab->hw_params.fw_wmi_diag_event) { in ath11k_qmi_firmware_start()
2838 ret = ath11k_qmi_wlanfw_wlan_ini_send(ab, true); in ath11k_qmi_firmware_start()
2840 ath11k_warn(ab, "qmi failed to send wlan fw ini:%d\n", ret); in ath11k_qmi_firmware_start()
2845 ret = ath11k_qmi_wlanfw_wlan_cfg_send(ab); in ath11k_qmi_firmware_start()
2847 ath11k_warn(ab, "qmi failed to send wlan cfg: %d\n", ret); in ath11k_qmi_firmware_start()
2851 ret = ath11k_qmi_wlanfw_mode_send(ab, mode); in ath11k_qmi_firmware_start()
2853 ath11k_warn(ab, "qmi failed to send wlan fw mode: %d\n", ret); in ath11k_qmi_firmware_start()
2860 int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) in ath11k_qmi_fwreset_from_cold_boot() argument
2864 if (!ath11k_core_coldboot_cal_support(ab) || in ath11k_qmi_fwreset_from_cold_boot()
2865 ab->hw_params.cbcal_restart_fw == 0) in ath11k_qmi_fwreset_from_cold_boot()
2868 ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n"); in ath11k_qmi_fwreset_from_cold_boot()
2870 time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, in ath11k_qmi_fwreset_from_cold_boot()
2871 (ab->qmi.cal_done == 1), in ath11k_qmi_fwreset_from_cold_boot()
2875 ath11k_warn(ab, "Coldboot Calibration timed out\n"); in ath11k_qmi_fwreset_from_cold_boot()
2880 ath11k_hif_power_down(ab); in ath11k_qmi_fwreset_from_cold_boot()
2881 ath11k_hif_power_up(ab); in ath11k_qmi_fwreset_from_cold_boot()
2882 ath11k_dbg(ab, ATH11K_DBG_QMI, "exit wait for cold boot done\n"); in ath11k_qmi_fwreset_from_cold_boot()
2887 static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) in ath11k_qmi_process_coldboot_calibration() argument
2892 ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT); in ath11k_qmi_process_coldboot_calibration()
2894 ath11k_warn(ab, "qmi failed to send wlan fw mode: %d\n", ret); in ath11k_qmi_process_coldboot_calibration()
2898 ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n"); in ath11k_qmi_process_coldboot_calibration()
2900 time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, in ath11k_qmi_process_coldboot_calibration()
2901 (ab->qmi.cal_done == 1), in ath11k_qmi_process_coldboot_calibration()
2904 ath11k_warn(ab, "coldboot calibration timed out\n"); in ath11k_qmi_process_coldboot_calibration()
2908 ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration done\n"); in ath11k_qmi_process_coldboot_calibration()
2938 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_event_mem_request() local
2941 ret = ath11k_qmi_respond_fw_mem_request(ab); in ath11k_qmi_event_mem_request()
2943 ath11k_warn(ab, "qmi failed to respond fw mem req: %d\n", ret); in ath11k_qmi_event_mem_request()
2952 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_event_load_bdf() local
2955 ret = ath11k_qmi_request_target_cap(ab); in ath11k_qmi_event_load_bdf()
2957 ath11k_warn(ab, "failed to request qmi target capabilities: %d\n", in ath11k_qmi_event_load_bdf()
2962 ret = ath11k_qmi_request_device_info(ab); in ath11k_qmi_event_load_bdf()
2964 ath11k_warn(ab, "failed to request qmi device info: %d\n", ret); in ath11k_qmi_event_load_bdf()
2968 if (ab->hw_params.supports_regdb) in ath11k_qmi_event_load_bdf()
2969 ath11k_qmi_load_bdf_qmi(ab, true); in ath11k_qmi_event_load_bdf()
2971 ret = ath11k_qmi_load_bdf_qmi(ab, false); in ath11k_qmi_event_load_bdf()
2973 ath11k_warn(ab, "failed to load board data file: %d\n", ret); in ath11k_qmi_event_load_bdf()
2982 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_event_server_arrive() local
2985 ret = ath11k_qmi_fw_ind_register_send(ab); in ath11k_qmi_event_server_arrive()
2987 ath11k_warn(ab, "failed to send qmi firmware indication: %d\n", in ath11k_qmi_event_server_arrive()
2992 ret = ath11k_qmi_host_cap_send(ab); in ath11k_qmi_event_server_arrive()
2994 ath11k_warn(ab, "failed to send qmi host cap: %d\n", ret); in ath11k_qmi_event_server_arrive()
2998 if (!ab->hw_params.fixed_fw_mem) in ath11k_qmi_event_server_arrive()
3003 ath11k_warn(ab, "qmi failed to download BDF:%d\n", ret); in ath11k_qmi_event_server_arrive()
3016 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_mem_request_cb() local
3020 ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware request memory request\n"); in ath11k_qmi_msg_mem_request_cb()
3024 ath11k_warn(ab, "invalid memory segment length: %u\n", in ath11k_qmi_msg_mem_request_cb()
3027 ab->qmi.mem_seg_count = msg->mem_seg_len; in ath11k_qmi_msg_mem_request_cb()
3030 ab->qmi.target_mem[i].type = msg->mem_seg[i].type; in ath11k_qmi_msg_mem_request_cb()
3031 ab->qmi.target_mem[i].size = msg->mem_seg[i].size; in ath11k_qmi_msg_mem_request_cb()
3032 ath11k_dbg(ab, ATH11K_DBG_QMI, "mem seg type %d size %d\n", in ath11k_qmi_msg_mem_request_cb()
3036 if (ab->hw_params.fixed_mem_region || in ath11k_qmi_msg_mem_request_cb()
3037 test_bit(ATH11K_FLAG_FIXED_MEM_RGN, &ab->dev_flags)) { in ath11k_qmi_msg_mem_request_cb()
3038 ret = ath11k_qmi_assign_target_mem_chunk(ab); in ath11k_qmi_msg_mem_request_cb()
3040 ath11k_warn(ab, "failed to assign qmi target memory: %d\n", in ath11k_qmi_msg_mem_request_cb()
3045 ret = ath11k_qmi_alloc_target_mem_chunk(ab); in ath11k_qmi_msg_mem_request_cb()
3047 ath11k_warn(ab, "failed to allocate qmi target memory: %d\n", in ath11k_qmi_msg_mem_request_cb()
3062 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_mem_ready_cb() local
3064 ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware memory ready indication\n"); in ath11k_qmi_msg_mem_ready_cb()
3074 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_fw_ready_cb() local
3076 ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware ready\n"); in ath11k_qmi_msg_fw_ready_cb()
3078 if (!ab->qmi.cal_done) { in ath11k_qmi_msg_fw_ready_cb()
3079 ab->qmi.cal_done = 1; in ath11k_qmi_msg_fw_ready_cb()
3080 wake_up(&ab->qmi.cold_boot_waitq); in ath11k_qmi_msg_fw_ready_cb()
3093 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_cold_boot_cal_done_cb() local
3095 ab->qmi.cal_done = 1; in ath11k_qmi_msg_cold_boot_cal_done_cb()
3096 wake_up(&ab->qmi.cold_boot_waitq); in ath11k_qmi_msg_cold_boot_cal_done_cb()
3097 ath11k_dbg(ab, ATH11K_DBG_QMI, "cold boot calibration done\n"); in ath11k_qmi_msg_cold_boot_cal_done_cb()
3107 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_msg_fw_init_done_cb() local
3110 ath11k_dbg(ab, ATH11K_DBG_QMI, "firmware init done\n"); in ath11k_qmi_msg_fw_init_done_cb()
3160 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_ops_new_server() local
3171 ath11k_warn(ab, "failed to connect to qmi remote service: %d\n", ret); in ath11k_qmi_ops_new_server()
3175 ath11k_dbg(ab, ATH11K_DBG_QMI, "wifi fw qmi service connected\n"); in ath11k_qmi_ops_new_server()
3185 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_ops_del_server() local
3187 ath11k_dbg(ab, ATH11K_DBG_QMI, "wifi fw del server\n"); in ath11k_qmi_ops_del_server()
3201 struct ath11k_base *ab = qmi->ab; in ath11k_qmi_driver_event_work() local
3211 if (test_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags)) { in ath11k_qmi_driver_event_work()
3220 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3223 set_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3224 set_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3226 if (!ab->is_reset) in ath11k_qmi_driver_event_work()
3227 ath11k_core_pre_reconfigure_recovery(ab); in ath11k_qmi_driver_event_work()
3232 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3237 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3241 ret = ath11k_qmi_wlanfw_m3_info_send(ab); in ath11k_qmi_driver_event_work()
3243 ath11k_warn(ab, in ath11k_qmi_driver_event_work()
3245 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3250 clear_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3251 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) { in ath11k_qmi_driver_event_work()
3252 if (ab->is_reset) in ath11k_qmi_driver_event_work()
3253 ath11k_hal_dump_srng_stats(ab); in ath11k_qmi_driver_event_work()
3254 queue_work(ab->workqueue, &ab->restart_work); in ath11k_qmi_driver_event_work()
3258 if (ab->qmi.cal_done == 0 && in ath11k_qmi_driver_event_work()
3259 ath11k_core_coldboot_cal_support(ab)) { in ath11k_qmi_driver_event_work()
3260 ath11k_qmi_process_coldboot_calibration(ab); in ath11k_qmi_driver_event_work()
3263 &ab->dev_flags); in ath11k_qmi_driver_event_work()
3264 clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3265 ret = ath11k_core_qmi_firmware_ready(ab); in ath11k_qmi_driver_event_work()
3267 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3270 set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3280 if (ab->hw_params.cbcal_restart_fw) in ath11k_qmi_driver_event_work()
3284 &ab->dev_flags); in ath11k_qmi_driver_event_work()
3285 clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3286 ath11k_core_qmi_firmware_ready(ab); in ath11k_qmi_driver_event_work()
3287 set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags); in ath11k_qmi_driver_event_work()
3293 ath11k_warn(ab, "invalid qmi event type: %d", event->type); in ath11k_qmi_driver_event_work()
3302 int ath11k_qmi_init_service(struct ath11k_base *ab) in ath11k_qmi_init_service() argument
3306 memset(&ab->qmi.target, 0, sizeof(struct target_info)); in ath11k_qmi_init_service()
3307 memset(&ab->qmi.target_mem, 0, sizeof(struct target_mem_chunk)); in ath11k_qmi_init_service()
3308 ab->qmi.ab = ab; in ath11k_qmi_init_service()
3310 ab->qmi.target_mem_mode = ab->hw_params.fw_mem_mode; in ath11k_qmi_init_service()
3311 ret = qmi_handle_init(&ab->qmi.handle, ATH11K_QMI_RESP_LEN_MAX, in ath11k_qmi_init_service()
3314 ath11k_warn(ab, "failed to initialize qmi handle: %d\n", ret); in ath11k_qmi_init_service()
3318 ab->qmi.event_wq = alloc_ordered_workqueue("ath11k_qmi_driver_event", 0); in ath11k_qmi_init_service()
3319 if (!ab->qmi.event_wq) { in ath11k_qmi_init_service()
3320 ath11k_err(ab, "failed to allocate workqueue\n"); in ath11k_qmi_init_service()
3324 INIT_LIST_HEAD(&ab->qmi.event_list); in ath11k_qmi_init_service()
3325 spin_lock_init(&ab->qmi.event_lock); in ath11k_qmi_init_service()
3326 INIT_WORK(&ab->qmi.event_work, ath11k_qmi_driver_event_work); in ath11k_qmi_init_service()
3328 ret = qmi_add_lookup(&ab->qmi.handle, ATH11K_QMI_WLFW_SERVICE_ID_V01, in ath11k_qmi_init_service()
3330 ab->qmi.service_ins_id); in ath11k_qmi_init_service()
3332 ath11k_warn(ab, "failed to add qmi lookup: %d\n", ret); in ath11k_qmi_init_service()
3333 destroy_workqueue(ab->qmi.event_wq); in ath11k_qmi_init_service()
3340 void ath11k_qmi_deinit_service(struct ath11k_base *ab) in ath11k_qmi_deinit_service() argument
3342 qmi_handle_release(&ab->qmi.handle); in ath11k_qmi_deinit_service()
3343 cancel_work_sync(&ab->qmi.event_work); in ath11k_qmi_deinit_service()
3344 destroy_workqueue(ab->qmi.event_wq); in ath11k_qmi_deinit_service()
3345 ath11k_qmi_m3_free(ab); in ath11k_qmi_deinit_service()
3346 ath11k_qmi_free_target_mem_chunk(ab); in ath11k_qmi_deinit_service()
3350 void ath11k_qmi_free_resource(struct ath11k_base *ab) in ath11k_qmi_free_resource() argument
3352 ath11k_qmi_free_target_mem_chunk(ab); in ath11k_qmi_free_resource()
3353 ath11k_qmi_m3_free(ab); in ath11k_qmi_free_resource()