linux/drivers/gpu/drm/amd/display/dmub/dmub_srv.h
<<
>>
Prefs
   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)
  70extern "C" {
  71#endif
  72
  73/* Forward declarations */
  74struct dmub_srv;
  75struct dmub_srv_common_regs;
  76struct dmub_srv_dcn31_regs;
  77
  78struct dmcub_trace_buf_entry;
  79
  80/* enum dmub_status - return code for dmcub functions */
  81enum 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 */
  91enum 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 */
 107enum 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 */
 120enum 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 */
 134struct 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 */
 144struct 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 */
 155struct 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 */
 168struct 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 */
 191struct 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 */
 203struct 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 */
 222struct 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 */
 235struct 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        bool usb4_cm_version;
 247};
 248
 249/**
 250 * struct dmub_diagnostic_data - Diagnostic data retrieved from DMCUB for
 251 * debugging purposes, including logging, crash analysis, etc.
 252 */
 253struct dmub_diagnostic_data {
 254        uint32_t dmcub_version;
 255        uint32_t scratch[16];
 256        uint32_t pc;
 257        uint32_t undefined_address_fault_addr;
 258        uint32_t inst_fetch_fault_addr;
 259        uint32_t data_write_fault_addr;
 260        uint32_t inbox1_rptr;
 261        uint32_t inbox1_wptr;
 262        uint32_t inbox1_size;
 263        uint32_t inbox0_rptr;
 264        uint32_t inbox0_wptr;
 265        uint32_t inbox0_size;
 266        uint8_t is_dmcub_enabled : 1;
 267        uint8_t is_dmcub_soft_reset : 1;
 268        uint8_t is_dmcub_secure_reset : 1;
 269        uint8_t is_traceport_en : 1;
 270        uint8_t is_cw0_enabled : 1;
 271        uint8_t is_cw6_enabled : 1;
 272};
 273
 274/**
 275 * struct dmub_srv_base_funcs - Driver specific base callbacks
 276 */
 277struct dmub_srv_base_funcs {
 278        /**
 279         * @reg_read:
 280         *
 281         * Hook for reading a register.
 282         *
 283         * Return: The 32-bit register value from the given address.
 284         */
 285        uint32_t (*reg_read)(void *ctx, uint32_t address);
 286
 287        /**
 288         * @reg_write:
 289         *
 290         * Hook for writing a value to the register specified by address.
 291         */
 292        void (*reg_write)(void *ctx, uint32_t address, uint32_t value);
 293};
 294
 295/**
 296 * struct dmub_srv_hw_funcs - hardware sequencer funcs for dmub
 297 */
 298struct dmub_srv_hw_funcs {
 299        /* private: internal use only */
 300
 301        void (*init)(struct dmub_srv *dmub);
 302
 303        void (*reset)(struct dmub_srv *dmub);
 304
 305        void (*reset_release)(struct dmub_srv *dmub);
 306
 307        void (*backdoor_load)(struct dmub_srv *dmub,
 308                              const struct dmub_window *cw0,
 309                              const struct dmub_window *cw1);
 310
 311        void (*setup_windows)(struct dmub_srv *dmub,
 312                              const struct dmub_window *cw2,
 313                              const struct dmub_window *cw3,
 314                              const struct dmub_window *cw4,
 315                              const struct dmub_window *cw5,
 316                              const struct dmub_window *cw6);
 317
 318        void (*setup_mailbox)(struct dmub_srv *dmub,
 319                              const struct dmub_region *inbox1);
 320
 321        uint32_t (*get_inbox1_rptr)(struct dmub_srv *dmub);
 322
 323        void (*set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset);
 324
 325        void (*setup_out_mailbox)(struct dmub_srv *dmub,
 326                              const struct dmub_region *outbox1);
 327
 328        uint32_t (*get_outbox1_wptr)(struct dmub_srv *dmub);
 329
 330        void (*set_outbox1_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset);
 331
 332        void (*setup_outbox0)(struct dmub_srv *dmub,
 333                              const struct dmub_region *outbox0);
 334
 335        uint32_t (*get_outbox0_wptr)(struct dmub_srv *dmub);
 336
 337        void (*set_outbox0_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset);
 338
 339        uint32_t (*emul_get_inbox1_rptr)(struct dmub_srv *dmub);
 340
 341        void (*emul_set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset);
 342
 343        bool (*is_supported)(struct dmub_srv *dmub);
 344
 345        bool (*is_hw_init)(struct dmub_srv *dmub);
 346
 347        bool (*is_phy_init)(struct dmub_srv *dmub);
 348        void (*enable_dmub_boot_options)(struct dmub_srv *dmub,
 349                                const struct dmub_srv_hw_params *params);
 350
 351        void (*skip_dmub_panel_power_sequence)(struct dmub_srv *dmub, bool skip);
 352
 353        union dmub_fw_boot_status (*get_fw_status)(struct dmub_srv *dmub);
 354
 355
 356        void (*set_gpint)(struct dmub_srv *dmub,
 357                          union dmub_gpint_data_register reg);
 358
 359        bool (*is_gpint_acked)(struct dmub_srv *dmub,
 360                               union dmub_gpint_data_register reg);
 361
 362        uint32_t (*get_gpint_response)(struct dmub_srv *dmub);
 363
 364        uint32_t (*get_gpint_dataout)(struct dmub_srv *dmub);
 365
 366        void (*clear_inbox0_ack_register)(struct dmub_srv *dmub);
 367        uint32_t (*read_inbox0_ack_register)(struct dmub_srv *dmub);
 368        void (*send_inbox0_cmd)(struct dmub_srv *dmub, union dmub_inbox0_data_register data);
 369        uint32_t (*get_current_time)(struct dmub_srv *dmub);
 370
 371        void (*get_diagnostic_data)(struct dmub_srv *dmub, struct dmub_diagnostic_data *dmub_oca);
 372
 373        bool (*should_detect)(struct dmub_srv *dmub);
 374};
 375
 376/**
 377 * struct dmub_srv_create_params - params for dmub service creation
 378 * @base_funcs: driver supplied base routines
 379 * @hw_funcs: optional overrides for hw funcs
 380 * @user_ctx: context data for callback funcs
 381 * @asic: driver supplied asic
 382 * @fw_version: the current firmware version, if any
 383 * @is_virtual: false for hw support only
 384 */
 385struct dmub_srv_create_params {
 386        struct dmub_srv_base_funcs funcs;
 387        struct dmub_srv_hw_funcs *hw_funcs;
 388        void *user_ctx;
 389        enum dmub_asic asic;
 390        uint32_t fw_version;
 391        bool is_virtual;
 392};
 393
 394/**
 395 * struct dmub_srv - software state for dmcub
 396 * @asic: dmub asic identifier
 397 * @user_ctx: user provided context for the dmub_srv
 398 * @fw_version: the current firmware version, if any
 399 * @is_virtual: false if hardware support only
 400 * @fw_state: dmub firmware state pointer
 401 */
 402struct dmub_srv {
 403        enum dmub_asic asic;
 404        void *user_ctx;
 405        uint32_t fw_version;
 406        bool is_virtual;
 407        struct dmub_fb scratch_mem_fb;
 408        volatile const struct dmub_fw_state *fw_state;
 409
 410        /* private: internal use only */
 411        const struct dmub_srv_common_regs *regs;
 412        const struct dmub_srv_dcn31_regs *regs_dcn31;
 413
 414        struct dmub_srv_base_funcs funcs;
 415        struct dmub_srv_hw_funcs hw_funcs;
 416        struct dmub_rb inbox1_rb;
 417        uint32_t inbox1_last_wptr;
 418        /**
 419         * outbox1_rb is accessed without locks (dal & dc)
 420         * and to be used only in dmub_srv_stat_get_notification()
 421         */
 422        struct dmub_rb outbox1_rb;
 423
 424        struct dmub_rb outbox0_rb;
 425
 426        bool sw_init;
 427        bool hw_init;
 428
 429        uint64_t fb_base;
 430        uint64_t fb_offset;
 431        uint32_t psp_version;
 432
 433        /* Feature capabilities reported by fw */
 434        struct dmub_feature_caps feature_caps;
 435};
 436
 437/**
 438 * struct dmub_notification - dmub notification data
 439 * @type: dmub notification type
 440 * @link_index: link index to identify aux connection
 441 * @result: USB4 status returned from dmub
 442 * @pending_notification: Indicates there are other pending notifications
 443 * @aux_reply: aux reply
 444 * @hpd_status: hpd status
 445 */
 446struct dmub_notification {
 447        enum dmub_notification_type type;
 448        uint8_t link_index;
 449        uint8_t result;
 450        bool pending_notification;
 451        union {
 452                struct aux_reply_data aux_reply;
 453                enum dp_hpd_status hpd_status;
 454                enum set_config_status sc_status;
 455        };
 456};
 457
 458/**
 459 * DMUB firmware version helper macro - useful for checking if the version
 460 * of a firmware to know if feature or functionality is supported or present.
 461 */
 462#define DMUB_FW_VERSION(major, minor, revision) \
 463        ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF))
 464
 465/**
 466 * dmub_srv_create() - creates the DMUB service.
 467 * @dmub: the dmub service
 468 * @params: creation parameters for the service
 469 *
 470 * Return:
 471 *   DMUB_STATUS_OK - success
 472 *   DMUB_STATUS_INVALID - unspecified error
 473 */
 474enum dmub_status dmub_srv_create(struct dmub_srv *dmub,
 475                                 const struct dmub_srv_create_params *params);
 476
 477/**
 478 * dmub_srv_destroy() - destroys the DMUB service.
 479 * @dmub: the dmub service
 480 */
 481void dmub_srv_destroy(struct dmub_srv *dmub);
 482
 483/**
 484 * dmub_srv_calc_region_info() - retreives region info from the dmub service
 485 * @dmub: the dmub service
 486 * @params: parameters used to calculate region locations
 487 * @info_out: the output region info from dmub
 488 *
 489 * Calculates the base and top address for all relevant dmub regions
 490 * using the parameters given (if any).
 491 *
 492 * Return:
 493 *   DMUB_STATUS_OK - success
 494 *   DMUB_STATUS_INVALID - unspecified error
 495 */
 496enum dmub_status
 497dmub_srv_calc_region_info(struct dmub_srv *dmub,
 498                          const struct dmub_srv_region_params *params,
 499                          struct dmub_srv_region_info *out);
 500
 501/**
 502 * dmub_srv_calc_region_info() - retreives fb info from the dmub service
 503 * @dmub: the dmub service
 504 * @params: parameters used to calculate fb locations
 505 * @info_out: the output fb info from dmub
 506 *
 507 * Calculates the base and top address for all relevant dmub regions
 508 * using the parameters given (if any).
 509 *
 510 * Return:
 511 *   DMUB_STATUS_OK - success
 512 *   DMUB_STATUS_INVALID - unspecified error
 513 */
 514enum dmub_status dmub_srv_calc_fb_info(struct dmub_srv *dmub,
 515                                       const struct dmub_srv_fb_params *params,
 516                                       struct dmub_srv_fb_info *out);
 517
 518/**
 519 * dmub_srv_has_hw_support() - returns hw support state for dmcub
 520 * @dmub: the dmub service
 521 * @is_supported: hw support state
 522 *
 523 * Queries the hardware for DMCUB support and returns the result.
 524 *
 525 * Can be called before dmub_srv_hw_init().
 526 *
 527 * Return:
 528 *   DMUB_STATUS_OK - success
 529 *   DMUB_STATUS_INVALID - unspecified error
 530 */
 531enum dmub_status dmub_srv_has_hw_support(struct dmub_srv *dmub,
 532                                         bool *is_supported);
 533
 534/**
 535 * dmub_srv_is_hw_init() - returns hardware init state
 536 *
 537 * Return:
 538 *   DMUB_STATUS_OK - success
 539 *   DMUB_STATUS_INVALID - unspecified error
 540 */
 541enum dmub_status dmub_srv_is_hw_init(struct dmub_srv *dmub, bool *is_hw_init);
 542
 543/**
 544 * dmub_srv_hw_init() - initializes the underlying DMUB hardware
 545 * @dmub: the dmub service
 546 * @params: params for hardware initialization
 547 *
 548 * Resets the DMUB hardware and performs backdoor loading of the
 549 * required cache regions based on the input framebuffer regions.
 550 *
 551 * Return:
 552 *   DMUB_STATUS_OK - success
 553 *   DMUB_STATUS_NO_CTX - dmcub context not initialized
 554 *   DMUB_STATUS_INVALID - unspecified error
 555 */
 556enum dmub_status dmub_srv_hw_init(struct dmub_srv *dmub,
 557                                  const struct dmub_srv_hw_params *params);
 558
 559/**
 560 * dmub_srv_hw_reset() - puts the DMUB hardware in reset state if initialized
 561 * @dmub: the dmub service
 562 *
 563 * Before destroying the DMUB service or releasing the backing framebuffer
 564 * memory we'll need to put the DMCUB into reset first.
 565 *
 566 * A subsequent call to dmub_srv_hw_init() will re-enable the DMCUB.
 567 *
 568 * Return:
 569 *   DMUB_STATUS_OK - success
 570 *   DMUB_STATUS_INVALID - unspecified error
 571 */
 572enum dmub_status dmub_srv_hw_reset(struct dmub_srv *dmub);
 573
 574/**
 575 * dmub_srv_cmd_queue() - queues a command to the DMUB
 576 * @dmub: the dmub service
 577 * @cmd: the command to queue
 578 *
 579 * Queues a command to the DMUB service but does not begin execution
 580 * immediately.
 581 *
 582 * Return:
 583 *   DMUB_STATUS_OK - success
 584 *   DMUB_STATUS_QUEUE_FULL - no remaining room in queue
 585 *   DMUB_STATUS_INVALID - unspecified error
 586 */
 587enum dmub_status dmub_srv_cmd_queue(struct dmub_srv *dmub,
 588                                    const union dmub_rb_cmd *cmd);
 589
 590/**
 591 * dmub_srv_cmd_execute() - Executes a queued sequence to the dmub
 592 * @dmub: the dmub service
 593 *
 594 * Begins execution of queued commands on the dmub.
 595 *
 596 * Return:
 597 *   DMUB_STATUS_OK - success
 598 *   DMUB_STATUS_INVALID - unspecified error
 599 */
 600enum dmub_status dmub_srv_cmd_execute(struct dmub_srv *dmub);
 601
 602/**
 603 * dmub_srv_wait_for_auto_load() - Waits for firmware auto load to complete
 604 * @dmub: the dmub service
 605 * @timeout_us: the maximum number of microseconds to wait
 606 *
 607 * Waits until firmware has been autoloaded by the DMCUB. The maximum
 608 * wait time is given in microseconds to prevent spinning forever.
 609 *
 610 * On ASICs without firmware autoload support this function will return
 611 * immediately.
 612 *
 613 * Return:
 614 *   DMUB_STATUS_OK - success
 615 *   DMUB_STATUS_TIMEOUT - wait for phy init timed out
 616 *   DMUB_STATUS_INVALID - unspecified error
 617 */
 618enum dmub_status dmub_srv_wait_for_auto_load(struct dmub_srv *dmub,
 619                                             uint32_t timeout_us);
 620
 621/**
 622 * dmub_srv_wait_for_phy_init() - Waits for DMUB PHY init to complete
 623 * @dmub: the dmub service
 624 * @timeout_us: the maximum number of microseconds to wait
 625 *
 626 * Waits until the PHY has been initialized by the DMUB. The maximum
 627 * wait time is given in microseconds to prevent spinning forever.
 628 *
 629 * On ASICs without PHY init support this function will return
 630 * immediately.
 631 *
 632 * Return:
 633 *   DMUB_STATUS_OK - success
 634 *   DMUB_STATUS_TIMEOUT - wait for phy init timed out
 635 *   DMUB_STATUS_INVALID - unspecified error
 636 */
 637enum dmub_status dmub_srv_wait_for_phy_init(struct dmub_srv *dmub,
 638                                            uint32_t timeout_us);
 639
 640/**
 641 * dmub_srv_wait_for_idle() - Waits for the DMUB to be idle
 642 * @dmub: the dmub service
 643 * @timeout_us: the maximum number of microseconds to wait
 644 *
 645 * Waits until the DMUB buffer is empty and all commands have
 646 * finished processing. The maximum wait time is given in
 647 * microseconds to prevent spinning forever.
 648 *
 649 * Return:
 650 *   DMUB_STATUS_OK - success
 651 *   DMUB_STATUS_TIMEOUT - wait for buffer to flush timed out
 652 *   DMUB_STATUS_INVALID - unspecified error
 653 */
 654enum dmub_status dmub_srv_wait_for_idle(struct dmub_srv *dmub,
 655                                        uint32_t timeout_us);
 656
 657/**
 658 * dmub_srv_send_gpint_command() - Sends a GPINT based command.
 659 * @dmub: the dmub service
 660 * @command_code: the command code to send
 661 * @param: the command parameter to send
 662 * @timeout_us: the maximum number of microseconds to wait
 663 *
 664 * Sends a command via the general purpose interrupt (GPINT).
 665 * Waits for the number of microseconds specified by timeout_us
 666 * for the command ACK before returning.
 667 *
 668 * Can be called after software initialization.
 669 *
 670 * Return:
 671 *   DMUB_STATUS_OK - success
 672 *   DMUB_STATUS_TIMEOUT - wait for ACK timed out
 673 *   DMUB_STATUS_INVALID - unspecified error
 674 */
 675enum dmub_status
 676dmub_srv_send_gpint_command(struct dmub_srv *dmub,
 677                            enum dmub_gpint_command command_code,
 678                            uint16_t param, uint32_t timeout_us);
 679
 680/**
 681 * dmub_srv_get_gpint_response() - Queries the GPINT response.
 682 * @dmub: the dmub service
 683 * @response: the response for the last GPINT
 684 *
 685 * Returns the response code for the last GPINT interrupt.
 686 *
 687 * Can be called after software initialization.
 688 *
 689 * Return:
 690 *   DMUB_STATUS_OK - success
 691 *   DMUB_STATUS_INVALID - unspecified error
 692 */
 693enum dmub_status dmub_srv_get_gpint_response(struct dmub_srv *dmub,
 694                                             uint32_t *response);
 695
 696/**
 697 * dmub_srv_get_gpint_dataout() - Queries the GPINT DATAOUT.
 698 * @dmub: the dmub service
 699 * @dataout: the data for the GPINT DATAOUT
 700 *
 701 * Returns the response code for the last GPINT DATAOUT interrupt.
 702 *
 703 * Can be called after software initialization.
 704 *
 705 * Return:
 706 *   DMUB_STATUS_OK - success
 707 *   DMUB_STATUS_INVALID - unspecified error
 708 */
 709enum dmub_status dmub_srv_get_gpint_dataout(struct dmub_srv *dmub,
 710                                             uint32_t *dataout);
 711
 712/**
 713 * dmub_flush_buffer_mem() - Read back entire frame buffer region.
 714 * This ensures that the write from x86 has been flushed and will not
 715 * hang the DMCUB.
 716 * @fb: frame buffer to flush
 717 *
 718 * Can be called after software initialization.
 719 */
 720void dmub_flush_buffer_mem(const struct dmub_fb *fb);
 721
 722/**
 723 * dmub_srv_get_fw_boot_status() - Returns the DMUB boot status bits.
 724 *
 725 * @dmub: the dmub service
 726 * @status: out pointer for firmware status
 727 *
 728 * Return:
 729 *   DMUB_STATUS_OK - success
 730 *   DMUB_STATUS_INVALID - unspecified error, unsupported
 731 */
 732enum dmub_status dmub_srv_get_fw_boot_status(struct dmub_srv *dmub,
 733                                             union dmub_fw_boot_status *status);
 734
 735enum dmub_status dmub_srv_cmd_with_reply_data(struct dmub_srv *dmub,
 736                                              union dmub_rb_cmd *cmd);
 737
 738bool dmub_srv_get_outbox0_msg(struct dmub_srv *dmub, struct dmcub_trace_buf_entry *entry);
 739
 740bool dmub_srv_get_diagnostic_data(struct dmub_srv *dmub, struct dmub_diagnostic_data *diag_data);
 741
 742bool dmub_srv_should_detect(struct dmub_srv *dmub);
 743
 744/**
 745 * dmub_srv_send_inbox0_cmd() - Send command to DMUB using INBOX0
 746 * @dmub: the dmub service
 747 * @data: the data to be sent in the INBOX0 command
 748 *
 749 * Send command by writing directly to INBOX0 WPTR
 750 *
 751 * Return:
 752 *   DMUB_STATUS_OK - success
 753 *   DMUB_STATUS_INVALID - hw_init false or hw function does not exist
 754 */
 755enum dmub_status dmub_srv_send_inbox0_cmd(struct dmub_srv *dmub, union dmub_inbox0_data_register data);
 756
 757/**
 758 * dmub_srv_wait_for_inbox0_ack() - wait for DMUB to ACK INBOX0 command
 759 * @dmub: the dmub service
 760 * @timeout_us: the maximum number of microseconds to wait
 761 *
 762 * Wait for DMUB to ACK the INBOX0 message
 763 *
 764 * Return:
 765 *   DMUB_STATUS_OK - success
 766 *   DMUB_STATUS_INVALID - hw_init false or hw function does not exist
 767 *   DMUB_STATUS_TIMEOUT - wait for ack timed out
 768 */
 769enum dmub_status dmub_srv_wait_for_inbox0_ack(struct dmub_srv *dmub, uint32_t timeout_us);
 770
 771/**
 772 * dmub_srv_wait_for_inbox0_ack() - clear ACK register for INBOX0
 773 * @dmub: the dmub service
 774 *
 775 * Clear ACK register for INBOX0
 776 *
 777 * Return:
 778 *   DMUB_STATUS_OK - success
 779 *   DMUB_STATUS_INVALID - hw_init false or hw function does not exist
 780 */
 781enum dmub_status dmub_srv_clear_inbox0_ack(struct dmub_srv *dmub);
 782
 783#if defined(__cplusplus)
 784}
 785#endif
 786
 787#endif /* _DMUB_SRV_H_ */
 788