Commit | Line | Data |
---|---|---|
7c008829 NK |
1 | /* |
2 | * Copyright 2019 Advanced Micro Devices, Inc. | |
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 shall be included in | |
12 | * all copies or substantial portions of the Software. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
20 | * OTHER DEALINGS IN THE SOFTWARE. | |
21 | * | |
22 | * Authors: AMD | |
23 | * | |
24 | */ | |
25 | ||
26 | #ifndef _DMUB_SRV_H_ | |
27 | #define _DMUB_SRV_H_ | |
28 | ||
29 | /** | |
30 | * DOC: DMUB interface and operation | |
31 | * | |
32 | * DMUB is the interface to the display DMCUB microcontroller on DCN hardware. | |
33 | * It delegates hardware initialization and command submission to the | |
34 | * microcontroller. DMUB is the shortname for DMCUB. | |
35 | * | |
36 | * This interface is not thread-safe. Ensure that all access to the interface | |
37 | * is properly synchronized by the caller. | |
38 | * | |
39 | * Initialization and usage of the DMUB service should be done in the | |
40 | * steps given below: | |
41 | * | |
42 | * 1. dmub_srv_create() | |
43 | * 2. dmub_srv_has_hw_support() | |
44 | * 3. dmub_srv_calc_region_info() | |
45 | * 4. dmub_srv_hw_init() | |
46 | * | |
47 | * The call to dmub_srv_create() is required to use the server. | |
48 | * | |
49 | * The calls to dmub_srv_has_hw_support() and dmub_srv_calc_region_info() | |
50 | * are helpers to query cache window size and allocate framebuffer(s) | |
51 | * for the cache windows. | |
52 | * | |
53 | * The call to dmub_srv_hw_init() programs the DMCUB registers to prepare | |
54 | * for command submission. Commands can be queued via dmub_srv_cmd_queue() | |
55 | * and executed via dmub_srv_cmd_execute(). | |
56 | * | |
57 | * If the queue is full the dmub_srv_wait_for_idle() call can be used to | |
58 | * wait until the queue has been cleared. | |
59 | * | |
60 | * Destroying the DMUB service can be done by calling dmub_srv_destroy(). | |
61 | * This does not clear DMUB hardware state, only software state. | |
62 | * | |
63 | * The interface is intended to be standalone and should not depend on any | |
64 | * other component within DAL. | |
65 | */ | |
66 | ||
cdca3f21 | 67 | #include "inc/dmub_cmd.h" |
7c008829 NK |
68 | |
69 | #if defined(__cplusplus) | |
70 | extern "C" { | |
71 | #endif | |
72 | ||
73 | /* Forward declarations */ | |
74 | struct dmub_srv; | |
01c229d9 | 75 | struct dmub_srv_common_regs; |
7c008829 | 76 | |
70732504 YS |
77 | struct dmcub_trace_buf_entry; |
78 | ||
7c008829 NK |
79 | /* enum dmub_status - return code for dmcub functions */ |
80 | enum dmub_status { | |
81 | DMUB_STATUS_OK = 0, | |
82 | DMUB_STATUS_NO_CTX, | |
83 | DMUB_STATUS_QUEUE_FULL, | |
84 | DMUB_STATUS_TIMEOUT, | |
85 | DMUB_STATUS_INVALID, | |
86 | }; | |
87 | ||
88 | /* enum dmub_asic - dmub asic identifier */ | |
89 | enum dmub_asic { | |
90 | DMUB_ASIC_NONE = 0, | |
91 | DMUB_ASIC_DCN20, | |
92 | DMUB_ASIC_DCN21, | |
5baebf61 | 93 | DMUB_ASIC_DCN30, |
3a83e4e6 | 94 | DMUB_ASIC_DCN301, |
36d26912 | 95 | DMUB_ASIC_DCN302, |
7c008829 NK |
96 | DMUB_ASIC_MAX, |
97 | }; | |
98 | ||
99 | /* enum dmub_window_id - dmub window identifier */ | |
100 | enum dmub_window_id { | |
101 | DMUB_WINDOW_0_INST_CONST = 0, | |
102 | DMUB_WINDOW_1_STACK, | |
103 | DMUB_WINDOW_2_BSS_DATA, | |
104 | DMUB_WINDOW_3_VBIOS, | |
105 | DMUB_WINDOW_4_MAILBOX, | |
106 | DMUB_WINDOW_5_TRACEBUFF, | |
2f39835c | 107 | DMUB_WINDOW_6_FW_STATE, |
2277f01d | 108 | DMUB_WINDOW_7_SCRATCH_MEM, |
7c008829 NK |
109 | DMUB_WINDOW_TOTAL, |
110 | }; | |
111 | ||
4f8e37db MS |
112 | /* enum dmub_notification_type - dmub outbox notification identifier */ |
113 | enum dmub_notification_type { | |
114 | DMUB_NOTIFICATION_NO_DATA = 0, | |
115 | DMUB_NOTIFICATION_AUX_REPLY, | |
116 | DMUB_NOTIFICATION_HPD, | |
117 | DMUB_NOTIFICATION_HPD_IRQ, | |
118 | DMUB_NOTIFICATION_MAX | |
119 | }; | |
120 | ||
7c008829 NK |
121 | /** |
122 | * struct dmub_region - dmub hw memory region | |
123 | * @base: base address for region, must be 256 byte aligned | |
124 | * @top: top address for region | |
125 | */ | |
126 | struct dmub_region { | |
127 | uint32_t base; | |
128 | uint32_t top; | |
129 | }; | |
130 | ||
131 | /** | |
132 | * struct dmub_window - dmub hw cache window | |
133 | * @off: offset to the fb memory in gpu address space | |
134 | * @r: region in uc address space for cache window | |
135 | */ | |
136 | struct dmub_window { | |
137 | union dmub_addr offset; | |
138 | struct dmub_region region; | |
139 | }; | |
140 | ||
141 | /** | |
142 | * struct dmub_fb - defines a dmub framebuffer memory region | |
143 | * @cpu_addr: cpu virtual address for the region, NULL if invalid | |
144 | * @gpu_addr: gpu virtual address for the region, NULL if invalid | |
145 | * @size: size of the region in bytes, zero if invalid | |
146 | */ | |
147 | struct dmub_fb { | |
148 | void *cpu_addr; | |
149 | uint64_t gpu_addr; | |
150 | uint32_t size; | |
151 | }; | |
152 | ||
153 | /** | |
154 | * struct dmub_srv_region_params - params used for calculating dmub regions | |
155 | * @inst_const_size: size of the fw inst const section | |
156 | * @bss_data_size: size of the fw bss data section | |
157 | * @vbios_size: size of the vbios data | |
1f0674fd | 158 | * @fw_bss_data: raw firmware bss data section |
7c008829 NK |
159 | */ |
160 | struct dmub_srv_region_params { | |
161 | uint32_t inst_const_size; | |
162 | uint32_t bss_data_size; | |
163 | uint32_t vbios_size; | |
a576b345 | 164 | const uint8_t *fw_inst_const; |
1f0674fd | 165 | const uint8_t *fw_bss_data; |
7c008829 NK |
166 | }; |
167 | ||
168 | /** | |
169 | * struct dmub_srv_region_info - output region info from the dmub service | |
170 | * @fb_size: required minimum fb size for all regions, aligned to 4096 bytes | |
171 | * @num_regions: number of regions used by the dmub service | |
172 | * @regions: region info | |
173 | * | |
174 | * The regions are aligned such that they can be all placed within the | |
175 | * same framebuffer but they can also be placed into different framebuffers. | |
176 | * | |
177 | * The size of each region can be calculated by the caller: | |
178 | * size = reg.top - reg.base | |
179 | * | |
180 | * Care must be taken when performing custom allocations to ensure that each | |
181 | * region base address is 256 byte aligned. | |
182 | */ | |
183 | struct dmub_srv_region_info { | |
184 | uint32_t fb_size; | |
185 | uint8_t num_regions; | |
186 | struct dmub_region regions[DMUB_WINDOW_TOTAL]; | |
187 | }; | |
188 | ||
189 | /** | |
190 | * struct dmub_srv_fb_params - parameters used for driver fb setup | |
191 | * @region_info: region info calculated by dmub service | |
192 | * @cpu_addr: base cpu address for the framebuffer | |
193 | * @gpu_addr: base gpu virtual address for the framebuffer | |
194 | */ | |
195 | struct dmub_srv_fb_params { | |
196 | const struct dmub_srv_region_info *region_info; | |
197 | void *cpu_addr; | |
198 | uint64_t gpu_addr; | |
199 | }; | |
200 | ||
201 | /** | |
202 | * struct dmub_srv_fb_info - output fb info from the dmub service | |
203 | * @num_fbs: number of required dmub framebuffers | |
204 | * @fbs: fb data for each region | |
205 | * | |
206 | * Output from the dmub service helper that can be used by the | |
207 | * driver to prepare dmub_fb that can be passed into the dmub | |
208 | * hw init service. | |
209 | * | |
210 | * Assumes that all regions are within the same framebuffer | |
211 | * and have been setup according to the region_info generated | |
212 | * by the dmub service. | |
213 | */ | |
214 | struct dmub_srv_fb_info { | |
215 | uint8_t num_fb; | |
216 | struct dmub_fb fb[DMUB_WINDOW_TOTAL]; | |
217 | }; | |
218 | ||
219 | /** | |
220 | * struct dmub_srv_base_funcs - Driver specific base callbacks | |
221 | */ | |
222 | struct dmub_srv_base_funcs { | |
223 | /** | |
224 | * @reg_read: | |
225 | * | |
226 | * Hook for reading a register. | |
227 | * | |
228 | * Return: The 32-bit register value from the given address. | |
229 | */ | |
230 | uint32_t (*reg_read)(void *ctx, uint32_t address); | |
231 | ||
232 | /** | |
233 | * @reg_write: | |
234 | * | |
235 | * Hook for writing a value to the register specified by address. | |
236 | */ | |
237 | void (*reg_write)(void *ctx, uint32_t address, uint32_t value); | |
238 | }; | |
239 | ||
240 | /** | |
241 | * struct dmub_srv_hw_funcs - hardware sequencer funcs for dmub | |
242 | */ | |
243 | struct dmub_srv_hw_funcs { | |
244 | /* private: internal use only */ | |
245 | ||
153ca760 NK |
246 | void (*init)(struct dmub_srv *dmub); |
247 | ||
7c008829 NK |
248 | void (*reset)(struct dmub_srv *dmub); |
249 | ||
250 | void (*reset_release)(struct dmub_srv *dmub); | |
251 | ||
252 | void (*backdoor_load)(struct dmub_srv *dmub, | |
253 | const struct dmub_window *cw0, | |
254 | const struct dmub_window *cw1); | |
255 | ||
256 | void (*setup_windows)(struct dmub_srv *dmub, | |
257 | const struct dmub_window *cw2, | |
258 | const struct dmub_window *cw3, | |
259 | const struct dmub_window *cw4, | |
2f39835c NK |
260 | const struct dmub_window *cw5, |
261 | const struct dmub_window *cw6); | |
7c008829 NK |
262 | |
263 | void (*setup_mailbox)(struct dmub_srv *dmub, | |
264 | const struct dmub_region *inbox1); | |
265 | ||
266 | uint32_t (*get_inbox1_rptr)(struct dmub_srv *dmub); | |
267 | ||
268 | void (*set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset); | |
269 | ||
4f8e37db MS |
270 | void (*setup_out_mailbox)(struct dmub_srv *dmub, |
271 | const struct dmub_region *outbox1); | |
272 | ||
273 | uint32_t (*get_outbox1_wptr)(struct dmub_srv *dmub); | |
274 | ||
275 | void (*set_outbox1_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset); | |
276 | ||
70732504 YS |
277 | void (*setup_outbox0)(struct dmub_srv *dmub, |
278 | const struct dmub_region *outbox0); | |
279 | ||
280 | uint32_t (*get_outbox0_wptr)(struct dmub_srv *dmub); | |
281 | ||
282 | void (*set_outbox0_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset); | |
283 | ||
37ffa7a1 YS |
284 | uint32_t (*emul_get_inbox1_rptr)(struct dmub_srv *dmub); |
285 | ||
286 | void (*emul_set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset); | |
287 | ||
7c008829 NK |
288 | bool (*is_supported)(struct dmub_srv *dmub); |
289 | ||
c09eeee4 NK |
290 | bool (*is_hw_init)(struct dmub_srv *dmub); |
291 | ||
64c51ea5 | 292 | bool (*is_phy_init)(struct dmub_srv *dmub); |
5fe6b98a BL |
293 | void (*enable_dmub_boot_options)(struct dmub_srv *dmub); |
294 | ||
295 | void (*skip_dmub_panel_power_sequence)(struct dmub_srv *dmub, bool skip); | |
296 | ||
297 | union dmub_fw_boot_status (*get_fw_status)(struct dmub_srv *dmub); | |
7c008829 | 298 | |
fbbd3f8f NK |
299 | |
300 | void (*set_gpint)(struct dmub_srv *dmub, | |
301 | union dmub_gpint_data_register reg); | |
302 | ||
303 | bool (*is_gpint_acked)(struct dmub_srv *dmub, | |
304 | union dmub_gpint_data_register reg); | |
305 | ||
306 | uint32_t (*get_gpint_response)(struct dmub_srv *dmub); | |
70732504 | 307 | |
7c008829 NK |
308 | }; |
309 | ||
310 | /** | |
311 | * struct dmub_srv_create_params - params for dmub service creation | |
312 | * @base_funcs: driver supplied base routines | |
313 | * @hw_funcs: optional overrides for hw funcs | |
314 | * @user_ctx: context data for callback funcs | |
315 | * @asic: driver supplied asic | |
455802c7 | 316 | * @fw_version: the current firmware version, if any |
7c008829 NK |
317 | * @is_virtual: false for hw support only |
318 | */ | |
319 | struct dmub_srv_create_params { | |
320 | struct dmub_srv_base_funcs funcs; | |
321 | struct dmub_srv_hw_funcs *hw_funcs; | |
322 | void *user_ctx; | |
323 | enum dmub_asic asic; | |
455802c7 | 324 | uint32_t fw_version; |
7c008829 NK |
325 | bool is_virtual; |
326 | }; | |
327 | ||
328 | /* | |
329 | * struct dmub_srv_hw_params - params for dmub hardware initialization | |
330 | * @fb: framebuffer info for each region | |
331 | * @fb_base: base of the framebuffer aperture | |
332 | * @fb_offset: offset of the framebuffer aperture | |
333 | * @psp_version: psp version to pass for DMCU init | |
ab16c736 | 334 | * @load_inst_const: true if DMUB should load inst const fw |
7c008829 NK |
335 | */ |
336 | struct dmub_srv_hw_params { | |
337 | struct dmub_fb *fb[DMUB_WINDOW_TOTAL]; | |
338 | uint64_t fb_base; | |
339 | uint64_t fb_offset; | |
340 | uint32_t psp_version; | |
ab16c736 | 341 | bool load_inst_const; |
5fe6b98a | 342 | bool skip_panel_power_sequence; |
7c008829 NK |
343 | }; |
344 | ||
345 | /** | |
346 | * struct dmub_srv - software state for dmcub | |
347 | * @asic: dmub asic identifier | |
348 | * @user_ctx: user provided context for the dmub_srv | |
455802c7 | 349 | * @fw_version: the current firmware version, if any |
7c008829 | 350 | * @is_virtual: false if hardware support only |
2f39835c | 351 | * @fw_state: dmub firmware state pointer |
7c008829 NK |
352 | */ |
353 | struct dmub_srv { | |
354 | enum dmub_asic asic; | |
355 | void *user_ctx; | |
455802c7 | 356 | uint32_t fw_version; |
7c008829 | 357 | bool is_virtual; |
2277f01d | 358 | struct dmub_fb scratch_mem_fb; |
2f39835c | 359 | volatile const struct dmub_fw_state *fw_state; |
7c008829 NK |
360 | |
361 | /* private: internal use only */ | |
01c229d9 NK |
362 | const struct dmub_srv_common_regs *regs; |
363 | ||
7c008829 NK |
364 | struct dmub_srv_base_funcs funcs; |
365 | struct dmub_srv_hw_funcs hw_funcs; | |
366 | struct dmub_rb inbox1_rb; | |
4f8e37db MS |
367 | /** |
368 | * outbox1_rb is accessed without locks (dal & dc) | |
369 | * and to be used only in dmub_srv_stat_get_notification() | |
370 | */ | |
371 | struct dmub_rb outbox1_rb; | |
7c008829 | 372 | |
70732504 YS |
373 | struct dmub_rb outbox0_rb; |
374 | ||
7c008829 NK |
375 | bool sw_init; |
376 | bool hw_init; | |
377 | ||
378 | uint64_t fb_base; | |
379 | uint64_t fb_offset; | |
380 | uint32_t psp_version; | |
92f1fa0d WW |
381 | |
382 | /* Feature capabilities reported by fw */ | |
383 | struct dmub_feature_caps feature_caps; | |
7c008829 NK |
384 | }; |
385 | ||
4f8e37db MS |
386 | /** |
387 | * struct dmub_notification - dmub notification data | |
388 | * @type: dmub notification type | |
389 | * @link_index: link index to identify aux connection | |
390 | * @result: USB4 status returned from dmub | |
391 | * @pending_notification: Indicates there are other pending notifications | |
392 | * @aux_reply: aux reply | |
393 | * @hpd_status: hpd status | |
394 | */ | |
395 | struct dmub_notification { | |
396 | enum dmub_notification_type type; | |
397 | uint8_t link_index; | |
398 | uint8_t result; | |
399 | bool pending_notification; | |
400 | union { | |
401 | struct aux_reply_data aux_reply; | |
402 | enum dp_hpd_status hpd_status; | |
403 | }; | |
404 | }; | |
405 | ||
455802c7 NK |
406 | /** |
407 | * DMUB firmware version helper macro - useful for checking if the version | |
408 | * of a firmware to know if feature or functionality is supported or present. | |
409 | */ | |
410 | #define DMUB_FW_VERSION(major, minor, revision) \ | |
411 | ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF)) | |
412 | ||
7c008829 NK |
413 | /** |
414 | * dmub_srv_create() - creates the DMUB service. | |
415 | * @dmub: the dmub service | |
416 | * @params: creation parameters for the service | |
417 | * | |
418 | * Return: | |
419 | * DMUB_STATUS_OK - success | |
420 | * DMUB_STATUS_INVALID - unspecified error | |
421 | */ | |
422 | enum dmub_status dmub_srv_create(struct dmub_srv *dmub, | |
423 | const struct dmub_srv_create_params *params); | |
424 | ||
425 | /** | |
426 | * dmub_srv_destroy() - destroys the DMUB service. | |
427 | * @dmub: the dmub service | |
428 | */ | |
429 | void dmub_srv_destroy(struct dmub_srv *dmub); | |
430 | ||
431 | /** | |
432 | * dmub_srv_calc_region_info() - retreives region info from the dmub service | |
433 | * @dmub: the dmub service | |
434 | * @params: parameters used to calculate region locations | |
435 | * @info_out: the output region info from dmub | |
436 | * | |
437 | * Calculates the base and top address for all relevant dmub regions | |
438 | * using the parameters given (if any). | |
439 | * | |
440 | * Return: | |
441 | * DMUB_STATUS_OK - success | |
442 | * DMUB_STATUS_INVALID - unspecified error | |
443 | */ | |
444 | enum dmub_status | |
445 | dmub_srv_calc_region_info(struct dmub_srv *dmub, | |
446 | const struct dmub_srv_region_params *params, | |
447 | struct dmub_srv_region_info *out); | |
448 | ||
449 | /** | |
450 | * dmub_srv_calc_region_info() - retreives fb info from the dmub service | |
451 | * @dmub: the dmub service | |
452 | * @params: parameters used to calculate fb locations | |
453 | * @info_out: the output fb info from dmub | |
454 | * | |
455 | * Calculates the base and top address for all relevant dmub regions | |
456 | * using the parameters given (if any). | |
457 | * | |
458 | * Return: | |
459 | * DMUB_STATUS_OK - success | |
460 | * DMUB_STATUS_INVALID - unspecified error | |
461 | */ | |
462 | enum dmub_status dmub_srv_calc_fb_info(struct dmub_srv *dmub, | |
463 | const struct dmub_srv_fb_params *params, | |
464 | struct dmub_srv_fb_info *out); | |
465 | ||
466 | /** | |
467 | * dmub_srv_has_hw_support() - returns hw support state for dmcub | |
468 | * @dmub: the dmub service | |
469 | * @is_supported: hw support state | |
470 | * | |
471 | * Queries the hardware for DMCUB support and returns the result. | |
472 | * | |
473 | * Can be called before dmub_srv_hw_init(). | |
474 | * | |
475 | * Return: | |
476 | * DMUB_STATUS_OK - success | |
477 | * DMUB_STATUS_INVALID - unspecified error | |
478 | */ | |
479 | enum dmub_status dmub_srv_has_hw_support(struct dmub_srv *dmub, | |
480 | bool *is_supported); | |
481 | ||
c09eeee4 NK |
482 | /** |
483 | * dmub_srv_is_hw_init() - returns hardware init state | |
484 | * | |
485 | * Return: | |
486 | * DMUB_STATUS_OK - success | |
487 | * DMUB_STATUS_INVALID - unspecified error | |
488 | */ | |
489 | enum dmub_status dmub_srv_is_hw_init(struct dmub_srv *dmub, bool *is_hw_init); | |
490 | ||
7c008829 NK |
491 | /** |
492 | * dmub_srv_hw_init() - initializes the underlying DMUB hardware | |
493 | * @dmub: the dmub service | |
494 | * @params: params for hardware initialization | |
495 | * | |
496 | * Resets the DMUB hardware and performs backdoor loading of the | |
497 | * required cache regions based on the input framebuffer regions. | |
498 | * | |
499 | * Return: | |
500 | * DMUB_STATUS_OK - success | |
501 | * DMUB_STATUS_NO_CTX - dmcub context not initialized | |
502 | * DMUB_STATUS_INVALID - unspecified error | |
503 | */ | |
504 | enum dmub_status dmub_srv_hw_init(struct dmub_srv *dmub, | |
505 | const struct dmub_srv_hw_params *params); | |
506 | ||
0167da49 NK |
507 | /** |
508 | * dmub_srv_hw_reset() - puts the DMUB hardware in reset state if initialized | |
509 | * @dmub: the dmub service | |
510 | * | |
511 | * Before destroying the DMUB service or releasing the backing framebuffer | |
512 | * memory we'll need to put the DMCUB into reset first. | |
513 | * | |
514 | * A subsequent call to dmub_srv_hw_init() will re-enable the DMCUB. | |
515 | * | |
516 | * Return: | |
517 | * DMUB_STATUS_OK - success | |
518 | * DMUB_STATUS_INVALID - unspecified error | |
519 | */ | |
520 | enum dmub_status dmub_srv_hw_reset(struct dmub_srv *dmub); | |
521 | ||
7c008829 NK |
522 | /** |
523 | * dmub_srv_cmd_queue() - queues a command to the DMUB | |
524 | * @dmub: the dmub service | |
525 | * @cmd: the command to queue | |
526 | * | |
527 | * Queues a command to the DMUB service but does not begin execution | |
528 | * immediately. | |
529 | * | |
530 | * Return: | |
531 | * DMUB_STATUS_OK - success | |
532 | * DMUB_STATUS_QUEUE_FULL - no remaining room in queue | |
533 | * DMUB_STATUS_INVALID - unspecified error | |
534 | */ | |
535 | enum dmub_status dmub_srv_cmd_queue(struct dmub_srv *dmub, | |
0ed3bcc4 | 536 | const union dmub_rb_cmd *cmd); |
7c008829 NK |
537 | |
538 | /** | |
539 | * dmub_srv_cmd_execute() - Executes a queued sequence to the dmub | |
540 | * @dmub: the dmub service | |
541 | * | |
243a8f41 | 542 | * Begins execution of queued commands on the dmub. |
7c008829 NK |
543 | * |
544 | * Return: | |
545 | * DMUB_STATUS_OK - success | |
546 | * DMUB_STATUS_INVALID - unspecified error | |
547 | */ | |
548 | enum dmub_status dmub_srv_cmd_execute(struct dmub_srv *dmub); | |
549 | ||
7c008829 NK |
550 | /** |
551 | * dmub_srv_wait_for_auto_load() - Waits for firmware auto load to complete | |
552 | * @dmub: the dmub service | |
553 | * @timeout_us: the maximum number of microseconds to wait | |
554 | * | |
555 | * Waits until firmware has been autoloaded by the DMCUB. The maximum | |
556 | * wait time is given in microseconds to prevent spinning forever. | |
557 | * | |
558 | * On ASICs without firmware autoload support this function will return | |
559 | * immediately. | |
560 | * | |
561 | * Return: | |
562 | * DMUB_STATUS_OK - success | |
563 | * DMUB_STATUS_TIMEOUT - wait for phy init timed out | |
564 | * DMUB_STATUS_INVALID - unspecified error | |
565 | */ | |
566 | enum dmub_status dmub_srv_wait_for_auto_load(struct dmub_srv *dmub, | |
567 | uint32_t timeout_us); | |
568 | ||
569 | /** | |
570 | * dmub_srv_wait_for_phy_init() - Waits for DMUB PHY init to complete | |
571 | * @dmub: the dmub service | |
572 | * @timeout_us: the maximum number of microseconds to wait | |
573 | * | |
574 | * Waits until the PHY has been initialized by the DMUB. The maximum | |
575 | * wait time is given in microseconds to prevent spinning forever. | |
576 | * | |
577 | * On ASICs without PHY init support this function will return | |
578 | * immediately. | |
579 | * | |
580 | * Return: | |
581 | * DMUB_STATUS_OK - success | |
582 | * DMUB_STATUS_TIMEOUT - wait for phy init timed out | |
583 | * DMUB_STATUS_INVALID - unspecified error | |
584 | */ | |
585 | enum dmub_status dmub_srv_wait_for_phy_init(struct dmub_srv *dmub, | |
586 | uint32_t timeout_us); | |
587 | ||
588 | /** | |
589 | * dmub_srv_wait_for_idle() - Waits for the DMUB to be idle | |
590 | * @dmub: the dmub service | |
591 | * @timeout_us: the maximum number of microseconds to wait | |
592 | * | |
593 | * Waits until the DMUB buffer is empty and all commands have | |
594 | * finished processing. The maximum wait time is given in | |
595 | * microseconds to prevent spinning forever. | |
596 | * | |
597 | * Return: | |
598 | * DMUB_STATUS_OK - success | |
599 | * DMUB_STATUS_TIMEOUT - wait for buffer to flush timed out | |
600 | * DMUB_STATUS_INVALID - unspecified error | |
601 | */ | |
602 | enum dmub_status dmub_srv_wait_for_idle(struct dmub_srv *dmub, | |
603 | uint32_t timeout_us); | |
604 | ||
fbbd3f8f NK |
605 | /** |
606 | * dmub_srv_send_gpint_command() - Sends a GPINT based command. | |
607 | * @dmub: the dmub service | |
608 | * @command_code: the command code to send | |
609 | * @param: the command parameter to send | |
610 | * @timeout_us: the maximum number of microseconds to wait | |
611 | * | |
612 | * Sends a command via the general purpose interrupt (GPINT). | |
613 | * Waits for the number of microseconds specified by timeout_us | |
614 | * for the command ACK before returning. | |
615 | * | |
616 | * Can be called after software initialization. | |
617 | * | |
618 | * Return: | |
619 | * DMUB_STATUS_OK - success | |
620 | * DMUB_STATUS_TIMEOUT - wait for ACK timed out | |
621 | * DMUB_STATUS_INVALID - unspecified error | |
622 | */ | |
623 | enum dmub_status | |
624 | dmub_srv_send_gpint_command(struct dmub_srv *dmub, | |
625 | enum dmub_gpint_command command_code, | |
626 | uint16_t param, uint32_t timeout_us); | |
627 | ||
628 | /** | |
629 | * dmub_srv_get_gpint_response() - Queries the GPINT response. | |
630 | * @dmub: the dmub service | |
631 | * @response: the response for the last GPINT | |
632 | * | |
633 | * Returns the response code for the last GPINT interrupt. | |
634 | * | |
635 | * Can be called after software initialization. | |
636 | * | |
637 | * Return: | |
638 | * DMUB_STATUS_OK - success | |
639 | * DMUB_STATUS_INVALID - unspecified error | |
640 | */ | |
641 | enum dmub_status dmub_srv_get_gpint_response(struct dmub_srv *dmub, | |
642 | uint32_t *response); | |
643 | ||
c5d5b0ec WW |
644 | /** |
645 | * dmub_flush_buffer_mem() - Read back entire frame buffer region. | |
646 | * This ensures that the write from x86 has been flushed and will not | |
647 | * hang the DMCUB. | |
648 | * @fb: frame buffer to flush | |
649 | * | |
650 | * Can be called after software initialization. | |
651 | */ | |
652 | void dmub_flush_buffer_mem(const struct dmub_fb *fb); | |
653 | ||
5fe6b98a BL |
654 | /** |
655 | * dmub_srv_get_fw_boot_status() - Returns the DMUB boot status bits. | |
656 | * | |
657 | * @dmub: the dmub service | |
658 | * @status: out pointer for firmware status | |
659 | * | |
660 | * Return: | |
661 | * DMUB_STATUS_OK - success | |
662 | * DMUB_STATUS_INVALID - unspecified error, unsupported | |
663 | */ | |
664 | enum dmub_status dmub_srv_get_fw_boot_status(struct dmub_srv *dmub, | |
665 | union dmub_fw_boot_status *status); | |
666 | ||
92f1fa0d WW |
667 | enum dmub_status dmub_srv_cmd_with_reply_data(struct dmub_srv *dmub, |
668 | union dmub_rb_cmd *cmd); | |
669 | ||
70732504 YS |
670 | enum dmub_status dmub_srv_get_outbox0_msg(struct dmub_srv *dmub, struct dmcub_trace_buf_entry *entry); |
671 | ||
7c008829 NK |
672 | #if defined(__cplusplus) |
673 | } | |
674 | #endif | |
675 | ||
676 | #endif /* _DMUB_SRV_H_ */ |