Browse Source

qcacld-3.0: Add PLD API for Audio SMMU map and unmap

Add PLD API support for mapping and unmapping memory
regions via platform driver API calls to Audio SMMU
context bank.

Change-Id: I93b5308ce6cb024773a780c0aaf98a4fd06281d7
CRs-Fixed: 3351568
Yeshwanth Sriram Guntuka 2 years ago
parent
commit
8ec8609bb9
3 changed files with 103 additions and 0 deletions
  1. 36 0
      core/pld/inc/pld_common.h
  2. 30 0
      core/pld/src/pld_common.c
  3. 37 0
      core/pld/src/pld_pcie.h

+ 36 - 0
core/pld/inc/pld_common.h

@@ -1267,4 +1267,40 @@ static inline bool pld_get_enable_intx(struct device *dev)
  * Return: true if it is one MSI
  */
 bool pld_is_one_msi(struct device *dev);
+
+#ifdef FEATURE_DIRECT_LINK
+/**
+ * pld_audio_smmu_map()- Map memory region into Audio SMMU CB
+ * @dev: pointer to device structure
+ * @paddr: physical address
+ * @iova: DMA address
+ * @size: memory region size
+ *
+ * Return: 0 on success else failure code
+ */
+int pld_audio_smmu_map(struct device *dev, phys_addr_t paddr, dma_addr_t iova,
+		       size_t size);
+
+/**
+ * pld_audio_smmu_unmap()- Remove memory region mapping from Audio SMMU CB
+ * @dev: pointer to device structure
+ * @iova: DMA address
+ * @size: memory region size
+ *
+ * Return: None
+ */
+void pld_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size);
+#else
+static inline
+int pld_audio_smmu_map(struct device *dev, phys_addr_t paddr, dma_addr_t iova,
+		       size_t size)
+{
+	return 0;
+}
+
+static inline
+void pld_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size)
+{
+}
+#endif
 #endif

+ 30 - 0
core/pld/src/pld_common.c

@@ -3436,3 +3436,33 @@ bool pld_is_one_msi(struct device *dev)
 
 	return ret;
 }
+
+#ifdef FEATURE_DIRECT_LINK
+int pld_audio_smmu_map(struct device *dev, phys_addr_t paddr, dma_addr_t iova,
+		       size_t size)
+{
+	int ret;
+
+	switch (pld_get_bus_type(dev)) {
+	case PLD_BUS_TYPE_PCIE:
+		ret = pld_pcie_audio_smmu_map(dev, paddr, iova, size);
+		break;
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+void pld_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size)
+{
+	switch (pld_get_bus_type(dev)) {
+	case PLD_BUS_TYPE_PCIE:
+		pld_pcie_audio_smmu_unmap(dev, iova, size);
+		break;
+	default:
+		break;
+	}
+}
+#endif

+ 37 - 0
core/pld/src/pld_pcie.h

@@ -438,6 +438,18 @@ static inline bool pld_pcie_is_direct_link_supported(struct device *dev)
 {
 	return false;
 }
+
+static inline
+int pld_pcie_audio_smmu_map(struct device *dev, phys_addr_t paddr,
+			    dma_addr_t iova, size_t size)
+{
+	return 0;
+}
+
+static inline
+void pld_pcie_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size)
+{
+}
 #else
 int pld_pcie_get_fw_files_for_target(struct device *dev,
 				     struct pld_fw_files *pfw_files,
@@ -746,11 +758,36 @@ static inline bool pld_pcie_is_direct_link_supported(struct device *dev)
 {
 	return cnss_get_fw_cap(dev, CNSS_FW_CAP_DIRECT_LINK_SUPPORT);
 }
+
+static inline
+int pld_pcie_audio_smmu_map(struct device *dev, phys_addr_t paddr,
+			    dma_addr_t iova, size_t size)
+{
+	return cnss_audio_smmu_map(dev, paddr, iova, size);
+}
+
+static inline
+void pld_pcie_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size)
+{
+	cnss_audio_smmu_unmap(dev, iova, size);
+}
 #else
 static inline bool pld_pcie_is_direct_link_supported(struct device *dev)
 {
 	return false;
 }
+
+static inline
+int pld_pcie_audio_smmu_map(struct device *dev, phys_addr_t paddr,
+			    dma_addr_t iova, size_t size)
+{
+	return 0;
+}
+
+static inline
+void pld_pcie_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size)
+{
+}
 #endif
 #endif
 #endif