18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2016 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * Author: Huang Rui
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_ci#ifndef __AMDGPU_PSP_H__
268c2ecf20Sopenharmony_ci#define __AMDGPU_PSP_H__
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#include "amdgpu.h"
298c2ecf20Sopenharmony_ci#include "psp_gfx_if.h"
308c2ecf20Sopenharmony_ci#include "ta_xgmi_if.h"
318c2ecf20Sopenharmony_ci#include "ta_ras_if.h"
328c2ecf20Sopenharmony_ci#include "ta_rap_if.h"
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define PSP_FENCE_BUFFER_SIZE	0x1000
358c2ecf20Sopenharmony_ci#define PSP_CMD_BUFFER_SIZE	0x1000
368c2ecf20Sopenharmony_ci#define PSP_XGMI_SHARED_MEM_SIZE 0x4000
378c2ecf20Sopenharmony_ci#define PSP_RAS_SHARED_MEM_SIZE 0x4000
388c2ecf20Sopenharmony_ci#define PSP_1_MEG		0x100000
398c2ecf20Sopenharmony_ci#define PSP_TMR_SIZE	0x400000
408c2ecf20Sopenharmony_ci#define PSP_HDCP_SHARED_MEM_SIZE	0x4000
418c2ecf20Sopenharmony_ci#define PSP_DTM_SHARED_MEM_SIZE	0x4000
428c2ecf20Sopenharmony_ci#define PSP_RAP_SHARED_MEM_SIZE	0x4000
438c2ecf20Sopenharmony_ci#define PSP_SHARED_MEM_SIZE		0x4000
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistruct psp_context;
468c2ecf20Sopenharmony_cistruct psp_xgmi_node_info;
478c2ecf20Sopenharmony_cistruct psp_xgmi_topology_info;
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cienum psp_bootloader_cmd {
508c2ecf20Sopenharmony_ci	PSP_BL__LOAD_SYSDRV		= 0x10000,
518c2ecf20Sopenharmony_ci	PSP_BL__LOAD_SOSDRV		= 0x20000,
528c2ecf20Sopenharmony_ci	PSP_BL__LOAD_KEY_DATABASE	= 0x80000,
538c2ecf20Sopenharmony_ci	PSP_BL__DRAM_LONG_TRAIN		= 0x100000,
548c2ecf20Sopenharmony_ci	PSP_BL__DRAM_SHORT_TRAIN	= 0x200000,
558c2ecf20Sopenharmony_ci	PSP_BL__LOAD_TOS_SPL_TABLE	= 0x10000000,
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_cienum psp_ring_type
598c2ecf20Sopenharmony_ci{
608c2ecf20Sopenharmony_ci	PSP_RING_TYPE__INVALID = 0,
618c2ecf20Sopenharmony_ci	/*
628c2ecf20Sopenharmony_ci	 * These values map to the way the PSP kernel identifies the
638c2ecf20Sopenharmony_ci	 * rings.
648c2ecf20Sopenharmony_ci	 */
658c2ecf20Sopenharmony_ci	PSP_RING_TYPE__UM = 1, /* User mode ring (formerly called RBI) */
668c2ecf20Sopenharmony_ci	PSP_RING_TYPE__KM = 2  /* Kernel mode ring (formerly called GPCOM) */
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistruct psp_ring
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	enum psp_ring_type		ring_type;
728c2ecf20Sopenharmony_ci	struct psp_gfx_rb_frame		*ring_mem;
738c2ecf20Sopenharmony_ci	uint64_t			ring_mem_mc_addr;
748c2ecf20Sopenharmony_ci	void				*ring_mem_handle;
758c2ecf20Sopenharmony_ci	uint32_t			ring_size;
768c2ecf20Sopenharmony_ci	uint32_t			ring_wptr;
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/* More registers may will be supported */
808c2ecf20Sopenharmony_cienum psp_reg_prog_id {
818c2ecf20Sopenharmony_ci	PSP_REG_IH_RB_CNTL        = 0,  /* register IH_RB_CNTL */
828c2ecf20Sopenharmony_ci	PSP_REG_IH_RB_CNTL_RING1  = 1,  /* register IH_RB_CNTL_RING1 */
838c2ecf20Sopenharmony_ci	PSP_REG_IH_RB_CNTL_RING2  = 2,  /* register IH_RB_CNTL_RING2 */
848c2ecf20Sopenharmony_ci	PSP_REG_LAST
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistruct psp_funcs
888c2ecf20Sopenharmony_ci{
898c2ecf20Sopenharmony_ci	int (*init_microcode)(struct psp_context *psp);
908c2ecf20Sopenharmony_ci	int (*bootloader_load_kdb)(struct psp_context *psp);
918c2ecf20Sopenharmony_ci	int (*bootloader_load_spl)(struct psp_context *psp);
928c2ecf20Sopenharmony_ci	int (*bootloader_load_sysdrv)(struct psp_context *psp);
938c2ecf20Sopenharmony_ci	int (*bootloader_load_sos)(struct psp_context *psp);
948c2ecf20Sopenharmony_ci	int (*ring_init)(struct psp_context *psp, enum psp_ring_type ring_type);
958c2ecf20Sopenharmony_ci	int (*ring_create)(struct psp_context *psp,
968c2ecf20Sopenharmony_ci			   enum psp_ring_type ring_type);
978c2ecf20Sopenharmony_ci	int (*ring_stop)(struct psp_context *psp,
988c2ecf20Sopenharmony_ci			    enum psp_ring_type ring_type);
998c2ecf20Sopenharmony_ci	int (*ring_destroy)(struct psp_context *psp,
1008c2ecf20Sopenharmony_ci			    enum psp_ring_type ring_type);
1018c2ecf20Sopenharmony_ci	bool (*smu_reload_quirk)(struct psp_context *psp);
1028c2ecf20Sopenharmony_ci	int (*mode1_reset)(struct psp_context *psp);
1038c2ecf20Sopenharmony_ci	int (*mem_training)(struct psp_context *psp, uint32_t ops);
1048c2ecf20Sopenharmony_ci	uint32_t (*ring_get_wptr)(struct psp_context *psp);
1058c2ecf20Sopenharmony_ci	void (*ring_set_wptr)(struct psp_context *psp, uint32_t value);
1068c2ecf20Sopenharmony_ci	int (*load_usbc_pd_fw)(struct psp_context *psp, dma_addr_t dma_addr);
1078c2ecf20Sopenharmony_ci	int (*read_usbc_pd_fw)(struct psp_context *psp, uint32_t *fw_ver);
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#define AMDGPU_XGMI_MAX_CONNECTED_NODES		64
1118c2ecf20Sopenharmony_cistruct psp_xgmi_node_info {
1128c2ecf20Sopenharmony_ci	uint64_t				node_id;
1138c2ecf20Sopenharmony_ci	uint8_t					num_hops;
1148c2ecf20Sopenharmony_ci	uint8_t					is_sharing_enabled;
1158c2ecf20Sopenharmony_ci	enum ta_xgmi_assigned_sdma_engine	sdma_engine;
1168c2ecf20Sopenharmony_ci};
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_cistruct psp_xgmi_topology_info {
1198c2ecf20Sopenharmony_ci	uint32_t			num_nodes;
1208c2ecf20Sopenharmony_ci	struct psp_xgmi_node_info	nodes[AMDGPU_XGMI_MAX_CONNECTED_NODES];
1218c2ecf20Sopenharmony_ci};
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_cistruct psp_asd_context {
1248c2ecf20Sopenharmony_ci	bool			asd_initialized;
1258c2ecf20Sopenharmony_ci	uint32_t		session_id;
1268c2ecf20Sopenharmony_ci};
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_cistruct psp_xgmi_context {
1298c2ecf20Sopenharmony_ci	uint8_t				initialized;
1308c2ecf20Sopenharmony_ci	uint32_t			session_id;
1318c2ecf20Sopenharmony_ci	struct amdgpu_bo                *xgmi_shared_bo;
1328c2ecf20Sopenharmony_ci	uint64_t                        xgmi_shared_mc_addr;
1338c2ecf20Sopenharmony_ci	void                            *xgmi_shared_buf;
1348c2ecf20Sopenharmony_ci	struct psp_xgmi_topology_info	top_info;
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_cistruct psp_ras_context {
1388c2ecf20Sopenharmony_ci	/*ras fw*/
1398c2ecf20Sopenharmony_ci	bool			ras_initialized;
1408c2ecf20Sopenharmony_ci	uint32_t		session_id;
1418c2ecf20Sopenharmony_ci	struct amdgpu_bo	*ras_shared_bo;
1428c2ecf20Sopenharmony_ci	uint64_t		ras_shared_mc_addr;
1438c2ecf20Sopenharmony_ci	void			*ras_shared_buf;
1448c2ecf20Sopenharmony_ci	struct amdgpu_ras	*ras;
1458c2ecf20Sopenharmony_ci};
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_cistruct psp_hdcp_context {
1488c2ecf20Sopenharmony_ci	bool			hdcp_initialized;
1498c2ecf20Sopenharmony_ci	uint32_t		session_id;
1508c2ecf20Sopenharmony_ci	struct amdgpu_bo	*hdcp_shared_bo;
1518c2ecf20Sopenharmony_ci	uint64_t		hdcp_shared_mc_addr;
1528c2ecf20Sopenharmony_ci	void			*hdcp_shared_buf;
1538c2ecf20Sopenharmony_ci	struct mutex		mutex;
1548c2ecf20Sopenharmony_ci};
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistruct psp_dtm_context {
1578c2ecf20Sopenharmony_ci	bool			dtm_initialized;
1588c2ecf20Sopenharmony_ci	uint32_t		session_id;
1598c2ecf20Sopenharmony_ci	struct amdgpu_bo	*dtm_shared_bo;
1608c2ecf20Sopenharmony_ci	uint64_t		dtm_shared_mc_addr;
1618c2ecf20Sopenharmony_ci	void			*dtm_shared_buf;
1628c2ecf20Sopenharmony_ci	struct mutex		mutex;
1638c2ecf20Sopenharmony_ci};
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_cistruct psp_rap_context {
1668c2ecf20Sopenharmony_ci	bool			rap_initialized;
1678c2ecf20Sopenharmony_ci	uint32_t		session_id;
1688c2ecf20Sopenharmony_ci	struct amdgpu_bo	*rap_shared_bo;
1698c2ecf20Sopenharmony_ci	uint64_t		rap_shared_mc_addr;
1708c2ecf20Sopenharmony_ci	void			*rap_shared_buf;
1718c2ecf20Sopenharmony_ci	struct mutex		mutex;
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#define MEM_TRAIN_SYSTEM_SIGNATURE		0x54534942
1758c2ecf20Sopenharmony_ci#define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES	0x1000
1768c2ecf20Sopenharmony_ci#define GDDR6_MEM_TRAINING_OFFSET		0x8000
1778c2ecf20Sopenharmony_ci/*Define the VRAM size that will be encroached by BIST training.*/
1788c2ecf20Sopenharmony_ci#define GDDR6_MEM_TRAINING_ENCROACHED_SIZE	0x2000000
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cienum psp_memory_training_init_flag {
1818c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_NOT_SUPPORT	= 0x0,
1828c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_SUPPORT		= 0x1,
1838c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_INIT_FAILED	= 0x2,
1848c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_RESERVE_SUCCESS	= 0x4,
1858c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_INIT_SUCCESS	= 0x8,
1868c2ecf20Sopenharmony_ci};
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_cienum psp_memory_training_ops {
1898c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_SEND_LONG_MSG	= 0x1,
1908c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_SAVE		= 0x2,
1918c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_RESTORE		= 0x4,
1928c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_SEND_SHORT_MSG	= 0x8,
1938c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_COLD_BOOT		= PSP_MEM_TRAIN_SEND_LONG_MSG,
1948c2ecf20Sopenharmony_ci	PSP_MEM_TRAIN_RESUME		= PSP_MEM_TRAIN_SEND_SHORT_MSG,
1958c2ecf20Sopenharmony_ci};
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_cistruct psp_memory_training_context {
1988c2ecf20Sopenharmony_ci	/*training data size*/
1998c2ecf20Sopenharmony_ci	u64 train_data_size;
2008c2ecf20Sopenharmony_ci	/*
2018c2ecf20Sopenharmony_ci	 * sys_cache
2028c2ecf20Sopenharmony_ci	 * cpu virtual address
2038c2ecf20Sopenharmony_ci	 * system memory buffer that used to store the training data.
2048c2ecf20Sopenharmony_ci	 */
2058c2ecf20Sopenharmony_ci	void *sys_cache;
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci	/*vram offset of the p2c training data*/
2088c2ecf20Sopenharmony_ci	u64 p2c_train_data_offset;
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci	/*vram offset of the c2p training data*/
2118c2ecf20Sopenharmony_ci	u64 c2p_train_data_offset;
2128c2ecf20Sopenharmony_ci	struct amdgpu_bo *c2p_bo;
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	enum psp_memory_training_init_flag init;
2158c2ecf20Sopenharmony_ci	u32 training_cnt;
2168c2ecf20Sopenharmony_ci};
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistruct psp_context
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	struct amdgpu_device            *adev;
2218c2ecf20Sopenharmony_ci	struct psp_ring                 km_ring;
2228c2ecf20Sopenharmony_ci	struct psp_gfx_cmd_resp		*cmd;
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	const struct psp_funcs		*funcs;
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci	/* firmware buffer */
2278c2ecf20Sopenharmony_ci	struct amdgpu_bo		*fw_pri_bo;
2288c2ecf20Sopenharmony_ci	uint64_t			fw_pri_mc_addr;
2298c2ecf20Sopenharmony_ci	void				*fw_pri_buf;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	/* sos firmware */
2328c2ecf20Sopenharmony_ci	const struct firmware		*sos_fw;
2338c2ecf20Sopenharmony_ci	uint32_t			sos_fw_version;
2348c2ecf20Sopenharmony_ci	uint32_t			sos_feature_version;
2358c2ecf20Sopenharmony_ci	uint32_t			sys_bin_size;
2368c2ecf20Sopenharmony_ci	uint32_t			sos_bin_size;
2378c2ecf20Sopenharmony_ci	uint32_t			toc_bin_size;
2388c2ecf20Sopenharmony_ci	uint32_t			kdb_bin_size;
2398c2ecf20Sopenharmony_ci	uint32_t			spl_bin_size;
2408c2ecf20Sopenharmony_ci	uint8_t				*sys_start_addr;
2418c2ecf20Sopenharmony_ci	uint8_t				*sos_start_addr;
2428c2ecf20Sopenharmony_ci	uint8_t				*toc_start_addr;
2438c2ecf20Sopenharmony_ci	uint8_t				*kdb_start_addr;
2448c2ecf20Sopenharmony_ci	uint8_t				*spl_start_addr;
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	/* tmr buffer */
2478c2ecf20Sopenharmony_ci	struct amdgpu_bo		*tmr_bo;
2488c2ecf20Sopenharmony_ci	uint64_t			tmr_mc_addr;
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	/* asd firmware */
2518c2ecf20Sopenharmony_ci	const struct firmware		*asd_fw;
2528c2ecf20Sopenharmony_ci	uint32_t			asd_fw_version;
2538c2ecf20Sopenharmony_ci	uint32_t			asd_feature_version;
2548c2ecf20Sopenharmony_ci	uint32_t			asd_ucode_size;
2558c2ecf20Sopenharmony_ci	uint8_t				*asd_start_addr;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	/* fence buffer */
2588c2ecf20Sopenharmony_ci	struct amdgpu_bo		*fence_buf_bo;
2598c2ecf20Sopenharmony_ci	uint64_t			fence_buf_mc_addr;
2608c2ecf20Sopenharmony_ci	void				*fence_buf;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	/* cmd buffer */
2638c2ecf20Sopenharmony_ci	struct amdgpu_bo		*cmd_buf_bo;
2648c2ecf20Sopenharmony_ci	uint64_t			cmd_buf_mc_addr;
2658c2ecf20Sopenharmony_ci	struct psp_gfx_cmd_resp		*cmd_buf_mem;
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci	/* fence value associated with cmd buffer */
2688c2ecf20Sopenharmony_ci	atomic_t			fence_value;
2698c2ecf20Sopenharmony_ci	/* flag to mark whether gfx fw autoload is supported or not */
2708c2ecf20Sopenharmony_ci	bool				autoload_supported;
2718c2ecf20Sopenharmony_ci	/* flag to mark whether df cstate management centralized to PMFW */
2728c2ecf20Sopenharmony_ci	bool				pmfw_centralized_cstate_management;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	/* xgmi ta firmware and buffer */
2758c2ecf20Sopenharmony_ci	const struct firmware		*ta_fw;
2768c2ecf20Sopenharmony_ci	uint32_t			ta_fw_version;
2778c2ecf20Sopenharmony_ci	uint32_t			ta_xgmi_ucode_version;
2788c2ecf20Sopenharmony_ci	uint32_t			ta_xgmi_ucode_size;
2798c2ecf20Sopenharmony_ci	uint8_t				*ta_xgmi_start_addr;
2808c2ecf20Sopenharmony_ci	uint32_t			ta_ras_ucode_version;
2818c2ecf20Sopenharmony_ci	uint32_t			ta_ras_ucode_size;
2828c2ecf20Sopenharmony_ci	uint8_t				*ta_ras_start_addr;
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	uint32_t			ta_hdcp_ucode_version;
2858c2ecf20Sopenharmony_ci	uint32_t			ta_hdcp_ucode_size;
2868c2ecf20Sopenharmony_ci	uint8_t				*ta_hdcp_start_addr;
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	uint32_t			ta_dtm_ucode_version;
2898c2ecf20Sopenharmony_ci	uint32_t			ta_dtm_ucode_size;
2908c2ecf20Sopenharmony_ci	uint8_t				*ta_dtm_start_addr;
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	uint32_t			ta_rap_ucode_version;
2938c2ecf20Sopenharmony_ci	uint32_t			ta_rap_ucode_size;
2948c2ecf20Sopenharmony_ci	uint8_t				*ta_rap_start_addr;
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci	struct psp_asd_context		asd_context;
2978c2ecf20Sopenharmony_ci	struct psp_xgmi_context		xgmi_context;
2988c2ecf20Sopenharmony_ci	struct psp_ras_context		ras;
2998c2ecf20Sopenharmony_ci	struct psp_hdcp_context 	hdcp_context;
3008c2ecf20Sopenharmony_ci	struct psp_dtm_context		dtm_context;
3018c2ecf20Sopenharmony_ci	struct psp_rap_context		rap_context;
3028c2ecf20Sopenharmony_ci	struct mutex			mutex;
3038c2ecf20Sopenharmony_ci	struct psp_memory_training_context mem_train_ctx;
3048c2ecf20Sopenharmony_ci};
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_cistruct amdgpu_psp_funcs {
3078c2ecf20Sopenharmony_ci	bool (*check_fw_loading_status)(struct amdgpu_device *adev,
3088c2ecf20Sopenharmony_ci					enum AMDGPU_UCODE_ID);
3098c2ecf20Sopenharmony_ci};
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci#define psp_ring_init(psp, type) (psp)->funcs->ring_init((psp), (type))
3138c2ecf20Sopenharmony_ci#define psp_ring_create(psp, type) (psp)->funcs->ring_create((psp), (type))
3148c2ecf20Sopenharmony_ci#define psp_ring_stop(psp, type) (psp)->funcs->ring_stop((psp), (type))
3158c2ecf20Sopenharmony_ci#define psp_ring_destroy(psp, type) ((psp)->funcs->ring_destroy((psp), (type)))
3168c2ecf20Sopenharmony_ci#define psp_init_microcode(psp) \
3178c2ecf20Sopenharmony_ci		((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0)
3188c2ecf20Sopenharmony_ci#define psp_bootloader_load_kdb(psp) \
3198c2ecf20Sopenharmony_ci		((psp)->funcs->bootloader_load_kdb ? (psp)->funcs->bootloader_load_kdb((psp)) : 0)
3208c2ecf20Sopenharmony_ci#define psp_bootloader_load_spl(psp) \
3218c2ecf20Sopenharmony_ci		((psp)->funcs->bootloader_load_spl ? (psp)->funcs->bootloader_load_spl((psp)) : 0)
3228c2ecf20Sopenharmony_ci#define psp_bootloader_load_sysdrv(psp) \
3238c2ecf20Sopenharmony_ci		((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
3248c2ecf20Sopenharmony_ci#define psp_bootloader_load_sos(psp) \
3258c2ecf20Sopenharmony_ci		((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
3268c2ecf20Sopenharmony_ci#define psp_smu_reload_quirk(psp) \
3278c2ecf20Sopenharmony_ci		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
3288c2ecf20Sopenharmony_ci#define psp_mode1_reset(psp) \
3298c2ecf20Sopenharmony_ci		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
3308c2ecf20Sopenharmony_ci#define psp_mem_training(psp, ops) \
3318c2ecf20Sopenharmony_ci	((psp)->funcs->mem_training ? (psp)->funcs->mem_training((psp), (ops)) : 0)
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci#define psp_ring_get_wptr(psp) (psp)->funcs->ring_get_wptr((psp))
3348c2ecf20Sopenharmony_ci#define psp_ring_set_wptr(psp, value) (psp)->funcs->ring_set_wptr((psp), (value))
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci#define psp_load_usbc_pd_fw(psp, dma_addr) \
3378c2ecf20Sopenharmony_ci	((psp)->funcs->load_usbc_pd_fw ? \
3388c2ecf20Sopenharmony_ci	(psp)->funcs->load_usbc_pd_fw((psp), (dma_addr)) : -EINVAL)
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci#define psp_read_usbc_pd_fw(psp, fw_ver) \
3418c2ecf20Sopenharmony_ci	((psp)->funcs->read_usbc_pd_fw ? \
3428c2ecf20Sopenharmony_ci	(psp)->funcs->read_usbc_pd_fw((psp), fw_ver) : -EINVAL)
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ciextern const struct amd_ip_funcs psp_ip_funcs;
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ciextern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
3478c2ecf20Sopenharmony_ciextern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
3488c2ecf20Sopenharmony_ci			uint32_t field_val, uint32_t mask, bool check_changed);
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ciextern const struct amdgpu_ip_block_version psp_v10_0_ip_block;
3518c2ecf20Sopenharmony_ciextern const struct amdgpu_ip_block_version psp_v12_0_ip_block;
3528c2ecf20Sopenharmony_ci
3538c2ecf20Sopenharmony_ciint psp_gpu_reset(struct amdgpu_device *adev);
3548c2ecf20Sopenharmony_ciint psp_update_vcn_sram(struct amdgpu_device *adev, int inst_idx,
3558c2ecf20Sopenharmony_ci			uint64_t cmd_gpu_addr, int cmd_size);
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ciint psp_xgmi_initialize(struct psp_context *psp);
3588c2ecf20Sopenharmony_ciint psp_xgmi_terminate(struct psp_context *psp);
3598c2ecf20Sopenharmony_ciint psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
3608c2ecf20Sopenharmony_ciint psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id);
3618c2ecf20Sopenharmony_ciint psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id);
3628c2ecf20Sopenharmony_ciint psp_xgmi_get_topology_info(struct psp_context *psp,
3638c2ecf20Sopenharmony_ci			       int number_devices,
3648c2ecf20Sopenharmony_ci			       struct psp_xgmi_topology_info *topology);
3658c2ecf20Sopenharmony_ciint psp_xgmi_set_topology_info(struct psp_context *psp,
3668c2ecf20Sopenharmony_ci			       int number_devices,
3678c2ecf20Sopenharmony_ci			       struct psp_xgmi_topology_info *topology);
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ciint psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
3708c2ecf20Sopenharmony_ciint psp_ras_enable_features(struct psp_context *psp,
3718c2ecf20Sopenharmony_ci		union ta_ras_cmd_input *info, bool enable);
3728c2ecf20Sopenharmony_ciint psp_ras_trigger_error(struct psp_context *psp,
3738c2ecf20Sopenharmony_ci			  struct ta_ras_trigger_error_input *info);
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ciint psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
3768c2ecf20Sopenharmony_ciint psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
3778c2ecf20Sopenharmony_ciint psp_rap_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ciint psp_rlc_autoload_start(struct psp_context *psp);
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ciextern const struct amdgpu_ip_block_version psp_v11_0_ip_block;
3828c2ecf20Sopenharmony_ciint psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg,
3838c2ecf20Sopenharmony_ci		uint32_t value);
3848c2ecf20Sopenharmony_ciint psp_ring_cmd_submit(struct psp_context *psp,
3858c2ecf20Sopenharmony_ci			uint64_t cmd_buf_mc_addr,
3868c2ecf20Sopenharmony_ci			uint64_t fence_mc_addr,
3878c2ecf20Sopenharmony_ci			int index);
3888c2ecf20Sopenharmony_ciint psp_init_asd_microcode(struct psp_context *psp,
3898c2ecf20Sopenharmony_ci			   const char *chip_name);
3908c2ecf20Sopenharmony_ciint psp_init_sos_microcode(struct psp_context *psp,
3918c2ecf20Sopenharmony_ci			   const char *chip_name);
3928c2ecf20Sopenharmony_ciint psp_init_ta_microcode(struct psp_context *psp,
3938c2ecf20Sopenharmony_ci			  const char *chip_name);
3948c2ecf20Sopenharmony_ci#endif
395