summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorYuanyuan Liu <yuanliu@codeaurora.org>2016-08-16 13:39:17 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-09-21 17:08:03 -0700
commit137755f15971132cbeeb644efdd8bf3c923e1677 (patch)
treef063372f9136821a27922f9907101b23b2aa236b /core
parent5ef6bfef5b766275b109b200721987fd8de18b0a (diff)
qcacld-3.0: Provide PLD APIs for SMMU operations
Proivde PLD wrapper APIs for getting SMMU mapping context and mapping SMMU to a specific physical address. Change-Id: I3feb61b26c839547e4d050f62963e64f5ca062a7 CRs-Fixed: 1057714
Diffstat (limited to 'core')
-rw-r--r--core/pld/inc/pld_common.h4
-rw-r--r--core/pld/src/pld_common.c59
-rw-r--r--core/pld/src/pld_snoc.h18
3 files changed, 80 insertions, 1 deletions
diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h
index d2cfdd7ebb72..3127fdd8a144 100644
--- a/core/pld/inc/pld_common.h
+++ b/core/pld/inc/pld_common.h
@@ -394,5 +394,7 @@ int pld_athdiag_read(struct device *dev, uint32_t offset, uint32_t memtype,
uint32_t datalen, uint8_t *output);
int pld_athdiag_write(struct device *dev, uint32_t offset, uint32_t memtype,
uint32_t datalen, uint8_t *input);
-
+void *pld_smmu_get_mapping(struct device *dev);
+int pld_smmu_map(struct device *dev, phys_addr_t paddr,
+ uint32_t *iova_addr, size_t size);
#endif
diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c
index 60ea7cecf88b..7c9372ed88c8 100644
--- a/core/pld/src/pld_common.c
+++ b/core/pld/src/pld_common.c
@@ -1490,3 +1490,62 @@ int pld_athdiag_write(struct device *dev, uint32_t offset,
return ret;
}
+
+/**
+ * pld_smmu_get_mapping() - Get SMMU mapping context
+ * @dev: device
+ *
+ * Return: Pointer to the mapping context
+ */
+void *pld_smmu_get_mapping(struct device *dev)
+{
+ void *ptr = NULL;
+ enum pld_bus_type type = pld_get_bus_type(dev);
+
+ switch (type) {
+ case PLD_BUS_TYPE_SNOC:
+ ptr = pld_snoc_smmu_get_mapping(dev);
+ break;
+ case PLD_BUS_TYPE_PCIE:
+ pr_err("Not supported on type %d\n", type);
+ break;
+ default:
+ pr_err("Invalid device type %d\n", type);
+ break;
+ }
+
+ return ptr;
+}
+
+/**
+ * pld_smmu_map() - Map SMMU
+ * @dev: device
+ * @paddr: physical address that needs to map to
+ * @iova_addr: IOVA address
+ * @size: size to be mapped
+ *
+ * Return: 0 for success
+ * Non zero failure code for errors
+ */
+int pld_smmu_map(struct device *dev, phys_addr_t paddr,
+ uint32_t *iova_addr, size_t size)
+{
+ int ret = 0;
+ enum pld_bus_type type = pld_get_bus_type(dev);
+
+ switch (type) {
+ case PLD_BUS_TYPE_SNOC:
+ ret = pld_snoc_smmu_map(dev, paddr, iova_addr, size);
+ break;
+ case PLD_BUS_TYPE_PCIE:
+ pr_err("Not supported on type %d\n", type);
+ ret = -ENODEV;
+ break;
+ default:
+ pr_err("Invalid device type %d\n", type);
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
diff --git a/core/pld/src/pld_snoc.h b/core/pld/src/pld_snoc.h
index b97d632b4461..9c48da418bab 100644
--- a/core/pld/src/pld_snoc.h
+++ b/core/pld/src/pld_snoc.h
@@ -121,6 +121,15 @@ static inline int pld_snoc_athdiag_write(struct device *dev, uint32_t offset,
{
return 0;
}
+static inline void *pld_snoc_smmu_get_mapping(struct device *dev)
+{
+ return NULL;
+}
+static inline int pld_snoc_smmu_map(struct device *dev, phys_addr_t paddr,
+ uint32_t *iova_addr, size_t size)
+{
+ return 0;
+}
#else
int pld_snoc_register_driver(void);
void pld_snoc_unregister_driver(void);
@@ -155,5 +164,14 @@ static inline int pld_snoc_athdiag_write(struct device *dev, uint32_t offset,
{
return icnss_athdiag_write(dev, offset, memtype, datalen, input);
}
+static inline void *pld_snoc_smmu_get_mapping(struct device *dev)
+{
+ return icnss_smmu_get_mapping(dev);
+}
+static inline int pld_snoc_smmu_map(struct device *dev, phys_addr_t paddr,
+ uint32_t *iova_addr, size_t size)
+{
+ return icnss_smmu_map(dev, paddr, iova_addr, size);
+}
#endif
#endif