Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | *** To edit the content of this header, modify the corresponding |
| 11 | *** source file (e.g. under external/kernel-headers/original/) then |
| 12 | *** run bionic/libc/kernel/tools/update_all.py |
| 13 | *** |
| 14 | *** Any manual change here will be lost the next time this script will |
| 15 | *** be run. You've been warned! |
| 16 | *** |
| 17 | **************************************************************************** |
| 18 | ****************************************************************************/ |
| 19 | #ifndef HABANALABS_H_ |
| 20 | #define HABANALABS_H_ |
| 21 | #include <linux/types.h> |
| 22 | #include <linux/ioctl.h> |
| 23 | #define GOYA_KMD_SRAM_RESERVED_SIZE_FROM_START 0x8000 |
| 24 | enum goya_queue_id { |
| 25 | GOYA_QUEUE_ID_DMA_0 = 0, |
| 26 | GOYA_QUEUE_ID_DMA_1, |
| 27 | GOYA_QUEUE_ID_DMA_2, |
| 28 | GOYA_QUEUE_ID_DMA_3, |
| 29 | GOYA_QUEUE_ID_DMA_4, |
| 30 | GOYA_QUEUE_ID_CPU_PQ, |
| 31 | GOYA_QUEUE_ID_MME, |
| 32 | GOYA_QUEUE_ID_TPC0, |
| 33 | GOYA_QUEUE_ID_TPC1, |
| 34 | GOYA_QUEUE_ID_TPC2, |
| 35 | GOYA_QUEUE_ID_TPC3, |
| 36 | GOYA_QUEUE_ID_TPC4, |
| 37 | GOYA_QUEUE_ID_TPC5, |
| 38 | GOYA_QUEUE_ID_TPC6, |
| 39 | GOYA_QUEUE_ID_TPC7, |
| 40 | GOYA_QUEUE_ID_SIZE |
| 41 | }; |
Christopher Ferris | b8a95e2 | 2019-10-02 18:29:20 -0700 | [diff] [blame^] | 42 | enum goya_engine_id { |
| 43 | GOYA_ENGINE_ID_DMA_0 = 0, |
| 44 | GOYA_ENGINE_ID_DMA_1, |
| 45 | GOYA_ENGINE_ID_DMA_2, |
| 46 | GOYA_ENGINE_ID_DMA_3, |
| 47 | GOYA_ENGINE_ID_DMA_4, |
| 48 | GOYA_ENGINE_ID_MME_0, |
| 49 | GOYA_ENGINE_ID_TPC_0, |
| 50 | GOYA_ENGINE_ID_TPC_1, |
| 51 | GOYA_ENGINE_ID_TPC_2, |
| 52 | GOYA_ENGINE_ID_TPC_3, |
| 53 | GOYA_ENGINE_ID_TPC_4, |
| 54 | GOYA_ENGINE_ID_TPC_5, |
| 55 | GOYA_ENGINE_ID_TPC_6, |
| 56 | GOYA_ENGINE_ID_TPC_7, |
| 57 | GOYA_ENGINE_ID_SIZE |
| 58 | }; |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 59 | enum hl_device_status { |
| 60 | HL_DEVICE_STATUS_OPERATIONAL, |
| 61 | HL_DEVICE_STATUS_IN_RESET, |
| 62 | HL_DEVICE_STATUS_MALFUNCTION |
| 63 | }; |
Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 64 | #define HL_INFO_HW_IP_INFO 0 |
| 65 | #define HL_INFO_HW_EVENTS 1 |
| 66 | #define HL_INFO_DRAM_USAGE 2 |
| 67 | #define HL_INFO_HW_IDLE 3 |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 68 | #define HL_INFO_DEVICE_STATUS 4 |
Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 69 | #define HL_INFO_VERSION_MAX_LEN 128 |
| 70 | struct hl_info_hw_ip_info { |
| 71 | __u64 sram_base_address; |
| 72 | __u64 dram_base_address; |
| 73 | __u64 dram_size; |
| 74 | __u32 sram_size; |
| 75 | __u32 num_of_events; |
| 76 | __u32 device_id; |
| 77 | __u32 reserved[3]; |
| 78 | __u32 armcp_cpld_version; |
| 79 | __u32 psoc_pci_pll_nr; |
| 80 | __u32 psoc_pci_pll_nf; |
| 81 | __u32 psoc_pci_pll_od; |
| 82 | __u32 psoc_pci_pll_div_factor; |
| 83 | __u8 tpc_enabled_mask; |
| 84 | __u8 dram_enabled; |
| 85 | __u8 pad[2]; |
| 86 | __u8 armcp_version[HL_INFO_VERSION_MAX_LEN]; |
| 87 | }; |
| 88 | struct hl_info_dram_usage { |
| 89 | __u64 dram_free_mem; |
| 90 | __u64 ctx_dram_mem; |
| 91 | }; |
| 92 | struct hl_info_hw_idle { |
| 93 | __u32 is_idle; |
Christopher Ferris | b8a95e2 | 2019-10-02 18:29:20 -0700 | [diff] [blame^] | 94 | __u32 busy_engines_mask; |
Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 95 | }; |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 96 | struct hl_info_device_status { |
| 97 | __u32 status; |
| 98 | __u32 pad; |
| 99 | }; |
Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 100 | struct hl_info_args { |
| 101 | __u64 return_pointer; |
| 102 | __u32 return_size; |
| 103 | __u32 op; |
| 104 | __u32 ctx_id; |
| 105 | __u32 pad; |
| 106 | }; |
| 107 | #define HL_CB_OP_CREATE 0 |
| 108 | #define HL_CB_OP_DESTROY 1 |
| 109 | struct hl_cb_in { |
| 110 | __u64 cb_handle; |
| 111 | __u32 op; |
| 112 | __u32 cb_size; |
| 113 | __u32 ctx_id; |
| 114 | __u32 pad; |
| 115 | }; |
| 116 | struct hl_cb_out { |
| 117 | __u64 cb_handle; |
| 118 | }; |
| 119 | union hl_cb_args { |
| 120 | struct hl_cb_in in; |
| 121 | struct hl_cb_out out; |
| 122 | }; |
| 123 | struct hl_cs_chunk { |
| 124 | __u64 cb_handle; |
| 125 | __u32 queue_index; |
| 126 | __u32 cb_size; |
| 127 | __u32 cs_chunk_flags; |
| 128 | __u32 pad[11]; |
| 129 | }; |
| 130 | #define HL_CS_FLAGS_FORCE_RESTORE 0x1 |
| 131 | #define HL_CS_STATUS_SUCCESS 0 |
| 132 | struct hl_cs_in { |
| 133 | __u64 chunks_restore; |
| 134 | __u64 chunks_execute; |
| 135 | __u64 chunks_store; |
| 136 | __u32 num_chunks_restore; |
| 137 | __u32 num_chunks_execute; |
| 138 | __u32 num_chunks_store; |
| 139 | __u32 cs_flags; |
| 140 | __u32 ctx_id; |
| 141 | }; |
| 142 | struct hl_cs_out { |
| 143 | __u64 seq; |
| 144 | __u32 status; |
| 145 | __u32 pad; |
| 146 | }; |
| 147 | union hl_cs_args { |
| 148 | struct hl_cs_in in; |
| 149 | struct hl_cs_out out; |
| 150 | }; |
| 151 | struct hl_wait_cs_in { |
| 152 | __u64 seq; |
| 153 | __u64 timeout_us; |
| 154 | __u32 ctx_id; |
| 155 | __u32 pad; |
| 156 | }; |
| 157 | #define HL_WAIT_CS_STATUS_COMPLETED 0 |
| 158 | #define HL_WAIT_CS_STATUS_BUSY 1 |
| 159 | #define HL_WAIT_CS_STATUS_TIMEDOUT 2 |
| 160 | #define HL_WAIT_CS_STATUS_ABORTED 3 |
| 161 | #define HL_WAIT_CS_STATUS_INTERRUPTED 4 |
| 162 | struct hl_wait_cs_out { |
| 163 | __u32 status; |
| 164 | __u32 pad; |
| 165 | }; |
| 166 | union hl_wait_cs_args { |
| 167 | struct hl_wait_cs_in in; |
| 168 | struct hl_wait_cs_out out; |
| 169 | }; |
| 170 | #define HL_MEM_OP_ALLOC 0 |
| 171 | #define HL_MEM_OP_FREE 1 |
| 172 | #define HL_MEM_OP_MAP 2 |
| 173 | #define HL_MEM_OP_UNMAP 3 |
| 174 | #define HL_MEM_CONTIGUOUS 0x1 |
| 175 | #define HL_MEM_SHARED 0x2 |
| 176 | #define HL_MEM_USERPTR 0x4 |
| 177 | struct hl_mem_in { |
| 178 | union { |
| 179 | struct { |
| 180 | __u64 mem_size; |
| 181 | } alloc; |
| 182 | struct { |
| 183 | __u64 handle; |
| 184 | } free; |
| 185 | struct { |
| 186 | __u64 hint_addr; |
| 187 | __u64 handle; |
| 188 | } map_device; |
| 189 | struct { |
| 190 | __u64 host_virt_addr; |
| 191 | __u64 hint_addr; |
| 192 | __u64 mem_size; |
| 193 | } map_host; |
| 194 | struct { |
| 195 | __u64 device_virt_addr; |
| 196 | } unmap; |
| 197 | }; |
| 198 | __u32 op; |
| 199 | __u32 flags; |
| 200 | __u32 ctx_id; |
| 201 | __u32 pad; |
| 202 | }; |
| 203 | struct hl_mem_out { |
| 204 | union { |
| 205 | __u64 device_virt_addr; |
| 206 | __u64 handle; |
| 207 | }; |
| 208 | }; |
| 209 | union hl_mem_args { |
| 210 | struct hl_mem_in in; |
| 211 | struct hl_mem_out out; |
| 212 | }; |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 213 | #define HL_DEBUG_MAX_AUX_VALUES 10 |
| 214 | struct hl_debug_params_etr { |
| 215 | __u64 buffer_address; |
| 216 | __u64 buffer_size; |
| 217 | __u32 sink_mode; |
| 218 | __u32 pad; |
| 219 | }; |
| 220 | struct hl_debug_params_etf { |
| 221 | __u64 buffer_address; |
| 222 | __u64 buffer_size; |
| 223 | __u32 sink_mode; |
| 224 | __u32 pad; |
| 225 | }; |
| 226 | struct hl_debug_params_stm { |
| 227 | __u64 he_mask; |
| 228 | __u64 sp_mask; |
| 229 | __u32 id; |
| 230 | __u32 frequency; |
| 231 | }; |
| 232 | struct hl_debug_params_bmon { |
| 233 | __u64 start_addr0; |
| 234 | __u64 addr_mask0; |
| 235 | __u64 start_addr1; |
| 236 | __u64 addr_mask1; |
| 237 | __u32 bw_win; |
| 238 | __u32 win_capture; |
| 239 | __u32 id; |
| 240 | __u32 pad; |
| 241 | }; |
| 242 | struct hl_debug_params_spmu { |
| 243 | __u64 event_types[HL_DEBUG_MAX_AUX_VALUES]; |
| 244 | __u32 event_types_num; |
| 245 | __u32 pad; |
| 246 | }; |
| 247 | #define HL_DEBUG_OP_ETR 0 |
| 248 | #define HL_DEBUG_OP_ETF 1 |
| 249 | #define HL_DEBUG_OP_STM 2 |
| 250 | #define HL_DEBUG_OP_FUNNEL 3 |
| 251 | #define HL_DEBUG_OP_BMON 4 |
| 252 | #define HL_DEBUG_OP_SPMU 5 |
| 253 | #define HL_DEBUG_OP_TIMESTAMP 6 |
| 254 | #define HL_DEBUG_OP_SET_MODE 7 |
| 255 | struct hl_debug_args { |
| 256 | __u64 input_ptr; |
| 257 | __u64 output_ptr; |
| 258 | __u32 input_size; |
| 259 | __u32 output_size; |
| 260 | __u32 op; |
| 261 | __u32 reg_idx; |
| 262 | __u32 enable; |
| 263 | __u32 ctx_id; |
| 264 | }; |
Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 265 | #define HL_IOCTL_INFO _IOWR('H', 0x01, struct hl_info_args) |
| 266 | #define HL_IOCTL_CB _IOWR('H', 0x02, union hl_cb_args) |
| 267 | #define HL_IOCTL_CS _IOWR('H', 0x03, union hl_cs_args) |
| 268 | #define HL_IOCTL_WAIT_CS _IOWR('H', 0x04, union hl_wait_cs_args) |
| 269 | #define HL_IOCTL_MEMORY _IOWR('H', 0x05, union hl_mem_args) |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 270 | #define HL_IOCTL_DEBUG _IOWR('H', 0x06, struct hl_debug_args) |
Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 271 | #define HL_COMMAND_START 0x01 |
Christopher Ferris | aeddbcf | 2019-07-08 12:45:46 -0700 | [diff] [blame] | 272 | #define HL_COMMAND_END 0x07 |
Christopher Ferris | 24f97eb | 2019-05-20 12:58:13 -0700 | [diff] [blame] | 273 | #endif |