linux/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h

/*
 * Copyright 2016 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Author: Huang Rui
 *
 */
#ifndef __AMDGPU_PSP_H__
#define __AMDGPU_PSP_H__

#include "amdgpu.h"
#include "psp_gfx_if.h"
#include "ta_xgmi_if.h"
#include "ta_ras_if.h"
#include "ta_rap_if.h"
#include "ta_secureDisplay_if.h"

#define PSP_FENCE_BUFFER_SIZE
#define PSP_CMD_BUFFER_SIZE
#define PSP_1_MEG
#define PSP_TMR_SIZE(adev)
#define PSP_TMR_ALIGNMENT
#define PSP_FW_NAME_LEN

extern const struct attribute_group amdgpu_flash_attr_group;

enum psp_shared_mem_size {};

enum ta_type_id {};

struct psp_context;
struct psp_xgmi_node_info;
struct psp_xgmi_topology_info;
struct psp_bin_desc;

enum psp_bootloader_cmd {};

enum psp_ring_type {};

struct psp_ring {};

/* More registers may will be supported */
enum psp_reg_prog_id {};

struct psp_funcs {};

struct ta_funcs {};

#define AMDGPU_XGMI_MAX_CONNECTED_NODES
struct psp_xgmi_node_info {};

struct psp_xgmi_topology_info {};

struct psp_bin_desc {};

struct ta_mem_context {};

struct ta_context {};

struct ta_cp_context {};

struct psp_xgmi_context {};

struct psp_ras_context {};

#define MEM_TRAIN_SYSTEM_SIGNATURE
#define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES
#define GDDR6_MEM_TRAINING_OFFSET
/*Define the VRAM size that will be encroached by BIST training.*/
#define BIST_MEM_TRAINING_ENCROACHED_SIZE

enum psp_memory_training_init_flag {};

enum psp_memory_training_ops {};

struct psp_memory_training_context {};

/** PSP runtime DB **/
#define PSP_RUNTIME_DB_SIZE_IN_BYTES
#define PSP_RUNTIME_DB_OFFSET
#define PSP_RUNTIME_DB_COOKIE_ID
#define PSP_RUNTIME_DB_VER_1
#define PSP_RUNTIME_DB_DIAG_ENTRY_MAX_COUNT

enum psp_runtime_entry_type {};

/* PSP runtime DB header */
struct psp_runtime_data_header {};

/* PSP runtime DB entry */
struct psp_runtime_entry {};

/* PSP runtime DB directory */
struct psp_runtime_data_directory {};

/* PSP runtime DB boot config feature bitmask */
enum psp_runtime_boot_cfg_feature {};

/* PSP run time DB SCPM authentication defines */
enum psp_runtime_scpm_authentication {};

/* PSP runtime DB boot config entry */
struct psp_runtime_boot_cfg_entry {};

/* PSP runtime DB SCPM entry */
struct psp_runtime_scpm_entry {};

struct psp_context {};

struct amdgpu_psp_funcs {};


#define psp_ring_create(psp, type)
#define psp_ring_stop(psp, type)
#define psp_ring_destroy(psp, type)
#define psp_init_microcode(psp)
#define psp_bootloader_load_kdb(psp)
#define psp_bootloader_load_spl(psp)
#define psp_bootloader_load_sysdrv(psp)
#define psp_bootloader_load_soc_drv(psp)
#define psp_bootloader_load_intf_drv(psp)
#define psp_bootloader_load_dbg_drv(psp)
#define psp_bootloader_load_ras_drv(psp)
#define psp_bootloader_load_ipkeymgr_drv(psp)
#define psp_bootloader_load_sos(psp)
#define psp_smu_reload_quirk(psp)
#define psp_mode1_reset(psp)
#define psp_mem_training(psp, ops)

#define psp_ring_get_wptr(psp)
#define psp_ring_set_wptr(psp, value)

#define psp_load_usbc_pd_fw(psp, fw_pri_mc_addr)

#define psp_read_usbc_pd_fw(psp, fw_ver)

#define psp_update_spirom(psp, fw_pri_mc_addr)

#define psp_vbflash_status(psp)

#define psp_fatal_error_recovery_quirk(psp)

extern const struct amd_ip_funcs psp_ip_funcs;

extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
extern const struct amdgpu_ip_block_version psp_v10_0_ip_block;
extern const struct amdgpu_ip_block_version psp_v11_0_ip_block;
extern const struct amdgpu_ip_block_version psp_v11_0_8_ip_block;
extern const struct amdgpu_ip_block_version psp_v12_0_ip_block;
extern const struct amdgpu_ip_block_version psp_v13_0_ip_block;
extern const struct amdgpu_ip_block_version psp_v13_0_4_ip_block;
extern const struct amdgpu_ip_block_version psp_v14_0_ip_block;

extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
			uint32_t field_val, uint32_t mask, bool check_changed);
extern int psp_wait_for_spirom_update(struct psp_context *psp, uint32_t reg_index,
			uint32_t field_val, uint32_t mask, uint32_t msec_timeout);

int psp_execute_ip_fw_load(struct psp_context *psp,
			   struct amdgpu_firmware_info *ucode);

int psp_gpu_reset(struct amdgpu_device *adev);

int psp_ta_init_shared_buf(struct psp_context *psp,
				  struct ta_mem_context *mem_ctx);
void psp_ta_free_shared_buf(struct ta_mem_context *mem_ctx);
int psp_ta_unload(struct psp_context *psp, struct ta_context *context);
int psp_ta_load(struct psp_context *psp, struct ta_context *context);
int psp_ta_invoke(struct psp_context *psp,
			uint32_t ta_cmd_id,
			struct ta_context *context);

int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool load_ta);
int psp_xgmi_terminate(struct psp_context *psp);
int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id);
int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id);
int psp_xgmi_get_topology_info(struct psp_context *psp,
			       int number_devices,
			       struct psp_xgmi_topology_info *topology,
			       bool get_extended_data);
int psp_xgmi_set_topology_info(struct psp_context *psp,
			       int number_devices,
			       struct psp_xgmi_topology_info *topology);
int psp_ras_initialize(struct psp_context *psp);
int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
int psp_ras_enable_features(struct psp_context *psp,
		union ta_ras_cmd_input *info, bool enable);
int psp_ras_trigger_error(struct psp_context *psp,
			  struct ta_ras_trigger_error_input *info, uint32_t instance_mask);
int psp_ras_terminate(struct psp_context *psp);
int psp_ras_query_address(struct psp_context *psp,
			  struct ta_ras_query_address_input *addr_in,
			  struct ta_ras_query_address_output *addr_out);

int psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
int psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
int psp_rap_invoke(struct psp_context *psp, uint32_t ta_cmd_id, enum ta_rap_status *status);
int psp_securedisplay_invoke(struct psp_context *psp, uint32_t ta_cmd_id);

int psp_rlc_autoload_start(struct psp_context *psp);

int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg,
		uint32_t value);
int psp_ring_cmd_submit(struct psp_context *psp,
			uint64_t cmd_buf_mc_addr,
			uint64_t fence_mc_addr,
			int index);
int psp_init_asd_microcode(struct psp_context *psp,
			   const char *chip_name);
int psp_init_toc_microcode(struct psp_context *psp,
			   const char *chip_name);
int psp_init_sos_microcode(struct psp_context *psp,
			   const char *chip_name);
int psp_init_ta_microcode(struct psp_context *psp,
			  const char *chip_name);
int psp_init_cap_microcode(struct psp_context *psp,
			  const char *chip_name);
int psp_get_fw_attestation_records_addr(struct psp_context *psp,
					uint64_t *output_ptr);

int psp_load_fw_list(struct psp_context *psp,
		     struct amdgpu_firmware_info **ucode_list, int ucode_count);
void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size);

int psp_spatial_partition(struct psp_context *psp, int mode);

int is_psp_fw_valid(struct psp_bin_desc bin);

int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
bool amdgpu_psp_get_ras_capability(struct psp_context *psp);
#endif