blob: bc9829eaabb301d83d6e94a7dbee50923f37f7b6 [file] [log] [blame]
Dave Gordon26172682015-07-09 19:29:04 +01001/*
2 * Copyright © 2014 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23#ifndef _INTEL_GUC_FWIF_H
24#define _INTEL_GUC_FWIF_H
25
26/*
27 * This file is partially autogenerated, although currently with some manual
28 * fixups afterwards. In future, it should be entirely autogenerated, in order
29 * to ensure that the definitions herein remain in sync with those used by the
30 * GuC's own firmware.
31 *
32 * EDITING THIS FILE IS THEREFORE NOT RECOMMENDED - YOUR CHANGES MAY BE LOST.
33 */
34
Dave Gordon26172682015-07-09 19:29:04 +010035#define GFXCORE_FAMILY_GEN9 12
Alex Dai33a732f2015-08-12 15:43:36 +010036#define GFXCORE_FAMILY_UNKNOWN 0x7fffffff
Dave Gordon26172682015-07-09 19:29:04 +010037
Dave Gordon44a28b12015-08-12 15:43:41 +010038#define GUC_CTX_PRIORITY_KMD_HIGH 0
Dave Gordon26172682015-07-09 19:29:04 +010039#define GUC_CTX_PRIORITY_HIGH 1
Dave Gordon44a28b12015-08-12 15:43:41 +010040#define GUC_CTX_PRIORITY_KMD_NORMAL 2
41#define GUC_CTX_PRIORITY_NORMAL 3
Dave Gordon26172682015-07-09 19:29:04 +010042
43#define GUC_MAX_GPU_CONTEXTS 1024
Alex Daiaa557ab2015-08-18 14:32:35 -070044#define GUC_INVALID_CTX_ID GUC_MAX_GPU_CONTEXTS
Dave Gordon26172682015-07-09 19:29:04 +010045
46/* Work queue item header definitions */
47#define WQ_STATUS_ACTIVE 1
48#define WQ_STATUS_SUSPENDED 2
49#define WQ_STATUS_CMD_ERROR 3
50#define WQ_STATUS_ENGINE_ID_NOT_USED 4
51#define WQ_STATUS_SUSPENDED_FROM_RESET 5
52#define WQ_TYPE_SHIFT 0
53#define WQ_TYPE_BATCH_BUF (0x1 << WQ_TYPE_SHIFT)
54#define WQ_TYPE_PSEUDO (0x2 << WQ_TYPE_SHIFT)
55#define WQ_TYPE_INORDER (0x3 << WQ_TYPE_SHIFT)
56#define WQ_TARGET_SHIFT 10
57#define WQ_LEN_SHIFT 16
58#define WQ_NO_WCFLUSH_WAIT (1 << 27)
59#define WQ_PRESENT_WORKLOAD (1 << 28)
60#define WQ_WORKLOAD_SHIFT 29
61#define WQ_WORKLOAD_GENERAL (0 << WQ_WORKLOAD_SHIFT)
62#define WQ_WORKLOAD_GPGPU (1 << WQ_WORKLOAD_SHIFT)
63#define WQ_WORKLOAD_TOUCH (2 << WQ_WORKLOAD_SHIFT)
64
65#define WQ_RING_TAIL_SHIFT 20
66#define WQ_RING_TAIL_MASK (0x7FF << WQ_RING_TAIL_SHIFT)
67
68#define GUC_DOORBELL_ENABLED 1
69#define GUC_DOORBELL_DISABLED 0
70
71#define GUC_CTX_DESC_ATTR_ACTIVE (1 << 0)
72#define GUC_CTX_DESC_ATTR_PENDING_DB (1 << 1)
73#define GUC_CTX_DESC_ATTR_KERNEL (1 << 2)
74#define GUC_CTX_DESC_ATTR_PREEMPT (1 << 3)
75#define GUC_CTX_DESC_ATTR_RESET (1 << 4)
76#define GUC_CTX_DESC_ATTR_WQLOCKED (1 << 5)
77#define GUC_CTX_DESC_ATTR_PCH (1 << 6)
Alex Daiaa557ab2015-08-18 14:32:35 -070078#define GUC_CTX_DESC_ATTR_TERMINATED (1 << 7)
Dave Gordon26172682015-07-09 19:29:04 +010079
80/* The guc control data is 10 DWORDs */
81#define GUC_CTL_CTXINFO 0
82#define GUC_CTL_CTXNUM_IN16_SHIFT 0
83#define GUC_CTL_BASE_ADDR_SHIFT 12
Alex Dai68371a92015-12-18 12:00:09 -080084
Dave Gordon26172682015-07-09 19:29:04 +010085#define GUC_CTL_ARAT_HIGH 1
86#define GUC_CTL_ARAT_LOW 2
Alex Dai68371a92015-12-18 12:00:09 -080087
Dave Gordon26172682015-07-09 19:29:04 +010088#define GUC_CTL_DEVICE_INFO 3
89#define GUC_CTL_GTTYPE_SHIFT 0
90#define GUC_CTL_COREFAMILY_SHIFT 7
Alex Dai68371a92015-12-18 12:00:09 -080091
Dave Gordon26172682015-07-09 19:29:04 +010092#define GUC_CTL_LOG_PARAMS 4
93#define GUC_LOG_VALID (1 << 0)
94#define GUC_LOG_NOTIFY_ON_HALF_FULL (1 << 1)
95#define GUC_LOG_ALLOC_IN_MEGABYTE (1 << 3)
96#define GUC_LOG_CRASH_PAGES 1
97#define GUC_LOG_CRASH_SHIFT 4
98#define GUC_LOG_DPC_PAGES 3
99#define GUC_LOG_DPC_SHIFT 6
100#define GUC_LOG_ISR_PAGES 3
101#define GUC_LOG_ISR_SHIFT 9
102#define GUC_LOG_BUF_ADDR_SHIFT 12
Alex Dai68371a92015-12-18 12:00:09 -0800103
Dave Gordon26172682015-07-09 19:29:04 +0100104#define GUC_CTL_PAGE_FAULT_CONTROL 5
Alex Dai68371a92015-12-18 12:00:09 -0800105
Dave Gordon26172682015-07-09 19:29:04 +0100106#define GUC_CTL_WA 6
107#define GUC_CTL_WA_UK_BY_DRIVER (1 << 3)
Alex Dai68371a92015-12-18 12:00:09 -0800108
Dave Gordon26172682015-07-09 19:29:04 +0100109#define GUC_CTL_FEATURE 7
110#define GUC_CTL_VCS2_ENABLED (1 << 0)
111#define GUC_CTL_KERNEL_SUBMISSIONS (1 << 1)
112#define GUC_CTL_FEATURE2 (1 << 2)
113#define GUC_CTL_POWER_GATING (1 << 3)
114#define GUC_CTL_DISABLE_SCHEDULER (1 << 4)
115#define GUC_CTL_PREEMPTION_LOG (1 << 5)
116#define GUC_CTL_ENABLE_SLPC (1 << 7)
Alex Daiaa557ab2015-08-18 14:32:35 -0700117#define GUC_CTL_RESET_ON_PREMPT_FAILURE (1 << 8)
Alex Dai68371a92015-12-18 12:00:09 -0800118
Dave Gordon26172682015-07-09 19:29:04 +0100119#define GUC_CTL_DEBUG 8
120#define GUC_LOG_VERBOSITY_SHIFT 0
121#define GUC_LOG_VERBOSITY_LOW (0 << GUC_LOG_VERBOSITY_SHIFT)
122#define GUC_LOG_VERBOSITY_MED (1 << GUC_LOG_VERBOSITY_SHIFT)
123#define GUC_LOG_VERBOSITY_HIGH (2 << GUC_LOG_VERBOSITY_SHIFT)
124#define GUC_LOG_VERBOSITY_ULTRA (3 << GUC_LOG_VERBOSITY_SHIFT)
125/* Verbosity range-check limits, without the shift */
126#define GUC_LOG_VERBOSITY_MIN 0
127#define GUC_LOG_VERBOSITY_MAX 3
Alex Dai68371a92015-12-18 12:00:09 -0800128#define GUC_LOG_VERBOSITY_MASK 0x0000000f
129#define GUC_LOG_DESTINATION_MASK (3 << 4)
130#define GUC_LOG_DISABLED (1 << 6)
131#define GUC_PROFILE_ENABLED (1 << 7)
132#define GUC_WQ_TRACK_ENABLED (1 << 8)
133#define GUC_ADS_ENABLED (1 << 9)
134#define GUC_DEBUG_RESERVED (1 << 10)
135#define GUC_ADS_ADDR_SHIFT 11
136#define GUC_ADS_ADDR_MASK 0xfffff800
137
Alex Daiaa557ab2015-08-18 14:32:35 -0700138#define GUC_CTL_RSRVD 9
Dave Gordon26172682015-07-09 19:29:04 +0100139
Alex Dai68371a92015-12-18 12:00:09 -0800140#define GUC_CTL_MAX_DWORDS (SOFT_SCRATCH_COUNT - 2) /* [1..14] */
Dave Gordon26172682015-07-09 19:29:04 +0100141
Alex Daifeda33e2015-10-19 16:10:54 -0700142/**
143 * DOC: GuC Firmware Layout
144 *
145 * The GuC firmware layout looks like this:
146 *
147 * +-------------------------------+
148 * | guc_css_header |
149 * | contains major/minor version |
150 * +-------------------------------+
151 * | uCode |
152 * +-------------------------------+
153 * | RSA signature |
154 * +-------------------------------+
155 * | modulus key |
156 * +-------------------------------+
157 * | exponent val |
158 * +-------------------------------+
159 *
160 * The firmware may or may not have modulus key and exponent data. The header,
161 * uCode and RSA signature are must-have components that will be used by driver.
162 * Length of each components, which is all in dwords, can be found in header.
163 * In the case that modulus and exponent are not present in fw, a.k.a truncated
164 * image, the length value still appears in header.
165 *
166 * Driver will do some basic fw size validation based on the following rules:
167 *
168 * 1. Header, uCode and RSA are must-have components.
169 * 2. All firmware components, if they present, are in the sequence illustrated
170 * in the layout table above.
171 * 3. Length info of each component can be found in header, in dwords.
172 * 4. Modulus and exponent key are not required by driver. They may not appear
173 * in fw. So driver will load a truncated firmware in this case.
174 */
175
176struct guc_css_header {
177 uint32_t module_type;
178 /* header_size includes all non-uCode bits, including css_header, rsa
179 * key, modulus key and exponent data. */
180 uint32_t header_size_dw;
181 uint32_t header_version;
182 uint32_t module_id;
183 uint32_t module_vendor;
184 union {
185 struct {
186 uint8_t day;
187 uint8_t month;
188 uint16_t year;
189 };
190 uint32_t date;
191 };
192 uint32_t size_dw; /* uCode plus header_size_dw */
193 uint32_t key_size_dw;
194 uint32_t modulus_size_dw;
195 uint32_t exponent_size_dw;
196 union {
197 struct {
198 uint8_t hour;
199 uint8_t min;
200 uint16_t sec;
201 };
202 uint32_t time;
203 };
204
205 char username[8];
206 char buildnumber[12];
207 uint32_t device_id;
208 uint32_t guc_sw_version;
209 uint32_t prod_preprod_fw;
210 uint32_t reserved[12];
211 uint32_t header_info;
212} __packed;
213
Dave Gordon26172682015-07-09 19:29:04 +0100214struct guc_doorbell_info {
215 u32 db_status;
216 u32 cookie;
217 u32 reserved[14];
218} __packed;
219
220union guc_doorbell_qw {
221 struct {
222 u32 db_status;
223 u32 cookie;
224 };
225 u64 value_qw;
226} __packed;
227
228#define GUC_MAX_DOORBELLS 256
229#define GUC_INVALID_DOORBELL_ID (GUC_MAX_DOORBELLS)
230
231#define GUC_DB_SIZE (PAGE_SIZE)
232#define GUC_WQ_SIZE (PAGE_SIZE * 2)
233
234/* Work item for submitting workloads into work queue of GuC. */
235struct guc_wq_item {
236 u32 header;
237 u32 context_desc;
238 u32 ring_tail;
239 u32 fence_id;
240} __packed;
241
242struct guc_process_desc {
243 u32 context_id;
244 u64 db_base_addr;
245 u32 head;
246 u32 tail;
247 u32 error_offset;
248 u64 wq_base_addr;
249 u32 wq_size_bytes;
250 u32 wq_status;
251 u32 engine_presence;
252 u32 priority;
253 u32 reserved[30];
254} __packed;
255
256/* engine id and context id is packed into guc_execlist_context.context_id*/
257#define GUC_ELC_CTXID_OFFSET 0
258#define GUC_ELC_ENGINE_OFFSET 29
259
260/* The execlist context including software and HW information */
261struct guc_execlist_context {
262 u32 context_desc;
263 u32 context_id;
264 u32 ring_status;
265 u32 ring_lcra;
266 u32 ring_begin;
267 u32 ring_end;
268 u32 ring_next_free_location;
269 u32 ring_current_tail_pointer_value;
270 u8 engine_state_submit_value;
271 u8 engine_state_wait_value;
272 u16 pagefault_count;
273 u16 engine_submit_queue_count;
274} __packed;
275
276/*Context descriptor for communicating between uKernel and Driver*/
277struct guc_context_desc {
278 u32 sched_common_area;
279 u32 context_id;
280 u32 pas_id;
281 u8 engines_used;
282 u64 db_trigger_cpu;
283 u32 db_trigger_uk;
284 u64 db_trigger_phy;
285 u16 db_id;
286
287 struct guc_execlist_context lrc[I915_NUM_RINGS];
288
289 u8 attribute;
290
291 u32 priority;
292
293 u32 wq_sampled_tail_offset;
294 u32 wq_total_submit_enqueues;
295
296 u32 process_desc;
297 u32 wq_addr;
298 u32 wq_size;
299
300 u32 engine_presence;
301
Alex Daiaa557ab2015-08-18 14:32:35 -0700302 u8 engine_suspended;
303
304 u8 reserved0[3];
Dave Gordon26172682015-07-09 19:29:04 +0100305 u64 reserved1[1];
306
307 u64 desc_private;
308} __packed;
309
Alex Dai93f25312015-09-25 11:46:56 -0700310#define GUC_FORCEWAKE_RENDER (1 << 0)
311#define GUC_FORCEWAKE_MEDIA (1 << 1)
312
Alex Daia1c41992015-09-30 09:46:37 -0700313#define GUC_POWER_UNSPECIFIED 0
314#define GUC_POWER_D0 1
315#define GUC_POWER_D1 2
316#define GUC_POWER_D2 3
317#define GUC_POWER_D3 4
318
Alex Dai68371a92015-12-18 12:00:09 -0800319/* GuC Additional Data Struct */
320
321struct guc_ads {
322 u32 reg_state_addr;
323 u32 reg_state_buffer;
324 u32 golden_context_lrca;
325 u32 scheduler_policies;
326 u32 reserved0[3];
327 u32 eng_state_size[I915_NUM_RINGS];
328 u32 reserved2[4];
329} __packed;
330
Dave Gordon26172682015-07-09 19:29:04 +0100331/* This Action will be programmed in C180 - SOFT_SCRATCH_O_REG */
332enum host2guc_action {
333 HOST2GUC_ACTION_DEFAULT = 0x0,
334 HOST2GUC_ACTION_SAMPLE_FORCEWAKE = 0x6,
335 HOST2GUC_ACTION_ALLOCATE_DOORBELL = 0x10,
336 HOST2GUC_ACTION_DEALLOCATE_DOORBELL = 0x20,
Alex Daia1c41992015-09-30 09:46:37 -0700337 HOST2GUC_ACTION_ENTER_S_STATE = 0x501,
338 HOST2GUC_ACTION_EXIT_S_STATE = 0x502,
Dave Gordon26172682015-07-09 19:29:04 +0100339 HOST2GUC_ACTION_SLPC_REQUEST = 0x3003,
340 HOST2GUC_ACTION_LIMIT
341};
342
343/*
344 * The GuC sends its response to a command by overwriting the
345 * command in SS0. The response is distinguishable from a command
346 * by the fact that all the MASK bits are set. The remaining bits
347 * give more detail.
348 */
349#define GUC2HOST_RESPONSE_MASK ((u32)0xF0000000)
350#define GUC2HOST_IS_RESPONSE(x) ((u32)(x) >= GUC2HOST_RESPONSE_MASK)
351#define GUC2HOST_STATUS(x) (GUC2HOST_RESPONSE_MASK | (x))
352
353/* GUC will return status back to SOFT_SCRATCH_O_REG */
354enum guc2host_status {
355 GUC2HOST_STATUS_SUCCESS = GUC2HOST_STATUS(0x0),
356 GUC2HOST_STATUS_ALLOCATE_DOORBELL_FAIL = GUC2HOST_STATUS(0x10),
357 GUC2HOST_STATUS_DEALLOCATE_DOORBELL_FAIL = GUC2HOST_STATUS(0x20),
358 GUC2HOST_STATUS_GENERIC_FAIL = GUC2HOST_STATUS(0x0000F000)
359};
360
361#endif