Ver código fonte

msm: ipa3: get mhi pre-configure data using new kernel APIs

Channel and event ring doorbell base addresses are PCIe root
complex dependent. Move away from that dependency by using newly
introduced APIs to query those values from MHI driver.

Change-Id: Iac1fcf625287e4b50daf5785106eac414d161826
Signed-off-by: Bhaumik Bhatt <[email protected]>
Chaitanya Pratapa 4 anos atrás
pai
commit
59d0c3ec7a

+ 28 - 1
drivers/platform/msm/ipa/ipa_v3/ipa_mhi_proxy.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/dma-mapping.h>
@@ -133,8 +133,13 @@ struct imp_dev_info {
 	bool smmu_enabled;
 	struct imp_iova_addr ctrl;
 	struct imp_iova_addr data;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
+	phys_addr_t chdb_base;
+	phys_addr_t erdb_base;
+#else
 	u32 chdb_base;
 	u32 erdb_base;
+#endif
 };
 
 struct imp_event_props {
@@ -808,6 +813,25 @@ static int imp_mhi_probe_cb(struct mhi_device *mhi_dev,
 		return -EPERM;
 	}
 
+	/* Read the MHI CH/ER DB address from MHI Driver. */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
+	ret = mhi_get_channel_db_base(mhi_dev, &imp_ctx->dev_info.chdb_base);
+	if (ret) {
+		IMP_ERR("Could not populate channel db base address\n");
+		return -EINVAL;
+	}
+
+	IMP_DBG("chdb-base=0x%x\n", imp_ctx->dev_info.chdb_base);
+
+	ret = mhi_get_event_ring_db_base(mhi_dev, &imp_ctx->dev_info.erdb_base);
+	if (ret) {
+		IMP_ERR("Could not populate event ring db base address\n");
+		return -EINVAL;
+	}
+
+	IMP_DBG("erdb-base=0x%x\n", imp_ctx->dev_info.erdb_base);
+#endif
+
 	/* vote for IPA clock. IPA clock will be devoted when MHI enters LPM */
 	IPA_ACTIVE_CLIENTS_INC_SPECIAL("IMP");
 
@@ -991,6 +1015,8 @@ static int imp_probe(struct platform_device *pdev)
 
 	IMP_DBG("smmu_enabled=%d\n", imp_ctx->dev_info.smmu_enabled);
 
+	/* Read the MHI CH/ER DB address from DT. */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	if (of_property_read_u32(pdev->dev.of_node, "qcom,mhi-chdb-base",
 		&imp_ctx->dev_info.chdb_base)) {
 		IMP_ERR("failed to read of_node %s\n", "qcom,mhi-chdb-base");
@@ -1004,6 +1030,7 @@ static int imp_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 	IMP_DBG("erdb-base=0x%x\n", imp_ctx->dev_info.erdb_base);
+#endif
 
 	imp_ctx->state = IMP_PROBED;
 	ret = mhi_driver_register(&mhi_driver);

+ 31 - 1
drivers/platform/msm/ipa/ipa_v3/ipa_mpm.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/dma-mapping.h>
@@ -303,8 +303,14 @@ struct ipa_mpm_dev_info {
 	bool pcie_smmu_enabled;
 	struct ipa_mpm_iova_addr ctrl;
 	struct ipa_mpm_iova_addr data;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
+	phys_addr_t chdb_base;
+	phys_addr_t erdb_base;
+#else
 	u32 chdb_base;
 	u32 erdb_base;
+#endif
+
 	bool is_cache_coherent;
 };
 
@@ -2159,6 +2165,27 @@ static int ipa_mpm_mhi_probe_cb(struct mhi_device *mhi_dev,
 		return 0;
 	}
 
+	/* Read the MHI CH/ER DB address from MHI Driver. */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))
+	ret = mhi_get_channel_db_base(mhi_dev,
+				      &ipa_mpm_ctx->dev_info.chdb_base);
+	if (ret) {
+		IPA_MPM_ERR("Could not populate channel db base address\n");
+		return -EINVAL;
+	}
+
+	IPA_MPM_DBG("chdb-base=0x%x\n", ipa_mpm_ctx->dev_info.chdb_base);
+
+	ret = mhi_get_event_ring_db_base(mhi_dev,
+					 &ipa_mpm_ctx->dev_info.erdb_base);
+	if (ret) {
+		IPA_MPM_ERR("Could not populate event ring db base address\n");
+		return -EINVAL;
+	}
+
+	IPA_MPM_DBG("erdb-base=0x%x\n", ipa_mpm_ctx->dev_info.erdb_base);
+#endif
+
 	IPA_MPM_DBG("Received probe for id=%d\n", probe_id);
 
 	get_ipa3_client(probe_id, &ul_prod, &dl_cons);
@@ -3119,6 +3146,8 @@ static int ipa_mpm_probe(struct platform_device *pdev)
 
 	ipa_mpm_init_mhip_channel_info();
 
+	/* Read the MHI CH/ER DB address from DT. */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
 	if (of_property_read_u32(pdev->dev.of_node, "qcom,mhi-chdb-base",
 		&ipa_mpm_ctx->dev_info.chdb_base)) {
 		IPA_MPM_ERR("failed to read qcom,mhi-chdb-base\n");
@@ -3132,6 +3161,7 @@ static int ipa_mpm_probe(struct platform_device *pdev)
 		goto fail_probe;
 	}
 	IPA_MPM_DBG("erdb-base=0x%x\n", ipa_mpm_ctx->dev_info.erdb_base);
+#endif
 
 	ret = ipa_mpm_populate_smmu_info(pdev);