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