Commit 958df3a0 authored by Kalle Valo's avatar Kalle Valo

ath10k: store separate pointers for firmware data

Needed for firmware IE formatted images.
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 36527916
...@@ -168,8 +168,7 @@ static const struct firmware *ath10k_fetch_fw_file(struct ath10k *ar, ...@@ -168,8 +168,7 @@ static const struct firmware *ath10k_fetch_fw_file(struct ath10k *ar,
return fw; return fw;
} }
static int ath10k_push_board_ext_data(struct ath10k *ar, static int ath10k_push_board_ext_data(struct ath10k *ar)
const struct firmware *fw)
{ {
u32 board_data_size = QCA988X_BOARD_DATA_SZ; u32 board_data_size = QCA988X_BOARD_DATA_SZ;
u32 board_ext_data_size = QCA988X_BOARD_EXT_DATA_SZ; u32 board_ext_data_size = QCA988X_BOARD_EXT_DATA_SZ;
...@@ -189,14 +188,14 @@ static int ath10k_push_board_ext_data(struct ath10k *ar, ...@@ -189,14 +188,14 @@ static int ath10k_push_board_ext_data(struct ath10k *ar,
if (board_ext_data_addr == 0) if (board_ext_data_addr == 0)
return 0; return 0;
if (fw->size != (board_data_size + board_ext_data_size)) { if (ar->board_len != (board_data_size + board_ext_data_size)) {
ath10k_err("invalid board (ext) data sizes %zu != %d+%d\n", ath10k_err("invalid board (ext) data sizes %zu != %d+%d\n",
fw->size, board_data_size, board_ext_data_size); ar->board_len, board_data_size, board_ext_data_size);
return -EINVAL; return -EINVAL;
} }
ret = ath10k_bmi_write_memory(ar, board_ext_data_addr, ret = ath10k_bmi_write_memory(ar, board_ext_data_addr,
fw->data + board_data_size, ar->board_data + board_data_size,
board_ext_data_size); board_ext_data_size);
if (ret) { if (ret) {
ath10k_err("could not write board ext data (%d)\n", ret); ath10k_err("could not write board ext data (%d)\n", ret);
...@@ -215,12 +214,11 @@ static int ath10k_push_board_ext_data(struct ath10k *ar, ...@@ -215,12 +214,11 @@ static int ath10k_push_board_ext_data(struct ath10k *ar,
static int ath10k_download_board_data(struct ath10k *ar) static int ath10k_download_board_data(struct ath10k *ar)
{ {
const struct firmware *fw = ar->board;
u32 board_data_size = QCA988X_BOARD_DATA_SZ; u32 board_data_size = QCA988X_BOARD_DATA_SZ;
u32 address; u32 address;
int ret; int ret;
ret = ath10k_push_board_ext_data(ar, fw); ret = ath10k_push_board_ext_data(ar);
if (ret) { if (ret) {
ath10k_err("could not push board ext data (%d)\n", ret); ath10k_err("could not push board ext data (%d)\n", ret);
goto exit; goto exit;
...@@ -232,8 +230,9 @@ static int ath10k_download_board_data(struct ath10k *ar) ...@@ -232,8 +230,9 @@ static int ath10k_download_board_data(struct ath10k *ar)
goto exit; goto exit;
} }
ret = ath10k_bmi_write_memory(ar, address, fw->data, ret = ath10k_bmi_write_memory(ar, address, ar->board_data,
min_t(u32, board_data_size, fw->size)); min_t(u32, board_data_size,
ar->board_len));
if (ret) { if (ret) {
ath10k_err("could not write board data (%d)\n", ret); ath10k_err("could not write board data (%d)\n", ret);
goto exit; goto exit;
...@@ -251,17 +250,16 @@ static int ath10k_download_board_data(struct ath10k *ar) ...@@ -251,17 +250,16 @@ static int ath10k_download_board_data(struct ath10k *ar)
static int ath10k_download_and_run_otp(struct ath10k *ar) static int ath10k_download_and_run_otp(struct ath10k *ar)
{ {
const struct firmware *fw = ar->otp;
u32 address = ar->hw_params.patch_load_addr; u32 address = ar->hw_params.patch_load_addr;
u32 exec_param; u32 exec_param;
int ret; int ret;
/* OTP is optional */ /* OTP is optional */
if (!ar->otp) if (!ar->otp_data || !ar->otp_len)
return 0; return 0;
ret = ath10k_bmi_fast_download(ar, address, fw->data, fw->size); ret = ath10k_bmi_fast_download(ar, address, ar->otp_data, ar->otp_len);
if (ret) { if (ret) {
ath10k_err("could not write otp (%d)\n", ret); ath10k_err("could not write otp (%d)\n", ret);
goto exit; goto exit;
...@@ -280,13 +278,13 @@ static int ath10k_download_and_run_otp(struct ath10k *ar) ...@@ -280,13 +278,13 @@ static int ath10k_download_and_run_otp(struct ath10k *ar)
static int ath10k_download_fw(struct ath10k *ar) static int ath10k_download_fw(struct ath10k *ar)
{ {
const struct firmware *fw = ar->firmware;
u32 address; u32 address;
int ret; int ret;
address = ar->hw_params.patch_load_addr; address = ar->hw_params.patch_load_addr;
ret = ath10k_bmi_fast_download(ar, address, fw->data, fw->size); ret = ath10k_bmi_fast_download(ar, address, ar->firmware_data,
ar->firmware_len);
if (ret) { if (ret) {
ath10k_err("could not write fw (%d)\n", ret); ath10k_err("could not write fw (%d)\n", ret);
goto exit; goto exit;
...@@ -308,8 +306,16 @@ static void ath10k_core_free_firmware_files(struct ath10k *ar) ...@@ -308,8 +306,16 @@ static void ath10k_core_free_firmware_files(struct ath10k *ar)
release_firmware(ar->firmware); release_firmware(ar->firmware);
ar->board = NULL; ar->board = NULL;
ar->board_data = NULL;
ar->board_len = 0;
ar->otp = NULL; ar->otp = NULL;
ar->otp_data = NULL;
ar->otp_len = 0;
ar->firmware = NULL; ar->firmware = NULL;
ar->firmware_data = NULL;
ar->firmware_len = 0;
} }
static int ath10k_core_fetch_firmware_files(struct ath10k *ar) static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
...@@ -335,6 +341,9 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar) ...@@ -335,6 +341,9 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
goto err; goto err;
} }
ar->board_data = ar->board->data;
ar->board_len = ar->board->size;
ar->firmware = ath10k_fetch_fw_file(ar, ar->firmware = ath10k_fetch_fw_file(ar,
ar->hw_params.fw.dir, ar->hw_params.fw.dir,
ar->hw_params.fw.fw); ar->hw_params.fw.fw);
...@@ -344,6 +353,9 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar) ...@@ -344,6 +353,9 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
goto err; goto err;
} }
ar->firmware_data = ar->firmware->data;
ar->firmware_len = ar->firmware->size;
/* OTP may be undefined. If so, don't fetch it at all */ /* OTP may be undefined. If so, don't fetch it at all */
if (ar->hw_params.fw.otp == NULL) if (ar->hw_params.fw.otp == NULL)
return 0; return 0;
...@@ -357,6 +369,9 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar) ...@@ -357,6 +369,9 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
goto err; goto err;
} }
ar->otp_data = ar->otp->data;
ar->otp_len = ar->otp->size;
return 0; return 0;
err: err:
......
...@@ -348,8 +348,16 @@ struct ath10k { ...@@ -348,8 +348,16 @@ struct ath10k {
} hw_params; } hw_params;
const struct firmware *board; const struct firmware *board;
const void *board_data;
size_t board_len;
const struct firmware *otp; const struct firmware *otp;
const void *otp_data;
size_t otp_len;
const struct firmware *firmware; const struct firmware *firmware;
const void *firmware_data;
size_t firmware_len;
struct { struct {
struct completion started; struct completion started;
......
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