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