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