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
This commit is contained in:
Yuanyuan Liu 2016-08-16 13:39:17 -07:00 • committed by Gerrit - the friendly Code Review server
commit 137755f159
3 changed files with 80 additions and 1 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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