Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2019 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 
0026 #ifndef _DMUB_SRV_H_
0027 #define _DMUB_SRV_H_
0028 
0029 /**
0030  * DOC: DMUB interface and operation
0031  *
0032  * DMUB is the interface to the display DMCUB microcontroller on DCN hardware.
0033  * It delegates hardware initialization and command submission to the
0034  * microcontroller. DMUB is the shortname for DMCUB.
0035  *
0036  * This interface is not thread-safe. Ensure that all access to the interface
0037  * is properly synchronized by the caller.
0038  *
0039  * Initialization and usage of the DMUB service should be done in the
0040  * steps given below:
0041  *
0042  * 1. dmub_srv_create()
0043  * 2. dmub_srv_has_hw_support()
0044  * 3. dmub_srv_calc_region_info()
0045  * 4. dmub_srv_hw_init()
0046  *
0047  * The call to dmub_srv_create() is required to use the server.
0048  *
0049  * The calls to dmub_srv_has_hw_support() and dmub_srv_calc_region_info()
0050  * are helpers to query cache window size and allocate framebuffer(s)
0051  * for the cache windows.
0052  *
0053  * The call to dmub_srv_hw_init() programs the DMCUB registers to prepare
0054  * for command submission. Commands can be queued via dmub_srv_cmd_queue()
0055  * and executed via dmub_srv_cmd_execute().
0056  *
0057  * If the queue is full the dmub_srv_wait_for_idle() call can be used to
0058  * wait until the queue has been cleared.
0059  *
0060  * Destroying the DMUB service can be done by calling dmub_srv_destroy().
0061  * This does not clear DMUB hardware state, only software state.
0062  *
0063  * The interface is intended to be standalone and should not depend on any
0064  * other component within DAL.
0065  */
0066 
0067 #include "inc/dmub_cmd.h"
0068 
0069 #if defined(__cplusplus)
0070 extern "C" {
0071 #endif
0072 
0073 /* Forward declarations */
0074 struct dmub_srv;
0075 struct dmub_srv_common_regs;
0076 struct dmub_srv_dcn31_regs;
0077 
0078 struct dmcub_trace_buf_entry;
0079 
0080 /* enum dmub_status - return code for dmcub functions */
0081 enum dmub_status {
0082     DMUB_STATUS_OK = 0,
0083     DMUB_STATUS_NO_CTX,
0084     DMUB_STATUS_QUEUE_FULL,
0085     DMUB_STATUS_TIMEOUT,
0086     DMUB_STATUS_INVALID,
0087     DMUB_STATUS_HW_FAILURE,
0088 };
0089 
0090 /* enum dmub_asic - dmub asic identifier */
0091 enum dmub_asic {
0092     DMUB_ASIC_NONE = 0,
0093     DMUB_ASIC_DCN20,
0094     DMUB_ASIC_DCN21,
0095     DMUB_ASIC_DCN30,
0096     DMUB_ASIC_DCN301,
0097     DMUB_ASIC_DCN302,
0098     DMUB_ASIC_DCN303,
0099     DMUB_ASIC_DCN31,
0100     DMUB_ASIC_DCN31B,
0101     DMUB_ASIC_DCN314,
0102     DMUB_ASIC_DCN315,
0103     DMUB_ASIC_DCN316,
0104     DMUB_ASIC_DCN32,
0105     DMUB_ASIC_DCN321,
0106     DMUB_ASIC_MAX,
0107 };
0108 
0109 /* enum dmub_window_id - dmub window identifier */
0110 enum dmub_window_id {
0111     DMUB_WINDOW_0_INST_CONST = 0,
0112     DMUB_WINDOW_1_STACK,
0113     DMUB_WINDOW_2_BSS_DATA,
0114     DMUB_WINDOW_3_VBIOS,
0115     DMUB_WINDOW_4_MAILBOX,
0116     DMUB_WINDOW_5_TRACEBUFF,
0117     DMUB_WINDOW_6_FW_STATE,
0118     DMUB_WINDOW_7_SCRATCH_MEM,
0119     DMUB_WINDOW_TOTAL,
0120 };
0121 
0122 /* enum dmub_notification_type - dmub outbox notification identifier */
0123 enum dmub_notification_type {
0124     DMUB_NOTIFICATION_NO_DATA = 0,
0125     DMUB_NOTIFICATION_AUX_REPLY,
0126     DMUB_NOTIFICATION_HPD,
0127     DMUB_NOTIFICATION_HPD_IRQ,
0128     DMUB_NOTIFICATION_SET_CONFIG_REPLY,
0129     DMUB_NOTIFICATION_MAX
0130 };
0131 
0132 /**
0133  * struct dmub_region - dmub hw memory region
0134  * @base: base address for region, must be 256 byte aligned
0135  * @top: top address for region
0136  */
0137 struct dmub_region {
0138     uint32_t base;
0139     uint32_t top;
0140 };
0141 
0142 /**
0143  * struct dmub_window - dmub hw cache window
0144  * @off: offset to the fb memory in gpu address space
0145  * @r: region in uc address space for cache window
0146  */
0147 struct dmub_window {
0148     union dmub_addr offset;
0149     struct dmub_region region;
0150 };
0151 
0152 /**
0153  * struct dmub_fb - defines a dmub framebuffer memory region
0154  * @cpu_addr: cpu virtual address for the region, NULL if invalid
0155  * @gpu_addr: gpu virtual address for the region, NULL if invalid
0156  * @size: size of the region in bytes, zero if invalid
0157  */
0158 struct dmub_fb {
0159     void *cpu_addr;
0160     uint64_t gpu_addr;
0161     uint32_t size;
0162 };
0163 
0164 /**
0165  * struct dmub_srv_region_params - params used for calculating dmub regions
0166  * @inst_const_size: size of the fw inst const section
0167  * @bss_data_size: size of the fw bss data section
0168  * @vbios_size: size of the vbios data
0169  * @fw_bss_data: raw firmware bss data section
0170  */
0171 struct dmub_srv_region_params {
0172     uint32_t inst_const_size;
0173     uint32_t bss_data_size;
0174     uint32_t vbios_size;
0175     const uint8_t *fw_inst_const;
0176     const uint8_t *fw_bss_data;
0177 };
0178 
0179 /**
0180  * struct dmub_srv_region_info - output region info from the dmub service
0181  * @fb_size: required minimum fb size for all regions, aligned to 4096 bytes
0182  * @num_regions: number of regions used by the dmub service
0183  * @regions: region info
0184  *
0185  * The regions are aligned such that they can be all placed within the
0186  * same framebuffer but they can also be placed into different framebuffers.
0187  *
0188  * The size of each region can be calculated by the caller:
0189  * size = reg.top - reg.base
0190  *
0191  * Care must be taken when performing custom allocations to ensure that each
0192  * region base address is 256 byte aligned.
0193  */
0194 struct dmub_srv_region_info {
0195     uint32_t fb_size;
0196     uint8_t num_regions;
0197     struct dmub_region regions[DMUB_WINDOW_TOTAL];
0198 };
0199 
0200 /**
0201  * struct dmub_srv_fb_params - parameters used for driver fb setup
0202  * @region_info: region info calculated by dmub service
0203  * @cpu_addr: base cpu address for the framebuffer
0204  * @gpu_addr: base gpu virtual address for the framebuffer
0205  */
0206 struct dmub_srv_fb_params {
0207     const struct dmub_srv_region_info *region_info;
0208     void *cpu_addr;
0209     uint64_t gpu_addr;
0210 };
0211 
0212 /**
0213  * struct dmub_srv_fb_info - output fb info from the dmub service
0214  * @num_fbs: number of required dmub framebuffers
0215  * @fbs: fb data for each region
0216  *
0217  * Output from the dmub service helper that can be used by the
0218  * driver to prepare dmub_fb that can be passed into the dmub
0219  * hw init service.
0220  *
0221  * Assumes that all regions are within the same framebuffer
0222  * and have been setup according to the region_info generated
0223  * by the dmub service.
0224  */
0225 struct dmub_srv_fb_info {
0226     uint8_t num_fb;
0227     struct dmub_fb fb[DMUB_WINDOW_TOTAL];
0228 };
0229 
0230 /*
0231  * struct dmub_srv_hw_params - params for dmub hardware initialization
0232  * @fb: framebuffer info for each region
0233  * @fb_base: base of the framebuffer aperture
0234  * @fb_offset: offset of the framebuffer aperture
0235  * @psp_version: psp version to pass for DMCU init
0236  * @load_inst_const: true if DMUB should load inst const fw
0237  */
0238 struct dmub_srv_hw_params {
0239     struct dmub_fb *fb[DMUB_WINDOW_TOTAL];
0240     uint64_t fb_base;
0241     uint64_t fb_offset;
0242     uint32_t psp_version;
0243     bool load_inst_const;
0244     bool skip_panel_power_sequence;
0245     bool disable_z10;
0246     bool power_optimization;
0247     bool dpia_supported;
0248     bool disable_dpia;
0249     bool usb4_cm_version;
0250     bool fw_in_system_memory;
0251 };
0252 
0253 /**
0254  * struct dmub_diagnostic_data - Diagnostic data retrieved from DMCUB for
0255  * debugging purposes, including logging, crash analysis, etc.
0256  */
0257 struct dmub_diagnostic_data {
0258     uint32_t dmcub_version;
0259     uint32_t scratch[16];
0260     uint32_t pc;
0261     uint32_t undefined_address_fault_addr;
0262     uint32_t inst_fetch_fault_addr;
0263     uint32_t data_write_fault_addr;
0264     uint32_t inbox1_rptr;
0265     uint32_t inbox1_wptr;
0266     uint32_t inbox1_size;
0267     uint32_t inbox0_rptr;
0268     uint32_t inbox0_wptr;
0269     uint32_t inbox0_size;
0270     uint8_t is_dmcub_enabled : 1;
0271     uint8_t is_dmcub_soft_reset : 1;
0272     uint8_t is_dmcub_secure_reset : 1;
0273     uint8_t is_traceport_en : 1;
0274     uint8_t is_cw0_enabled : 1;
0275     uint8_t is_cw6_enabled : 1;
0276 };
0277 
0278 /**
0279  * struct dmub_srv_base_funcs - Driver specific base callbacks
0280  */
0281 struct dmub_srv_base_funcs {
0282     /**
0283      * @reg_read:
0284      *
0285      * Hook for reading a register.
0286      *
0287      * Return: The 32-bit register value from the given address.
0288      */
0289     uint32_t (*reg_read)(void *ctx, uint32_t address);
0290 
0291     /**
0292      * @reg_write:
0293      *
0294      * Hook for writing a value to the register specified by address.
0295      */
0296     void (*reg_write)(void *ctx, uint32_t address, uint32_t value);
0297 };
0298 
0299 /**
0300  * struct dmub_srv_hw_funcs - hardware sequencer funcs for dmub
0301  */
0302 struct dmub_srv_hw_funcs {
0303     /* private: internal use only */
0304 
0305     void (*init)(struct dmub_srv *dmub);
0306 
0307     void (*reset)(struct dmub_srv *dmub);
0308 
0309     void (*reset_release)(struct dmub_srv *dmub);
0310 
0311     void (*backdoor_load)(struct dmub_srv *dmub,
0312                   const struct dmub_window *cw0,
0313                   const struct dmub_window *cw1);
0314 
0315     void (*backdoor_load_zfb_mode)(struct dmub_srv *dmub,
0316                   const struct dmub_window *cw0,
0317                   const struct dmub_window *cw1);
0318     void (*setup_windows)(struct dmub_srv *dmub,
0319                   const struct dmub_window *cw2,
0320                   const struct dmub_window *cw3,
0321                   const struct dmub_window *cw4,
0322                   const struct dmub_window *cw5,
0323                   const struct dmub_window *cw6);
0324 
0325     void (*setup_mailbox)(struct dmub_srv *dmub,
0326                   const struct dmub_region *inbox1);
0327 
0328     uint32_t (*get_inbox1_rptr)(struct dmub_srv *dmub);
0329 
0330     void (*set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset);
0331 
0332     void (*setup_out_mailbox)(struct dmub_srv *dmub,
0333                   const struct dmub_region *outbox1);
0334 
0335     uint32_t (*get_outbox1_wptr)(struct dmub_srv *dmub);
0336 
0337     void (*set_outbox1_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset);
0338 
0339     void (*setup_outbox0)(struct dmub_srv *dmub,
0340                   const struct dmub_region *outbox0);
0341 
0342     uint32_t (*get_outbox0_wptr)(struct dmub_srv *dmub);
0343 
0344     void (*set_outbox0_rptr)(struct dmub_srv *dmub, uint32_t rptr_offset);
0345 
0346     uint32_t (*emul_get_inbox1_rptr)(struct dmub_srv *dmub);
0347 
0348     void (*emul_set_inbox1_wptr)(struct dmub_srv *dmub, uint32_t wptr_offset);
0349 
0350     bool (*is_supported)(struct dmub_srv *dmub);
0351 
0352     bool (*is_hw_init)(struct dmub_srv *dmub);
0353 
0354     bool (*is_phy_init)(struct dmub_srv *dmub);
0355     void (*enable_dmub_boot_options)(struct dmub_srv *dmub,
0356                 const struct dmub_srv_hw_params *params);
0357 
0358     void (*skip_dmub_panel_power_sequence)(struct dmub_srv *dmub, bool skip);
0359 
0360     union dmub_fw_boot_status (*get_fw_status)(struct dmub_srv *dmub);
0361 
0362 
0363     void (*set_gpint)(struct dmub_srv *dmub,
0364               union dmub_gpint_data_register reg);
0365 
0366     bool (*is_gpint_acked)(struct dmub_srv *dmub,
0367                    union dmub_gpint_data_register reg);
0368 
0369     uint32_t (*get_gpint_response)(struct dmub_srv *dmub);
0370 
0371     uint32_t (*get_gpint_dataout)(struct dmub_srv *dmub);
0372 
0373     void (*configure_dmub_in_system_memory)(struct dmub_srv *dmub);
0374     void (*clear_inbox0_ack_register)(struct dmub_srv *dmub);
0375     uint32_t (*read_inbox0_ack_register)(struct dmub_srv *dmub);
0376     void (*send_inbox0_cmd)(struct dmub_srv *dmub, union dmub_inbox0_data_register data);
0377     uint32_t (*get_current_time)(struct dmub_srv *dmub);
0378 
0379     void (*get_diagnostic_data)(struct dmub_srv *dmub, struct dmub_diagnostic_data *dmub_oca);
0380 
0381     bool (*should_detect)(struct dmub_srv *dmub);
0382 };
0383 
0384 /**
0385  * struct dmub_srv_create_params - params for dmub service creation
0386  * @base_funcs: driver supplied base routines
0387  * @hw_funcs: optional overrides for hw funcs
0388  * @user_ctx: context data for callback funcs
0389  * @asic: driver supplied asic
0390  * @fw_version: the current firmware version, if any
0391  * @is_virtual: false for hw support only
0392  */
0393 struct dmub_srv_create_params {
0394     struct dmub_srv_base_funcs funcs;
0395     struct dmub_srv_hw_funcs *hw_funcs;
0396     void *user_ctx;
0397     enum dmub_asic asic;
0398     uint32_t fw_version;
0399     bool is_virtual;
0400 };
0401 
0402 /**
0403  * struct dmub_srv - software state for dmcub
0404  * @asic: dmub asic identifier
0405  * @user_ctx: user provided context for the dmub_srv
0406  * @fw_version: the current firmware version, if any
0407  * @is_virtual: false if hardware support only
0408  * @fw_state: dmub firmware state pointer
0409  */
0410 struct dmub_srv {
0411     enum dmub_asic asic;
0412     void *user_ctx;
0413     uint32_t fw_version;
0414     bool is_virtual;
0415     struct dmub_fb scratch_mem_fb;
0416     volatile const struct dmub_fw_state *fw_state;
0417 
0418     /* private: internal use only */
0419     const struct dmub_srv_common_regs *regs;
0420     const struct dmub_srv_dcn31_regs *regs_dcn31;
0421     const struct dmub_srv_dcn32_regs *regs_dcn32;
0422 
0423     struct dmub_srv_base_funcs funcs;
0424     struct dmub_srv_hw_funcs hw_funcs;
0425     struct dmub_rb inbox1_rb;
0426     uint32_t inbox1_last_wptr;
0427     /**
0428      * outbox1_rb is accessed without locks (dal & dc)
0429      * and to be used only in dmub_srv_stat_get_notification()
0430      */
0431     struct dmub_rb outbox1_rb;
0432 
0433     struct dmub_rb outbox0_rb;
0434 
0435     bool sw_init;
0436     bool hw_init;
0437 
0438     uint64_t fb_base;
0439     uint64_t fb_offset;
0440     uint32_t psp_version;
0441 
0442     /* Feature capabilities reported by fw */
0443     struct dmub_feature_caps feature_caps;
0444 };
0445 
0446 /**
0447  * struct dmub_notification - dmub notification data
0448  * @type: dmub notification type
0449  * @link_index: link index to identify aux connection
0450  * @result: USB4 status returned from dmub
0451  * @pending_notification: Indicates there are other pending notifications
0452  * @aux_reply: aux reply
0453  * @hpd_status: hpd status
0454  */
0455 struct dmub_notification {
0456     enum dmub_notification_type type;
0457     uint8_t link_index;
0458     uint8_t result;
0459     bool pending_notification;
0460     union {
0461         struct aux_reply_data aux_reply;
0462         enum dp_hpd_status hpd_status;
0463         enum set_config_status sc_status;
0464     };
0465 };
0466 
0467 /**
0468  * DMUB firmware version helper macro - useful for checking if the version
0469  * of a firmware to know if feature or functionality is supported or present.
0470  */
0471 #define DMUB_FW_VERSION(major, minor, revision) \
0472     ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((revision) & 0xFFFF))
0473 
0474 /**
0475  * dmub_srv_create() - creates the DMUB service.
0476  * @dmub: the dmub service
0477  * @params: creation parameters for the service
0478  *
0479  * Return:
0480  *   DMUB_STATUS_OK - success
0481  *   DMUB_STATUS_INVALID - unspecified error
0482  */
0483 enum dmub_status dmub_srv_create(struct dmub_srv *dmub,
0484                  const struct dmub_srv_create_params *params);
0485 
0486 /**
0487  * dmub_srv_destroy() - destroys the DMUB service.
0488  * @dmub: the dmub service
0489  */
0490 void dmub_srv_destroy(struct dmub_srv *dmub);
0491 
0492 /**
0493  * dmub_srv_calc_region_info() - retreives region info from the dmub service
0494  * @dmub: the dmub service
0495  * @params: parameters used to calculate region locations
0496  * @info_out: the output region info from dmub
0497  *
0498  * Calculates the base and top address for all relevant dmub regions
0499  * using the parameters given (if any).
0500  *
0501  * Return:
0502  *   DMUB_STATUS_OK - success
0503  *   DMUB_STATUS_INVALID - unspecified error
0504  */
0505 enum dmub_status
0506 dmub_srv_calc_region_info(struct dmub_srv *dmub,
0507               const struct dmub_srv_region_params *params,
0508               struct dmub_srv_region_info *out);
0509 
0510 /**
0511  * dmub_srv_calc_region_info() - retreives fb info from the dmub service
0512  * @dmub: the dmub service
0513  * @params: parameters used to calculate fb locations
0514  * @info_out: the output fb info from dmub
0515  *
0516  * Calculates the base and top address for all relevant dmub regions
0517  * using the parameters given (if any).
0518  *
0519  * Return:
0520  *   DMUB_STATUS_OK - success
0521  *   DMUB_STATUS_INVALID - unspecified error
0522  */
0523 enum dmub_status dmub_srv_calc_fb_info(struct dmub_srv *dmub,
0524                        const struct dmub_srv_fb_params *params,
0525                        struct dmub_srv_fb_info *out);
0526 
0527 /**
0528  * dmub_srv_has_hw_support() - returns hw support state for dmcub
0529  * @dmub: the dmub service
0530  * @is_supported: hw support state
0531  *
0532  * Queries the hardware for DMCUB support and returns the result.
0533  *
0534  * Can be called before dmub_srv_hw_init().
0535  *
0536  * Return:
0537  *   DMUB_STATUS_OK - success
0538  *   DMUB_STATUS_INVALID - unspecified error
0539  */
0540 enum dmub_status dmub_srv_has_hw_support(struct dmub_srv *dmub,
0541                      bool *is_supported);
0542 
0543 /**
0544  * dmub_srv_is_hw_init() - returns hardware init state
0545  *
0546  * Return:
0547  *   DMUB_STATUS_OK - success
0548  *   DMUB_STATUS_INVALID - unspecified error
0549  */
0550 enum dmub_status dmub_srv_is_hw_init(struct dmub_srv *dmub, bool *is_hw_init);
0551 
0552 /**
0553  * dmub_srv_hw_init() - initializes the underlying DMUB hardware
0554  * @dmub: the dmub service
0555  * @params: params for hardware initialization
0556  *
0557  * Resets the DMUB hardware and performs backdoor loading of the
0558  * required cache regions based on the input framebuffer regions.
0559  *
0560  * Return:
0561  *   DMUB_STATUS_OK - success
0562  *   DMUB_STATUS_NO_CTX - dmcub context not initialized
0563  *   DMUB_STATUS_INVALID - unspecified error
0564  */
0565 enum dmub_status dmub_srv_hw_init(struct dmub_srv *dmub,
0566                   const struct dmub_srv_hw_params *params);
0567 
0568 /**
0569  * dmub_srv_hw_reset() - puts the DMUB hardware in reset state if initialized
0570  * @dmub: the dmub service
0571  *
0572  * Before destroying the DMUB service or releasing the backing framebuffer
0573  * memory we'll need to put the DMCUB into reset first.
0574  *
0575  * A subsequent call to dmub_srv_hw_init() will re-enable the DMCUB.
0576  *
0577  * Return:
0578  *   DMUB_STATUS_OK - success
0579  *   DMUB_STATUS_INVALID - unspecified error
0580  */
0581 enum dmub_status dmub_srv_hw_reset(struct dmub_srv *dmub);
0582 
0583 /**
0584  * dmub_srv_cmd_queue() - queues a command to the DMUB
0585  * @dmub: the dmub service
0586  * @cmd: the command to queue
0587  *
0588  * Queues a command to the DMUB service but does not begin execution
0589  * immediately.
0590  *
0591  * Return:
0592  *   DMUB_STATUS_OK - success
0593  *   DMUB_STATUS_QUEUE_FULL - no remaining room in queue
0594  *   DMUB_STATUS_INVALID - unspecified error
0595  */
0596 enum dmub_status dmub_srv_cmd_queue(struct dmub_srv *dmub,
0597                     const union dmub_rb_cmd *cmd);
0598 
0599 /**
0600  * dmub_srv_cmd_execute() - Executes a queued sequence to the dmub
0601  * @dmub: the dmub service
0602  *
0603  * Begins execution of queued commands on the dmub.
0604  *
0605  * Return:
0606  *   DMUB_STATUS_OK - success
0607  *   DMUB_STATUS_INVALID - unspecified error
0608  */
0609 enum dmub_status dmub_srv_cmd_execute(struct dmub_srv *dmub);
0610 
0611 /**
0612  * dmub_srv_wait_for_auto_load() - Waits for firmware auto load to complete
0613  * @dmub: the dmub service
0614  * @timeout_us: the maximum number of microseconds to wait
0615  *
0616  * Waits until firmware has been autoloaded by the DMCUB. The maximum
0617  * wait time is given in microseconds to prevent spinning forever.
0618  *
0619  * On ASICs without firmware autoload support this function will return
0620  * immediately.
0621  *
0622  * Return:
0623  *   DMUB_STATUS_OK - success
0624  *   DMUB_STATUS_TIMEOUT - wait for phy init timed out
0625  *   DMUB_STATUS_INVALID - unspecified error
0626  */
0627 enum dmub_status dmub_srv_wait_for_auto_load(struct dmub_srv *dmub,
0628                          uint32_t timeout_us);
0629 
0630 /**
0631  * dmub_srv_wait_for_phy_init() - Waits for DMUB PHY init to complete
0632  * @dmub: the dmub service
0633  * @timeout_us: the maximum number of microseconds to wait
0634  *
0635  * Waits until the PHY has been initialized by the DMUB. The maximum
0636  * wait time is given in microseconds to prevent spinning forever.
0637  *
0638  * On ASICs without PHY init support this function will return
0639  * immediately.
0640  *
0641  * Return:
0642  *   DMUB_STATUS_OK - success
0643  *   DMUB_STATUS_TIMEOUT - wait for phy init timed out
0644  *   DMUB_STATUS_INVALID - unspecified error
0645  */
0646 enum dmub_status dmub_srv_wait_for_phy_init(struct dmub_srv *dmub,
0647                         uint32_t timeout_us);
0648 
0649 /**
0650  * dmub_srv_wait_for_idle() - Waits for the DMUB to be idle
0651  * @dmub: the dmub service
0652  * @timeout_us: the maximum number of microseconds to wait
0653  *
0654  * Waits until the DMUB buffer is empty and all commands have
0655  * finished processing. The maximum wait time is given in
0656  * microseconds to prevent spinning forever.
0657  *
0658  * Return:
0659  *   DMUB_STATUS_OK - success
0660  *   DMUB_STATUS_TIMEOUT - wait for buffer to flush timed out
0661  *   DMUB_STATUS_INVALID - unspecified error
0662  */
0663 enum dmub_status dmub_srv_wait_for_idle(struct dmub_srv *dmub,
0664                     uint32_t timeout_us);
0665 
0666 /**
0667  * dmub_srv_send_gpint_command() - Sends a GPINT based command.
0668  * @dmub: the dmub service
0669  * @command_code: the command code to send
0670  * @param: the command parameter to send
0671  * @timeout_us: the maximum number of microseconds to wait
0672  *
0673  * Sends a command via the general purpose interrupt (GPINT).
0674  * Waits for the number of microseconds specified by timeout_us
0675  * for the command ACK before returning.
0676  *
0677  * Can be called after software initialization.
0678  *
0679  * Return:
0680  *   DMUB_STATUS_OK - success
0681  *   DMUB_STATUS_TIMEOUT - wait for ACK timed out
0682  *   DMUB_STATUS_INVALID - unspecified error
0683  */
0684 enum dmub_status
0685 dmub_srv_send_gpint_command(struct dmub_srv *dmub,
0686                 enum dmub_gpint_command command_code,
0687                 uint16_t param, uint32_t timeout_us);
0688 
0689 /**
0690  * dmub_srv_get_gpint_response() - Queries the GPINT response.
0691  * @dmub: the dmub service
0692  * @response: the response for the last GPINT
0693  *
0694  * Returns the response code for the last GPINT interrupt.
0695  *
0696  * Can be called after software initialization.
0697  *
0698  * Return:
0699  *   DMUB_STATUS_OK - success
0700  *   DMUB_STATUS_INVALID - unspecified error
0701  */
0702 enum dmub_status dmub_srv_get_gpint_response(struct dmub_srv *dmub,
0703                          uint32_t *response);
0704 
0705 /**
0706  * dmub_srv_get_gpint_dataout() - Queries the GPINT DATAOUT.
0707  * @dmub: the dmub service
0708  * @dataout: the data for the GPINT DATAOUT
0709  *
0710  * Returns the response code for the last GPINT DATAOUT interrupt.
0711  *
0712  * Can be called after software initialization.
0713  *
0714  * Return:
0715  *   DMUB_STATUS_OK - success
0716  *   DMUB_STATUS_INVALID - unspecified error
0717  */
0718 enum dmub_status dmub_srv_get_gpint_dataout(struct dmub_srv *dmub,
0719                          uint32_t *dataout);
0720 
0721 /**
0722  * dmub_flush_buffer_mem() - Read back entire frame buffer region.
0723  * This ensures that the write from x86 has been flushed and will not
0724  * hang the DMCUB.
0725  * @fb: frame buffer to flush
0726  *
0727  * Can be called after software initialization.
0728  */
0729 void dmub_flush_buffer_mem(const struct dmub_fb *fb);
0730 
0731 /**
0732  * dmub_srv_get_fw_boot_status() - Returns the DMUB boot status bits.
0733  *
0734  * @dmub: the dmub service
0735  * @status: out pointer for firmware status
0736  *
0737  * Return:
0738  *   DMUB_STATUS_OK - success
0739  *   DMUB_STATUS_INVALID - unspecified error, unsupported
0740  */
0741 enum dmub_status dmub_srv_get_fw_boot_status(struct dmub_srv *dmub,
0742                          union dmub_fw_boot_status *status);
0743 
0744 enum dmub_status dmub_srv_cmd_with_reply_data(struct dmub_srv *dmub,
0745                           union dmub_rb_cmd *cmd);
0746 
0747 bool dmub_srv_get_outbox0_msg(struct dmub_srv *dmub, struct dmcub_trace_buf_entry *entry);
0748 
0749 bool dmub_srv_get_diagnostic_data(struct dmub_srv *dmub, struct dmub_diagnostic_data *diag_data);
0750 
0751 bool dmub_srv_should_detect(struct dmub_srv *dmub);
0752 
0753 /**
0754  * dmub_srv_send_inbox0_cmd() - Send command to DMUB using INBOX0
0755  * @dmub: the dmub service
0756  * @data: the data to be sent in the INBOX0 command
0757  *
0758  * Send command by writing directly to INBOX0 WPTR
0759  *
0760  * Return:
0761  *   DMUB_STATUS_OK - success
0762  *   DMUB_STATUS_INVALID - hw_init false or hw function does not exist
0763  */
0764 enum dmub_status dmub_srv_send_inbox0_cmd(struct dmub_srv *dmub, union dmub_inbox0_data_register data);
0765 
0766 /**
0767  * dmub_srv_wait_for_inbox0_ack() - wait for DMUB to ACK INBOX0 command
0768  * @dmub: the dmub service
0769  * @timeout_us: the maximum number of microseconds to wait
0770  *
0771  * Wait for DMUB to ACK the INBOX0 message
0772  *
0773  * Return:
0774  *   DMUB_STATUS_OK - success
0775  *   DMUB_STATUS_INVALID - hw_init false or hw function does not exist
0776  *   DMUB_STATUS_TIMEOUT - wait for ack timed out
0777  */
0778 enum dmub_status dmub_srv_wait_for_inbox0_ack(struct dmub_srv *dmub, uint32_t timeout_us);
0779 
0780 /**
0781  * dmub_srv_wait_for_inbox0_ack() - clear ACK register for INBOX0
0782  * @dmub: the dmub service
0783  *
0784  * Clear ACK register for INBOX0
0785  *
0786  * Return:
0787  *   DMUB_STATUS_OK - success
0788  *   DMUB_STATUS_INVALID - hw_init false or hw function does not exist
0789  */
0790 enum dmub_status dmub_srv_clear_inbox0_ack(struct dmub_srv *dmub);
0791 
0792 #if defined(__cplusplus)
0793 }
0794 #endif
0795 
0796 #endif /* _DMUB_SRV_H_ */