3036: fix iomap base addr error
[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 #ifdef CONFIG_ROCKCHIP_IOVMM
11 struct scatterlist;
12 struct device;
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
64 #else
65 #define iovmm_activate(dev)             (-ENOSYS)
66 #define iovmm_deactivate(dev)           do { } while (0)
67 #define iovmm_map(dev, sg, offset, size) (-ENOSYS)
68 #define iovmm_unmap(dev, iova)          do { } while (0)
69 #define iovmm_map_oto(dev, phys, size)  (-ENOSYS)
70 #define iovmm_unmap_oto(dev, phys)      do { } while (0)
71 #define rockchip_get_sysmmu_device_by_compatible(compt) do { } while (0)
72
73 #endif /* CONFIG_ROCKCHIP_IOVMM */
74
75 #endif /*__ASM_PLAT_IOVMM_H*/