Skip to content

Commit

Permalink
ath10k: fetch firmware images in a loop
Browse files Browse the repository at this point in the history
To make it easier to handle minimum and maximum firmware API numbers convert
the firmware fetch functionality to a loop. If no firmware image is found print
an error with minimum and maximum API numbers and the name of firmware
directory. This is needed when we switch to using request_firmware_direct()
which doesn't print any errors anymore.

Also add a new function for creating the fw file name dynamically which makes it
easier to add new bus support, for example SDIO and USB, later.

Signed-off-by: Erik Stromdahl <erik.stromdahl@gmail.com>
[kvalo@qca.qualcomm.com: remove sdio/usb part, new error message, clarify commit log]
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  • Loading branch information
Erik Stromdahl authored and Kalle Valo committed Feb 14, 2017
1 parent 1427228 commit 1c61bed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
51 changes: 23 additions & 28 deletions drivers/net/wireless/ath/ath10k/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,44 +1358,39 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name,
return ret;
}

static void ath10k_core_get_fw_name(struct ath10k *ar, char *fw_name,
size_t fw_name_len, int fw_api)
{
scnprintf(fw_name, fw_name_len, "%s-%d.bin", ATH10K_FW_FILE_BASE, fw_api);
}

static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
{
int ret;
int ret, i;
char fw_name[100];

/* calibration file is optional, don't check for any errors */
ath10k_fetch_cal_file(ar);

ar->fw_api = 5;
ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);

ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE,
&ar->normal_mode_fw.fw_file);
if (ret == 0)
goto success;

ar->fw_api = 4;
ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);

ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE,
&ar->normal_mode_fw.fw_file);
if (ret == 0)
goto success;
for (i = ATH10K_FW_API_MAX; i >= ATH10K_FW_API_MIN; i--) {
ar->fw_api = i;
ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n",
ar->fw_api);

ar->fw_api = 3;
ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
ath10k_core_get_fw_name(ar, fw_name, sizeof(fw_name), ar->fw_api);
ret = ath10k_core_fetch_firmware_api_n(ar, fw_name,
&ar->normal_mode_fw.fw_file);
if (!ret)
goto success;
}

ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE,
&ar->normal_mode_fw.fw_file);
if (ret == 0)
goto success;
/* we end up here if we couldn't fetch any firmware */

ar->fw_api = 2;
ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api);
ath10k_err(ar, "Failed to find firmware-N.bin (N between %d and %d) from %s: %d",
ATH10K_FW_API_MIN, ATH10K_FW_API_MAX, ar->hw_params.fw.dir,
ret);

ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE,
&ar->normal_mode_fw.fw_file);
if (ret)
return ret;
return ret;

success:
ath10k_dbg(ar, ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api);
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/wireless/ath/ath10k/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ enum qca9377_chip_id_rev {
#define QCA4019_HW_1_0_BOARD_DATA_FILE "board.bin"
#define QCA4019_HW_1_0_PATCH_LOAD_ADDR 0x1234

#define ATH10K_FW_FILE_BASE "firmware"
#define ATH10K_FW_API_MAX 5
#define ATH10K_FW_API_MIN 2

#define ATH10K_FW_API2_FILE "firmware-2.bin"
#define ATH10K_FW_API3_FILE "firmware-3.bin"

Expand Down

0 comments on commit 1c61bed

Please sign in to comment.