bus: mhi: host: Add fallback image support

In case firmware request fails to find firmware at the default
location, re-try once with a fallback location. This is done by
adding fallback firmware image location in controller structure
and firmware request is sent again using fallback location.
Send a status call back to controller when re-try is done to
notify them as some features may not be available.

Change-Id: I6c832c121e7bfaf798c06d0341541a2677653fd0
Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Signed-off-by: Lazarus Motha <quic_lmotha@quicinc.com>
This commit is contained in:
Bhaumik Bhatt 2020-10-26 11:02:00 -07:00 committed by Lazarus Motha
parent d3dd2a1713
commit c5dd45c17a
2 changed files with 18 additions and 2 deletions

View File

@ -435,8 +435,20 @@ void mhi_fw_load_handler(struct mhi_controller *mhi_cntrl)
ret = request_firmware(&firmware, fw_name, dev);
if (ret) {
dev_err(dev, "Error loading firmware: %d\n", ret);
goto error_fw_load;
if (!mhi_cntrl->fallback_fw_image) {
dev_err(dev, "Error loading firmware: %d\n", ret);
goto error_fw_load;
}
ret = request_firmware(&firmware,
mhi_cntrl->fallback_fw_image,
dev);
if (ret) {
dev_err(dev, "Error loading fallback firmware: %d\n",
ret);
goto error_fw_load;
}
mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_FALLBACK_IMG);
}
size = (mhi_cntrl->fbc_download) ? mhi_cntrl->sbl_size : firmware->size;

View File

@ -34,6 +34,7 @@ struct mhi_buf_info;
* @MHI_CB_SYS_ERROR: MHI device entered error state (may recover)
* @MHI_CB_FATAL_ERROR: MHI device entered fatal error state
* @MHI_CB_BW_REQ: Received a bandwidth switch request from device
* @MHI_CB_FALLBACK_IMG: MHI device was loaded with the provided fallback image
*/
enum mhi_callback {
MHI_CB_IDLE,
@ -45,6 +46,7 @@ enum mhi_callback {
MHI_CB_SYS_ERROR,
MHI_CB_FATAL_ERROR,
MHI_CB_BW_REQ,
MHI_CB_FALLBACK_IMG,
};
/**
@ -299,6 +301,7 @@ struct mhi_controller_config {
* @iova_start: IOMMU starting address for data (required)
* @iova_stop: IOMMU stop address for data (required)
* @fw_image: Firmware image name for normal booting (optional)
* @fallback_fw_image: Fallback firmware image name for backup boot (optional)
* @edl_image: Firmware image name for emergency download mode (optional)
* @rddm_size: RAM dump size that host should allocate for debugging purpose
* @sbl_size: SBL image size downloaded through BHIe (optional)
@ -384,6 +387,7 @@ struct mhi_controller {
dma_addr_t iova_start;
dma_addr_t iova_stop;
const char *fw_image;
const char *fallback_fw_image;
const char *edl_image;
size_t rddm_size;
size_t sbl_size;