rk fb:modify iommu interface to match upstream request
[firefly-linux-kernel-4.4.55.git] / include / linux / rockchip / iovmm.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License version 2 as
4  * published by the Free Software Foundation.
5  */
6
7 #ifndef __ASM_PLAT_IOVMM_H
8 #define __ASM_PLAT_IOVMM_H
9
10 struct scatterlist;
11 struct device;
12 #ifdef CONFIG_ROCKCHIP_IOVMM
13
14 int iovmm_activate(struct device *dev);
15 void iovmm_deactivate(struct device *dev);
16
17 /* iovmm_map() - Maps a list of physical memory chunks
18  * @dev: the owner of the IO address space where the mapping is created
19  * @sg: list of physical memory chunks to map
20  * @offset: length in bytes where the mapping starts
21  * @size: how much memory to map in bytes. @offset + @size must not exceed
22  *        total size of @sg
23  *
24  * This function returns mapped IO address in the address space of @dev.
25  * Returns minus error number if mapping fails.
26  * Caller must check its return code with IS_ERROR_VALUE() if the function
27  * succeeded.
28  *
29  * The caller of this function must ensure that iovmm_cleanup() is not called
30  * while this function is called.
31  *
32  */
33 dma_addr_t iovmm_map(struct device *dev, struct scatterlist *sg, off_t offset,
34                                                                 size_t size);
35
36 /* iovmm_unmap() - unmaps the given IO address
37  * @dev: the owner of the IO address space where @iova belongs
38  * @iova: IO address that needs to be unmapped and freed.
39  *
40  * The caller of this function must ensure that iovmm_cleanup() is not called
41  * while this function is called.
42  */
43 void iovmm_unmap(struct device *dev, dma_addr_t iova);
44
45 /* iovmm_map_oto - create one to one mapping for the given physical address
46  * @dev: the owner of the IO address space to map
47  * @phys: physical address to map
48  * @size: size of the mapping to create
49  *
50  * This function return 0 if mapping is successful. Otherwise, minus error
51  * value.
52  */
53 int iovmm_map_oto(struct device *dev, phys_addr_t phys, size_t size);
54
55 /* iovmm_unmap_oto - remove one to one mapping
56  * @dev: the owner ofthe IO address space
57  * @phys: physical address to remove mapping
58  */
59 void iovmm_unmap_oto(struct device *dev, phys_addr_t phys);
60
61 struct device *rockchip_get_sysmmu_device_by_compatible(const char *compt);
62
63 #else
64 static inline int iovmm_activate(struct device *dev) {return -ENOSYS; }
65 static inline void iovmm_deactivate(struct device *dev) { }
66 static inline dma_addr_t iovmm_map(struct device *dev, struct scatterlist *sg, off_t offset,
67                                    size_t size) { return -ENOSYS; }
68 static inline void iovmm_unmap(struct device *dev, dma_addr_t iova) { }
69 static inline int iovmm_map_oto(struct device *dev, phys_addr_t phys, size_t size) {return -ENOSYS; }
70 static inline void iovmm_unmap_oto(struct device *dev, phys_addr_t phys) { }
71 static inline struct device *rockchip_get_sysmmu_device_by_compatible(const char *compt) {return NULL; }
72 #endif /* CONFIG_ROCKCHIP_IOVMM */
73
74 #endif /*__ASM_PLAT_IOVMM_H*/