Commit 4ba3b05e authored by Anilkumar Kolli's avatar Anilkumar Kolli Committed by Kalle Valo

ath11k: add caldata download support from EEPROM

Firmware updates EEPROM support capability in QMI FW caps, send QMI BDF
download request message with file type EEPROM, to get caldata download
from EEPROM. Firmware takes more time to update cal data from EEPROM, so
increase QMI timeout.

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.4.0.1-01838-QCAHKSWPL_SILICONZ-1
Signed-off-by: default avatarAnilkumar Kolli <akolli@codeaurora.org>
Signed-off-by: default avatarJouni Malinen <jouni@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210721201927.100369-5-jouni@codeaurora.org
parent e82dfe7b
...@@ -950,6 +950,78 @@ static struct qmi_elem_info qmi_wlanfw_cap_resp_msg_v01_ei[] = { ...@@ -950,6 +950,78 @@ static struct qmi_elem_info qmi_wlanfw_cap_resp_msg_v01_ei[] = {
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
num_macs), num_macs),
}, },
{
.data_type = QMI_OPT_FLAG,
.elem_len = 1,
.elem_size = sizeof(u8),
.array_type = NO_ARRAY,
.tlv_type = 0x16,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
voltage_mv_valid),
},
{
.data_type = QMI_UNSIGNED_4_BYTE,
.elem_len = 1,
.elem_size = sizeof(u32),
.array_type = NO_ARRAY,
.tlv_type = 0x16,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
voltage_mv),
},
{
.data_type = QMI_OPT_FLAG,
.elem_len = 1,
.elem_size = sizeof(u8),
.array_type = NO_ARRAY,
.tlv_type = 0x17,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
time_freq_hz_valid),
},
{
.data_type = QMI_UNSIGNED_4_BYTE,
.elem_len = 1,
.elem_size = sizeof(u32),
.array_type = NO_ARRAY,
.tlv_type = 0x17,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
time_freq_hz),
},
{
.data_type = QMI_OPT_FLAG,
.elem_len = 1,
.elem_size = sizeof(u8),
.array_type = NO_ARRAY,
.tlv_type = 0x18,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
otp_version_valid),
},
{
.data_type = QMI_UNSIGNED_4_BYTE,
.elem_len = 1,
.elem_size = sizeof(u32),
.array_type = NO_ARRAY,
.tlv_type = 0x18,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
otp_version),
},
{
.data_type = QMI_OPT_FLAG,
.elem_len = 1,
.elem_size = sizeof(u8),
.array_type = NO_ARRAY,
.tlv_type = 0x19,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
eeprom_read_timeout_valid),
},
{
.data_type = QMI_UNSIGNED_4_BYTE,
.elem_len = 1,
.elem_size = sizeof(u32),
.array_type = NO_ARRAY,
.tlv_type = 0x19,
.offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
eeprom_read_timeout),
},
{ {
.data_type = QMI_EOTI, .data_type = QMI_EOTI,
.array_type = NO_ARRAY, .array_type = NO_ARRAY,
...@@ -1846,8 +1918,8 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) ...@@ -1846,8 +1918,8 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab)
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
memset(&resp, 0, sizeof(resp)); memset(&resp, 0, sizeof(resp));
ret = qmi_txn_init(&ab->qmi.handle, &txn, ret = qmi_txn_init(&ab->qmi.handle, &txn, qmi_wlanfw_cap_resp_msg_v01_ei,
qmi_wlanfw_cap_resp_msg_v01_ei, &resp); &resp);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -1900,6 +1972,12 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab) ...@@ -1900,6 +1972,12 @@ static int ath11k_qmi_request_target_cap(struct ath11k_base *ab)
strlcpy(ab->qmi.target.fw_build_id, resp.fw_build_id, strlcpy(ab->qmi.target.fw_build_id, resp.fw_build_id,
sizeof(ab->qmi.target.fw_build_id)); sizeof(ab->qmi.target.fw_build_id));
if (resp.eeprom_read_timeout_valid) {
ab->qmi.target.eeprom_caldata =
resp.eeprom_read_timeout;
ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cal data supported from eeprom\n");
}
ath11k_info(ab, "chip_id 0x%x chip_family 0x%x board_id 0x%x soc_id 0x%x\n", ath11k_info(ab, "chip_id 0x%x chip_family 0x%x board_id 0x%x soc_id 0x%x\n",
ab->qmi.target.chip_id, ab->qmi.target.chip_family, ab->qmi.target.chip_id, ab->qmi.target.chip_family,
ab->qmi.target.board_id, ab->qmi.target.soc_id); ab->qmi.target.board_id, ab->qmi.target.soc_id);
...@@ -1963,7 +2041,8 @@ static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab, ...@@ -1963,7 +2041,8 @@ static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab,
req->end = 1; req->end = 1;
} }
if (ab->bus_params.fixed_bdf_addr) { if (ab->bus_params.fixed_bdf_addr ||
type == ATH11K_QMI_FILE_TYPE_EEPROM) {
req->data_valid = 0; req->data_valid = 0;
req->end = 1; req->end = 1;
req->data_len = ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE; req->data_len = ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE;
...@@ -2010,7 +2089,8 @@ static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab, ...@@ -2010,7 +2089,8 @@ static int ath11k_qmi_load_file_target_mem(struct ath11k_base *ab,
goto err_iounmap; goto err_iounmap;
} }
if (ab->bus_params.fixed_bdf_addr) { if (ab->bus_params.fixed_bdf_addr ||
type == ATH11K_QMI_FILE_TYPE_EEPROM) {
remaining = 0; remaining = 0;
} else { } else {
remaining -= req->data_len; remaining -= req->data_len;
...@@ -2039,6 +2119,7 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab) ...@@ -2039,6 +2119,7 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
struct ath11k_board_data bd; struct ath11k_board_data bd;
u32 fw_size, file_type; u32 fw_size, file_type;
int ret = 0, bdf_type; int ret = 0, bdf_type;
const u8 *tmp;
memset(&bd, 0, sizeof(bd)); memset(&bd, 0, sizeof(bd));
ret = ath11k_core_fetch_bdf(ab, &bd); ret = ath11k_core_fetch_bdf(ab, &bd);
...@@ -2063,31 +2144,38 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab) ...@@ -2063,31 +2144,38 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
goto out; goto out;
} }
/* QCA6390 does not support cal data file, skip it */ /* QCA6390 does not support cal data, skip it */
if (bdf_type == ATH11K_QMI_BDF_TYPE_ELF) if (bdf_type == ATH11K_QMI_BDF_TYPE_ELF)
goto out; goto out;
file_type = ATH11K_QMI_FILE_TYPE_CALDATA; if (ab->qmi.target.eeprom_caldata) {
file_type = ATH11K_QMI_FILE_TYPE_EEPROM;
/* cal-<bus>-<id>.bin */ tmp = filename;
snprintf(filename, sizeof(filename), "cal-%s-%s.bin", fw_size = ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE;
ath11k_bus_str(ab->hif.bus), dev_name(dev)); } else {
fw_entry = ath11k_core_firmware_request(ab, filename); file_type = ATH11K_QMI_FILE_TYPE_CALDATA;
if (!IS_ERR(fw_entry))
goto success; /* cal-<bus>-<id>.bin */
snprintf(filename, sizeof(filename), "cal-%s-%s.bin",
fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE); ath11k_bus_str(ab->hif.bus), dev_name(dev));
if (IS_ERR(fw_entry)) { fw_entry = ath11k_core_firmware_request(ab, filename);
ret = PTR_ERR(fw_entry); if (!IS_ERR(fw_entry))
ath11k_warn(ab, goto success;
"qmi failed to load CAL data file:%s\n",
filename); fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE);
goto out; if (IS_ERR(fw_entry)) {
ret = PTR_ERR(fw_entry);
ath11k_warn(ab,
"qmi failed to load CAL data file:%s\n",
filename);
goto out;
}
success:
fw_size = min_t(u32, ab->hw_params.fw.board_size, fw_entry->size);
tmp = fw_entry->data;
} }
success: ret = ath11k_qmi_load_file_target_mem(ab, tmp, fw_size, file_type);
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) { if (ret < 0) {
ath11k_warn(ab, "qmi failed to load caldata\n"); ath11k_warn(ab, "qmi failed to load caldata\n");
goto out_qmi_cal; goto out_qmi_cal;
...@@ -2096,7 +2184,8 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab) ...@@ -2096,7 +2184,8 @@ static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi caldata type: %u\n", file_type); ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi caldata type: %u\n", file_type);
out_qmi_cal: out_qmi_cal:
release_firmware(fw_entry); if (!ab->qmi.target.eeprom_caldata)
release_firmware(fw_entry);
out: out:
ath11k_core_free_bdf(ab, &bd); ath11k_core_free_bdf(ab, &bd);
ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi BDF download sequence completed\n"); ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi BDF download sequence completed\n");
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <linux/soc/qcom/qmi.h> #include <linux/soc/qcom/qmi.h>
#define ATH11K_HOST_VERSION_STRING "WIN" #define ATH11K_HOST_VERSION_STRING "WIN"
#define ATH11K_QMI_WLANFW_TIMEOUT_MS 5000 #define ATH11K_QMI_WLANFW_TIMEOUT_MS 10000
#define ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE 64 #define ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE 64
#define ATH11K_QMI_CALDB_ADDRESS 0x4BA00000 #define ATH11K_QMI_CALDB_ADDRESS 0x4BA00000
#define ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 128 #define ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 128
...@@ -42,6 +42,7 @@ struct ath11k_base; ...@@ -42,6 +42,7 @@ struct ath11k_base;
enum ath11k_qmi_file_type { enum ath11k_qmi_file_type {
ATH11K_QMI_FILE_TYPE_BDF_GOLDEN, ATH11K_QMI_FILE_TYPE_BDF_GOLDEN,
ATH11K_QMI_FILE_TYPE_CALDATA, ATH11K_QMI_FILE_TYPE_CALDATA,
ATH11K_QMI_FILE_TYPE_EEPROM,
ATH11K_QMI_MAX_FILE_TYPE, ATH11K_QMI_MAX_FILE_TYPE,
}; };
...@@ -102,6 +103,7 @@ struct target_info { ...@@ -102,6 +103,7 @@ struct target_info {
u32 board_id; u32 board_id;
u32 soc_id; u32 soc_id;
u32 fw_version; u32 fw_version;
u32 eeprom_caldata;
char fw_build_timestamp[ATH11K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1]; char fw_build_timestamp[ATH11K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1];
char fw_build_id[ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1]; char fw_build_id[ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1];
char bdf_ext[ATH11K_QMI_BDF_EXT_STR_LENGTH]; char bdf_ext[ATH11K_QMI_BDF_EXT_STR_LENGTH];
...@@ -133,7 +135,7 @@ struct ath11k_qmi { ...@@ -133,7 +135,7 @@ struct ath11k_qmi {
wait_queue_head_t cold_boot_waitq; wait_queue_head_t cold_boot_waitq;
}; };
#define QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN 189 #define QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN 261
#define QMI_WLANFW_HOST_CAP_REQ_V01 0x0034 #define QMI_WLANFW_HOST_CAP_REQ_V01 0x0034
#define QMI_WLANFW_HOST_CAP_RESP_MSG_V01_MAX_LEN 7 #define QMI_WLANFW_HOST_CAP_RESP_MSG_V01_MAX_LEN 7
#define QMI_WLFW_HOST_CAP_RESP_V01 0x0034 #define QMI_WLFW_HOST_CAP_RESP_V01 0x0034
...@@ -283,7 +285,7 @@ struct qmi_wlanfw_fw_cold_cal_done_ind_msg_v01 { ...@@ -283,7 +285,7 @@ struct qmi_wlanfw_fw_cold_cal_done_ind_msg_v01 {
}; };
#define QMI_WLANFW_CAP_REQ_MSG_V01_MAX_LEN 0 #define QMI_WLANFW_CAP_REQ_MSG_V01_MAX_LEN 0
#define QMI_WLANFW_CAP_RESP_MSG_V01_MAX_LEN 207 #define QMI_WLANFW_CAP_RESP_MSG_V01_MAX_LEN 235
#define QMI_WLANFW_CAP_REQ_V01 0x0024 #define QMI_WLANFW_CAP_REQ_V01 0x0024
#define QMI_WLANFW_CAP_RESP_V01 0x0024 #define QMI_WLANFW_CAP_RESP_V01 0x0024
...@@ -364,6 +366,14 @@ struct qmi_wlanfw_cap_resp_msg_v01 { ...@@ -364,6 +366,14 @@ struct qmi_wlanfw_cap_resp_msg_v01 {
char fw_build_id[ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1]; char fw_build_id[ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1];
u8 num_macs_valid; u8 num_macs_valid;
u8 num_macs; u8 num_macs;
u8 voltage_mv_valid;
u32 voltage_mv;
u8 time_freq_hz_valid;
u32 time_freq_hz;
u8 otp_version_valid;
u32 otp_version;
u8 eeprom_read_timeout_valid;
u32 eeprom_read_timeout;
}; };
struct qmi_wlanfw_cap_req_msg_v01 { struct qmi_wlanfw_cap_req_msg_v01 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment