Lines Matching +full:segment +full:- +full:gpios

1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
126 gpios),
2024 for (i = 0; i < ag->num_devices; i++) { in ath12k_host_cap_hw_link_id_init()
2026 ab = ag->ab[i]; in ath12k_host_cap_hw_link_id_init()
2028 for (j = 0; j < ag->num_devices; j++) { in ath12k_host_cap_hw_link_id_init()
2029 partner_ab = ag->ab[j]; in ath12k_host_cap_hw_link_id_init()
2031 if (partner_ab->wsi_info.index >= ab->wsi_info.index) in ath12k_host_cap_hw_link_id_init()
2034 hw_id_base += partner_ab->qmi.num_radios; in ath12k_host_cap_hw_link_id_init()
2037 ab->wsi_info.hw_link_id_base = hw_id_base; in ath12k_host_cap_hw_link_id_init()
2040 ag->hw_link_id_init_done = true; in ath12k_host_cap_hw_link_id_init()
2047 struct ath12k_hw_group *ag = ab->ag; in ath12k_host_cap_parse_mlo()
2052 if (!ag->mlo_capable) { in ath12k_host_cap_parse_mlo()
2058 if (!ab->qmi.num_radios || ab->qmi.num_radios == U8_MAX) { in ath12k_host_cap_parse_mlo()
2059 ag->mlo_capable = false; in ath12k_host_cap_parse_mlo()
2062 ab->qmi.num_radios); in ath12k_host_cap_parse_mlo()
2066 if (ab->device_id == ATH12K_INVALID_DEVICE_ID) { in ath12k_host_cap_parse_mlo()
2068 return -EINVAL; in ath12k_host_cap_parse_mlo()
2071 req->mlo_capable_valid = 1; in ath12k_host_cap_parse_mlo()
2072 req->mlo_capable = 1; in ath12k_host_cap_parse_mlo()
2073 req->mlo_chip_id_valid = 1; in ath12k_host_cap_parse_mlo()
2074 req->mlo_chip_id = ab->device_id; in ath12k_host_cap_parse_mlo()
2075 req->mlo_group_id_valid = 1; in ath12k_host_cap_parse_mlo()
2076 req->mlo_group_id = ag->id; in ath12k_host_cap_parse_mlo()
2077 req->max_mlo_peer_valid = 1; in ath12k_host_cap_parse_mlo()
2081 req->max_mlo_peer = ab->hw_params->max_mlo_peer; in ath12k_host_cap_parse_mlo()
2082 req->mlo_num_chips_valid = 1; in ath12k_host_cap_parse_mlo()
2083 req->mlo_num_chips = ag->num_devices; in ath12k_host_cap_parse_mlo()
2086 req->mlo_chip_id, req->mlo_group_id, req->mlo_num_chips); in ath12k_host_cap_parse_mlo()
2088 mutex_lock(&ag->mutex); in ath12k_host_cap_parse_mlo()
2090 if (!ag->hw_link_id_init_done) in ath12k_host_cap_parse_mlo()
2093 for (i = 0; i < ag->num_devices; i++) { in ath12k_host_cap_parse_mlo()
2094 info = &req->mlo_chip_info[i]; in ath12k_host_cap_parse_mlo()
2095 partner_ab = ag->ab[i]; in ath12k_host_cap_parse_mlo()
2097 if (partner_ab->device_id == ATH12K_INVALID_DEVICE_ID) { in ath12k_host_cap_parse_mlo()
2099 ret = -EINVAL; in ath12k_host_cap_parse_mlo()
2103 info->chip_id = partner_ab->device_id; in ath12k_host_cap_parse_mlo()
2104 info->num_local_links = partner_ab->qmi.num_radios; in ath12k_host_cap_parse_mlo()
2107 info->chip_id, info->num_local_links); in ath12k_host_cap_parse_mlo()
2109 for (j = 0; j < info->num_local_links; j++) { in ath12k_host_cap_parse_mlo()
2110 info->hw_link_id[j] = partner_ab->wsi_info.hw_link_id_base + j; in ath12k_host_cap_parse_mlo()
2111 info->valid_mlo_link_id[j] = 1; in ath12k_host_cap_parse_mlo()
2114 info->hw_link_id[j]); in ath12k_host_cap_parse_mlo()
2121 ag->mlo_capable = false; in ath12k_host_cap_parse_mlo()
2123 req->mlo_chip_info_valid = 1; in ath12k_host_cap_parse_mlo()
2125 mutex_unlock(&ag->mutex); in ath12k_host_cap_parse_mlo()
2130 for (i = i - 1; i >= 0; i--) { in ath12k_host_cap_parse_mlo()
2131 info = &req->mlo_chip_info[i]; in ath12k_host_cap_parse_mlo()
2136 req->mlo_num_chips = 0; in ath12k_host_cap_parse_mlo()
2137 req->mlo_num_chips_valid = 0; in ath12k_host_cap_parse_mlo()
2139 req->max_mlo_peer = 0; in ath12k_host_cap_parse_mlo()
2140 req->max_mlo_peer_valid = 0; in ath12k_host_cap_parse_mlo()
2141 req->mlo_group_id = 0; in ath12k_host_cap_parse_mlo()
2142 req->mlo_group_id_valid = 0; in ath12k_host_cap_parse_mlo()
2143 req->mlo_chip_id = 0; in ath12k_host_cap_parse_mlo()
2144 req->mlo_chip_id_valid = 0; in ath12k_host_cap_parse_mlo()
2145 req->mlo_capable = 0; in ath12k_host_cap_parse_mlo()
2146 req->mlo_capable_valid = 0; in ath12k_host_cap_parse_mlo()
2148 ag->mlo_capable = false; in ath12k_host_cap_parse_mlo()
2150 mutex_unlock(&ag->mutex); in ath12k_host_cap_parse_mlo()
2166 req.mem_cfg_mode = ab->qmi.target_mem_mode; in ath12k_qmi_host_cap_send()
2177 req.cal_done = ab->qmi.cal_done; in ath12k_qmi_host_cap_send()
2179 if (ab->hw_params->qmi_cnss_feature_bitmap) { in ath12k_qmi_host_cap_send()
2181 req.feature_list = ab->hw_params->qmi_cnss_feature_bitmap; in ath12k_qmi_host_cap_send()
2187 if (ab->hw_params->internal_sleep_clock) { in ath12k_qmi_host_cap_send()
2190 /* Notify firmware that this is non-qualcomm platform. */ in ath12k_qmi_host_cap_send()
2195 * non-qualcomm platforms should select internal sleep in ath12k_qmi_host_cap_send()
2206 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_host_cap_send()
2211 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_host_cap_send()
2228 ret = -EINVAL; in ath12k_qmi_host_cap_send()
2243 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_phy_cap_send()
2248 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_phy_cap_send()
2263 ret = -EOPNOTSUPP; in ath12k_qmi_phy_cap_send()
2268 ret = -ENODATA; in ath12k_qmi_phy_cap_send()
2272 ab->qmi.num_radios = resp.num_phy; in ath12k_qmi_phy_cap_send()
2283 ab->qmi.num_radios = ab->hw_params->def_num_link; in ath12k_qmi_phy_cap_send()
2287 ab->qmi.num_radios); in ath12k_qmi_phy_cap_send()
2294 struct qmi_handle *handle = &ab->qmi.handle; in ath12k_qmi_fw_ind_register_send()
2300 return -ENOMEM; in ath12k_qmi_fw_ind_register_send()
2304 ret = -ENOMEM; in ath12k_qmi_fw_ind_register_send()
2308 req->client_id_valid = 1; in ath12k_qmi_fw_ind_register_send()
2309 req->client_id = QMI_WLANFW_CLIENT_ID; in ath12k_qmi_fw_ind_register_send()
2310 req->fw_ready_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2311 req->fw_ready_enable = 1; in ath12k_qmi_fw_ind_register_send()
2312 req->request_mem_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2313 req->request_mem_enable = 1; in ath12k_qmi_fw_ind_register_send()
2314 req->fw_mem_ready_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2315 req->fw_mem_ready_enable = 1; in ath12k_qmi_fw_ind_register_send()
2316 req->cal_done_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2317 req->cal_done_enable = 1; in ath12k_qmi_fw_ind_register_send()
2318 req->fw_init_done_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2319 req->fw_init_done_enable = 1; in ath12k_qmi_fw_ind_register_send()
2321 req->pin_connect_result_enable_valid = 0; in ath12k_qmi_fw_ind_register_send()
2322 req->pin_connect_result_enable = 0; in ath12k_qmi_fw_ind_register_send()
2329 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_fw_ind_register_send()
2346 if (resp->resp.result != QMI_RESULT_SUCCESS_V01) { in ath12k_qmi_fw_ind_register_send()
2348 resp->resp.result, resp->resp.error); in ath12k_qmi_fw_ind_register_send()
2349 ret = -EINVAL; in ath12k_qmi_fw_ind_register_send()
2372 return -ENOMEM; in ath12k_qmi_respond_fw_mem_request()
2379 if (ab->qmi.target_mem_delayed) { in ath12k_qmi_respond_fw_mem_request()
2382 ab->qmi.mem_seg_count); in ath12k_qmi_respond_fw_mem_request()
2385 req->mem_seg_len = ab->qmi.mem_seg_count; in ath12k_qmi_respond_fw_mem_request()
2386 for (i = 0; i < req->mem_seg_len ; i++) { in ath12k_qmi_respond_fw_mem_request()
2387 req->mem_seg[i].addr = ab->qmi.target_mem[i].paddr; in ath12k_qmi_respond_fw_mem_request()
2388 req->mem_seg[i].size = ab->qmi.target_mem[i].size; in ath12k_qmi_respond_fw_mem_request()
2389 req->mem_seg[i].type = ab->qmi.target_mem[i].type; in ath12k_qmi_respond_fw_mem_request()
2392 &ab->qmi.target_mem[i].paddr, in ath12k_qmi_respond_fw_mem_request()
2393 ab->qmi.target_mem[i].size, in ath12k_qmi_respond_fw_mem_request()
2394 ab->qmi.target_mem[i].type); in ath12k_qmi_respond_fw_mem_request()
2398 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_respond_fw_mem_request()
2403 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_respond_fw_mem_request()
2429 ret = -EINVAL; in ath12k_qmi_respond_fw_mem_request()
2441 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_free_mlo_mem_chunk()
2444 lockdep_assert_held(&ag->mutex); in ath12k_qmi_free_mlo_mem_chunk()
2446 if (!ag->mlo_mem.init_done || ag->num_started) in ath12k_qmi_free_mlo_mem_chunk()
2449 if (idx >= ARRAY_SIZE(ag->mlo_mem.chunk)) { in ath12k_qmi_free_mlo_mem_chunk()
2454 mlo_chunk = &ag->mlo_mem.chunk[idx]; in ath12k_qmi_free_mlo_mem_chunk()
2455 if (mlo_chunk->v.addr) { in ath12k_qmi_free_mlo_mem_chunk()
2456 dma_free_coherent(ab->dev, in ath12k_qmi_free_mlo_mem_chunk()
2457 mlo_chunk->size, in ath12k_qmi_free_mlo_mem_chunk()
2458 mlo_chunk->v.addr, in ath12k_qmi_free_mlo_mem_chunk()
2459 mlo_chunk->paddr); in ath12k_qmi_free_mlo_mem_chunk()
2460 mlo_chunk->v.addr = NULL; in ath12k_qmi_free_mlo_mem_chunk()
2463 mlo_chunk->paddr = 0; in ath12k_qmi_free_mlo_mem_chunk()
2464 mlo_chunk->size = 0; in ath12k_qmi_free_mlo_mem_chunk()
2465 chunk->v.addr = NULL; in ath12k_qmi_free_mlo_mem_chunk()
2466 chunk->paddr = 0; in ath12k_qmi_free_mlo_mem_chunk()
2467 chunk->size = 0; in ath12k_qmi_free_mlo_mem_chunk()
2472 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_free_target_mem_chunk()
2475 for (i = 0, mlo_idx = 0; i < ab->qmi.mem_seg_count; i++) { in ath12k_qmi_free_target_mem_chunk()
2476 if (!ab->qmi.target_mem[i].v.addr) in ath12k_qmi_free_target_mem_chunk()
2479 if (ab->qmi.target_mem[i].type == MLO_GLOBAL_MEM_REGION_TYPE) { in ath12k_qmi_free_target_mem_chunk()
2481 &ab->qmi.target_mem[i], in ath12k_qmi_free_target_mem_chunk()
2484 dma_free_coherent(ab->dev, in ath12k_qmi_free_target_mem_chunk()
2485 ab->qmi.target_mem[i].prev_size, in ath12k_qmi_free_target_mem_chunk()
2486 ab->qmi.target_mem[i].v.addr, in ath12k_qmi_free_target_mem_chunk()
2487 ab->qmi.target_mem[i].paddr); in ath12k_qmi_free_target_mem_chunk()
2488 ab->qmi.target_mem[i].v.addr = NULL; in ath12k_qmi_free_target_mem_chunk()
2492 if (!ag->num_started && ag->mlo_mem.init_done) { in ath12k_qmi_free_target_mem_chunk()
2493 ag->mlo_mem.init_done = false; in ath12k_qmi_free_target_mem_chunk()
2494 ag->mlo_mem.mlo_mem_size = 0; in ath12k_qmi_free_target_mem_chunk()
2504 if (chunk->v.addr) { in ath12k_qmi_alloc_chunk()
2505 if (chunk->prev_type == chunk->type && in ath12k_qmi_alloc_chunk()
2506 chunk->prev_size == chunk->size) in ath12k_qmi_alloc_chunk()
2510 dma_free_coherent(ab->dev, chunk->prev_size, in ath12k_qmi_alloc_chunk()
2511 chunk->v.addr, chunk->paddr); in ath12k_qmi_alloc_chunk()
2512 chunk->v.addr = NULL; in ath12k_qmi_alloc_chunk()
2515 chunk->v.addr = dma_alloc_coherent(ab->dev, in ath12k_qmi_alloc_chunk()
2516 chunk->size, in ath12k_qmi_alloc_chunk()
2517 &chunk->paddr, in ath12k_qmi_alloc_chunk()
2519 if (!chunk->v.addr) { in ath12k_qmi_alloc_chunk()
2520 if (chunk->size > ATH12K_QMI_MAX_CHUNK_SIZE) { in ath12k_qmi_alloc_chunk()
2521 ab->qmi.target_mem_delayed = true; in ath12k_qmi_alloc_chunk()
2524 chunk->size, in ath12k_qmi_alloc_chunk()
2525 chunk->type); in ath12k_qmi_alloc_chunk()
2527 return -EAGAIN; in ath12k_qmi_alloc_chunk()
2530 chunk->type, chunk->size); in ath12k_qmi_alloc_chunk()
2531 return -ENOMEM; in ath12k_qmi_alloc_chunk()
2533 chunk->prev_type = chunk->type; in ath12k_qmi_alloc_chunk()
2534 chunk->prev_size = chunk->size; in ath12k_qmi_alloc_chunk()
2542 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_alloc_target_mem_chunk()
2546 mutex_lock(&ag->mutex); in ath12k_qmi_alloc_target_mem_chunk()
2548 if (!ag->mlo_mem.init_done) { in ath12k_qmi_alloc_target_mem_chunk()
2549 memset(ag->mlo_mem.chunk, 0, sizeof(ag->mlo_mem.chunk)); in ath12k_qmi_alloc_target_mem_chunk()
2550 ag->mlo_mem.init_done = true; in ath12k_qmi_alloc_target_mem_chunk()
2553 ab->qmi.target_mem_delayed = false; in ath12k_qmi_alloc_target_mem_chunk()
2555 for (i = 0, mlo_idx = 0; i < ab->qmi.mem_seg_count; i++) { in ath12k_qmi_alloc_target_mem_chunk()
2556 chunk = &ab->qmi.target_mem[i]; in ath12k_qmi_alloc_target_mem_chunk()
2559 * on the host. For the non-supported memory region, host does not in ath12k_qmi_alloc_target_mem_chunk()
2562 switch (chunk->type) { in ath12k_qmi_alloc_target_mem_chunk()
2572 mlo_size += chunk->size; in ath12k_qmi_alloc_target_mem_chunk()
2573 if (ag->mlo_mem.mlo_mem_size && in ath12k_qmi_alloc_target_mem_chunk()
2574 mlo_size > ag->mlo_mem.mlo_mem_size) { in ath12k_qmi_alloc_target_mem_chunk()
2576 mlo_size, ag->mlo_mem.mlo_mem_size); in ath12k_qmi_alloc_target_mem_chunk()
2577 ret = -EINVAL; in ath12k_qmi_alloc_target_mem_chunk()
2581 mlo_chunk = &ag->mlo_mem.chunk[mlo_idx]; in ath12k_qmi_alloc_target_mem_chunk()
2582 if (mlo_chunk->paddr) { in ath12k_qmi_alloc_target_mem_chunk()
2583 if (chunk->size != mlo_chunk->size) { in ath12k_qmi_alloc_target_mem_chunk()
2585 mlo_idx, chunk->size, mlo_chunk->size); in ath12k_qmi_alloc_target_mem_chunk()
2586 ret = -EINVAL; in ath12k_qmi_alloc_target_mem_chunk()
2590 mlo_chunk->size = chunk->size; in ath12k_qmi_alloc_target_mem_chunk()
2591 mlo_chunk->type = chunk->type; in ath12k_qmi_alloc_target_mem_chunk()
2595 memset(mlo_chunk->v.addr, 0, mlo_chunk->size); in ath12k_qmi_alloc_target_mem_chunk()
2598 chunk->paddr = mlo_chunk->paddr; in ath12k_qmi_alloc_target_mem_chunk()
2599 chunk->v.addr = mlo_chunk->v.addr; in ath12k_qmi_alloc_target_mem_chunk()
2605 chunk->type); in ath12k_qmi_alloc_target_mem_chunk()
2606 chunk->paddr = 0; in ath12k_qmi_alloc_target_mem_chunk()
2607 chunk->v.addr = NULL; in ath12k_qmi_alloc_target_mem_chunk()
2612 if (!ag->mlo_mem.mlo_mem_size) { in ath12k_qmi_alloc_target_mem_chunk()
2613 ag->mlo_mem.mlo_mem_size = mlo_size; in ath12k_qmi_alloc_target_mem_chunk()
2614 } else if (ag->mlo_mem.mlo_mem_size != mlo_size) { in ath12k_qmi_alloc_target_mem_chunk()
2616 ag->mlo_mem.mlo_mem_size, mlo_size); in ath12k_qmi_alloc_target_mem_chunk()
2617 ret = -EINVAL; in ath12k_qmi_alloc_target_mem_chunk()
2621 mutex_unlock(&ag->mutex); in ath12k_qmi_alloc_target_mem_chunk()
2628 mutex_unlock(&ag->mutex); in ath12k_qmi_alloc_target_mem_chunk()
2635 if (ret == -EAGAIN) in ath12k_qmi_alloc_target_mem_chunk()
2653 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_request_target_cap()
2658 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_request_target_cap()
2678 ret = -EINVAL; in ath12k_qmi_request_target_cap()
2683 ab->qmi.target.chip_id = resp.chip_info.chip_id; in ath12k_qmi_request_target_cap()
2684 ab->qmi.target.chip_family = resp.chip_info.chip_family; in ath12k_qmi_request_target_cap()
2688 ab->qmi.target.board_id = resp.board_info.board_id; in ath12k_qmi_request_target_cap()
2690 ab->qmi.target.board_id = board_id; in ath12k_qmi_request_target_cap()
2693 ab->qmi.target.soc_id = resp.soc_info.soc_id; in ath12k_qmi_request_target_cap()
2696 ab->qmi.target.fw_version = resp.fw_version_info.fw_version; in ath12k_qmi_request_target_cap()
2697 strscpy(ab->qmi.target.fw_build_timestamp, in ath12k_qmi_request_target_cap()
2699 sizeof(ab->qmi.target.fw_build_timestamp)); in ath12k_qmi_request_target_cap()
2703 strscpy(ab->qmi.target.fw_build_id, resp.fw_build_id, in ath12k_qmi_request_target_cap()
2704 sizeof(ab->qmi.target.fw_build_id)); in ath12k_qmi_request_target_cap()
2708 ab->qmi.dev_mem[i].start = in ath12k_qmi_request_target_cap()
2710 ab->qmi.dev_mem[i].size = in ath12k_qmi_request_target_cap()
2714 ab->qmi.dev_mem[i].start, in ath12k_qmi_request_target_cap()
2715 ab->qmi.dev_mem[i].size); in ath12k_qmi_request_target_cap()
2720 ab->qmi.target.eeprom_caldata = resp.eeprom_caldata_read_timeout; in ath12k_qmi_request_target_cap()
2725 ab->qmi.target.chip_id, ab->qmi.target.chip_family, in ath12k_qmi_request_target_cap()
2726 ab->qmi.target.board_id, ab->qmi.target.soc_id); in ath12k_qmi_request_target_cap()
2729 ab->qmi.target.fw_version, in ath12k_qmi_request_target_cap()
2730 ab->qmi.target.fw_build_timestamp, in ath12k_qmi_request_target_cap()
2731 ab->qmi.target.fw_build_id); in ath12k_qmi_request_target_cap()
2762 return -ENOMEM; in ath12k_qmi_load_file_target_mem()
2765 req->valid = 1; in ath12k_qmi_load_file_target_mem()
2766 req->file_id_valid = 1; in ath12k_qmi_load_file_target_mem()
2767 req->file_id = ab->qmi.target.board_id; in ath12k_qmi_load_file_target_mem()
2768 req->total_size_valid = 1; in ath12k_qmi_load_file_target_mem()
2769 req->total_size = remaining; in ath12k_qmi_load_file_target_mem()
2770 req->seg_id_valid = 1; in ath12k_qmi_load_file_target_mem()
2771 req->data_valid = 1; in ath12k_qmi_load_file_target_mem()
2772 req->bdf_type = type; in ath12k_qmi_load_file_target_mem()
2773 req->bdf_type_valid = 1; in ath12k_qmi_load_file_target_mem()
2774 req->end_valid = 1; in ath12k_qmi_load_file_target_mem()
2775 req->end = 0; in ath12k_qmi_load_file_target_mem()
2778 req->data_len = QMI_WLANFW_MAX_DATA_SIZE_V01; in ath12k_qmi_load_file_target_mem()
2780 req->data_len = remaining; in ath12k_qmi_load_file_target_mem()
2781 req->end = 1; in ath12k_qmi_load_file_target_mem()
2785 req->data_valid = 0; in ath12k_qmi_load_file_target_mem()
2786 req->end = 1; in ath12k_qmi_load_file_target_mem()
2787 req->data_len = ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE; in ath12k_qmi_load_file_target_mem()
2789 memcpy(req->data, temp, req->data_len); in ath12k_qmi_load_file_target_mem()
2792 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_load_file_target_mem()
2801 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_load_file_target_mem()
2817 ret = -EINVAL; in ath12k_qmi_load_file_target_mem()
2824 remaining -= req->data_len; in ath12k_qmi_load_file_target_mem()
2825 temp += req->data_len; in ath12k_qmi_load_file_target_mem()
2826 req->seg_id++; in ath12k_qmi_load_file_target_mem()
2843 struct device *dev = ab->dev; in ath12k_qmi_load_bdf_qmi()
2876 if (ab->qmi.target.eeprom_caldata) { in ath12k_qmi_load_bdf_qmi()
2883 /* cal-<bus>-<id>.bin */ in ath12k_qmi_load_bdf_qmi()
2884 snprintf(filename, sizeof(filename), "cal-%s-%s.bin", in ath12k_qmi_load_bdf_qmi()
2885 ath12k_bus_str(ab->hif.bus), dev_name(dev)); in ath12k_qmi_load_bdf_qmi()
2901 fw_size = min_t(u32, ab->hw_params->fw.board_size, in ath12k_qmi_load_bdf_qmi()
2902 fw_entry->size); in ath12k_qmi_load_bdf_qmi()
2903 tmp = fw_entry->data; in ath12k_qmi_load_bdf_qmi()
2915 if (!ab->qmi.target.eeprom_caldata) in ath12k_qmi_load_bdf_qmi()
2925 fw_size = min_t(u32, ab->hw_params->fw.board_size, bd.len); in ath12k_qmi_load_bdf_qmi()
2940 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath12k_qmi_m3_free()
2942 if (!m3_mem->vaddr) in ath12k_qmi_m3_free()
2945 dma_free_coherent(ab->dev, m3_mem->size, in ath12k_qmi_m3_free()
2946 m3_mem->vaddr, m3_mem->paddr); in ath12k_qmi_m3_free()
2947 m3_mem->vaddr = NULL; in ath12k_qmi_m3_free()
2948 m3_mem->size = 0; in ath12k_qmi_m3_free()
2953 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath12k_qmi_m3_load()
2960 if (ab->fw.m3_data && ab->fw.m3_len > 0) { in ath12k_qmi_m3_load()
2961 /* firmware-N.bin had a m3 firmware file so use that */ in ath12k_qmi_m3_load()
2962 m3_data = ab->fw.m3_data; in ath12k_qmi_m3_load()
2963 m3_len = ab->fw.m3_len; in ath12k_qmi_m3_load()
2965 /* No m3 file in firmware-N.bin so try to request old in ath12k_qmi_m3_load()
2977 m3_data = fw->data; in ath12k_qmi_m3_load()
2978 m3_len = fw->size; in ath12k_qmi_m3_load()
2982 if (m3_mem->vaddr) { in ath12k_qmi_m3_load()
2983 if (m3_mem->size >= m3_len) in ath12k_qmi_m3_load()
2990 m3_mem->vaddr = dma_alloc_coherent(ab->dev, in ath12k_qmi_m3_load()
2991 m3_len, &m3_mem->paddr, in ath12k_qmi_m3_load()
2993 if (!m3_mem->vaddr) { in ath12k_qmi_m3_load()
2995 fw->size); in ath12k_qmi_m3_load()
2996 ret = -ENOMEM; in ath12k_qmi_m3_load()
3001 memcpy(m3_mem->vaddr, m3_data, m3_len); in ath12k_qmi_m3_load()
3002 m3_mem->size = m3_len; in ath12k_qmi_m3_load()
3016 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath12k_qmi_wlanfw_m3_info_send()
3028 req.addr = m3_mem->paddr; in ath12k_qmi_wlanfw_m3_info_send()
3029 req.size = m3_mem->size; in ath12k_qmi_wlanfw_m3_info_send()
3031 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_m3_info_send()
3036 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_m3_info_send()
3056 ret = -EINVAL; in ath12k_qmi_wlanfw_m3_info_send()
3075 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_mode_send()
3080 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_mode_send()
3093 if (mode == ATH12K_FIRMWARE_MODE_OFF && ret == -ENETRESET) { in ath12k_qmi_wlanfw_mode_send()
3094 ath12k_warn(ab, "WLFW service is dis-connected\n"); in ath12k_qmi_wlanfw_mode_send()
3105 ret = -EINVAL; in ath12k_qmi_wlanfw_mode_send()
3122 ce_cfg = (struct ce_pipe_config *)ab->qmi.ce_cfg.tgt_ce; in ath12k_qmi_wlanfw_wlan_cfg_send()
3123 svc_cfg = (struct service_to_pipe *)ab->qmi.ce_cfg.svc_to_ce_map; in ath12k_qmi_wlanfw_wlan_cfg_send()
3127 return -ENOMEM; in ath12k_qmi_wlanfw_wlan_cfg_send()
3129 req->host_version_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3130 strscpy(req->host_version, ATH12K_HOST_VERSION_STRING, in ath12k_qmi_wlanfw_wlan_cfg_send()
3131 sizeof(req->host_version)); in ath12k_qmi_wlanfw_wlan_cfg_send()
3133 req->tgt_cfg_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3135 req->tgt_cfg_len = ab->qmi.ce_cfg.tgt_ce_len; in ath12k_qmi_wlanfw_wlan_cfg_send()
3136 for (pipe_num = 0; pipe_num < req->tgt_cfg_len ; pipe_num++) { in ath12k_qmi_wlanfw_wlan_cfg_send()
3137 req->tgt_cfg[pipe_num].pipe_num = ce_cfg[pipe_num].pipenum; in ath12k_qmi_wlanfw_wlan_cfg_send()
3138 req->tgt_cfg[pipe_num].pipe_dir = ce_cfg[pipe_num].pipedir; in ath12k_qmi_wlanfw_wlan_cfg_send()
3139 req->tgt_cfg[pipe_num].nentries = ce_cfg[pipe_num].nentries; in ath12k_qmi_wlanfw_wlan_cfg_send()
3140 req->tgt_cfg[pipe_num].nbytes_max = ce_cfg[pipe_num].nbytes_max; in ath12k_qmi_wlanfw_wlan_cfg_send()
3141 req->tgt_cfg[pipe_num].flags = ce_cfg[pipe_num].flags; in ath12k_qmi_wlanfw_wlan_cfg_send()
3144 req->svc_cfg_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3146 req->svc_cfg_len = ab->qmi.ce_cfg.svc_to_ce_map_len; in ath12k_qmi_wlanfw_wlan_cfg_send()
3147 for (pipe_num = 0; pipe_num < req->svc_cfg_len; pipe_num++) { in ath12k_qmi_wlanfw_wlan_cfg_send()
3148 req->svc_cfg[pipe_num].service_id = svc_cfg[pipe_num].service_id; in ath12k_qmi_wlanfw_wlan_cfg_send()
3149 req->svc_cfg[pipe_num].pipe_dir = svc_cfg[pipe_num].pipedir; in ath12k_qmi_wlanfw_wlan_cfg_send()
3150 req->svc_cfg[pipe_num].pipe_num = svc_cfg[pipe_num].pipenum; in ath12k_qmi_wlanfw_wlan_cfg_send()
3154 if (ab->hw_params->supports_shadow_regs) { in ath12k_qmi_wlanfw_wlan_cfg_send()
3155 req->shadow_reg_v3_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3156 req->shadow_reg_v3_len = min_t(u32, in ath12k_qmi_wlanfw_wlan_cfg_send()
3157 ab->qmi.ce_cfg.shadow_reg_v3_len, in ath12k_qmi_wlanfw_wlan_cfg_send()
3159 memcpy(&req->shadow_reg_v3, ab->qmi.ce_cfg.shadow_reg_v3, in ath12k_qmi_wlanfw_wlan_cfg_send()
3160 sizeof(u32) * req->shadow_reg_v3_len); in ath12k_qmi_wlanfw_wlan_cfg_send()
3162 req->shadow_reg_v3_valid = 0; in ath12k_qmi_wlanfw_wlan_cfg_send()
3165 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_wlan_cfg_send()
3170 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_wlan_cfg_send()
3190 ret = -EINVAL; in ath12k_qmi_wlanfw_wlan_cfg_send()
3209 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_wlan_ini_send()
3214 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_wlan_ini_send()
3234 ret = -EINVAL; in ath12k_qmi_wlanfw_wlan_ini_send()
3246 clear_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags); in ath12k_qmi_firmware_stop()
3290 return -ENOMEM; in ath12k_qmi_driver_event_post()
3292 event->type = type; in ath12k_qmi_driver_event_post()
3293 event->data = data; in ath12k_qmi_driver_event_post()
3295 spin_lock(&qmi->event_lock); in ath12k_qmi_driver_event_post()
3296 list_add_tail(&event->list, &qmi->event_list); in ath12k_qmi_driver_event_post()
3297 spin_unlock(&qmi->event_lock); in ath12k_qmi_driver_event_post()
3299 queue_work(qmi->event_wq, &qmi->event_work); in ath12k_qmi_driver_event_post()
3306 struct ath12k_qmi *qmi = &ab->qmi; in ath12k_qmi_trigger_host_cap()
3308 spin_lock(&qmi->event_lock); in ath12k_qmi_trigger_host_cap()
3313 spin_unlock(&qmi->event_lock); in ath12k_qmi_trigger_host_cap()
3316 ab->device_id); in ath12k_qmi_trigger_host_cap()
3326 for (i = 0; i < ag->num_devices; i++) { in ath12k_qmi_hw_group_host_cap_ready()
3327 ab = ag->ab[i]; in ath12k_qmi_hw_group_host_cap_ready()
3329 if (!(ab && ab->qmi.num_radios != U8_MAX)) in ath12k_qmi_hw_group_host_cap_ready()
3341 lockdep_assert_held(&ag->mutex); in ath12k_qmi_hw_group_find_blocked()
3343 for (i = 0; i < ag->num_devices; i++) { in ath12k_qmi_hw_group_find_blocked()
3344 ab = ag->ab[i]; in ath12k_qmi_hw_group_find_blocked()
3348 spin_lock(&ab->qmi.event_lock); in ath12k_qmi_hw_group_find_blocked()
3350 if (ath12k_qmi_get_event_block(&ab->qmi)) { in ath12k_qmi_hw_group_find_blocked()
3351 spin_unlock(&ab->qmi.event_lock); in ath12k_qmi_hw_group_find_blocked()
3355 spin_unlock(&ab->qmi.event_lock); in ath12k_qmi_hw_group_find_blocked()
3365 struct ath12k_base *ab = qmi->ab, *block_ab; in ath12k_qmi_event_server_arrive()
3366 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_event_server_arrive()
3377 spin_lock(&qmi->event_lock); in ath12k_qmi_event_server_arrive()
3381 spin_unlock(&qmi->event_lock); in ath12k_qmi_event_server_arrive()
3383 mutex_lock(&ag->mutex); in ath12k_qmi_event_server_arrive()
3393 mutex_unlock(&ag->mutex); in ath12k_qmi_event_server_arrive()
3402 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_event_mem_request()
3418 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_event_load_bdf()
3439 if (ab->hw_params->download_calib) { in ath12k_qmi_event_load_bdf()
3460 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_msg_mem_request_cb()
3466 if (msg->mem_seg_len == 0 || in ath12k_qmi_msg_mem_request_cb()
3467 msg->mem_seg_len > ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01) in ath12k_qmi_msg_mem_request_cb()
3468 ath12k_warn(ab, "Invalid memory segment length: %u\n", in ath12k_qmi_msg_mem_request_cb()
3469 msg->mem_seg_len); in ath12k_qmi_msg_mem_request_cb()
3471 ab->qmi.mem_seg_count = msg->mem_seg_len; in ath12k_qmi_msg_mem_request_cb()
3473 for (i = 0; i < qmi->mem_seg_count ; i++) { in ath12k_qmi_msg_mem_request_cb()
3474 ab->qmi.target_mem[i].type = msg->mem_seg[i].type; in ath12k_qmi_msg_mem_request_cb()
3475 ab->qmi.target_mem[i].size = msg->mem_seg[i].size; in ath12k_qmi_msg_mem_request_cb()
3477 msg->mem_seg[i].type, msg->mem_seg[i].size); in ath12k_qmi_msg_mem_request_cb()
3496 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_msg_mem_ready_cb()
3508 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_msg_fw_ready_cb()
3545 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_ops_new_server()
3546 struct sockaddr_qrtr *sq = &qmi->sq; in ath12k_qmi_ops_new_server()
3549 sq->sq_family = AF_QIPCRTR; in ath12k_qmi_ops_new_server()
3550 sq->sq_node = service->node; in ath12k_qmi_ops_new_server()
3551 sq->sq_port = service->port; in ath12k_qmi_ops_new_server()
3553 ret = kernel_connect(qmi_hdl->sock, (struct sockaddr *)sq, in ath12k_qmi_ops_new_server()
3570 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_ops_del_server()
3583 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_event_host_cap()
3589 ab->device_id, ret); in ath12k_qmi_event_host_cap()
3601 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_driver_event_work()
3604 spin_lock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3605 while (!list_empty(&qmi->event_list)) { in ath12k_qmi_driver_event_work()
3606 event = list_first_entry(&qmi->event_list, in ath12k_qmi_driver_event_work()
3608 list_del(&event->list); in ath12k_qmi_driver_event_work()
3609 spin_unlock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3611 if (test_bit(ATH12K_FLAG_UNREGISTERING, &ab->dev_flags)) in ath12k_qmi_driver_event_work()
3614 switch (event->type) { in ath12k_qmi_driver_event_work()
3618 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3621 set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3626 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3631 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3634 clear_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3635 if (test_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags)) { in ath12k_qmi_driver_event_work()
3636 if (ab->is_reset) in ath12k_qmi_driver_event_work()
3639 set_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3640 queue_work(ab->workqueue, &ab->restart_work); in ath12k_qmi_driver_event_work()
3645 &ab->dev_flags); in ath12k_qmi_driver_event_work()
3649 &ab->dev_flags); in ath12k_qmi_driver_event_work()
3655 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3658 ath12k_warn(ab, "invalid event type: %d", event->type); in ath12k_qmi_driver_event_work()
3664 spin_lock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3666 spin_unlock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3673 memset(&ab->qmi.target, 0, sizeof(struct target_info)); in ath12k_qmi_init_service()
3674 memset(&ab->qmi.target_mem, 0, sizeof(struct target_mem_chunk)); in ath12k_qmi_init_service()
3675 ab->qmi.ab = ab; in ath12k_qmi_init_service()
3677 ab->qmi.target_mem_mode = ATH12K_QMI_TARGET_MEM_MODE_DEFAULT; in ath12k_qmi_init_service()
3678 ret = qmi_handle_init(&ab->qmi.handle, ATH12K_QMI_RESP_LEN_MAX, in ath12k_qmi_init_service()
3685 ab->qmi.event_wq = alloc_ordered_workqueue("ath12k_qmi_driver_event", 0); in ath12k_qmi_init_service()
3686 if (!ab->qmi.event_wq) { in ath12k_qmi_init_service()
3688 return -EFAULT; in ath12k_qmi_init_service()
3691 INIT_LIST_HEAD(&ab->qmi.event_list); in ath12k_qmi_init_service()
3692 spin_lock_init(&ab->qmi.event_lock); in ath12k_qmi_init_service()
3693 INIT_WORK(&ab->qmi.event_work, ath12k_qmi_driver_event_work); in ath12k_qmi_init_service()
3695 ret = qmi_add_lookup(&ab->qmi.handle, ATH12K_QMI_WLFW_SERVICE_ID_V01, in ath12k_qmi_init_service()
3697 ab->qmi.service_ins_id); in ath12k_qmi_init_service()
3700 destroy_workqueue(ab->qmi.event_wq); in ath12k_qmi_init_service()
3709 if (!ab->qmi.ab) in ath12k_qmi_deinit_service()
3712 qmi_handle_release(&ab->qmi.handle); in ath12k_qmi_deinit_service()
3713 cancel_work_sync(&ab->qmi.event_work); in ath12k_qmi_deinit_service()
3714 destroy_workqueue(ab->qmi.event_wq); in ath12k_qmi_deinit_service()
3717 ab->qmi.ab = NULL; in ath12k_qmi_deinit_service()