xref: /linux/drivers/gpu/drm/amd/display/dmub/dmub_srv.h (revision ffd89aa968d9046ab5fb9f7cdb7f8d3c383a15c1)
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 
67 #include "inc/dmub_cmd.h"
68 
69 #if defined(__cplusplus)
70 extern "C" {
71 #endif
72 
73 /* Forward declarations */
74 struct dmub_srv;
75 struct dmub_srv_common_regs;
76 struct dmub_srv_dcn31_regs;
77 
78 struct dmcub_trace_buf_entry;
79 
80 /* enum dmub_status - return code for dmcub functions */
81 enum dmub_status {
82 	DMUB_STATUS_OK = 0,
83 	DMUB_STATUS_NO_CTX,
84 	DMUB_STATUS_QUEUE_FULL,
85 	DMUB_STATUS_TIMEOUT,
86 	DMUB_STATUS_INVALID,
87 	DMUB_STATUS_HW_FAILURE,
88 };
89 
90 /* enum dmub_asic - dmub asic identifier */
91 enum dmub_asic {
92 	DMUB_ASIC_NONE = 0,
93 	DMUB_ASIC_DCN20,
94 	DMUB_ASIC_DCN21,
95 	DMUB_ASIC_DCN30,
96 	DMUB_ASIC_DCN301,
97 	DMUB_ASIC_DCN302,
98 	DMUB_ASIC_DCN303,
99 	DMUB_ASIC_DCN31,
100 	DMUB_ASIC_MAX,
101 };
102 
103 /* enum dmub_window_id - dmub window identifier */
104 enum dmub_window_id {
105 	DMUB_WINDOW_0_INST_CONST = 0,
106 	DMUB_WINDOW_1_STACK,
107 	DMUB_WINDOW_2_BSS_DATA,
108 	DMUB_WINDOW_3_VBIOS,
109 	DMUB_WINDOW_4_MAILBOX,
110 	DMUB_WINDOW_5_TRACEBUFF,
111 	DMUB_WINDOW_6_FW_STATE,
112 	DMUB_WINDOW_7_SCRATCH_MEM,
113 	DMUB_WINDOW_TOTAL,
114 };
115 
116 /* enum dmub_notification_type - dmub outbox notification identifier */
117 enum dmub_notification_type {
118 	DMUB_NOTIFICATION_NO_DATA = 0,
119 	DMUB_NOTIFICATION_AUX_REPLY,
120 	DMUB_NOTIFICATION_HPD,
121 	DMUB_NOTIFICATION_HPD_IRQ,
122 	DMUB_NOTIFICATION_SET_CONFIG_REPLY,
123 	DMUB_NOTIFICATION_MAX
124 };
125 
126 /**
127  * struct dmub_region - dmub hw memory region
128  * @base: base address for region, must be 256 byte aligned
129  * @top: top address for region
130  */
131 struct dmub_region {
132 	uint32_t base;
133 	uint32_t top;
134 };
135 
136 /**
137  * struct dmub_window - dmub hw cache window
138  * @off: offset to the fb memory in gpu address space
139  * @r: region in uc address space for cache window
140  */
141 struct dmub_window {
142 	union dmub_addr offset;
143 	struct dmub_region region;
144 };
145 
146 /**
147  * struct dmub_fb - defines a dmub framebuffer memory region
148  * @cpu_addr: cpu virtual address for the region, NULL if invalid
149  * @gpu_addr: gpu virtual address for the region, NULL if invalid
150  * @size: size of the region in bytes, zero if invalid
151  */
152 struct dmub_fb {
153 	void *cpu_addr;
154 	uint64_t gpu_addr;
155 	uint32_t size;
156 };
157 
158 /**
159  * struct dmub_srv_region_params - params used for calculating dmub regions
160  * @inst_const_size: size of the fw inst const section
161  * @bss_data_size: size of the fw bss data section
162  * @vbios_size: size of the vbios data
163  * @fw_bss_data: raw firmware bss data section
164  */
165 struct dmub_srv_region_params {
166 	uint32_t inst_const_size;
167 	uint32_t bss_data_size;
168 	uint32_t vbios_size;
169 	const uint8_t *fw_inst_const;
170 	const uint8_t *fw_bss_data;
171 };
172 
173 /**
174  * struct dmub_srv_region_info - output region info from the dmub service
175  * @fb_size: required minimum fb size for all regions, aligned to 4096 bytes
176  * @num_regions: number of regions used by the dmub service
177  * @regions: region info
178  *
179  * The regions are aligned such that they can be all placed within the
180  * same framebuffer but they can also be placed into different framebuffers.
181  *
182  * The size of each region can be calculated by the caller:
183  * size = reg.top - reg.base
184  *
185  * Care must be taken when performing custom allocations to ensure that each
186  * region base address is 256 byte aligned.
187  */
188 struct dmub_srv_region_info {
189 	uint32_t fb_size;
190 	uint8_t num_regions;
191 	struct dmub_region regions[DMUB_WINDOW_TOTAL];
192 };
193 
194 /**
195  * struct dmub_srv_fb_params - parameters used for driver fb setup
196  * @region_info: region info calculated by dmub service
197  * @cpu_addr: base cpu address for the framebuffer
198  * @gpu_addr: base gpu virtual address for the framebuffer
199  */
200 struct dmub_srv_fb_params {
201 	const struct dmub_srv_region_info *region_info;
202 	void *cpu_addr;
203 	uint64_t gpu_addr;
204 };
205 
206 /**
207  * struct dmub_srv_fb_info - output fb info from the dmub service
208  * @num_fbs: number of required dmub framebuffers
209  * @fbs: fb data for each region
210  *
211  * Output from the dmub service helper that can be used by the
212  * driver to prepare dmub_fb that can be passed into the dmub
213  * hw init service.
214  *
215  * Assumes that all regions are within the same framebuffer
216  * and have been setup according to the region_info generated
217  * by the dmub service.
218  */
219 struct dmub_srv_fb_info {
220 	uint8_t num_fb;
221 	struct dmub_fb fb[DMUB_WINDOW_TOTAL];
222 };
223 
224 /*
225  * struct dmub_srv_hw_params - params for dmub hardware initialization
226  * @fb: framebuffer info for each region
227  * @fb_base: base of the framebuffer aperture
228  * @fb_offset: offset of the framebuffer aperture
229  * @psp_version: psp version to pass for DMCU init
230  * @load_inst_const: true if DMUB should load inst const fw
231  */
232 struct dmub_srv_hw_params {
233 	struct dmub_fb *fb[DMUB_WINDOW_TOTAL];
234 	uint64_t fb_base;
235 	uint64_t fb_offset;
236 	uint32_t psp_version;
237 	bool load_inst_const;
238 	bool skip_panel_power_sequence;
239 	bool disable_z10;
240 	bool disable_dpia;
241 };
242 
243 /**
244  * struct dmub_diagnostic_data - Diagnostic data retrieved from DMCUB for
245  * debugging purposes, including logging, crash analysis, etc.
246  */
247 struct dmub_diagnostic_data {
248 	uint32_t dmcub_version;
249 	uint32_t scratch[16];
250 	uint32_t pc;
251 	uint32_t undefined_address_fault_addr;
252 	uint32_t inst_fetch_fault_addr;
253 	uint32_t data_write_fault_addr;
254 	uint32_t inbox1_rptr;
255 	uint32_t inbox1_wptr;
256 	uint32_t inbox1_size;
257 	uint32_t inbox0_rptr;
258 	uint32_t inbox0_wptr;
259 	uint32_t inbox0_size;
260 	uint8_t is_dmcub_enabled : 1;
261 	uint8_t is_dmcub_soft_reset : 1;
262 	uint8_t is_dmcub_secure_reset : 1;
263 	uint8_t is_traceport_en : 1;
264 	uint8_t is_cw0_enabled : 1;
265 	uint8_t is_cw6_enabled : 1;
266 };
267 
268 /**
269  * struct dmub_srv_base_funcs - Driver specific base callbacks
270  */
271 struct dmub_srv_base_funcs {
272 	/**
273 	 * @reg_read:
274 	 *
275 	 * Hook for reading a register.
276 	 *
277 	 * Return: The 32-bit register value from the given address.
278 	 */
279 	uint32_t (*reg_read)(void *ctx, uint32_t address);
280 
281 	/**
282 	 * @reg_write:
283 	 *
284 	 * Hook for writing a value to the register specified by address.
285 	 */
286 	void (*reg_write)(void *ctx, uint32_t address, uint32_t value);
287 };
288 
289 /**
290  * struct dmub_srv_hw_funcs - hardware sequencer funcs for dmub
291  */
292 struct dmub_srv_hw_funcs {
293 	/* private: internal use only */
294 
295 	void (*init)(struct dmub_srv *dmub);
296 
297 	void (*reset)(struct dmub_srv *dmub);
298 
299 	void (*reset_release)(struct dmub_srv *dmub);
300 
301 	void (*backdoor_load)(struct dmub_srv *dmub,
302 			      const struct dmub_window *cw0,
303 			      const struct dmub_window *cw1);
304 
305 	void (*setup_windows)(struct dmub_srv *dmub,
306 			      const struct dmub_window *cw2,
307 			      const struct dmub_window *cw3,
308 			      const struct dmub_window *cw4,
309 			      const struct dmub_window *cw5,
310 			      const struct dmub_window *cw6);
311 
312 	void (*setup_mailbox)(struct dmub_srv *dmub,
313 			      const struct dmub_region *inbox1);
314 
315 	uint32_t (*get_inbox1_rptr)(struct dmub_srv *dmub);
316 
317 	void (*set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset);
318 
319 	void (*setup_out_mailbox)(struct dmub_srv *dmub,
320 			      const struct dmub_region *outbox1);
321 
322 	uint32_t (*get_outbox1_wptr)(struct dmub_srv *dmub);
323 
324 	void (*set_outbox1_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset);
325 
326 	void (*setup_outbox0)(struct dmub_srv *dmub,
327 			      const struct dmub_region *outbox0);
328 
329 	uint32_t (*get_outbox0_wptr)(struct dmub_srv *dmub);
330 
331 	void (*set_outbox0_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset);
332 
333 	uint32_t (*emul_get_inbox1_rptr)(struct dmub_srv *dmub);
334 
335 	void (*emul_set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset);
336 
337 	bool (*is_supported)(struct dmub_srv *dmub);
338 
339 	bool (*is_hw_init)(struct dmub_srv *dmub);
340 
341 	bool (*is_phy_init)(struct dmub_srv *dmub);
342 	void (*enable_dmub_boot_options)(struct dmub_srv *dmub,
343 				const struct dmub_srv_hw_params *params);
344 
345 	void (*skip_dmub_panel_power_sequence)(struct dmub_srv *dmub, bool skip);
346 
347 	union dmub_fw_boot_status (*get_fw_status)(struct dmub_srv *dmub);
348 
349 
350 	void (*set_gpint)(struct dmub_srv *dmub,
351 			  union dmub_gpint_data_register reg);
352 
353 	bool (*is_gpint_acked)(struct dmub_srv *dmub,
354 			       union dmub_gpint_data_register reg);
355 
356 	uint32_t (*get_gpint_response)(struct dmub_srv *dmub);
357 
358 	uint32_t (*get_gpint_dataout)(struct dmub_srv *dmub);
359 
360 	void (*send_inbox0_cmd)(struct dmub_srv *dmub, union dmub_inbox0_data_register data);
361 	uint32_t (*get_current_time)(struct dmub_srv *dmub);
362 
363 	void (*get_diagnostic_data)(struct dmub_srv *dmub, struct dmub_diagnostic_data *dmub_oca);
364 
365 	bool (*should_detect)(struct dmub_srv *dmub);
366 };
367 
368 /**
369  * struct dmub_srv_create_params - params for dmub service creation
370  * @base_funcs: driver supplied base routines
371  * @hw_funcs: optional overrides for hw funcs
372  * @user_ctx: context data for callback funcs
373  * @asic: driver supplied asic
374  * @fw_version: the current firmware version, if any
375  * @is_virtual: false for hw support only
376  */
377 struct dmub_srv_create_params {
378 	struct dmub_srv_base_funcs funcs;
379 	struct dmub_srv_hw_funcs *hw_funcs;
380 	void *user_ctx;
381 	enum dmub_asic asic;
382 	uint32_t fw_version;
383 	bool is_virtual;
384 };
385 
386 /**
387  * struct dmub_srv - software state for dmcub
388  * @asic: dmub asic identifier
389  * @user_ctx: user provided context for the dmub_srv
390  * @fw_version: the current firmware version, if any
391  * @is_virtual: false if hardware support only
392  * @fw_state: dmub firmware state pointer
393  */
394 struct dmub_srv {
395 	enum dmub_asic asic;
396 	void *user_ctx;
397 	uint32_t fw_version;
398 	bool is_virtual;
399 	struct dmub_fb scratch_mem_fb;
400 	volatile const struct dmub_fw_state *fw_state;
401 
402 	/* private: internal use only */
403 	const struct dmub_srv_common_regs *regs;
404 	const struct dmub_srv_dcn31_regs *regs_dcn31;
405 
406 	struct dmub_srv_base_funcs funcs;
407 	struct dmub_srv_hw_funcs hw_funcs;
408 	struct dmub_rb inbox1_rb;
409 	/**
410 	 * outbox1_rb is accessed without locks (dal & dc)
411 	 * and to be used only in dmub_srv_stat_get_notification()
412 	 */
413 	struct dmub_rb outbox1_rb;
414 
415 	struct dmub_rb outbox0_rb;
416 
417 	bool sw_init;
418 	bool hw_init;
419 
420 	uint64_t fb_base;
421 	uint64_t fb_offset;
422 	uint32_t psp_version;
423 
424 	/* Feature capabilities reported by fw */
425 	struct dmub_feature_caps feature_caps;
426 };
427 
428 /**
429  * struct dmub_notification - dmub notification data
430  * @type: dmub notification type
431  * @link_index: link index to identify aux connection
432  * @result: USB4 status returned from dmub
433  * @pending_notification: Indicates there are other pending notifications
434  * @aux_reply: aux reply
435  * @hpd_status: hpd status
436  */
437 struct dmub_notification {
438 	enum dmub_notification_type type;
439 	uint8_t link_index;
440 	uint8_t result;
441 	bool pending_notification;
442 	union {
443 		struct aux_reply_data aux_reply;
444 		enum dp_hpd_status hpd_status;
445 		enum set_config_status sc_status;
446 	};
447 };
448 
449 /**
450  * DMUB firmware version helper macro - useful for checking if the version
451  * of a firmware to know if feature or functionality is supported or present.
452  */
453 #define DMUB_FW_VERSION(major, minor, revision) \
454 	((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF))
455 
456 /**
457  * dmub_srv_create() - creates the DMUB service.
458  * @dmub: the dmub service
459  * @params: creation parameters for the service
460  *
461  * Return:
462  *   DMUB_STATUS_OK - success
463  *   DMUB_STATUS_INVALID - unspecified error
464  */
465 enum dmub_status dmub_srv_create(struct dmub_srv *dmub,
466 				 const struct dmub_srv_create_params *params);
467 
468 /**
469  * dmub_srv_destroy() - destroys the DMUB service.
470  * @dmub: the dmub service
471  */
472 void dmub_srv_destroy(struct dmub_srv *dmub);
473 
474 /**
475  * dmub_srv_calc_region_info() - retreives region info from the dmub service
476  * @dmub: the dmub service
477  * @params: parameters used to calculate region locations
478  * @info_out: the output region info from dmub
479  *
480  * Calculates the base and top address for all relevant dmub regions
481  * using the parameters given (if any).
482  *
483  * Return:
484  *   DMUB_STATUS_OK - success
485  *   DMUB_STATUS_INVALID - unspecified error
486  */
487 enum dmub_status
488 dmub_srv_calc_region_info(struct dmub_srv *dmub,
489 			  const struct dmub_srv_region_params *params,
490 			  struct dmub_srv_region_info *out);
491 
492 /**
493  * dmub_srv_calc_region_info() - retreives fb info from the dmub service
494  * @dmub: the dmub service
495  * @params: parameters used to calculate fb locations
496  * @info_out: the output fb info from dmub
497  *
498  * Calculates the base and top address for all relevant dmub regions
499  * using the parameters given (if any).
500  *
501  * Return:
502  *   DMUB_STATUS_OK - success
503  *   DMUB_STATUS_INVALID - unspecified error
504  */
505 enum dmub_status dmub_srv_calc_fb_info(struct dmub_srv *dmub,
506 				       const struct dmub_srv_fb_params *params,
507 				       struct dmub_srv_fb_info *out);
508 
509 /**
510  * dmub_srv_has_hw_support() - returns hw support state for dmcub
511  * @dmub: the dmub service
512  * @is_supported: hw support state
513  *
514  * Queries the hardware for DMCUB support and returns the result.
515  *
516  * Can be called before dmub_srv_hw_init().
517  *
518  * Return:
519  *   DMUB_STATUS_OK - success
520  *   DMUB_STATUS_INVALID - unspecified error
521  */
522 enum dmub_status dmub_srv_has_hw_support(struct dmub_srv *dmub,
523 					 bool *is_supported);
524 
525 /**
526  * dmub_srv_is_hw_init() - returns hardware init state
527  *
528  * Return:
529  *   DMUB_STATUS_OK - success
530  *   DMUB_STATUS_INVALID - unspecified error
531  */
532 enum dmub_status dmub_srv_is_hw_init(struct dmub_srv *dmub, bool *is_hw_init);
533 
534 /**
535  * dmub_srv_hw_init() - initializes the underlying DMUB hardware
536  * @dmub: the dmub service
537  * @params: params for hardware initialization
538  *
539  * Resets the DMUB hardware and performs backdoor loading of the
540  * required cache regions based on the input framebuffer regions.
541  *
542  * Return:
543  *   DMUB_STATUS_OK - success
544  *   DMUB_STATUS_NO_CTX - dmcub context not initialized
545  *   DMUB_STATUS_INVALID - unspecified error
546  */
547 enum dmub_status dmub_srv_hw_init(struct dmub_srv *dmub,
548 				  const struct dmub_srv_hw_params *params);
549 
550 /**
551  * dmub_srv_hw_reset() - puts the DMUB hardware in reset state if initialized
552  * @dmub: the dmub service
553  *
554  * Before destroying the DMUB service or releasing the backing framebuffer
555  * memory we'll need to put the DMCUB into reset first.
556  *
557  * A subsequent call to dmub_srv_hw_init() will re-enable the DMCUB.
558  *
559  * Return:
560  *   DMUB_STATUS_OK - success
561  *   DMUB_STATUS_INVALID - unspecified error
562  */
563 enum dmub_status dmub_srv_hw_reset(struct dmub_srv *dmub);
564 
565 /**
566  * dmub_srv_cmd_queue() - queues a command to the DMUB
567  * @dmub: the dmub service
568  * @cmd: the command to queue
569  *
570  * Queues a command to the DMUB service but does not begin execution
571  * immediately.
572  *
573  * Return:
574  *   DMUB_STATUS_OK - success
575  *   DMUB_STATUS_QUEUE_FULL - no remaining room in queue
576  *   DMUB_STATUS_INVALID - unspecified error
577  */
578 enum dmub_status dmub_srv_cmd_queue(struct dmub_srv *dmub,
579 				    const union dmub_rb_cmd *cmd);
580 
581 /**
582  * dmub_srv_cmd_execute() - Executes a queued sequence to the dmub
583  * @dmub: the dmub service
584  *
585  * Begins execution of queued commands on the dmub.
586  *
587  * Return:
588  *   DMUB_STATUS_OK - success
589  *   DMUB_STATUS_INVALID - unspecified error
590  */
591 enum dmub_status dmub_srv_cmd_execute(struct dmub_srv *dmub);
592 
593 /**
594  * dmub_srv_wait_for_auto_load() - Waits for firmware auto load to complete
595  * @dmub: the dmub service
596  * @timeout_us: the maximum number of microseconds to wait
597  *
598  * Waits until firmware has been autoloaded by the DMCUB. The maximum
599  * wait time is given in microseconds to prevent spinning forever.
600  *
601  * On ASICs without firmware autoload support this function will return
602  * immediately.
603  *
604  * Return:
605  *   DMUB_STATUS_OK - success
606  *   DMUB_STATUS_TIMEOUT - wait for phy init timed out
607  *   DMUB_STATUS_INVALID - unspecified error
608  */
609 enum dmub_status dmub_srv_wait_for_auto_load(struct dmub_srv *dmub,
610 					     uint32_t timeout_us);
611 
612 /**
613  * dmub_srv_wait_for_phy_init() - Waits for DMUB PHY init to complete
614  * @dmub: the dmub service
615  * @timeout_us: the maximum number of microseconds to wait
616  *
617  * Waits until the PHY has been initialized by the DMUB. The maximum
618  * wait time is given in microseconds to prevent spinning forever.
619  *
620  * On ASICs without PHY init support this function will return
621  * immediately.
622  *
623  * Return:
624  *   DMUB_STATUS_OK - success
625  *   DMUB_STATUS_TIMEOUT - wait for phy init timed out
626  *   DMUB_STATUS_INVALID - unspecified error
627  */
628 enum dmub_status dmub_srv_wait_for_phy_init(struct dmub_srv *dmub,
629 					    uint32_t timeout_us);
630 
631 /**
632  * dmub_srv_wait_for_idle() - Waits for the DMUB to be idle
633  * @dmub: the dmub service
634  * @timeout_us: the maximum number of microseconds to wait
635  *
636  * Waits until the DMUB buffer is empty and all commands have
637  * finished processing. The maximum wait time is given in
638  * microseconds to prevent spinning forever.
639  *
640  * Return:
641  *   DMUB_STATUS_OK - success
642  *   DMUB_STATUS_TIMEOUT - wait for buffer to flush timed out
643  *   DMUB_STATUS_INVALID - unspecified error
644  */
645 enum dmub_status dmub_srv_wait_for_idle(struct dmub_srv *dmub,
646 					uint32_t timeout_us);
647 
648 /**
649  * dmub_srv_send_gpint_command() - Sends a GPINT based command.
650  * @dmub: the dmub service
651  * @command_code: the command code to send
652  * @param: the command parameter to send
653  * @timeout_us: the maximum number of microseconds to wait
654  *
655  * Sends a command via the general purpose interrupt (GPINT).
656  * Waits for the number of microseconds specified by timeout_us
657  * for the command ACK before returning.
658  *
659  * Can be called after software initialization.
660  *
661  * Return:
662  *   DMUB_STATUS_OK - success
663  *   DMUB_STATUS_TIMEOUT - wait for ACK timed out
664  *   DMUB_STATUS_INVALID - unspecified error
665  */
666 enum dmub_status
667 dmub_srv_send_gpint_command(struct dmub_srv *dmub,
668 			    enum dmub_gpint_command command_code,
669 			    uint16_t param, uint32_t timeout_us);
670 
671 /**
672  * dmub_srv_get_gpint_response() - Queries the GPINT response.
673  * @dmub: the dmub service
674  * @response: the response for the last GPINT
675  *
676  * Returns the response code for the last GPINT interrupt.
677  *
678  * Can be called after software initialization.
679  *
680  * Return:
681  *   DMUB_STATUS_OK - success
682  *   DMUB_STATUS_INVALID - unspecified error
683  */
684 enum dmub_status dmub_srv_get_gpint_response(struct dmub_srv *dmub,
685 					     uint32_t *response);
686 
687 /**
688  * dmub_srv_get_gpint_dataout() - Queries the GPINT DATAOUT.
689  * @dmub: the dmub service
690  * @dataout: the data for the GPINT DATAOUT
691  *
692  * Returns the response code for the last GPINT DATAOUT interrupt.
693  *
694  * Can be called after software initialization.
695  *
696  * Return:
697  *   DMUB_STATUS_OK - success
698  *   DMUB_STATUS_INVALID - unspecified error
699  */
700 enum dmub_status dmub_srv_get_gpint_dataout(struct dmub_srv *dmub,
701 					     uint32_t *dataout);
702 
703 /**
704  * dmub_flush_buffer_mem() - Read back entire frame buffer region.
705  * This ensures that the write from x86 has been flushed and will not
706  * hang the DMCUB.
707  * @fb: frame buffer to flush
708  *
709  * Can be called after software initialization.
710  */
711 void dmub_flush_buffer_mem(const struct dmub_fb *fb);
712 
713 /**
714  * dmub_srv_get_fw_boot_status() - Returns the DMUB boot status bits.
715  *
716  * @dmub: the dmub service
717  * @status: out pointer for firmware status
718  *
719  * Return:
720  *   DMUB_STATUS_OK - success
721  *   DMUB_STATUS_INVALID - unspecified error, unsupported
722  */
723 enum dmub_status dmub_srv_get_fw_boot_status(struct dmub_srv *dmub,
724 					     union dmub_fw_boot_status *status);
725 
726 enum dmub_status dmub_srv_cmd_with_reply_data(struct dmub_srv *dmub,
727 					      union dmub_rb_cmd *cmd);
728 
729 bool dmub_srv_get_outbox0_msg(struct dmub_srv *dmub, struct dmcub_trace_buf_entry *entry);
730 
731 bool dmub_srv_get_diagnostic_data(struct dmub_srv *dmub, struct dmub_diagnostic_data *diag_data);
732 
733 bool dmub_srv_should_detect(struct dmub_srv *dmub);
734 
735 #if defined(__cplusplus)
736 }
737 #endif
738 
739 #endif /* _DMUB_SRV_H_ */
740