1871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark/* 2871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * Copyright (C) 2013 Red Hat 3871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * Author: Rob Clark <robdclark@gmail.com> 4871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * 5871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * This program is free software; you can redistribute it and/or modify it 6871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * under the terms of the GNU General Public License version 2 as published by 7871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * the Free Software Foundation. 8871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * 9871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * This program is distributed in the hope that it will be useful, but WITHOUT 10871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * more details. 13871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * 14871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * You should have received a copy of the GNU General Public License along with 15871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark * this program. If not, see <http://www.gnu.org/licenses/>. 16871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark */ 17871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark 18871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark#ifndef __MSM_MMU_H__ 19871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark#define __MSM_MMU_H__ 20871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark 21871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark#include <linux/iommu.h> 22871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark 23871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clarkstruct msm_mmu_funcs { 24871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark int (*attach)(struct msm_mmu *mmu, const char **names, int cnt); 2587e956e9be0cdb832e90a4731b620286a8826842Stephane Viau void (*detach)(struct msm_mmu *mmu, const char **names, int cnt); 26871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark int (*map)(struct msm_mmu *mmu, uint32_t iova, struct sg_table *sgt, 27871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark unsigned len, int prot); 28871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark int (*unmap)(struct msm_mmu *mmu, uint32_t iova, struct sg_table *sgt, 29871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark unsigned len); 30871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark void (*destroy)(struct msm_mmu *mmu); 31871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark}; 32871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark 33871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clarkstruct msm_mmu { 34871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark const struct msm_mmu_funcs *funcs; 35944fc36c31ed685cf8d3d125eb681ae7198f06fcRob Clark struct device *dev; 36871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark}; 37871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark 38944fc36c31ed685cf8d3d125eb681ae7198f06fcRob Clarkstatic inline void msm_mmu_init(struct msm_mmu *mmu, struct device *dev, 39871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark const struct msm_mmu_funcs *funcs) 40871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark{ 41871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark mmu->dev = dev; 42871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark mmu->funcs = funcs; 43871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark} 44871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark 45944fc36c31ed685cf8d3d125eb681ae7198f06fcRob Clarkstruct msm_mmu *msm_iommu_new(struct device *dev, struct iommu_domain *domain); 46944fc36c31ed685cf8d3d125eb681ae7198f06fcRob Clarkstruct msm_mmu *msm_gpummu_new(struct device *dev, struct msm_gpu *gpu); 47871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark 48871d812aa43e6350a4edf41bf7cb0879675255f1Rob Clark#endif /* __MSM_MMU_H__ */ 49