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.
7 #ifndef __ASM_PLAT_IOVMM_H
8 #define __ASM_PLAT_IOVMM_H
12 #ifdef CONFIG_ROCKCHIP_IOVMM
14 int iovmm_activate(struct device *dev);
15 void iovmm_deactivate(struct device *dev);
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
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
29 * The caller of this function must ensure that iovmm_cleanup() is not called
30 * while this function is called.
33 dma_addr_t iovmm_map(struct device *dev, struct scatterlist *sg, off_t offset,
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.
40 * The caller of this function must ensure that iovmm_cleanup() is not called
41 * while this function is called.
43 void iovmm_unmap(struct device *dev, dma_addr_t iova);
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
50 * This function return 0 if mapping is successful. Otherwise, minus error
53 int iovmm_map_oto(struct device *dev, phys_addr_t phys, size_t size);
55 /* iovmm_unmap_oto - remove one to one mapping
56 * @dev: the owner ofthe IO address space
57 * @phys: physical address to remove mapping
59 void iovmm_unmap_oto(struct device *dev, phys_addr_t phys);
61 struct device *rockchip_get_sysmmu_device_by_compatible(const char *compt);
65 static inline int iovmm_activate(struct device *dev) {return -ENOSYS; }
66 static inline void iovmm_deactivate(struct device *dev) { }
67 static inline dma_addr_t iovmm_map(struct device *dev, struct scatterlist *sg, off_t offset,
68 size_t size) { return -ENOSYS; }
69 static inline void iovmm_unmap(struct device *dev, dma_addr_t iova) { }
70 static inline int iovmm_map_oto(struct device *dev, phys_addr_t phys, size_t size) {return -ENOSYS; }
71 static inline void iovmm_unmap_oto(struct device *dev, phys_addr_t phys) { }
72 static inline struct device *rockchip_get_sysmmu_device_by_compatible(const char *compt) {return NULL; }
73 #endif /* CONFIG_ROCKCHIP_IOVMM */
75 #endif /*__ASM_PLAT_IOVMM_H*/