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-2024 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 ab->single_chip_mlo_supp = false; in ath12k_host_cap_parse_mlo()
2063 ab->qmi.num_radios); in ath12k_host_cap_parse_mlo()
2067 if (ab->device_id == ATH12K_INVALID_DEVICE_ID) { in ath12k_host_cap_parse_mlo()
2069 return -EINVAL; in ath12k_host_cap_parse_mlo()
2072 req->mlo_capable_valid = 1; in ath12k_host_cap_parse_mlo()
2073 req->mlo_capable = 1; in ath12k_host_cap_parse_mlo()
2074 req->mlo_chip_id_valid = 1; in ath12k_host_cap_parse_mlo()
2075 req->mlo_chip_id = ab->device_id; in ath12k_host_cap_parse_mlo()
2076 req->mlo_group_id_valid = 1; in ath12k_host_cap_parse_mlo()
2077 req->mlo_group_id = ag->id; in ath12k_host_cap_parse_mlo()
2078 req->max_mlo_peer_valid = 1; in ath12k_host_cap_parse_mlo()
2082 req->max_mlo_peer = ab->hw_params->max_mlo_peer; in ath12k_host_cap_parse_mlo()
2083 req->mlo_num_chips_valid = 1; in ath12k_host_cap_parse_mlo()
2084 req->mlo_num_chips = ag->num_devices; in ath12k_host_cap_parse_mlo()
2087 req->mlo_chip_id, req->mlo_group_id, req->mlo_num_chips); in ath12k_host_cap_parse_mlo()
2089 mutex_lock(&ag->mutex); in ath12k_host_cap_parse_mlo()
2091 if (!ag->hw_link_id_init_done) in ath12k_host_cap_parse_mlo()
2094 for (i = 0; i < ag->num_devices; i++) { in ath12k_host_cap_parse_mlo()
2095 info = &req->mlo_chip_info[i]; in ath12k_host_cap_parse_mlo()
2096 partner_ab = ag->ab[i]; in ath12k_host_cap_parse_mlo()
2098 if (partner_ab->device_id == ATH12K_INVALID_DEVICE_ID) { in ath12k_host_cap_parse_mlo()
2100 ret = -EINVAL; in ath12k_host_cap_parse_mlo()
2104 info->chip_id = partner_ab->device_id; in ath12k_host_cap_parse_mlo()
2105 info->num_local_links = partner_ab->qmi.num_radios; in ath12k_host_cap_parse_mlo()
2108 info->chip_id, info->num_local_links); in ath12k_host_cap_parse_mlo()
2110 for (j = 0; j < info->num_local_links; j++) { in ath12k_host_cap_parse_mlo()
2111 info->hw_link_id[j] = partner_ab->wsi_info.hw_link_id_base + j; in ath12k_host_cap_parse_mlo()
2112 info->valid_mlo_link_id[j] = 1; in ath12k_host_cap_parse_mlo()
2115 info->hw_link_id[j]); in ath12k_host_cap_parse_mlo()
2122 ag->mlo_capable = false; in ath12k_host_cap_parse_mlo()
2124 req->mlo_chip_info_valid = 1; in ath12k_host_cap_parse_mlo()
2126 mutex_unlock(&ag->mutex); in ath12k_host_cap_parse_mlo()
2131 for (i = i - 1; i >= 0; i--) { in ath12k_host_cap_parse_mlo()
2132 info = &req->mlo_chip_info[i]; in ath12k_host_cap_parse_mlo()
2137 req->mlo_num_chips = 0; in ath12k_host_cap_parse_mlo()
2138 req->mlo_num_chips_valid = 0; in ath12k_host_cap_parse_mlo()
2140 req->max_mlo_peer = 0; in ath12k_host_cap_parse_mlo()
2141 req->max_mlo_peer_valid = 0; in ath12k_host_cap_parse_mlo()
2142 req->mlo_group_id = 0; in ath12k_host_cap_parse_mlo()
2143 req->mlo_group_id_valid = 0; in ath12k_host_cap_parse_mlo()
2144 req->mlo_chip_id = 0; in ath12k_host_cap_parse_mlo()
2145 req->mlo_chip_id_valid = 0; in ath12k_host_cap_parse_mlo()
2146 req->mlo_capable = 0; in ath12k_host_cap_parse_mlo()
2147 req->mlo_capable_valid = 0; in ath12k_host_cap_parse_mlo()
2149 ag->mlo_capable = false; in ath12k_host_cap_parse_mlo()
2151 mutex_unlock(&ag->mutex); in ath12k_host_cap_parse_mlo()
2167 req.mem_cfg_mode = ab->qmi.target_mem_mode; in ath12k_qmi_host_cap_send()
2178 req.cal_done = ab->qmi.cal_done; in ath12k_qmi_host_cap_send()
2180 if (ab->hw_params->qmi_cnss_feature_bitmap) { in ath12k_qmi_host_cap_send()
2182 req.feature_list = ab->hw_params->qmi_cnss_feature_bitmap; in ath12k_qmi_host_cap_send()
2188 if (ab->hw_params->internal_sleep_clock) { in ath12k_qmi_host_cap_send()
2191 /* Notify firmware that this is non-qualcomm platform. */ in ath12k_qmi_host_cap_send()
2196 * non-qualcomm platforms should select internal sleep in ath12k_qmi_host_cap_send()
2207 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_host_cap_send()
2212 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_host_cap_send()
2229 ret = -EINVAL; in ath12k_qmi_host_cap_send()
2244 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_phy_cap_send()
2249 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_phy_cap_send()
2264 ret = -EOPNOTSUPP; in ath12k_qmi_phy_cap_send()
2270 ab->single_chip_mlo_supp = true; in ath12k_qmi_phy_cap_send()
2273 ret = -ENODATA; in ath12k_qmi_phy_cap_send()
2277 ab->qmi.num_radios = resp.num_phy; in ath12k_qmi_phy_cap_send()
2289 ab->qmi.num_radios = ab->hw_params->def_num_link; in ath12k_qmi_phy_cap_send()
2293 ab->qmi.num_radios); in ath12k_qmi_phy_cap_send()
2300 struct qmi_handle *handle = &ab->qmi.handle; in ath12k_qmi_fw_ind_register_send()
2306 return -ENOMEM; in ath12k_qmi_fw_ind_register_send()
2310 ret = -ENOMEM; in ath12k_qmi_fw_ind_register_send()
2314 req->client_id_valid = 1; in ath12k_qmi_fw_ind_register_send()
2315 req->client_id = QMI_WLANFW_CLIENT_ID; in ath12k_qmi_fw_ind_register_send()
2316 req->fw_ready_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2317 req->fw_ready_enable = 1; in ath12k_qmi_fw_ind_register_send()
2318 req->request_mem_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2319 req->request_mem_enable = 1; in ath12k_qmi_fw_ind_register_send()
2320 req->fw_mem_ready_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2321 req->fw_mem_ready_enable = 1; in ath12k_qmi_fw_ind_register_send()
2322 req->cal_done_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2323 req->cal_done_enable = 1; in ath12k_qmi_fw_ind_register_send()
2324 req->fw_init_done_enable_valid = 1; in ath12k_qmi_fw_ind_register_send()
2325 req->fw_init_done_enable = 1; in ath12k_qmi_fw_ind_register_send()
2327 req->pin_connect_result_enable_valid = 0; in ath12k_qmi_fw_ind_register_send()
2328 req->pin_connect_result_enable = 0; in ath12k_qmi_fw_ind_register_send()
2335 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_fw_ind_register_send()
2352 if (resp->resp.result != QMI_RESULT_SUCCESS_V01) { in ath12k_qmi_fw_ind_register_send()
2354 resp->resp.result, resp->resp.error); in ath12k_qmi_fw_ind_register_send()
2355 ret = -EINVAL; in ath12k_qmi_fw_ind_register_send()
2378 return -ENOMEM; in ath12k_qmi_respond_fw_mem_request()
2385 if (ab->qmi.target_mem_delayed) { in ath12k_qmi_respond_fw_mem_request()
2388 ab->qmi.mem_seg_count); in ath12k_qmi_respond_fw_mem_request()
2391 req->mem_seg_len = ab->qmi.mem_seg_count; in ath12k_qmi_respond_fw_mem_request()
2392 for (i = 0; i < req->mem_seg_len ; i++) { in ath12k_qmi_respond_fw_mem_request()
2393 req->mem_seg[i].addr = ab->qmi.target_mem[i].paddr; in ath12k_qmi_respond_fw_mem_request()
2394 req->mem_seg[i].size = ab->qmi.target_mem[i].size; in ath12k_qmi_respond_fw_mem_request()
2395 req->mem_seg[i].type = ab->qmi.target_mem[i].type; in ath12k_qmi_respond_fw_mem_request()
2398 &ab->qmi.target_mem[i].paddr, in ath12k_qmi_respond_fw_mem_request()
2399 ab->qmi.target_mem[i].size, in ath12k_qmi_respond_fw_mem_request()
2400 ab->qmi.target_mem[i].type); in ath12k_qmi_respond_fw_mem_request()
2404 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_respond_fw_mem_request()
2409 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_respond_fw_mem_request()
2435 ret = -EINVAL; in ath12k_qmi_respond_fw_mem_request()
2447 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_free_mlo_mem_chunk()
2450 lockdep_assert_held(&ag->mutex); in ath12k_qmi_free_mlo_mem_chunk()
2452 if (!ag->mlo_mem.init_done || ag->num_started) in ath12k_qmi_free_mlo_mem_chunk()
2455 if (idx >= ARRAY_SIZE(ag->mlo_mem.chunk)) { in ath12k_qmi_free_mlo_mem_chunk()
2460 mlo_chunk = &ag->mlo_mem.chunk[idx]; in ath12k_qmi_free_mlo_mem_chunk()
2461 if (mlo_chunk->v.addr) { in ath12k_qmi_free_mlo_mem_chunk()
2462 dma_free_coherent(ab->dev, in ath12k_qmi_free_mlo_mem_chunk()
2463 mlo_chunk->size, in ath12k_qmi_free_mlo_mem_chunk()
2464 mlo_chunk->v.addr, in ath12k_qmi_free_mlo_mem_chunk()
2465 mlo_chunk->paddr); in ath12k_qmi_free_mlo_mem_chunk()
2466 mlo_chunk->v.addr = NULL; in ath12k_qmi_free_mlo_mem_chunk()
2469 mlo_chunk->paddr = 0; in ath12k_qmi_free_mlo_mem_chunk()
2470 mlo_chunk->size = 0; in ath12k_qmi_free_mlo_mem_chunk()
2471 chunk->v.addr = NULL; in ath12k_qmi_free_mlo_mem_chunk()
2472 chunk->paddr = 0; in ath12k_qmi_free_mlo_mem_chunk()
2473 chunk->size = 0; in ath12k_qmi_free_mlo_mem_chunk()
2478 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_free_target_mem_chunk()
2481 for (i = 0, mlo_idx = 0; i < ab->qmi.mem_seg_count; i++) { in ath12k_qmi_free_target_mem_chunk()
2482 if (!ab->qmi.target_mem[i].v.addr) in ath12k_qmi_free_target_mem_chunk()
2485 if (ab->qmi.target_mem[i].type == MLO_GLOBAL_MEM_REGION_TYPE) { in ath12k_qmi_free_target_mem_chunk()
2487 &ab->qmi.target_mem[i], in ath12k_qmi_free_target_mem_chunk()
2490 dma_free_coherent(ab->dev, in ath12k_qmi_free_target_mem_chunk()
2491 ab->qmi.target_mem[i].prev_size, in ath12k_qmi_free_target_mem_chunk()
2492 ab->qmi.target_mem[i].v.addr, in ath12k_qmi_free_target_mem_chunk()
2493 ab->qmi.target_mem[i].paddr); in ath12k_qmi_free_target_mem_chunk()
2494 ab->qmi.target_mem[i].v.addr = NULL; in ath12k_qmi_free_target_mem_chunk()
2498 if (!ag->num_started && ag->mlo_mem.init_done) { in ath12k_qmi_free_target_mem_chunk()
2499 ag->mlo_mem.init_done = false; in ath12k_qmi_free_target_mem_chunk()
2500 ag->mlo_mem.mlo_mem_size = 0; in ath12k_qmi_free_target_mem_chunk()
2510 if (chunk->v.addr) { in ath12k_qmi_alloc_chunk()
2511 if (chunk->prev_type == chunk->type && in ath12k_qmi_alloc_chunk()
2512 chunk->prev_size == chunk->size) in ath12k_qmi_alloc_chunk()
2516 dma_free_coherent(ab->dev, chunk->prev_size, in ath12k_qmi_alloc_chunk()
2517 chunk->v.addr, chunk->paddr); in ath12k_qmi_alloc_chunk()
2518 chunk->v.addr = NULL; in ath12k_qmi_alloc_chunk()
2521 chunk->v.addr = dma_alloc_coherent(ab->dev, in ath12k_qmi_alloc_chunk()
2522 chunk->size, in ath12k_qmi_alloc_chunk()
2523 &chunk->paddr, in ath12k_qmi_alloc_chunk()
2525 if (!chunk->v.addr) { in ath12k_qmi_alloc_chunk()
2526 if (chunk->size > ATH12K_QMI_MAX_CHUNK_SIZE) { in ath12k_qmi_alloc_chunk()
2527 ab->qmi.target_mem_delayed = true; in ath12k_qmi_alloc_chunk()
2530 chunk->size, in ath12k_qmi_alloc_chunk()
2531 chunk->type); in ath12k_qmi_alloc_chunk()
2533 return -EAGAIN; in ath12k_qmi_alloc_chunk()
2536 chunk->type, chunk->size); in ath12k_qmi_alloc_chunk()
2537 return -ENOMEM; in ath12k_qmi_alloc_chunk()
2539 chunk->prev_type = chunk->type; in ath12k_qmi_alloc_chunk()
2540 chunk->prev_size = chunk->size; in ath12k_qmi_alloc_chunk()
2548 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_alloc_target_mem_chunk()
2552 mutex_lock(&ag->mutex); in ath12k_qmi_alloc_target_mem_chunk()
2554 if (!ag->mlo_mem.init_done) { in ath12k_qmi_alloc_target_mem_chunk()
2555 memset(ag->mlo_mem.chunk, 0, sizeof(ag->mlo_mem.chunk)); in ath12k_qmi_alloc_target_mem_chunk()
2556 ag->mlo_mem.init_done = true; in ath12k_qmi_alloc_target_mem_chunk()
2559 ab->qmi.target_mem_delayed = false; in ath12k_qmi_alloc_target_mem_chunk()
2561 for (i = 0, mlo_idx = 0; i < ab->qmi.mem_seg_count; i++) { in ath12k_qmi_alloc_target_mem_chunk()
2562 chunk = &ab->qmi.target_mem[i]; in ath12k_qmi_alloc_target_mem_chunk()
2565 * on the host. For the non-supported memory region, host does not in ath12k_qmi_alloc_target_mem_chunk()
2568 switch (chunk->type) { in ath12k_qmi_alloc_target_mem_chunk()
2578 mlo_size += chunk->size; in ath12k_qmi_alloc_target_mem_chunk()
2579 if (ag->mlo_mem.mlo_mem_size && in ath12k_qmi_alloc_target_mem_chunk()
2580 mlo_size > ag->mlo_mem.mlo_mem_size) { in ath12k_qmi_alloc_target_mem_chunk()
2582 mlo_size, ag->mlo_mem.mlo_mem_size); in ath12k_qmi_alloc_target_mem_chunk()
2583 ret = -EINVAL; in ath12k_qmi_alloc_target_mem_chunk()
2587 mlo_chunk = &ag->mlo_mem.chunk[mlo_idx]; in ath12k_qmi_alloc_target_mem_chunk()
2588 if (mlo_chunk->paddr) { in ath12k_qmi_alloc_target_mem_chunk()
2589 if (chunk->size != mlo_chunk->size) { in ath12k_qmi_alloc_target_mem_chunk()
2591 mlo_idx, chunk->size, mlo_chunk->size); in ath12k_qmi_alloc_target_mem_chunk()
2592 ret = -EINVAL; in ath12k_qmi_alloc_target_mem_chunk()
2596 mlo_chunk->size = chunk->size; in ath12k_qmi_alloc_target_mem_chunk()
2597 mlo_chunk->type = chunk->type; in ath12k_qmi_alloc_target_mem_chunk()
2601 memset(mlo_chunk->v.addr, 0, mlo_chunk->size); in ath12k_qmi_alloc_target_mem_chunk()
2604 chunk->paddr = mlo_chunk->paddr; in ath12k_qmi_alloc_target_mem_chunk()
2605 chunk->v.addr = mlo_chunk->v.addr; in ath12k_qmi_alloc_target_mem_chunk()
2611 chunk->type); in ath12k_qmi_alloc_target_mem_chunk()
2612 chunk->paddr = 0; in ath12k_qmi_alloc_target_mem_chunk()
2613 chunk->v.addr = NULL; in ath12k_qmi_alloc_target_mem_chunk()
2618 if (!ag->mlo_mem.mlo_mem_size) { in ath12k_qmi_alloc_target_mem_chunk()
2619 ag->mlo_mem.mlo_mem_size = mlo_size; in ath12k_qmi_alloc_target_mem_chunk()
2620 } else if (ag->mlo_mem.mlo_mem_size != mlo_size) { in ath12k_qmi_alloc_target_mem_chunk()
2622 ag->mlo_mem.mlo_mem_size, mlo_size); in ath12k_qmi_alloc_target_mem_chunk()
2623 ret = -EINVAL; in ath12k_qmi_alloc_target_mem_chunk()
2627 mutex_unlock(&ag->mutex); in ath12k_qmi_alloc_target_mem_chunk()
2634 mutex_unlock(&ag->mutex); in ath12k_qmi_alloc_target_mem_chunk()
2641 if (ret == -EAGAIN) in ath12k_qmi_alloc_target_mem_chunk()
2659 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_request_target_cap()
2664 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_request_target_cap()
2684 ret = -EINVAL; in ath12k_qmi_request_target_cap()
2689 ab->qmi.target.chip_id = resp.chip_info.chip_id; in ath12k_qmi_request_target_cap()
2690 ab->qmi.target.chip_family = resp.chip_info.chip_family; in ath12k_qmi_request_target_cap()
2694 ab->qmi.target.board_id = resp.board_info.board_id; in ath12k_qmi_request_target_cap()
2696 ab->qmi.target.board_id = board_id; in ath12k_qmi_request_target_cap()
2699 ab->qmi.target.soc_id = resp.soc_info.soc_id; in ath12k_qmi_request_target_cap()
2702 ab->qmi.target.fw_version = resp.fw_version_info.fw_version; in ath12k_qmi_request_target_cap()
2703 strscpy(ab->qmi.target.fw_build_timestamp, in ath12k_qmi_request_target_cap()
2705 sizeof(ab->qmi.target.fw_build_timestamp)); in ath12k_qmi_request_target_cap()
2709 strscpy(ab->qmi.target.fw_build_id, resp.fw_build_id, in ath12k_qmi_request_target_cap()
2710 sizeof(ab->qmi.target.fw_build_id)); in ath12k_qmi_request_target_cap()
2714 ab->qmi.dev_mem[i].start = in ath12k_qmi_request_target_cap()
2716 ab->qmi.dev_mem[i].size = in ath12k_qmi_request_target_cap()
2720 ab->qmi.dev_mem[i].start, in ath12k_qmi_request_target_cap()
2721 ab->qmi.dev_mem[i].size); in ath12k_qmi_request_target_cap()
2726 ab->qmi.target.eeprom_caldata = resp.eeprom_caldata_read_timeout; in ath12k_qmi_request_target_cap()
2731 ab->qmi.target.chip_id, ab->qmi.target.chip_family, in ath12k_qmi_request_target_cap()
2732 ab->qmi.target.board_id, ab->qmi.target.soc_id); in ath12k_qmi_request_target_cap()
2735 ab->qmi.target.fw_version, in ath12k_qmi_request_target_cap()
2736 ab->qmi.target.fw_build_timestamp, in ath12k_qmi_request_target_cap()
2737 ab->qmi.target.fw_build_id); in ath12k_qmi_request_target_cap()
2759 return -ENOMEM; in ath12k_qmi_load_file_target_mem()
2762 req->valid = 1; in ath12k_qmi_load_file_target_mem()
2763 req->file_id_valid = 1; in ath12k_qmi_load_file_target_mem()
2764 req->file_id = ab->qmi.target.board_id; in ath12k_qmi_load_file_target_mem()
2765 req->total_size_valid = 1; in ath12k_qmi_load_file_target_mem()
2766 req->total_size = remaining; in ath12k_qmi_load_file_target_mem()
2767 req->seg_id_valid = 1; in ath12k_qmi_load_file_target_mem()
2768 req->data_valid = 1; in ath12k_qmi_load_file_target_mem()
2769 req->bdf_type = type; in ath12k_qmi_load_file_target_mem()
2770 req->bdf_type_valid = 1; in ath12k_qmi_load_file_target_mem()
2771 req->end_valid = 1; in ath12k_qmi_load_file_target_mem()
2772 req->end = 0; in ath12k_qmi_load_file_target_mem()
2775 req->data_len = QMI_WLANFW_MAX_DATA_SIZE_V01; in ath12k_qmi_load_file_target_mem()
2777 req->data_len = remaining; in ath12k_qmi_load_file_target_mem()
2778 req->end = 1; in ath12k_qmi_load_file_target_mem()
2782 req->data_valid = 0; in ath12k_qmi_load_file_target_mem()
2783 req->end = 1; in ath12k_qmi_load_file_target_mem()
2784 req->data_len = ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE; in ath12k_qmi_load_file_target_mem()
2786 memcpy(req->data, temp, req->data_len); in ath12k_qmi_load_file_target_mem()
2789 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_load_file_target_mem()
2798 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_load_file_target_mem()
2814 ret = -EINVAL; in ath12k_qmi_load_file_target_mem()
2821 remaining -= req->data_len; in ath12k_qmi_load_file_target_mem()
2822 temp += req->data_len; in ath12k_qmi_load_file_target_mem()
2823 req->seg_id++; in ath12k_qmi_load_file_target_mem()
2840 struct device *dev = ab->dev; in ath12k_qmi_load_bdf_qmi()
2873 if (ab->qmi.target.eeprom_caldata) { in ath12k_qmi_load_bdf_qmi()
2880 /* cal-<bus>-<id>.bin */ in ath12k_qmi_load_bdf_qmi()
2881 snprintf(filename, sizeof(filename), "cal-%s-%s.bin", in ath12k_qmi_load_bdf_qmi()
2882 ath12k_bus_str(ab->hif.bus), dev_name(dev)); in ath12k_qmi_load_bdf_qmi()
2898 fw_size = min_t(u32, ab->hw_params->fw.board_size, in ath12k_qmi_load_bdf_qmi()
2899 fw_entry->size); in ath12k_qmi_load_bdf_qmi()
2900 tmp = fw_entry->data; in ath12k_qmi_load_bdf_qmi()
2912 if (!ab->qmi.target.eeprom_caldata) in ath12k_qmi_load_bdf_qmi()
2922 fw_size = min_t(u32, ab->hw_params->fw.board_size, bd.len); in ath12k_qmi_load_bdf_qmi()
2937 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath12k_qmi_m3_free()
2939 if (!m3_mem->vaddr) in ath12k_qmi_m3_free()
2942 dma_free_coherent(ab->dev, m3_mem->size, in ath12k_qmi_m3_free()
2943 m3_mem->vaddr, m3_mem->paddr); in ath12k_qmi_m3_free()
2944 m3_mem->vaddr = NULL; in ath12k_qmi_m3_free()
2945 m3_mem->size = 0; in ath12k_qmi_m3_free()
2950 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath12k_qmi_m3_load()
2957 if (ab->fw.m3_data && ab->fw.m3_len > 0) { in ath12k_qmi_m3_load()
2958 /* firmware-N.bin had a m3 firmware file so use that */ in ath12k_qmi_m3_load()
2959 m3_data = ab->fw.m3_data; in ath12k_qmi_m3_load()
2960 m3_len = ab->fw.m3_len; in ath12k_qmi_m3_load()
2962 /* No m3 file in firmware-N.bin so try to request old in ath12k_qmi_m3_load()
2974 m3_data = fw->data; in ath12k_qmi_m3_load()
2975 m3_len = fw->size; in ath12k_qmi_m3_load()
2979 if (m3_mem->vaddr) { in ath12k_qmi_m3_load()
2980 if (m3_mem->size >= m3_len) in ath12k_qmi_m3_load()
2987 m3_mem->vaddr = dma_alloc_coherent(ab->dev, in ath12k_qmi_m3_load()
2988 m3_len, &m3_mem->paddr, in ath12k_qmi_m3_load()
2990 if (!m3_mem->vaddr) { in ath12k_qmi_m3_load()
2992 fw->size); in ath12k_qmi_m3_load()
2993 ret = -ENOMEM; in ath12k_qmi_m3_load()
2998 memcpy(m3_mem->vaddr, m3_data, m3_len); in ath12k_qmi_m3_load()
2999 m3_mem->size = m3_len; in ath12k_qmi_m3_load()
3013 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; in ath12k_qmi_wlanfw_m3_info_send()
3025 req.addr = m3_mem->paddr; in ath12k_qmi_wlanfw_m3_info_send()
3026 req.size = m3_mem->size; in ath12k_qmi_wlanfw_m3_info_send()
3028 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_m3_info_send()
3033 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_m3_info_send()
3053 ret = -EINVAL; in ath12k_qmi_wlanfw_m3_info_send()
3072 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_mode_send()
3077 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_mode_send()
3090 if (mode == ATH12K_FIRMWARE_MODE_OFF && ret == -ENETRESET) { in ath12k_qmi_wlanfw_mode_send()
3091 ath12k_warn(ab, "WLFW service is dis-connected\n"); in ath12k_qmi_wlanfw_mode_send()
3102 ret = -EINVAL; in ath12k_qmi_wlanfw_mode_send()
3119 ce_cfg = (struct ce_pipe_config *)ab->qmi.ce_cfg.tgt_ce; in ath12k_qmi_wlanfw_wlan_cfg_send()
3120 svc_cfg = (struct service_to_pipe *)ab->qmi.ce_cfg.svc_to_ce_map; in ath12k_qmi_wlanfw_wlan_cfg_send()
3124 return -ENOMEM; in ath12k_qmi_wlanfw_wlan_cfg_send()
3126 req->host_version_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3127 strscpy(req->host_version, ATH12K_HOST_VERSION_STRING, in ath12k_qmi_wlanfw_wlan_cfg_send()
3128 sizeof(req->host_version)); in ath12k_qmi_wlanfw_wlan_cfg_send()
3130 req->tgt_cfg_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3132 req->tgt_cfg_len = ab->qmi.ce_cfg.tgt_ce_len; in ath12k_qmi_wlanfw_wlan_cfg_send()
3133 for (pipe_num = 0; pipe_num < req->tgt_cfg_len ; pipe_num++) { in ath12k_qmi_wlanfw_wlan_cfg_send()
3134 req->tgt_cfg[pipe_num].pipe_num = ce_cfg[pipe_num].pipenum; in ath12k_qmi_wlanfw_wlan_cfg_send()
3135 req->tgt_cfg[pipe_num].pipe_dir = ce_cfg[pipe_num].pipedir; in ath12k_qmi_wlanfw_wlan_cfg_send()
3136 req->tgt_cfg[pipe_num].nentries = ce_cfg[pipe_num].nentries; in ath12k_qmi_wlanfw_wlan_cfg_send()
3137 req->tgt_cfg[pipe_num].nbytes_max = ce_cfg[pipe_num].nbytes_max; in ath12k_qmi_wlanfw_wlan_cfg_send()
3138 req->tgt_cfg[pipe_num].flags = ce_cfg[pipe_num].flags; in ath12k_qmi_wlanfw_wlan_cfg_send()
3141 req->svc_cfg_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3143 req->svc_cfg_len = ab->qmi.ce_cfg.svc_to_ce_map_len; in ath12k_qmi_wlanfw_wlan_cfg_send()
3144 for (pipe_num = 0; pipe_num < req->svc_cfg_len; pipe_num++) { in ath12k_qmi_wlanfw_wlan_cfg_send()
3145 req->svc_cfg[pipe_num].service_id = svc_cfg[pipe_num].service_id; in ath12k_qmi_wlanfw_wlan_cfg_send()
3146 req->svc_cfg[pipe_num].pipe_dir = svc_cfg[pipe_num].pipedir; in ath12k_qmi_wlanfw_wlan_cfg_send()
3147 req->svc_cfg[pipe_num].pipe_num = svc_cfg[pipe_num].pipenum; in ath12k_qmi_wlanfw_wlan_cfg_send()
3151 if (ab->hw_params->supports_shadow_regs) { in ath12k_qmi_wlanfw_wlan_cfg_send()
3152 req->shadow_reg_v3_valid = 1; in ath12k_qmi_wlanfw_wlan_cfg_send()
3153 req->shadow_reg_v3_len = min_t(u32, in ath12k_qmi_wlanfw_wlan_cfg_send()
3154 ab->qmi.ce_cfg.shadow_reg_v3_len, in ath12k_qmi_wlanfw_wlan_cfg_send()
3156 memcpy(&req->shadow_reg_v3, ab->qmi.ce_cfg.shadow_reg_v3, in ath12k_qmi_wlanfw_wlan_cfg_send()
3157 sizeof(u32) * req->shadow_reg_v3_len); in ath12k_qmi_wlanfw_wlan_cfg_send()
3159 req->shadow_reg_v3_valid = 0; in ath12k_qmi_wlanfw_wlan_cfg_send()
3162 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_wlan_cfg_send()
3167 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_wlan_cfg_send()
3187 ret = -EINVAL; in ath12k_qmi_wlanfw_wlan_cfg_send()
3206 ret = qmi_txn_init(&ab->qmi.handle, &txn, in ath12k_qmi_wlanfw_wlan_ini_send()
3211 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, in ath12k_qmi_wlanfw_wlan_ini_send()
3231 ret = -EINVAL; in ath12k_qmi_wlanfw_wlan_ini_send()
3243 clear_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags); in ath12k_qmi_firmware_stop()
3287 return -ENOMEM; in ath12k_qmi_driver_event_post()
3289 event->type = type; in ath12k_qmi_driver_event_post()
3290 event->data = data; in ath12k_qmi_driver_event_post()
3292 spin_lock(&qmi->event_lock); in ath12k_qmi_driver_event_post()
3293 list_add_tail(&event->list, &qmi->event_list); in ath12k_qmi_driver_event_post()
3294 spin_unlock(&qmi->event_lock); in ath12k_qmi_driver_event_post()
3296 queue_work(qmi->event_wq, &qmi->event_work); in ath12k_qmi_driver_event_post()
3303 struct ath12k_qmi *qmi = &ab->qmi; in ath12k_qmi_trigger_host_cap()
3305 spin_lock(&qmi->event_lock); in ath12k_qmi_trigger_host_cap()
3310 spin_unlock(&qmi->event_lock); in ath12k_qmi_trigger_host_cap()
3313 ab->device_id); in ath12k_qmi_trigger_host_cap()
3323 for (i = 0; i < ag->num_devices; i++) { in ath12k_qmi_hw_group_host_cap_ready()
3324 ab = ag->ab[i]; in ath12k_qmi_hw_group_host_cap_ready()
3326 if (!(ab && ab->qmi.num_radios != U8_MAX)) in ath12k_qmi_hw_group_host_cap_ready()
3338 lockdep_assert_held(&ag->mutex); in ath12k_qmi_hw_group_find_blocked()
3340 for (i = 0; i < ag->num_devices; i++) { in ath12k_qmi_hw_group_find_blocked()
3341 ab = ag->ab[i]; in ath12k_qmi_hw_group_find_blocked()
3345 spin_lock(&ab->qmi.event_lock); in ath12k_qmi_hw_group_find_blocked()
3347 if (ath12k_qmi_get_event_block(&ab->qmi)) { in ath12k_qmi_hw_group_find_blocked()
3348 spin_unlock(&ab->qmi.event_lock); in ath12k_qmi_hw_group_find_blocked()
3352 spin_unlock(&ab->qmi.event_lock); in ath12k_qmi_hw_group_find_blocked()
3362 struct ath12k_base *ab = qmi->ab, *block_ab; in ath12k_qmi_event_server_arrive()
3363 struct ath12k_hw_group *ag = ab->ag; in ath12k_qmi_event_server_arrive()
3374 spin_lock(&qmi->event_lock); in ath12k_qmi_event_server_arrive()
3378 spin_unlock(&qmi->event_lock); in ath12k_qmi_event_server_arrive()
3380 mutex_lock(&ag->mutex); in ath12k_qmi_event_server_arrive()
3390 mutex_unlock(&ag->mutex); in ath12k_qmi_event_server_arrive()
3399 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_event_mem_request()
3415 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_event_load_bdf()
3436 if (ab->hw_params->download_calib) { in ath12k_qmi_event_load_bdf()
3457 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_msg_mem_request_cb()
3463 if (msg->mem_seg_len == 0 || in ath12k_qmi_msg_mem_request_cb()
3464 msg->mem_seg_len > ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01) in ath12k_qmi_msg_mem_request_cb()
3465 ath12k_warn(ab, "Invalid memory segment length: %u\n", in ath12k_qmi_msg_mem_request_cb()
3466 msg->mem_seg_len); in ath12k_qmi_msg_mem_request_cb()
3468 ab->qmi.mem_seg_count = msg->mem_seg_len; in ath12k_qmi_msg_mem_request_cb()
3470 for (i = 0; i < qmi->mem_seg_count ; i++) { in ath12k_qmi_msg_mem_request_cb()
3471 ab->qmi.target_mem[i].type = msg->mem_seg[i].type; in ath12k_qmi_msg_mem_request_cb()
3472 ab->qmi.target_mem[i].size = msg->mem_seg[i].size; in ath12k_qmi_msg_mem_request_cb()
3474 msg->mem_seg[i].type, msg->mem_seg[i].size); in ath12k_qmi_msg_mem_request_cb()
3493 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_msg_mem_ready_cb()
3505 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_msg_fw_ready_cb()
3542 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_ops_new_server()
3543 struct sockaddr_qrtr *sq = &qmi->sq; in ath12k_qmi_ops_new_server()
3546 sq->sq_family = AF_QIPCRTR; in ath12k_qmi_ops_new_server()
3547 sq->sq_node = service->node; in ath12k_qmi_ops_new_server()
3548 sq->sq_port = service->port; in ath12k_qmi_ops_new_server()
3550 ret = kernel_connect(qmi_hdl->sock, (struct sockaddr *)sq, in ath12k_qmi_ops_new_server()
3567 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_ops_del_server()
3580 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_event_host_cap()
3586 ab->device_id, ret); in ath12k_qmi_event_host_cap()
3598 struct ath12k_base *ab = qmi->ab; in ath12k_qmi_driver_event_work()
3601 spin_lock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3602 while (!list_empty(&qmi->event_list)) { in ath12k_qmi_driver_event_work()
3603 event = list_first_entry(&qmi->event_list, in ath12k_qmi_driver_event_work()
3605 list_del(&event->list); in ath12k_qmi_driver_event_work()
3606 spin_unlock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3608 if (test_bit(ATH12K_FLAG_UNREGISTERING, &ab->dev_flags)) in ath12k_qmi_driver_event_work()
3611 switch (event->type) { in ath12k_qmi_driver_event_work()
3615 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3618 set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3623 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3628 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3631 clear_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3632 if (test_bit(ATH12K_FLAG_QMI_FW_READY_COMPLETE, &ab->dev_flags)) { in ath12k_qmi_driver_event_work()
3633 if (ab->is_reset) in ath12k_qmi_driver_event_work()
3636 set_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3637 queue_work(ab->workqueue, &ab->restart_work); in ath12k_qmi_driver_event_work()
3642 &ab->dev_flags); in ath12k_qmi_driver_event_work()
3646 &ab->dev_flags); in ath12k_qmi_driver_event_work()
3652 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); in ath12k_qmi_driver_event_work()
3655 ath12k_warn(ab, "invalid event type: %d", event->type); in ath12k_qmi_driver_event_work()
3661 spin_lock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3663 spin_unlock(&qmi->event_lock); in ath12k_qmi_driver_event_work()
3670 memset(&ab->qmi.target, 0, sizeof(struct target_info)); in ath12k_qmi_init_service()
3671 memset(&ab->qmi.target_mem, 0, sizeof(struct target_mem_chunk)); in ath12k_qmi_init_service()
3672 ab->qmi.ab = ab; in ath12k_qmi_init_service()
3674 ab->qmi.target_mem_mode = ATH12K_QMI_TARGET_MEM_MODE_DEFAULT; in ath12k_qmi_init_service()
3675 ret = qmi_handle_init(&ab->qmi.handle, ATH12K_QMI_RESP_LEN_MAX, in ath12k_qmi_init_service()
3682 ab->qmi.event_wq = alloc_ordered_workqueue("ath12k_qmi_driver_event", 0); in ath12k_qmi_init_service()
3683 if (!ab->qmi.event_wq) { in ath12k_qmi_init_service()
3685 return -EFAULT; in ath12k_qmi_init_service()
3688 INIT_LIST_HEAD(&ab->qmi.event_list); in ath12k_qmi_init_service()
3689 spin_lock_init(&ab->qmi.event_lock); in ath12k_qmi_init_service()
3690 INIT_WORK(&ab->qmi.event_work, ath12k_qmi_driver_event_work); in ath12k_qmi_init_service()
3692 ret = qmi_add_lookup(&ab->qmi.handle, ATH12K_QMI_WLFW_SERVICE_ID_V01, in ath12k_qmi_init_service()
3694 ab->qmi.service_ins_id); in ath12k_qmi_init_service()
3697 destroy_workqueue(ab->qmi.event_wq); in ath12k_qmi_init_service()
3706 if (!ab->qmi.ab) in ath12k_qmi_deinit_service()
3709 qmi_handle_release(&ab->qmi.handle); in ath12k_qmi_deinit_service()
3710 cancel_work_sync(&ab->qmi.event_work); in ath12k_qmi_deinit_service()
3711 destroy_workqueue(ab->qmi.event_wq); in ath12k_qmi_deinit_service()
3714 ab->qmi.ab = NULL; in ath12k_qmi_deinit_service()