diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h index cbd723d9f5cd9..5e0c0d3d05a32 100644 --- a/core/pld/inc/pld_common.h +++ b/core/pld/inc/pld_common.h @@ -616,7 +616,11 @@ 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); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) +void *pld_smmu_get_domain(struct device *dev); +#else void *pld_smmu_get_mapping(struct device *dev); +#endif int pld_smmu_map(struct device *dev, phys_addr_t paddr, uint32_t *iova_addr, size_t size); int pld_get_user_msi_assignment(struct device *dev, char *user_name, diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 8271410a49cd8..53b223c0bc3eb 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -1398,6 +1398,30 @@ int pld_athdiag_write(struct device *dev, uint32_t offset, return ret; } +/** + * pld_smmu_get_domain() - Get SMMU domain + * @dev: device + * + * Return: Pointer to the domain + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) +void *pld_smmu_get_domain(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_domain(dev); + break; + default: + pr_err("Invalid device type %d\n", type); + break; + } + + return ptr; +} +#else /** * pld_smmu_get_mapping() - Get SMMU mapping context * @dev: device @@ -1423,6 +1447,7 @@ void *pld_smmu_get_mapping(struct device *dev) return ptr; } +#endif /** * pld_smmu_map() - Map SMMU diff --git a/core/pld/src/pld_snoc.h b/core/pld/src/pld_snoc.h index 9eef1ff4f5cb5..f76d791d7ceb8 100644 --- a/core/pld/src/pld_snoc.h +++ b/core/pld/src/pld_snoc.h @@ -95,10 +95,20 @@ static inline int pld_snoc_athdiag_write(struct device *dev, uint32_t offset, { return 0; } + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) +static inline void *pld_snoc_smmu_get_domain(struct device *dev) +{ + return NULL; +} + +#else static inline void *pld_snoc_smmu_get_mapping(struct device *dev) { return NULL; } +#endif + static inline int pld_snoc_smmu_map(struct device *dev, phys_addr_t paddr, uint32_t *iova_addr, size_t size) { @@ -218,10 +228,20 @@ static inline int pld_snoc_athdiag_write(struct device *dev, uint32_t offset, { return icnss_athdiag_write(dev, offset, memtype, datalen, input); } + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) +static inline void *pld_snoc_smmu_get_domain(struct device *dev) +{ + return icnss_smmu_get_domain(dev); +} + +#else static inline void *pld_snoc_smmu_get_mapping(struct device *dev) { return icnss_smmu_get_mapping(dev); } +#endif + static inline int pld_snoc_smmu_map(struct device *dev, phys_addr_t paddr, uint32_t *iova_addr, size_t size) {