Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2013 Red Hat
0004  * Author: Rob Clark <robdclark@gmail.com>
0005  */
0006 
0007 #ifndef __MSM_MMU_H__
0008 #define __MSM_MMU_H__
0009 
0010 #include <linux/iommu.h>
0011 
0012 struct msm_mmu_funcs {
0013     void (*detach)(struct msm_mmu *mmu);
0014     int (*map)(struct msm_mmu *mmu, uint64_t iova, struct sg_table *sgt,
0015             size_t len, int prot);
0016     int (*unmap)(struct msm_mmu *mmu, uint64_t iova, size_t len);
0017     void (*destroy)(struct msm_mmu *mmu);
0018     void (*resume_translation)(struct msm_mmu *mmu);
0019 };
0020 
0021 enum msm_mmu_type {
0022     MSM_MMU_GPUMMU,
0023     MSM_MMU_IOMMU,
0024     MSM_MMU_IOMMU_PAGETABLE,
0025 };
0026 
0027 struct msm_mmu {
0028     const struct msm_mmu_funcs *funcs;
0029     struct device *dev;
0030     int (*handler)(void *arg, unsigned long iova, int flags, void *data);
0031     void *arg;
0032     enum msm_mmu_type type;
0033 };
0034 
0035 static inline void msm_mmu_init(struct msm_mmu *mmu, struct device *dev,
0036         const struct msm_mmu_funcs *funcs, enum msm_mmu_type type)
0037 {
0038     mmu->dev = dev;
0039     mmu->funcs = funcs;
0040     mmu->type = type;
0041 }
0042 
0043 struct msm_mmu *msm_iommu_new(struct device *dev, struct iommu_domain *domain);
0044 struct msm_mmu *msm_gpummu_new(struct device *dev, struct msm_gpu *gpu);
0045 
0046 static inline void msm_mmu_set_fault_handler(struct msm_mmu *mmu, void *arg,
0047         int (*handler)(void *arg, unsigned long iova, int flags, void *data))
0048 {
0049     mmu->arg = arg;
0050     mmu->handler = handler;
0051 }
0052 
0053 struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent);
0054 
0055 void msm_gpummu_params(struct msm_mmu *mmu, dma_addr_t *pt_base,
0056         dma_addr_t *tran_error);
0057 
0058 
0059 int msm_iommu_pagetable_params(struct msm_mmu *mmu, phys_addr_t *ttbr,
0060         int *asid);
0061 
0062 #endif /* __MSM_MMU_H__ */