The Sahara driver currently selects a firmware image table based on the
attached device, but it does not recognize QDU100 devices that expose the
protocol on the SAHARA MHI channel. As a result, the host cannot associate
QDU100 devices with the correct firmware namespace during image transfer.

Extend the probe time variant selection to match the SAHARA MHI channel and
associate it with the QDU100 firmware folder. Add a firmware lookup
fallback for cases where an image does not have an explicit entry in the
device's firmware table. This allows required images to be provisioned by
the platform.

This change only affects devices matched on the SAHARA MHI channel and
does not change behavior for existing AIC100 and AIC200 devices.

Signed-off-by: Kishore Batta <[email protected]>
---
 drivers/bus/mhi/host/clients/sahara/sahara.c | 27 ++++++++++++++++--
 drivers/bus/mhi/host/pci_generic.c           | 41 ++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/host/clients/sahara/sahara.c 
b/drivers/bus/mhi/host/clients/sahara/sahara.c
index 
74bf57f02873e463d0c2cfdd2673237840169df2..4baa47d0b94e326b5bfcaa80c8ddf008881c85c9
 100644
--- a/drivers/bus/mhi/host/clients/sahara/sahara.c
+++ b/drivers/bus/mhi/host/clients/sahara/sahara.c
@@ -189,6 +189,7 @@ static bool is_streaming(struct sahara_context *context)
 
 static int sahara_find_image(struct sahara_context *context, u32 image_id)
 {
+       char *fw_path;
        int ret;
 
        if (image_id == context->active_image_id)
@@ -201,8 +202,28 @@ static int sahara_find_image(struct sahara_context 
*context, u32 image_id)
        }
 
        if (image_id >= context->table_size || !context->image_table[image_id]) 
{
-               dev_err(&context->mhi_dev->dev, "request for unknown image: 
%d\n", image_id);
-               return -EINVAL;
+               if (!context->fw_folder) {
+                       dev_err(&context->mhi_dev->dev,
+                               "Request for unknown image: %u (no fw 
folder)\n", image_id);
+                       return -EINVAL;
+               }
+
+               fw_path = kasprintf(GFP_KERNEL, "qcom/%s/%u",
+                                   context->fw_folder, image_id);
+               if (!fw_path)
+                       return -ENOMEM;
+
+               ret = firmware_request_nowarn(&context->firmware,
+                                             fw_path,
+                                             &context->mhi_dev->dev);
+               kfree(fw_path);
+               if (ret) {
+                       dev_err(&context->mhi_dev->dev,
+                               "request for unknown image: %d\n", image_id);
+                       return -EINVAL;
+               }
+               context->active_image_id = image_id;
+               return 0;
        }
 
        /*
@@ -870,8 +891,10 @@ static void sahara_mhi_dl_xfer_cb(struct mhi_device 
*mhi_dev, struct mhi_result
 
 static const struct mhi_device_id sahara_mhi_match_table[] = {
        { .chan = "QAIC_SAHARA", },
+       { .chan = "SAHARA", },
        {},
 };
+MODULE_DEVICE_TABLE(mhi, sahara_mhi_match_table);
 
 static struct mhi_driver sahara_mhi_driver = {
        .id_table = sahara_mhi_match_table,
diff --git a/drivers/bus/mhi/host/pci_generic.c 
b/drivers/bus/mhi/host/pci_generic.c
index 
7193a384cca477be9e4f48cdf5f67e680ef55fc5..dcd49cd15074a20cab62a304143abbd0c0614cec
 100644
--- a/drivers/bus/mhi/host/pci_generic.c
+++ b/drivers/bus/mhi/host/pci_generic.c
@@ -47,10 +47,12 @@
  *                of inband wake support (such as sdx24)
  * @no_m3: M3 not supported
  * @reset_on_remove: Set true for devices that require SoC during driver 
removal
+ * @sahara_fw: Sahara firmware mapping
  */
 struct mhi_pci_dev_info {
        const struct mhi_controller_config *config;
        const struct mhi_controller_config *vf_config;
+       const struct mhi_sahara_fw_table *sahara_fw;
        const char *name;
        const char *fw;
        const char *edl;
@@ -287,11 +289,49 @@ static const struct mhi_controller_config 
mhi_qcom_qdu100_config = {
        .event_cfg = mhi_qcom_qdu100_events,
 };
 
+static const char * const qdu100_image_table[] = {
+       [5] = "qcom/qdu100/uefi.elf",
+       [8] = "qcom/qdu100/qdsp6sw.mbn",
+       [16] = "qcom/qdu100/efs1.bin",
+       [17] = "qcom/qdu100/efs2.bin",
+       [20] = "qcom/qdu100/efs3.bin",
+       [23] = "qcom/qdu100/aop.mbn",
+       [25] = "qcom/qdu100/tz.mbn",
+       [29] = "qcom/qdu100/zeros_1sector.bin",
+       [33] = "qcom/qdu100/hypvm.mbn",
+       [34] = "qcom/qdu100/mdmddr.mbn",
+       [36] = "qcom/qdu100/multi_image_qti.mbn",
+       [37] = "qcom/qdu100/multi_image.mbn",
+       [38] = "qcom/qdu100/xbl_config.elf",
+       [39] = "qcom/qdu100/abl_userdebug.elf",
+       [40] = "qcom/qdu100/zeros_1sector.bin",
+       [41] = "qcom/qdu100/devcfg.mbn",
+       [42] = "qcom/qdu100/zeros_1sector.bin",
+       [45] = "qcom/qdu100/tools_l.elf",
+       [46] = "qcom/qdu100/Quantum.elf",
+       [47] = "qcom/qdu100/quest.elf",
+       [48] = "qcom/qdu100/xbl_ramdump.elf",
+       [49] = "qcom/qdu100/shrm.elf",
+       [50] = "qcom/qdu100/cpucp.elf",
+       [51] = "qcom/qdu100/aop_devcfg.mbn",
+       [52] = "qcom/qdu100/fw_csm_gsi_3.0.elf",
+       [53] = "qcom/qdu100/qdsp6sw_dtbs.elf",
+       [54] = "qcom/qdu100/qupv3fw.elf",
+};
+
+static const struct mhi_sahara_fw_table qdu100_sahara_fw = {
+       .image_table = qdu100_image_table,
+       .table_size = ARRAY_SIZE(qdu100_image_table),
+       .fw_folder = "qdu100",
+       .non_streaming = false,
+};
+
 static const struct mhi_pci_dev_info mhi_qcom_qdu100_info = {
        .name = "qcom-qdu100",
        .fw = "qcom/qdu100/xbl_s.melf",
        .edl_trigger = true,
        .config = &mhi_qcom_qdu100_config,
+       .sahara_fw = &qdu100_sahara_fw,
        .bar_num = MHI_PCI_DEFAULT_BAR_NUM,
        .dma_data_width = 32,
        .vf_dma_data_width = 40,
@@ -1426,6 +1466,7 @@ static int mhi_pci_probe(struct pci_dev *pdev, const 
struct pci_device_id *id)
        mhi_cntrl->runtime_put = mhi_pci_runtime_put;
        mhi_cntrl->mru = info->mru_default;
        mhi_cntrl->name = info->name;
+       mhi_cntrl->sahara_fw = info->sahara_fw;
 
        mhi_pdev->no_m3 = info->no_m3;
 

-- 
2.34.1

Reply via email to