Laura Abbott | 6438e53 | 2012-07-20 10:10:41 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_MSM_ION_H |
| 2 | #define _LINUX_MSM_ION_H |
| 3 | |
| 4 | #include <linux/ion.h> |
| 5 | |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 6 | enum msm_ion_heap_types { |
| 7 | ION_HEAP_TYPE_MSM_START = ION_HEAP_TYPE_CUSTOM + 1, |
| 8 | ION_HEAP_TYPE_IOMMU = ION_HEAP_TYPE_MSM_START, |
Laura Abbott | 4f6c71d | 2013-04-02 12:38:20 -0700 | [diff] [blame] | 9 | ION_HEAP_TYPE_DMA, |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 10 | ION_HEAP_TYPE_CP, |
Laura Abbott | a8c373f | 2013-02-15 09:25:35 -0800 | [diff] [blame] | 11 | ION_HEAP_TYPE_SECURE_DMA, |
Laura Abbott | f8a269c | 2013-04-01 16:26:00 -0700 | [diff] [blame] | 12 | ION_HEAP_TYPE_REMOVED, |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 13 | }; |
| 14 | |
| 15 | /** |
| 16 | * These are the only ids that should be used for Ion heap ids. |
| 17 | * The ids listed are the order in which allocation will be attempted |
| 18 | * if specified. Don't swap the order of heap ids unless you know what |
| 19 | * you are doing! |
| 20 | * Id's are spaced by purpose to allow new Id's to be inserted in-between (for |
| 21 | * possible fallbacks) |
| 22 | */ |
| 23 | |
| 24 | enum ion_heap_ids { |
| 25 | INVALID_HEAP_ID = -1, |
| 26 | ION_CP_MM_HEAP_ID = 8, |
| 27 | ION_CP_MFC_HEAP_ID = 12, |
| 28 | ION_CP_WB_HEAP_ID = 16, /* 8660 only */ |
| 29 | ION_CAMERA_HEAP_ID = 20, /* 8660 only */ |
Mitchel Humpherys | f921042 | 2013-03-19 17:16:58 -0700 | [diff] [blame] | 30 | ION_SYSTEM_CONTIG_HEAP_ID = 21, |
Laura Abbott | 98e8ddc | 2013-02-09 09:35:30 -0800 | [diff] [blame] | 31 | ION_ADSP_HEAP_ID = 22, |
Neeti Desai | 9dc9db4 | 2012-10-18 17:53:51 -0700 | [diff] [blame] | 32 | ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */ |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 33 | ION_SF_HEAP_ID = 24, |
| 34 | ION_IOMMU_HEAP_ID = 25, |
Neeti Desai | 9dc9db4 | 2012-10-18 17:53:51 -0700 | [diff] [blame] | 35 | ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */ |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 36 | ION_QSECOM_HEAP_ID = 27, |
| 37 | ION_AUDIO_HEAP_ID = 28, |
| 38 | |
| 39 | ION_MM_FIRMWARE_HEAP_ID = 29, |
| 40 | ION_SYSTEM_HEAP_ID = 30, |
| 41 | |
Adrian Alexei | 9253859 | 2013-03-27 10:53:43 -0700 | [diff] [blame] | 42 | ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | enum ion_fixed_position { |
| 46 | NOT_FIXED, |
| 47 | FIXED_LOW, |
| 48 | FIXED_MIDDLE, |
| 49 | FIXED_HIGH, |
| 50 | }; |
| 51 | |
| 52 | enum cp_mem_usage { |
| 53 | VIDEO_BITSTREAM = 0x1, |
| 54 | VIDEO_PIXEL = 0x2, |
| 55 | VIDEO_NONPIXEL = 0x3, |
| 56 | MAX_USAGE = 0x4, |
| 57 | UNKNOWN = 0x7FFFFFFF, |
| 58 | }; |
| 59 | |
| 60 | #define ION_HEAP_CP_MASK (1 << ION_HEAP_TYPE_CP) |
Laura Abbott | 4f6c71d | 2013-04-02 12:38:20 -0700 | [diff] [blame] | 61 | #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * Flag to use when allocating to indicate that a heap is secure. |
| 65 | */ |
Adrian Alexei | 54276f6 | 2013-04-04 16:18:51 -0700 | [diff] [blame] | 66 | #define ION_FLAG_SECURE (1 << ION_HEAP_ID_RESERVED) |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
Laura Abbott | 7db4e0b | 2013-01-03 14:20:16 -0800 | [diff] [blame] | 69 | * Flag for clients to force contiguous memort allocation |
| 70 | * |
| 71 | * Use of this flag is carefully monitored! |
| 72 | */ |
Adrian Alexei | 54276f6 | 2013-04-04 16:18:51 -0700 | [diff] [blame] | 73 | #define ION_FLAG_FORCE_CONTIGUOUS (1 << 30) |
| 74 | |
| 75 | /** |
| 76 | * Deprecated! Please use the corresponding ION_FLAG_* |
| 77 | */ |
| 78 | #define ION_SECURE ION_FLAG_SECURE |
| 79 | #define ION_FORCE_CONTIGUOUS ION_FLAG_FORCE_CONTIGUOUS |
Laura Abbott | 7db4e0b | 2013-01-03 14:20:16 -0800 | [diff] [blame] | 80 | |
| 81 | /** |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 82 | * Macro should be used with ion_heap_ids defined above. |
| 83 | */ |
| 84 | #define ION_HEAP(bit) (1 << (bit)) |
| 85 | |
Laura Abbott | 98e8ddc | 2013-02-09 09:35:30 -0800 | [diff] [blame] | 86 | #define ION_ADSP_HEAP_NAME "adsp" |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 87 | #define ION_VMALLOC_HEAP_NAME "vmalloc" |
Mitchel Humpherys | f921042 | 2013-03-19 17:16:58 -0700 | [diff] [blame] | 88 | #define ION_KMALLOC_HEAP_NAME "kmalloc" |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 89 | #define ION_AUDIO_HEAP_NAME "audio" |
| 90 | #define ION_SF_HEAP_NAME "sf" |
| 91 | #define ION_MM_HEAP_NAME "mm" |
| 92 | #define ION_CAMERA_HEAP_NAME "camera_preview" |
| 93 | #define ION_IOMMU_HEAP_NAME "iommu" |
| 94 | #define ION_MFC_HEAP_NAME "mfc" |
| 95 | #define ION_WB_HEAP_NAME "wb" |
| 96 | #define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" |
Neeti Desai | 9dc9db4 | 2012-10-18 17:53:51 -0700 | [diff] [blame] | 97 | #define ION_PIL1_HEAP_NAME "pil_1" |
| 98 | #define ION_PIL2_HEAP_NAME "pil_2" |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 99 | #define ION_QSECOM_HEAP_NAME "qsecom" |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 100 | |
| 101 | #define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED) |
| 102 | #define ION_SET_UNCACHED(__cache) (__cache & ~ION_FLAG_CACHED) |
| 103 | |
| 104 | #define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) |
| 105 | |
| 106 | #ifdef __KERNEL__ |
| 107 | |
| 108 | /* |
| 109 | * This flag allows clients when mapping into the IOMMU to specify to |
| 110 | * defer un-mapping from the IOMMU until the buffer memory is freed. |
| 111 | */ |
| 112 | #define ION_IOMMU_UNMAP_DELAYED 1 |
| 113 | |
Laura Abbott | 9361930 | 2012-10-11 11:51:40 -0700 | [diff] [blame] | 114 | /* |
| 115 | * This flag allows clients to defer unsecuring a buffer until the buffer |
| 116 | * is actually freed. |
| 117 | */ |
| 118 | #define ION_UNSECURE_DELAYED 1 |
| 119 | |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 120 | /** |
| 121 | * struct ion_cp_heap_pdata - defines a content protection heap in the given |
| 122 | * platform |
| 123 | * @permission_type: Memory ID used to identify the memory to TZ |
| 124 | * @align: Alignment requirement for the memory |
| 125 | * @secure_base: Base address for securing the heap. |
| 126 | * Note: This might be different from actual base address |
| 127 | * of this heap in the case of a shared heap. |
| 128 | * @secure_size: Memory size for securing the heap. |
| 129 | * Note: This might be different from actual size |
| 130 | * of this heap in the case of a shared heap. |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 131 | * @fixed_position If nonzero, position in the fixed area. |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 132 | * @iommu_map_all: Indicates whether we should map whole heap into IOMMU. |
| 133 | * @iommu_2x_map_domain: Indicates the domain to use for overmapping. |
| 134 | * @request_region: function to be called when the number of allocations |
| 135 | * goes from 0 -> 1 |
| 136 | * @release_region: function to be called when the number of allocations |
| 137 | * goes from 1 -> 0 |
| 138 | * @setup_region: function to be called upon ion registration |
| 139 | * @memory_type:Memory type used for the heap |
Mitchel Humpherys | 345f023 | 2013-01-11 10:55:25 -0800 | [diff] [blame] | 140 | * @allow_nonsecure_alloc: allow non-secure allocations from this heap. For |
| 141 | * secure heaps, this flag must be set so allow non-secure |
| 142 | * allocations. For non-secure heaps, this flag is ignored. |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 143 | * |
| 144 | */ |
| 145 | struct ion_cp_heap_pdata { |
| 146 | enum ion_permission_type permission_type; |
| 147 | unsigned int align; |
| 148 | ion_phys_addr_t secure_base; /* Base addr used when heap is shared */ |
| 149 | size_t secure_size; /* Size used for securing heap when heap is shared*/ |
Laura Abbott | 3180a5f | 2012-08-03 17:31:03 -0700 | [diff] [blame] | 150 | int is_cma; |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 151 | enum ion_fixed_position fixed_position; |
| 152 | int iommu_map_all; |
| 153 | int iommu_2x_map_domain; |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 154 | int (*request_region)(void *); |
| 155 | int (*release_region)(void *); |
| 156 | void *(*setup_region)(void); |
| 157 | enum ion_memory_types memory_type; |
Mitchel Humpherys | 345f023 | 2013-01-11 10:55:25 -0800 | [diff] [blame] | 158 | int allow_nonsecure_alloc; |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | /** |
| 162 | * struct ion_co_heap_pdata - defines a carveout heap in the given platform |
| 163 | * @adjacent_mem_id: Id of heap that this heap must be adjacent to. |
| 164 | * @align: Alignment requirement for the memory |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 165 | * @fixed_position If nonzero, position in the fixed area. |
| 166 | * @request_region: function to be called when the number of allocations |
| 167 | * goes from 0 -> 1 |
| 168 | * @release_region: function to be called when the number of allocations |
| 169 | * goes from 1 -> 0 |
| 170 | * @setup_region: function to be called upon ion registration |
| 171 | * @memory_type:Memory type used for the heap |
| 172 | * |
| 173 | */ |
| 174 | struct ion_co_heap_pdata { |
| 175 | int adjacent_mem_id; |
| 176 | unsigned int align; |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 177 | enum ion_fixed_position fixed_position; |
| 178 | int (*request_region)(void *); |
| 179 | int (*release_region)(void *); |
| 180 | void *(*setup_region)(void); |
| 181 | enum ion_memory_types memory_type; |
| 182 | }; |
| 183 | |
| 184 | #ifdef CONFIG_ION |
| 185 | /** |
Laura Abbott | ca2f5db | 2013-03-21 11:10:05 -0700 | [diff] [blame] | 186 | * msm_ion_client_create - allocate a client using the ion_device specified in |
| 187 | * drivers/gpu/ion/msm/msm_ion.c |
| 188 | * |
| 189 | * heap_mask and name are the same as ion_client_create, return values |
| 190 | * are the same as ion_client_create. |
| 191 | */ |
| 192 | |
| 193 | struct ion_client *msm_ion_client_create(unsigned int heap_mask, |
| 194 | const char *name); |
| 195 | |
| 196 | /** |
| 197 | * ion_handle_get_flags - get the flags for a given handle |
| 198 | * |
| 199 | * @client - client who allocated the handle |
| 200 | * @handle - handle to get the flags |
| 201 | * @flags - pointer to store the flags |
| 202 | * |
| 203 | * Gets the current flags for a handle. These flags indicate various options |
| 204 | * of the buffer (caching, security, etc.) |
| 205 | */ |
| 206 | int ion_handle_get_flags(struct ion_client *client, struct ion_handle *handle, |
| 207 | unsigned long *flags); |
| 208 | |
| 209 | |
| 210 | /** |
| 211 | * ion_map_iommu - map the given handle into an iommu |
| 212 | * |
| 213 | * @client - client who allocated the handle |
| 214 | * @handle - handle to map |
| 215 | * @domain_num - domain number to map to |
| 216 | * @partition_num - partition number to allocate iova from |
| 217 | * @align - alignment for the iova |
| 218 | * @iova_length - length of iova to map. If the iova length is |
| 219 | * greater than the handle length, the remaining |
| 220 | * address space will be mapped to a dummy buffer. |
| 221 | * @iova - pointer to store the iova address |
| 222 | * @buffer_size - pointer to store the size of the buffer |
| 223 | * @flags - flags for options to map |
| 224 | * @iommu_flags - flags specific to the iommu. |
| 225 | * |
| 226 | * Maps the handle into the iova space specified via domain number. Iova |
| 227 | * will be allocated from the partition specified via partition_num. |
| 228 | * Returns 0 on success, negative value on error. |
| 229 | */ |
| 230 | int ion_map_iommu(struct ion_client *client, struct ion_handle *handle, |
| 231 | int domain_num, int partition_num, unsigned long align, |
| 232 | unsigned long iova_length, unsigned long *iova, |
| 233 | unsigned long *buffer_size, |
| 234 | unsigned long flags, unsigned long iommu_flags); |
| 235 | |
| 236 | |
| 237 | /** |
| 238 | * ion_handle_get_size - get the allocated size of a given handle |
| 239 | * |
| 240 | * @client - client who allocated the handle |
| 241 | * @handle - handle to get the size |
| 242 | * @size - pointer to store the size |
| 243 | * |
| 244 | * gives the allocated size of a handle. returns 0 on success, negative |
| 245 | * value on error |
| 246 | * |
| 247 | * NOTE: This is intended to be used only to get a size to pass to map_iommu. |
| 248 | * You should *NOT* rely on this for any other usage. |
| 249 | */ |
| 250 | |
| 251 | int ion_handle_get_size(struct ion_client *client, struct ion_handle *handle, |
| 252 | unsigned long *size); |
| 253 | |
| 254 | /** |
| 255 | * ion_unmap_iommu - unmap the handle from an iommu |
| 256 | * |
| 257 | * @client - client who allocated the handle |
| 258 | * @handle - handle to unmap |
| 259 | * @domain_num - domain to unmap from |
| 260 | * @partition_num - partition to unmap from |
| 261 | * |
| 262 | * Decrement the reference count on the iommu mapping. If the count is |
| 263 | * 0, the mapping will be removed from the iommu. |
| 264 | */ |
| 265 | void ion_unmap_iommu(struct ion_client *client, struct ion_handle *handle, |
| 266 | int domain_num, int partition_num); |
| 267 | |
| 268 | |
| 269 | /** |
| 270 | * ion_secure_heap - secure a heap |
| 271 | * |
| 272 | * @client - a client that has allocated from the heap heap_id |
| 273 | * @heap_id - heap id to secure. |
| 274 | * @version - version of content protection |
| 275 | * @data - extra data needed for protection |
| 276 | * |
| 277 | * Secure a heap |
| 278 | * Returns 0 on success |
| 279 | */ |
| 280 | int ion_secure_heap(struct ion_device *dev, int heap_id, int version, |
| 281 | void *data); |
| 282 | |
| 283 | /** |
| 284 | * ion_unsecure_heap - un-secure a heap |
| 285 | * |
| 286 | * @client - a client that has allocated from the heap heap_id |
| 287 | * @heap_id - heap id to un-secure. |
| 288 | * @version - version of content protection |
| 289 | * @data - extra data needed for protection |
| 290 | * |
| 291 | * Un-secure a heap |
| 292 | * Returns 0 on success |
| 293 | */ |
| 294 | int ion_unsecure_heap(struct ion_device *dev, int heap_id, int version, |
| 295 | void *data); |
| 296 | |
| 297 | /** |
| 298 | * msm_ion_do_cache_op - do cache operations. |
| 299 | * |
| 300 | * @client - pointer to ION client. |
| 301 | * @handle - pointer to buffer handle. |
| 302 | * @vaddr - virtual address to operate on. |
| 303 | * @len - Length of data to do cache operation on. |
| 304 | * @cmd - Cache operation to perform: |
| 305 | * ION_IOC_CLEAN_CACHES |
| 306 | * ION_IOC_INV_CACHES |
| 307 | * ION_IOC_CLEAN_INV_CACHES |
| 308 | * |
| 309 | * Returns 0 on success |
| 310 | */ |
| 311 | int msm_ion_do_cache_op(struct ion_client *client, struct ion_handle *handle, |
| 312 | void *vaddr, unsigned long len, unsigned int cmd); |
| 313 | |
| 314 | /** |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 315 | * msm_ion_secure_heap - secure a heap. Wrapper around ion_secure_heap. |
| 316 | * |
Laura Abbott | ca2f5db | 2013-03-21 11:10:05 -0700 | [diff] [blame] | 317 | * @heap_id - heap id to secure. |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 318 | * |
| 319 | * Secure a heap |
| 320 | * Returns 0 on success |
| 321 | */ |
| 322 | int msm_ion_secure_heap(int heap_id); |
| 323 | |
| 324 | /** |
| 325 | * msm_ion_unsecure_heap - unsecure a heap. Wrapper around ion_unsecure_heap. |
| 326 | * |
| 327 | * @heap_id - heap id to secure. |
| 328 | * |
| 329 | * Un-secure a heap |
| 330 | * Returns 0 on success |
| 331 | */ |
| 332 | int msm_ion_unsecure_heap(int heap_id); |
| 333 | |
| 334 | /** |
| 335 | * msm_ion_secure_heap_2_0 - secure a heap using 2.0 APIs |
| 336 | * Wrapper around ion_secure_heap. |
| 337 | * |
| 338 | * @heap_id - heap id to secure. |
| 339 | * @usage - usage hint to TZ |
| 340 | * |
| 341 | * Secure a heap |
| 342 | * Returns 0 on success |
| 343 | */ |
| 344 | int msm_ion_secure_heap_2_0(int heap_id, enum cp_mem_usage usage); |
| 345 | |
| 346 | /** |
| 347 | * msm_ion_unsecure_heap - unsecure a heap secured with 3.0 APIs. |
| 348 | * Wrapper around ion_unsecure_heap. |
| 349 | * |
| 350 | * @heap_id - heap id to secure. |
| 351 | * @usage - usage hint to TZ |
| 352 | * |
| 353 | * Un-secure a heap |
| 354 | * Returns 0 on success |
| 355 | */ |
| 356 | int msm_ion_unsecure_heap_2_0(int heap_id, enum cp_mem_usage usage); |
Laura Abbott | 9361930 | 2012-10-11 11:51:40 -0700 | [diff] [blame] | 357 | |
| 358 | /** |
| 359 | * msm_ion_secure_buffer - secure an individual buffer |
| 360 | * |
| 361 | * @client - client who has access to the buffer |
| 362 | * @handle - buffer to secure |
| 363 | * @usage - usage hint to TZ |
| 364 | * @flags - flags for the securing |
| 365 | */ |
| 366 | int msm_ion_secure_buffer(struct ion_client *client, struct ion_handle *handle, |
| 367 | enum cp_mem_usage usage, int flags); |
| 368 | |
| 369 | /** |
| 370 | * msm_ion_unsecure_buffer - unsecure an individual buffer |
| 371 | * |
| 372 | * @client - client who has access to the buffer |
| 373 | * @handle - buffer to secure |
| 374 | */ |
| 375 | int msm_ion_unsecure_buffer(struct ion_client *client, |
| 376 | struct ion_handle *handle); |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 377 | #else |
Laura Abbott | ca2f5db | 2013-03-21 11:10:05 -0700 | [diff] [blame] | 378 | static inline struct ion_client *msm_ion_client_create(unsigned int heap_mask, |
| 379 | const char *name) |
| 380 | { |
| 381 | return ERR_PTR(-ENODEV); |
| 382 | } |
| 383 | |
| 384 | static inline int ion_map_iommu(struct ion_client *client, |
| 385 | struct ion_handle *handle, int domain_num, |
| 386 | int partition_num, unsigned long align, |
| 387 | unsigned long iova_length, unsigned long *iova, |
| 388 | unsigned long *buffer_size, |
| 389 | unsigned long flags, |
| 390 | unsigned long iommu_flags) |
| 391 | { |
| 392 | return -ENODEV; |
| 393 | } |
| 394 | |
| 395 | static inline int ion_handle_get_size(struct ion_client *client, |
| 396 | struct ion_handle *handle, unsigned long *size) |
| 397 | { |
| 398 | return -ENODEV; |
| 399 | } |
| 400 | |
| 401 | static inline void ion_unmap_iommu(struct ion_client *client, |
| 402 | struct ion_handle *handle, int domain_num, |
| 403 | int partition_num) |
| 404 | { |
| 405 | return; |
| 406 | } |
| 407 | |
| 408 | static inline int ion_secure_heap(struct ion_device *dev, int heap_id, |
| 409 | int version, void *data) |
| 410 | { |
| 411 | return -ENODEV; |
| 412 | |
| 413 | } |
| 414 | |
| 415 | static inline int ion_unsecure_heap(struct ion_device *dev, int heap_id, |
| 416 | int version, void *data) |
| 417 | { |
| 418 | return -ENODEV; |
| 419 | } |
| 420 | |
| 421 | static inline void ion_mark_dangling_buffers_locked(struct ion_device *dev) |
| 422 | { |
| 423 | } |
| 424 | |
| 425 | static inline int msm_ion_do_cache_op(struct ion_client *client, |
| 426 | struct ion_handle *handle, void *vaddr, |
| 427 | unsigned long len, unsigned int cmd) |
| 428 | { |
| 429 | return -ENODEV; |
| 430 | } |
| 431 | |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 432 | static inline int msm_ion_secure_heap(int heap_id) |
| 433 | { |
| 434 | return -ENODEV; |
| 435 | |
| 436 | } |
| 437 | |
| 438 | static inline int msm_ion_unsecure_heap(int heap_id) |
| 439 | { |
| 440 | return -ENODEV; |
| 441 | } |
| 442 | |
| 443 | static inline int msm_ion_secure_heap_2_0(int heap_id, enum cp_mem_usage usage) |
| 444 | { |
| 445 | return -ENODEV; |
| 446 | } |
| 447 | |
| 448 | static inline int msm_ion_unsecure_heap_2_0(int heap_id, |
| 449 | enum cp_mem_usage usage) |
| 450 | { |
| 451 | return -ENODEV; |
| 452 | } |
Mitchel Humpherys | 782653e | 2013-02-25 18:54:53 -0800 | [diff] [blame] | 453 | |
| 454 | static inline int msm_ion_secure_buffer(struct ion_client *client, |
| 455 | struct ion_handle *handle, |
| 456 | enum cp_mem_usage usage, |
| 457 | int flags) |
| 458 | { |
| 459 | return -ENODEV; |
| 460 | } |
| 461 | |
| 462 | static inline int msm_ion_unsecure_buffer(struct ion_client *client, |
| 463 | struct ion_handle *handle) |
| 464 | { |
| 465 | return -ENODEV; |
| 466 | } |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 467 | #endif /* CONFIG_ION */ |
| 468 | |
| 469 | #endif /* __KERNEL */ |
| 470 | |
| 471 | /* struct ion_flush_data - data passed to ion for flushing caches |
| 472 | * |
| 473 | * @handle: handle with data to flush |
| 474 | * @fd: fd to flush |
| 475 | * @vaddr: userspace virtual address mapped with mmap |
| 476 | * @offset: offset into the handle to flush |
| 477 | * @length: length of handle to flush |
| 478 | * |
| 479 | * Performs cache operations on the handle. If p is the start address |
| 480 | * of the handle, p + offset through p + offset + length will have |
| 481 | * the cache operations performed |
| 482 | */ |
| 483 | struct ion_flush_data { |
| 484 | struct ion_handle *handle; |
| 485 | int fd; |
| 486 | void *vaddr; |
| 487 | unsigned int offset; |
| 488 | unsigned int length; |
| 489 | }; |
| 490 | |
Mitchel Humpherys | 362b52b | 2012-09-13 10:53:22 -0700 | [diff] [blame] | 491 | #define ION_IOC_MSM_MAGIC 'M' |
| 492 | |
| 493 | /** |
| 494 | * DOC: ION_IOC_CLEAN_CACHES - clean the caches |
| 495 | * |
| 496 | * Clean the caches of the handle specified. |
| 497 | */ |
| 498 | #define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \ |
| 499 | struct ion_flush_data) |
| 500 | /** |
| 501 | * DOC: ION_IOC_INV_CACHES - invalidate the caches |
| 502 | * |
| 503 | * Invalidate the caches of the handle specified. |
| 504 | */ |
| 505 | #define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \ |
| 506 | struct ion_flush_data) |
| 507 | /** |
| 508 | * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches |
| 509 | * |
| 510 | * Clean and invalidate the caches of the handle specified. |
| 511 | */ |
| 512 | #define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \ |
| 513 | struct ion_flush_data) |
| 514 | |
Laura Abbott | 6438e53 | 2012-07-20 10:10:41 -0700 | [diff] [blame] | 515 | #endif |