| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2013 Red Hat |
|---|
| 3 | 4 | * Author: Rob Clark <robdclark@gmail.com> |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of the GNU General Public License version 2 as published by |
|---|
| 7 | | - * the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 12 | | - * more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License along with |
|---|
| 15 | | - * this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 16 | 5 | */ |
|---|
| 17 | 6 | |
|---|
| 18 | 7 | #ifndef __MSM_MMU_H__ |
|---|
| .. | .. |
|---|
| 21 | 10 | #include <linux/iommu.h> |
|---|
| 22 | 11 | |
|---|
| 23 | 12 | struct msm_mmu_funcs { |
|---|
| 24 | | - int (*attach)(struct msm_mmu *mmu, const char * const *names, int cnt); |
|---|
| 25 | | - void (*detach)(struct msm_mmu *mmu, const char * const *names, int cnt); |
|---|
| 13 | + void (*detach)(struct msm_mmu *mmu); |
|---|
| 26 | 14 | int (*map)(struct msm_mmu *mmu, uint64_t iova, struct sg_table *sgt, |
|---|
| 27 | | - unsigned len, int prot); |
|---|
| 28 | | - int (*unmap)(struct msm_mmu *mmu, uint64_t iova, struct sg_table *sgt, |
|---|
| 29 | | - unsigned len); |
|---|
| 15 | + size_t len, int prot); |
|---|
| 16 | + int (*unmap)(struct msm_mmu *mmu, uint64_t iova, size_t len); |
|---|
| 30 | 17 | void (*destroy)(struct msm_mmu *mmu); |
|---|
| 18 | +}; |
|---|
| 19 | + |
|---|
| 20 | +enum msm_mmu_type { |
|---|
| 21 | + MSM_MMU_GPUMMU, |
|---|
| 22 | + MSM_MMU_IOMMU, |
|---|
| 23 | + MSM_MMU_IOMMU_PAGETABLE, |
|---|
| 31 | 24 | }; |
|---|
| 32 | 25 | |
|---|
| 33 | 26 | struct msm_mmu { |
|---|
| .. | .. |
|---|
| 35 | 28 | struct device *dev; |
|---|
| 36 | 29 | int (*handler)(void *arg, unsigned long iova, int flags); |
|---|
| 37 | 30 | void *arg; |
|---|
| 31 | + enum msm_mmu_type type; |
|---|
| 38 | 32 | }; |
|---|
| 39 | 33 | |
|---|
| 40 | 34 | static inline void msm_mmu_init(struct msm_mmu *mmu, struct device *dev, |
|---|
| 41 | | - const struct msm_mmu_funcs *funcs) |
|---|
| 35 | + const struct msm_mmu_funcs *funcs, enum msm_mmu_type type) |
|---|
| 42 | 36 | { |
|---|
| 43 | 37 | mmu->dev = dev; |
|---|
| 44 | 38 | mmu->funcs = funcs; |
|---|
| 39 | + mmu->type = type; |
|---|
| 45 | 40 | } |
|---|
| 46 | 41 | |
|---|
| 47 | 42 | struct msm_mmu *msm_iommu_new(struct device *dev, struct iommu_domain *domain); |
|---|
| .. | .. |
|---|
| 54 | 49 | mmu->handler = handler; |
|---|
| 55 | 50 | } |
|---|
| 56 | 51 | |
|---|
| 52 | +struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent); |
|---|
| 53 | + |
|---|
| 54 | +void msm_gpummu_params(struct msm_mmu *mmu, dma_addr_t *pt_base, |
|---|
| 55 | + dma_addr_t *tran_error); |
|---|
| 56 | + |
|---|
| 57 | + |
|---|
| 58 | +int msm_iommu_pagetable_params(struct msm_mmu *mmu, phys_addr_t *ttbr, |
|---|
| 59 | + int *asid); |
|---|
| 60 | + |
|---|
| 57 | 61 | #endif /* __MSM_MMU_H__ */ |
|---|