1 #ifndef _MSM_ION_H 2 #define _MSM_ION_H 3 4 #include "ion.h" 5 6 #define ION_BIT(nr) (1UL << (nr)) 7 8 enum msm_ion_heap_types { 9 ION_HEAP_TYPE_MSM_START = ION_HEAP_TYPE_CUSTOM + 1, 10 ION_HEAP_TYPE_SECURE_DMA = ION_HEAP_TYPE_MSM_START, 11 ION_HEAP_TYPE_SYSTEM_SECURE, 12 ION_HEAP_TYPE_HYP_CMA, 13 ION_HEAP_TYPE_SECURE_CARVEOUT, 14 /* 15 * if you add a heap type here you should also add it to 16 * heap_types_info[] in msm_ion.c 17 */ 18 }; 19 20 /** 21 * These are the only ids that should be used for Ion heap ids. 22 * The ids listed are the order in which allocation will be attempted 23 * if specified. Don't swap the order of heap ids unless you know what 24 * you are doing! 25 * Id's are spaced by purpose to allow new Id's to be inserted in-between (for 26 * possible fallbacks) 27 */ 28 29 enum ion_heap_ids { 30 INVALID_HEAP_ID = -1, 31 ION_CP_MM_HEAP_ID = 8, 32 ION_SECURE_HEAP_ID = 9, 33 ION_SECURE_DISPLAY_HEAP_ID = 10, 34 ION_CP_MFC_HEAP_ID = 12, 35 ION_SPSS_HEAP_ID = 13, /* Secure Processor ION heap */ 36 ION_SECURE_CARVEOUT_HEAP_ID = 14, 37 ION_CP_WB_HEAP_ID = 16, /* 8660 only */ 38 ION_QSECOM_TA_HEAP_ID = 19, 39 ION_CAMERA_HEAP_ID = 20, /* 8660 only */ 40 ION_SYSTEM_CONTIG_HEAP_ID = 21, 41 ION_ADSP_HEAP_ID = 22, 42 ION_PIL1_HEAP_ID = 23, /* Currently used for other PIL images */ 43 ION_SF_HEAP_ID = 24, 44 ION_SYSTEM_HEAP_ID = 25, 45 ION_PIL2_HEAP_ID = 26, /* Currently used for modem firmware images */ 46 ION_QSECOM_HEAP_ID = 27, 47 ION_AUDIO_HEAP_ID = 28, 48 49 ION_MM_FIRMWARE_HEAP_ID = 29, 50 ION_GOOGLE_HEAP_ID = 30, 51 52 ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ 53 }; 54 55 /* 56 * The IOMMU heap is deprecated! Here are some aliases for backwards 57 * compatibility: 58 */ 59 #define ION_IOMMU_HEAP_ID ION_SYSTEM_HEAP_ID 60 #define ION_HEAP_TYPE_IOMMU ION_HEAP_TYPE_SYSTEM 61 62 #define ION_SPSS_HEAP_ID ION_SPSS_HEAP_ID 63 64 enum ion_fixed_position { 65 NOT_FIXED, 66 FIXED_LOW, 67 FIXED_MIDDLE, 68 FIXED_HIGH, 69 }; 70 71 enum cp_mem_usage { 72 VIDEO_BITSTREAM = 0x1, 73 VIDEO_PIXEL = 0x2, 74 VIDEO_NONPIXEL = 0x3, 75 DISPLAY_SECURE_CP_USAGE = 0x4, 76 CAMERA_SECURE_CP_USAGE = 0x5, 77 MAX_USAGE = 0x6, 78 UNKNOWN = 0x7FFFFFFF, 79 }; 80 81 /** 82 * Flags to be used when allocating from the secure heap for 83 * content protection 84 */ 85 #define ION_FLAG_CP_TOUCH ION_BIT(17) 86 #define ION_FLAG_CP_BITSTREAM ION_BIT(18) 87 #define ION_FLAG_CP_PIXEL ION_BIT(19) 88 #define ION_FLAG_CP_NON_PIXEL ION_BIT(20) 89 #define ION_FLAG_CP_CAMERA ION_BIT(21) 90 #define ION_FLAG_CP_HLOS ION_BIT(22) 91 #define ION_FLAG_CP_SPSS_SP ION_BIT(23) 92 #define ION_FLAG_CP_SPSS_SP_SHARED ION_BIT(24) 93 #define ION_FLAG_CP_SEC_DISPLAY ION_BIT(25) 94 #define ION_FLAG_CP_APP ION_BIT(26) 95 #define ION_FLAG_CP_CAMERA_PREVIEW ION_BIT(27) 96 /* ION_FLAG_ALLOW_NON_CONTIG uses ION_BIT(28) */ 97 #define ION_FLAG_CP_CDSP ION_BIT(29) 98 #define ION_FLAG_CP_SPSS_HLOS_SHARED ION_BIT(30) 99 100 /** 101 * Flag to allow non continguous allocation of memory from secure 102 * heap 103 */ 104 #define ION_FLAG_ALLOW_NON_CONTIG ION_BIT(28) 105 106 /** 107 * Flag to use when allocating to indicate that a heap is secure. 108 * Do NOT use BIT macro since it is defined in #ifdef __KERNEL__ 109 */ 110 #define ION_FLAG_SECURE ION_BIT(ION_HEAP_ID_RESERVED) 111 112 /* 113 * Used in conjunction with heap which pool memory to force an allocation 114 * to come from the page allocator directly instead of from the pool allocation 115 */ 116 #define ION_FLAG_POOL_FORCE_ALLOC ION_BIT(16) 117 118 /** 119 * Deprecated! Please use the corresponding ION_FLAG_* 120 */ 121 #define ION_SECURE ION_FLAG_SECURE 122 123 /** 124 * Macro should be used with ion_heap_ids defined above. 125 */ 126 #define ION_HEAP(bit) ION_BIT(bit) 127 128 #define ION_ADSP_HEAP_NAME "adsp" 129 #define ION_SYSTEM_HEAP_NAME "system" 130 #define ION_VMALLOC_HEAP_NAME ION_SYSTEM_HEAP_NAME 131 #define ION_KMALLOC_HEAP_NAME "kmalloc" 132 #define ION_AUDIO_HEAP_NAME "audio" 133 #define ION_SF_HEAP_NAME "sf" 134 #define ION_MM_HEAP_NAME "mm" 135 #define ION_CAMERA_HEAP_NAME "camera_preview" 136 #define ION_IOMMU_HEAP_NAME "iommu" 137 #define ION_MFC_HEAP_NAME "mfc" 138 #define ION_SPSS_HEAP_NAME "spss" 139 #define ION_SECURE_CARVEOUT_HEAP_NAME "secure_carveout" 140 #define ION_WB_HEAP_NAME "wb" 141 #define ION_MM_FIRMWARE_HEAP_NAME "mm_fw" 142 #define ION_GOOGLE_HEAP_NAME "easel_mem" 143 #define ION_PIL1_HEAP_NAME "pil_1" 144 #define ION_PIL2_HEAP_NAME "pil_2" 145 #define ION_QSECOM_HEAP_NAME "qsecom" 146 #define ION_QSECOM_TA_HEAP_NAME "qsecom_ta" 147 #define ION_SECURE_HEAP_NAME "secure_heap" 148 #define ION_SECURE_DISPLAY_HEAP_NAME "secure_display" 149 150 #define ION_SET_CACHED(__cache) ((__cache) | ION_FLAG_CACHED) 151 #define ION_SET_UNCACHED(__cache) ((__cache) & ~ION_FLAG_CACHED) 152 153 #define ION_IS_CACHED(__flags) ((__flags) & ION_FLAG_CACHED) 154 155 /* struct ion_flush_data - data passed to ion for flushing caches 156 * 157 * @handle: handle with data to flush 158 * @fd: fd to flush 159 * @vaddr: userspace virtual address mapped with mmap 160 * @offset: offset into the handle to flush 161 * @length: length of handle to flush 162 * 163 * Performs cache operations on the handle. If p is the start address 164 * of the handle, p + offset through p + offset + length will have 165 * the cache operations performed 166 */ 167 struct ion_flush_data { 168 ion_user_handle_t handle; 169 int fd; 170 void *vaddr; 171 unsigned int offset; 172 unsigned int length; 173 }; 174 175 struct ion_prefetch_regions { 176 unsigned int vmid; 177 size_t *sizes; 178 unsigned int nr_sizes; 179 }; 180 181 struct ion_prefetch_data { 182 int heap_id; 183 unsigned long len; 184 struct ion_prefetch_regions *regions; 185 unsigned int nr_regions; 186 }; 187 188 #define ION_IOC_MSM_MAGIC 'M' 189 190 /** 191 * DOC: ION_IOC_CLEAN_CACHES - clean the caches 192 * 193 * Clean the caches of the handle specified. 194 */ 195 #define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \ 196 struct ion_flush_data) 197 /** 198 * DOC: ION_IOC_INV_CACHES - invalidate the caches 199 * 200 * Invalidate the caches of the handle specified. 201 */ 202 #define ION_IOC_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 1, \ 203 struct ion_flush_data) 204 /** 205 * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches 206 * 207 * Clean and invalidate the caches of the handle specified. 208 */ 209 #define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_MSM_MAGIC, 2, \ 210 struct ion_flush_data) 211 212 #define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ 213 struct ion_prefetch_data) 214 215 #define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ 216 struct ion_prefetch_data) 217 218 #endif 219