Revert "rk: ion: fix compilation error on arm64"
[firefly-linux-kernel-4.4.55.git] / include / linux / rockchip_ion.h
1 /*
2  *
3  * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #ifndef _LINUX_ROCKCHIP_ION_H
17 #define _LINUX_ROCKCHIP_ION_H
18
19 #ifdef __KERNEL__
20 #include "../../drivers/staging/android/ion/ion.h"
21 #else
22 #include <linux/ion.h>
23 #endif
24
25 #define ROCKCHIP_ION_VERSION    "v1.0"
26
27 enum ion_heap_ids {
28         INVALID_HEAP_ID = -1,
29         ION_CMA_HEAP_ID = 1,
30         ION_IOMMU_HEAP_ID,
31         ION_VMALLOC_HEAP_ID,
32         ION_DRM_HEAP_ID,
33         ION_CARVEOUT_HEAP_ID,
34
35         ION_HEAP_ID_RESERVED = 31
36 };
37
38 #define ION_HEAP(bit) (1 << (bit))
39
40 #define ION_CMA_HEAP_NAME               "cma"
41 #define ION_IOMMU_HEAP_NAME             "iommu"
42 #define ION_VMALLOC_HEAP_NAME           "vmalloc"
43 #define ION_DRM_HEAP_NAME               "drm"
44 #define ION_CARVEOUT_HEAP_NAME          "carveout"
45
46 #define ION_SET_CACHED(__cache)         (__cache | ION_FLAG_CACHED)
47 #define ION_SET_UNCACHED(__cache)       (__cache & ~ION_FLAG_CACHED)
48 #define ION_IS_CACHED(__flags)          ((__flags) & ION_FLAG_CACHED)
49
50 /* struct ion_flush_data - data passed to ion for flushing caches
51  *
52  * @handle:     handle with data to flush
53  * @fd:         fd to flush
54  * @vaddr:      userspace virtual address mapped with mmap
55  * @offset:     offset into the handle to flush
56  * @length:     length of handle to flush
57  *
58  * Performs cache operations on the handle. If p is the start address
59  * of the handle, p + offset through p + offset + length will have
60  * the cache operations performed
61  */
62 struct ion_flush_data {
63         ion_user_handle_t handle;
64         int fd;
65         void *vaddr;
66         unsigned int offset;
67         unsigned int length;
68 };
69
70 struct ion_phys_data {
71         ion_user_handle_t handle;
72         unsigned long phys;
73         unsigned long size;
74 };
75
76 struct ion_share_id_data {
77         int fd;
78         unsigned int id;
79 };
80
81 #define ION_IOC_ROCKCHIP_MAGIC 'R'
82
83 /**
84  * Clean the caches of the handle specified.
85  */
86 #define ION_IOC_CLEAN_CACHES    _IOWR(ION_IOC_ROCKCHIP_MAGIC, 0, \
87                                                 struct ion_flush_data)
88 /**
89  * Invalidate the caches of the handle specified.
90  */
91 #define ION_IOC_INV_CACHES      _IOWR(ION_IOC_ROCKCHIP_MAGIC, 1, \
92                                                 struct ion_flush_data)
93 /**
94  * Clean and invalidate the caches of the handle specified.
95  */
96 #define ION_IOC_CLEAN_INV_CACHES        _IOWR(ION_IOC_ROCKCHIP_MAGIC, 2, \
97                                                 struct ion_flush_data)
98
99 /**
100  * Get phys addr of the handle specified.
101  */
102 #define ION_IOC_GET_PHYS        _IOWR(ION_IOC_ROCKCHIP_MAGIC, 3, \
103                                                 struct ion_phys_data)
104
105 /**
106  * Get share object of the fd specified.
107  */
108 #define ION_IOC_GET_SHARE_ID    _IOWR(ION_IOC_ROCKCHIP_MAGIC, 4, \
109                                                 struct ion_share_id_data)
110
111 /**
112  * Set share object and associate new fd.
113  */
114 #define ION_IOC_SHARE_BY_ID     _IOWR(ION_IOC_ROCKCHIP_MAGIC, 5, \
115                                                 struct ion_share_id_data)
116
117 #endif