Commit 5459c5d4 authored by Tamizh chelvam's avatar Tamizh chelvam Committed by Kalle Valo

ath10k: move firmware_swap_code_seg_info to ath10k_fw_file

Preparation to make use of firmware_swap_code_seg_info for UTF binary.
Signed-off-by: default avatarTamizh chelvam <c_traja@qti.qualcomm.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 2690c4c0
...@@ -745,7 +745,7 @@ static int ath10k_download_fw(struct ath10k *ar) ...@@ -745,7 +745,7 @@ static int ath10k_download_fw(struct ath10k *ar)
data = ar->running_fw->fw_file.firmware_data; data = ar->running_fw->fw_file.firmware_data;
data_len = ar->running_fw->fw_file.firmware_len; data_len = ar->running_fw->fw_file.firmware_len;
ret = ath10k_swap_code_seg_configure(ar); ret = ath10k_swap_code_seg_configure(ar, &ar->running_fw->fw_file);
if (ret) { if (ret) {
ath10k_err(ar, "failed to configure fw code swap: %d\n", ath10k_err(ar, "failed to configure fw code swap: %d\n",
ret); ret);
...@@ -787,7 +787,7 @@ static void ath10k_core_free_firmware_files(struct ath10k *ar) ...@@ -787,7 +787,7 @@ static void ath10k_core_free_firmware_files(struct ath10k *ar)
if (!IS_ERR(ar->pre_cal_file)) if (!IS_ERR(ar->pre_cal_file))
release_firmware(ar->pre_cal_file); release_firmware(ar->pre_cal_file);
ath10k_swap_code_seg_release(ar); ath10k_swap_code_seg_release(ar, &ar->normal_mode_fw.fw_file);
ar->normal_mode_fw.fw_file.otp_data = NULL; ar->normal_mode_fw.fw_file.otp_data = NULL;
ar->normal_mode_fw.fw_file.otp_len = 0; ar->normal_mode_fw.fw_file.otp_len = 0;
...@@ -2031,7 +2031,7 @@ static int ath10k_core_probe_fw(struct ath10k *ar) ...@@ -2031,7 +2031,7 @@ static int ath10k_core_probe_fw(struct ath10k *ar)
goto err_free_firmware_files; goto err_free_firmware_files;
} }
ret = ath10k_swap_code_seg_init(ar); ret = ath10k_swap_code_seg_init(ar, &ar->normal_mode_fw.fw_file);
if (ret) { if (ret) {
ath10k_err(ar, "failed to initialize code swap segment: %d\n", ath10k_err(ar, "failed to initialize code swap segment: %d\n",
ret); ret);
......
...@@ -663,6 +663,15 @@ struct ath10k_fw_file { ...@@ -663,6 +663,15 @@ struct ath10k_fw_file {
const void *codeswap_data; const void *codeswap_data;
size_t codeswap_len; size_t codeswap_len;
/* The original idea of struct ath10k_fw_file was that it only
* contains struct firmware and pointers to various parts (actual
* firmware binary, otp, metadata etc) of the file. This seg_info
* is actually created separate but as this is used similarly as
* the other firmware components it's more convenient to have it
* here.
*/
struct ath10k_swap_code_seg_info *firmware_swap_code_seg_info;
}; };
struct ath10k_fw_components { struct ath10k_fw_components {
...@@ -774,10 +783,6 @@ struct ath10k { ...@@ -774,10 +783,6 @@ struct ath10k {
const struct firmware *pre_cal_file; const struct firmware *pre_cal_file;
const struct firmware *cal_file; const struct firmware *cal_file;
struct {
struct ath10k_swap_code_seg_info *firmware_swap_code_seg_info;
} swap;
struct { struct {
u32 vendor; u32 vendor;
u32 device; u32 device;
......
...@@ -134,17 +134,18 @@ ath10k_swap_code_seg_alloc(struct ath10k *ar, size_t swap_bin_len) ...@@ -134,17 +134,18 @@ ath10k_swap_code_seg_alloc(struct ath10k *ar, size_t swap_bin_len)
return seg_info; return seg_info;
} }
int ath10k_swap_code_seg_configure(struct ath10k *ar) int ath10k_swap_code_seg_configure(struct ath10k *ar,
const struct ath10k_fw_file *fw_file)
{ {
int ret; int ret;
struct ath10k_swap_code_seg_info *seg_info = NULL; struct ath10k_swap_code_seg_info *seg_info = NULL;
if (!ar->swap.firmware_swap_code_seg_info) if (!fw_file->firmware_swap_code_seg_info)
return 0; return 0;
ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot found firmware code swap binary\n"); ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot found firmware code swap binary\n");
seg_info = ar->swap.firmware_swap_code_seg_info; seg_info = fw_file->firmware_swap_code_seg_info;
ret = ath10k_bmi_write_memory(ar, seg_info->target_addr, ret = ath10k_bmi_write_memory(ar, seg_info->target_addr,
&seg_info->seg_hw_info, &seg_info->seg_hw_info,
...@@ -158,28 +159,29 @@ int ath10k_swap_code_seg_configure(struct ath10k *ar) ...@@ -158,28 +159,29 @@ int ath10k_swap_code_seg_configure(struct ath10k *ar)
return 0; return 0;
} }
void ath10k_swap_code_seg_release(struct ath10k *ar) void ath10k_swap_code_seg_release(struct ath10k *ar,
struct ath10k_fw_file *fw_file)
{ {
ath10k_swap_code_seg_free(ar, ar->swap.firmware_swap_code_seg_info); ath10k_swap_code_seg_free(ar, fw_file->firmware_swap_code_seg_info);
/* FIXME: these two assignments look to bein wrong place! Shouldn't /* FIXME: these two assignments look to bein wrong place! Shouldn't
* they be in ath10k_core_free_firmware_files() like the rest? * they be in ath10k_core_free_firmware_files() like the rest?
*/ */
ar->normal_mode_fw.fw_file.codeswap_data = NULL; fw_file->codeswap_data = NULL;
ar->normal_mode_fw.fw_file.codeswap_len = 0; fw_file->codeswap_len = 0;
ar->swap.firmware_swap_code_seg_info = NULL; fw_file->firmware_swap_code_seg_info = NULL;
} }
int ath10k_swap_code_seg_init(struct ath10k *ar) int ath10k_swap_code_seg_init(struct ath10k *ar, struct ath10k_fw_file *fw_file)
{ {
int ret; int ret;
struct ath10k_swap_code_seg_info *seg_info; struct ath10k_swap_code_seg_info *seg_info;
const void *codeswap_data; const void *codeswap_data;
size_t codeswap_len; size_t codeswap_len;
codeswap_data = ar->normal_mode_fw.fw_file.codeswap_data; codeswap_data = fw_file->codeswap_data;
codeswap_len = ar->normal_mode_fw.fw_file.codeswap_len; codeswap_len = fw_file->codeswap_len;
if (!codeswap_len || !codeswap_data) if (!codeswap_len || !codeswap_data)
return 0; return 0;
...@@ -200,7 +202,7 @@ int ath10k_swap_code_seg_init(struct ath10k *ar) ...@@ -200,7 +202,7 @@ int ath10k_swap_code_seg_init(struct ath10k *ar)
return ret; return ret;
} }
ar->swap.firmware_swap_code_seg_info = seg_info; fw_file->firmware_swap_code_seg_info = seg_info;
return 0; return 0;
} }
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
/* Currently only one swap segment is supported */ /* Currently only one swap segment is supported */
#define ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED 1 #define ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED 1
struct ath10k_fw_file;
struct ath10k_swap_code_seg_tlv { struct ath10k_swap_code_seg_tlv {
__le32 address; __le32 address;
__le32 length; __le32 length;
...@@ -58,8 +60,11 @@ struct ath10k_swap_code_seg_info { ...@@ -58,8 +60,11 @@ struct ath10k_swap_code_seg_info {
dma_addr_t paddr[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED]; dma_addr_t paddr[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED];
}; };
int ath10k_swap_code_seg_configure(struct ath10k *ar); int ath10k_swap_code_seg_configure(struct ath10k *ar,
void ath10k_swap_code_seg_release(struct ath10k *ar); const struct ath10k_fw_file *fw_file);
int ath10k_swap_code_seg_init(struct ath10k *ar); void ath10k_swap_code_seg_release(struct ath10k *ar,
struct ath10k_fw_file *fw_file);
int ath10k_swap_code_seg_init(struct ath10k *ar,
struct ath10k_fw_file *fw_file);
#endif #endif
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