2 * Copyright (C) 2015 Etnaviv Project
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef __ETNAVIV_MMU_H__
18 #define __ETNAVIV_MMU_H__
20 #include <linux/iommu.h>
22 enum etnaviv_iommu_version
{
28 struct etnaviv_vram_mapping
;
30 struct etnaviv_iommu_ops
{
32 size_t (*dump_size
)(struct iommu_domain
*);
33 void (*dump
)(struct iommu_domain
*, void *);
36 struct etnaviv_iommu
{
37 struct etnaviv_gpu
*gpu
;
38 struct iommu_domain
*domain
;
40 enum etnaviv_iommu_version version
;
42 /* memory manager for GPU address area */
44 struct list_head mappings
;
50 struct etnaviv_gem_object
;
52 int etnaviv_iommu_attach(struct etnaviv_iommu
*iommu
, const char **names
,
54 int etnaviv_iommu_map(struct etnaviv_iommu
*iommu
, u32 iova
,
55 struct sg_table
*sgt
, unsigned len
, int prot
);
56 int etnaviv_iommu_unmap(struct etnaviv_iommu
*iommu
, u32 iova
,
57 struct sg_table
*sgt
, unsigned len
);
58 int etnaviv_iommu_map_gem(struct etnaviv_iommu
*mmu
,
59 struct etnaviv_gem_object
*etnaviv_obj
, u32 memory_base
,
60 struct etnaviv_vram_mapping
*mapping
);
61 void etnaviv_iommu_unmap_gem(struct etnaviv_iommu
*mmu
,
62 struct etnaviv_vram_mapping
*mapping
);
63 void etnaviv_iommu_destroy(struct etnaviv_iommu
*iommu
);
65 u32
etnaviv_iommu_get_cmdbuf_va(struct etnaviv_gpu
*gpu
,
66 struct etnaviv_cmdbuf
*buf
);
67 void etnaviv_iommu_put_cmdbuf_va(struct etnaviv_gpu
*gpu
,
68 struct etnaviv_cmdbuf
*buf
);
70 size_t etnaviv_iommu_dump_size(struct etnaviv_iommu
*iommu
);
71 void etnaviv_iommu_dump(struct etnaviv_iommu
*iommu
, void *buf
);
73 struct etnaviv_iommu
*etnaviv_iommu_new(struct etnaviv_gpu
*gpu
);
74 void etnaviv_iommu_restore(struct etnaviv_gpu
*gpu
);
76 #endif /* __ETNAVIV_MMU_H__ */