Commit 42982259 authored by Dinesh Karthikeyan's avatar Dinesh Karthikeyan Committed by Kalle Valo
Browse files

wifi: ath12k: Add new qmi_bdf_type to handle caldata



With current implementation, the calibration data download request, is
sent twice incorrectly because the request for ELF_TYPE and REGDB_TYPE
are handled in a common api ath12k_qmi_load_bdf_qmi.
Add new type as ATH12K_QMI_BDF_TYPE_CALIBRATION to send calibration data
download request as a separate case. With this the firmware is indicated
to read caldata from EEPROM.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: default avatarDinesh Karthikeyan <quic_dinek@quicinc.com>
Signed-off-by: default avatarKalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20221223050646.27785-3-quic_dinek@quicinc.com
parent 27d7e348
Loading
Loading
Loading
Loading
+51 −64
Original line number Diff line number Diff line
@@ -2419,41 +2419,7 @@ static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab,
			goto out;
		}
		break;
	default:
		ath12k_warn(ab, "unknown file type for load %d", type);
		goto out;
	}

	ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi bdf_type %d\n", type);

	fw_size = min_t(u32, ab->hw_params->fw.board_size, bd.len);

	ret = ath12k_qmi_load_file_target_mem(ab, bd.data, fw_size, type);
	if (ret < 0) {
		ath12k_warn(ab, "qmi failed to load bdf file\n");
		goto out;
	}

	if (!ab->hw_params->download_calib)
		goto out;

	file_type = ATH12K_QMI_FILE_TYPE_CALDATA;

	/* cal-<bus>-<id>.bin */
	snprintf(filename, sizeof(filename), "cal-%s-%s.bin",
		 ath12k_bus_str(ab->hif.bus), dev_name(dev));
	fw_entry = ath12k_core_firmware_request(ab, filename);
	if (!IS_ERR(fw_entry))
		goto success;

	fw_entry = ath12k_core_firmware_request(ab, ATH12K_DEFAULT_CAL_FILE);
	if (IS_ERR(fw_entry)) {
		ret = PTR_ERR(fw_entry);
		ath12k_warn(ab,
			    "qmi failed to load CAL data file:%s\n",
			    filename);
		goto out;
	}
	case ATH12K_QMI_BDF_TYPE_CALIBRATION:

		if (ab->qmi.target.eeprom_caldata) {
			file_type = ATH12K_QMI_FILE_TYPE_CALDATA;
@@ -2469,7 +2435,8 @@ static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab,
			if (!IS_ERR(fw_entry))
				goto success;

		fw_entry = ath12k_core_firmware_request(ab, ATH12K_DEFAULT_CAL_FILE);
			fw_entry = ath12k_core_firmware_request(ab,
								ATH12K_DEFAULT_CAL_FILE);
			if (IS_ERR(fw_entry)) {
				ret = PTR_ERR(fw_entry);
				ath12k_warn(ab,
@@ -2479,10 +2446,10 @@ static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab,
			}

success:
		fw_size = min_t(u32, ab->hw_params->fw.board_size, fw_entry->size);
			fw_size = min_t(u32, ab->hw_params->fw.board_size,
					fw_entry->size);
			tmp = fw_entry->data;
		}

		ret = ath12k_qmi_load_file_target_mem(ab, tmp, fw_size, file_type);
		if (ret < 0) {
			ath12k_warn(ab, "qmi failed to load caldata\n");
@@ -2495,6 +2462,20 @@ static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab,
out_qmi_cal:
		if (!ab->qmi.target.eeprom_caldata)
			release_firmware(fw_entry);
		return ret;
	default:
		ath12k_warn(ab, "unknown file type for load %d", type);
		goto out;
	}

	ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi bdf_type %d\n", type);

	fw_size = min_t(u32, ab->hw_params->fw.board_size, bd.len);

	ret = ath12k_qmi_load_file_target_mem(ab, bd.data, fw_size, type);
	if (ret < 0)
		ath12k_warn(ab, "qmi failed to load bdf file\n");

out:
	ath12k_core_free_bdf(ab, &bd);
	ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi BDF download sequence completed\n");
@@ -2851,6 +2832,12 @@ static int ath12k_qmi_event_load_bdf(struct ath12k_qmi *qmi)
		return ret;
	}

	if (ab->hw_params->download_calib) {
		ret = ath12k_qmi_load_bdf_qmi(ab, ATH12K_QMI_BDF_TYPE_CALIBRATION);
		if (ret < 0)
			ath12k_warn(ab, "qmi failed to load calibrated data :%d\n", ret);
	}

	ret = ath12k_qmi_wlanfw_m3_info_send(ab);
	if (ret < 0) {
		ath12k_warn(ab, "qmi failed to send m3 info req:%d\n", ret);
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ enum ath12k_qmi_bdf_type {
	ATH12K_QMI_BDF_TYPE_BIN			= 0,
	ATH12K_QMI_BDF_TYPE_ELF			= 1,
	ATH12K_QMI_BDF_TYPE_REGDB		= 4,
	ATH12K_QMI_BDF_TYPE_CALIBRATION		= 5,
};

enum ath12k_qmi_event_type {