Blob Blame History Raw
From e82dfe7b5608592c270cc69100cb4322069f949d Mon Sep 17 00:00:00 2001
From: Anilkumar Kolli <akolli@codeaurora.org>
Date: Tue, 28 Sep 2021 12:05:39 +0300
Subject: [PATCH] ath11k: add caldata file for multiple radios
Git-commit: e82dfe7b5608592c270cc69100cb4322069f949d
Patch-mainline: v5.16-rc1
References: bsc#1206451

If multiple PCI cards are attached, each needs its own caldata file.

Added new Caldata file name,
PCI Bus:
        cal-pci-0001:01:00.0.bin
        cal-pci-0000:01:00.0.bin
AHB Bus:
	cal-ahb-c000000.wifi1.bin

Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.4.0.1-00009-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1-01838-QCAHKSWPL_SILICONZ-1

Signed-off-by: Anilkumar Kolli <akolli@codeaurora.org>
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210721201927.100369-4-jouni@codeaurora.org
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/net/wireless/ath/ath11k/qmi.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
index bcc87670f0e3..d7ceb9ae59df 100644
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -2033,6 +2033,7 @@ static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab,
 
 static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
 {
+	struct device *dev = ab->dev;
 	char filename[ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE];
 	const struct firmware *fw_entry;
 	struct ath11k_board_data bd;
@@ -2067,6 +2068,14 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
 		goto out;
 
 	file_type = ATH11K_QMI_FILE_TYPE_CALDATA;
+
+	/* cal-<bus>-<id>.bin */
+	snprintf(filename, sizeof(filename), "cal-%s-%s.bin",
+		 ath11k_bus_str(ab->hif.bus), dev_name(dev));
+	fw_entry = ath11k_core_firmware_request(ab, filename);
+	if (!IS_ERR(fw_entry))
+		goto success;
+
 	fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE);
 	if (IS_ERR(fw_entry)) {
 		ret = PTR_ERR(fw_entry);
@@ -2076,6 +2085,7 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
 		goto out;
 	}
 
+success:
 	fw_size = min_t(u32, ab->hw_params.fw.board_size, fw_entry->size);
 	ret = ath11k_qmi_load_file_target_mem(ab, fw_entry->data, fw_size, file_type);
 	if (ret < 0) {
@@ -2083,8 +2093,7 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
 		goto out_qmi_cal;
 	}
 
-	ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi caldata downloaded: type: %u\n",
-		   file_type);
+	ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi caldata type: %u\n", file_type);
 
 out_qmi_cal:
 	release_firmware(fw_entry);
-- 
2.35.3