xref: /OK3568_Linux_fs/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 2016 Advanced Micro Devices, Inc.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
5*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
6*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
7*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
9*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included in
12*4882a593Smuzhiyun  * all copies or substantial portions of the Software.
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*4882a593Smuzhiyun  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*4882a593Smuzhiyun  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*4882a593Smuzhiyun  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*4882a593Smuzhiyun  * OTHER DEALINGS IN THE SOFTWARE.
21*4882a593Smuzhiyun  *
22*4882a593Smuzhiyun  * Author: Huang Rui
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  */
25*4882a593Smuzhiyun #ifndef __AMDGPU_PSP_H__
26*4882a593Smuzhiyun #define __AMDGPU_PSP_H__
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #include "amdgpu.h"
29*4882a593Smuzhiyun #include "psp_gfx_if.h"
30*4882a593Smuzhiyun #include "ta_xgmi_if.h"
31*4882a593Smuzhiyun #include "ta_ras_if.h"
32*4882a593Smuzhiyun #include "ta_rap_if.h"
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #define PSP_FENCE_BUFFER_SIZE	0x1000
35*4882a593Smuzhiyun #define PSP_CMD_BUFFER_SIZE	0x1000
36*4882a593Smuzhiyun #define PSP_XGMI_SHARED_MEM_SIZE 0x4000
37*4882a593Smuzhiyun #define PSP_RAS_SHARED_MEM_SIZE 0x4000
38*4882a593Smuzhiyun #define PSP_1_MEG		0x100000
39*4882a593Smuzhiyun #define PSP_TMR_SIZE	0x400000
40*4882a593Smuzhiyun #define PSP_HDCP_SHARED_MEM_SIZE	0x4000
41*4882a593Smuzhiyun #define PSP_DTM_SHARED_MEM_SIZE	0x4000
42*4882a593Smuzhiyun #define PSP_RAP_SHARED_MEM_SIZE	0x4000
43*4882a593Smuzhiyun #define PSP_SHARED_MEM_SIZE		0x4000
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun struct psp_context;
46*4882a593Smuzhiyun struct psp_xgmi_node_info;
47*4882a593Smuzhiyun struct psp_xgmi_topology_info;
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun enum psp_bootloader_cmd {
50*4882a593Smuzhiyun 	PSP_BL__LOAD_SYSDRV		= 0x10000,
51*4882a593Smuzhiyun 	PSP_BL__LOAD_SOSDRV		= 0x20000,
52*4882a593Smuzhiyun 	PSP_BL__LOAD_KEY_DATABASE	= 0x80000,
53*4882a593Smuzhiyun 	PSP_BL__DRAM_LONG_TRAIN		= 0x100000,
54*4882a593Smuzhiyun 	PSP_BL__DRAM_SHORT_TRAIN	= 0x200000,
55*4882a593Smuzhiyun 	PSP_BL__LOAD_TOS_SPL_TABLE	= 0x10000000,
56*4882a593Smuzhiyun };
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun enum psp_ring_type
59*4882a593Smuzhiyun {
60*4882a593Smuzhiyun 	PSP_RING_TYPE__INVALID = 0,
61*4882a593Smuzhiyun 	/*
62*4882a593Smuzhiyun 	 * These values map to the way the PSP kernel identifies the
63*4882a593Smuzhiyun 	 * rings.
64*4882a593Smuzhiyun 	 */
65*4882a593Smuzhiyun 	PSP_RING_TYPE__UM = 1, /* User mode ring (formerly called RBI) */
66*4882a593Smuzhiyun 	PSP_RING_TYPE__KM = 2  /* Kernel mode ring (formerly called GPCOM) */
67*4882a593Smuzhiyun };
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun struct psp_ring
70*4882a593Smuzhiyun {
71*4882a593Smuzhiyun 	enum psp_ring_type		ring_type;
72*4882a593Smuzhiyun 	struct psp_gfx_rb_frame		*ring_mem;
73*4882a593Smuzhiyun 	uint64_t			ring_mem_mc_addr;
74*4882a593Smuzhiyun 	void				*ring_mem_handle;
75*4882a593Smuzhiyun 	uint32_t			ring_size;
76*4882a593Smuzhiyun 	uint32_t			ring_wptr;
77*4882a593Smuzhiyun };
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun /* More registers may will be supported */
80*4882a593Smuzhiyun enum psp_reg_prog_id {
81*4882a593Smuzhiyun 	PSP_REG_IH_RB_CNTL        = 0,  /* register IH_RB_CNTL */
82*4882a593Smuzhiyun 	PSP_REG_IH_RB_CNTL_RING1  = 1,  /* register IH_RB_CNTL_RING1 */
83*4882a593Smuzhiyun 	PSP_REG_IH_RB_CNTL_RING2  = 2,  /* register IH_RB_CNTL_RING2 */
84*4882a593Smuzhiyun 	PSP_REG_LAST
85*4882a593Smuzhiyun };
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun struct psp_funcs
88*4882a593Smuzhiyun {
89*4882a593Smuzhiyun 	int (*init_microcode)(struct psp_context *psp);
90*4882a593Smuzhiyun 	int (*bootloader_load_kdb)(struct psp_context *psp);
91*4882a593Smuzhiyun 	int (*bootloader_load_spl)(struct psp_context *psp);
92*4882a593Smuzhiyun 	int (*bootloader_load_sysdrv)(struct psp_context *psp);
93*4882a593Smuzhiyun 	int (*bootloader_load_sos)(struct psp_context *psp);
94*4882a593Smuzhiyun 	int (*ring_init)(struct psp_context *psp, enum psp_ring_type ring_type);
95*4882a593Smuzhiyun 	int (*ring_create)(struct psp_context *psp,
96*4882a593Smuzhiyun 			   enum psp_ring_type ring_type);
97*4882a593Smuzhiyun 	int (*ring_stop)(struct psp_context *psp,
98*4882a593Smuzhiyun 			    enum psp_ring_type ring_type);
99*4882a593Smuzhiyun 	int (*ring_destroy)(struct psp_context *psp,
100*4882a593Smuzhiyun 			    enum psp_ring_type ring_type);
101*4882a593Smuzhiyun 	bool (*smu_reload_quirk)(struct psp_context *psp);
102*4882a593Smuzhiyun 	int (*mode1_reset)(struct psp_context *psp);
103*4882a593Smuzhiyun 	int (*mem_training)(struct psp_context *psp, uint32_t ops);
104*4882a593Smuzhiyun 	uint32_t (*ring_get_wptr)(struct psp_context *psp);
105*4882a593Smuzhiyun 	void (*ring_set_wptr)(struct psp_context *psp, uint32_t value);
106*4882a593Smuzhiyun 	int (*load_usbc_pd_fw)(struct psp_context *psp, dma_addr_t dma_addr);
107*4882a593Smuzhiyun 	int (*read_usbc_pd_fw)(struct psp_context *psp, uint32_t *fw_ver);
108*4882a593Smuzhiyun };
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun #define AMDGPU_XGMI_MAX_CONNECTED_NODES		64
111*4882a593Smuzhiyun struct psp_xgmi_node_info {
112*4882a593Smuzhiyun 	uint64_t				node_id;
113*4882a593Smuzhiyun 	uint8_t					num_hops;
114*4882a593Smuzhiyun 	uint8_t					is_sharing_enabled;
115*4882a593Smuzhiyun 	enum ta_xgmi_assigned_sdma_engine	sdma_engine;
116*4882a593Smuzhiyun };
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun struct psp_xgmi_topology_info {
119*4882a593Smuzhiyun 	uint32_t			num_nodes;
120*4882a593Smuzhiyun 	struct psp_xgmi_node_info	nodes[AMDGPU_XGMI_MAX_CONNECTED_NODES];
121*4882a593Smuzhiyun };
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun struct psp_asd_context {
124*4882a593Smuzhiyun 	bool			asd_initialized;
125*4882a593Smuzhiyun 	uint32_t		session_id;
126*4882a593Smuzhiyun };
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun struct psp_xgmi_context {
129*4882a593Smuzhiyun 	uint8_t				initialized;
130*4882a593Smuzhiyun 	uint32_t			session_id;
131*4882a593Smuzhiyun 	struct amdgpu_bo                *xgmi_shared_bo;
132*4882a593Smuzhiyun 	uint64_t                        xgmi_shared_mc_addr;
133*4882a593Smuzhiyun 	void                            *xgmi_shared_buf;
134*4882a593Smuzhiyun 	struct psp_xgmi_topology_info	top_info;
135*4882a593Smuzhiyun };
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun struct psp_ras_context {
138*4882a593Smuzhiyun 	/*ras fw*/
139*4882a593Smuzhiyun 	bool			ras_initialized;
140*4882a593Smuzhiyun 	uint32_t		session_id;
141*4882a593Smuzhiyun 	struct amdgpu_bo	*ras_shared_bo;
142*4882a593Smuzhiyun 	uint64_t		ras_shared_mc_addr;
143*4882a593Smuzhiyun 	void			*ras_shared_buf;
144*4882a593Smuzhiyun 	struct amdgpu_ras	*ras;
145*4882a593Smuzhiyun };
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun struct psp_hdcp_context {
148*4882a593Smuzhiyun 	bool			hdcp_initialized;
149*4882a593Smuzhiyun 	uint32_t		session_id;
150*4882a593Smuzhiyun 	struct amdgpu_bo	*hdcp_shared_bo;
151*4882a593Smuzhiyun 	uint64_t		hdcp_shared_mc_addr;
152*4882a593Smuzhiyun 	void			*hdcp_shared_buf;
153*4882a593Smuzhiyun 	struct mutex		mutex;
154*4882a593Smuzhiyun };
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun struct psp_dtm_context {
157*4882a593Smuzhiyun 	bool			dtm_initialized;
158*4882a593Smuzhiyun 	uint32_t		session_id;
159*4882a593Smuzhiyun 	struct amdgpu_bo	*dtm_shared_bo;
160*4882a593Smuzhiyun 	uint64_t		dtm_shared_mc_addr;
161*4882a593Smuzhiyun 	void			*dtm_shared_buf;
162*4882a593Smuzhiyun 	struct mutex		mutex;
163*4882a593Smuzhiyun };
164*4882a593Smuzhiyun 
165*4882a593Smuzhiyun struct psp_rap_context {
166*4882a593Smuzhiyun 	bool			rap_initialized;
167*4882a593Smuzhiyun 	uint32_t		session_id;
168*4882a593Smuzhiyun 	struct amdgpu_bo	*rap_shared_bo;
169*4882a593Smuzhiyun 	uint64_t		rap_shared_mc_addr;
170*4882a593Smuzhiyun 	void			*rap_shared_buf;
171*4882a593Smuzhiyun 	struct mutex		mutex;
172*4882a593Smuzhiyun };
173*4882a593Smuzhiyun 
174*4882a593Smuzhiyun #define MEM_TRAIN_SYSTEM_SIGNATURE		0x54534942
175*4882a593Smuzhiyun #define GDDR6_MEM_TRAINING_DATA_SIZE_IN_BYTES	0x1000
176*4882a593Smuzhiyun #define GDDR6_MEM_TRAINING_OFFSET		0x8000
177*4882a593Smuzhiyun /*Define the VRAM size that will be encroached by BIST training.*/
178*4882a593Smuzhiyun #define GDDR6_MEM_TRAINING_ENCROACHED_SIZE	0x2000000
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun enum psp_memory_training_init_flag {
181*4882a593Smuzhiyun 	PSP_MEM_TRAIN_NOT_SUPPORT	= 0x0,
182*4882a593Smuzhiyun 	PSP_MEM_TRAIN_SUPPORT		= 0x1,
183*4882a593Smuzhiyun 	PSP_MEM_TRAIN_INIT_FAILED	= 0x2,
184*4882a593Smuzhiyun 	PSP_MEM_TRAIN_RESERVE_SUCCESS	= 0x4,
185*4882a593Smuzhiyun 	PSP_MEM_TRAIN_INIT_SUCCESS	= 0x8,
186*4882a593Smuzhiyun };
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun enum psp_memory_training_ops {
189*4882a593Smuzhiyun 	PSP_MEM_TRAIN_SEND_LONG_MSG	= 0x1,
190*4882a593Smuzhiyun 	PSP_MEM_TRAIN_SAVE		= 0x2,
191*4882a593Smuzhiyun 	PSP_MEM_TRAIN_RESTORE		= 0x4,
192*4882a593Smuzhiyun 	PSP_MEM_TRAIN_SEND_SHORT_MSG	= 0x8,
193*4882a593Smuzhiyun 	PSP_MEM_TRAIN_COLD_BOOT		= PSP_MEM_TRAIN_SEND_LONG_MSG,
194*4882a593Smuzhiyun 	PSP_MEM_TRAIN_RESUME		= PSP_MEM_TRAIN_SEND_SHORT_MSG,
195*4882a593Smuzhiyun };
196*4882a593Smuzhiyun 
197*4882a593Smuzhiyun struct psp_memory_training_context {
198*4882a593Smuzhiyun 	/*training data size*/
199*4882a593Smuzhiyun 	u64 train_data_size;
200*4882a593Smuzhiyun 	/*
201*4882a593Smuzhiyun 	 * sys_cache
202*4882a593Smuzhiyun 	 * cpu virtual address
203*4882a593Smuzhiyun 	 * system memory buffer that used to store the training data.
204*4882a593Smuzhiyun 	 */
205*4882a593Smuzhiyun 	void *sys_cache;
206*4882a593Smuzhiyun 
207*4882a593Smuzhiyun 	/*vram offset of the p2c training data*/
208*4882a593Smuzhiyun 	u64 p2c_train_data_offset;
209*4882a593Smuzhiyun 
210*4882a593Smuzhiyun 	/*vram offset of the c2p training data*/
211*4882a593Smuzhiyun 	u64 c2p_train_data_offset;
212*4882a593Smuzhiyun 	struct amdgpu_bo *c2p_bo;
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun 	enum psp_memory_training_init_flag init;
215*4882a593Smuzhiyun 	u32 training_cnt;
216*4882a593Smuzhiyun };
217*4882a593Smuzhiyun 
218*4882a593Smuzhiyun struct psp_context
219*4882a593Smuzhiyun {
220*4882a593Smuzhiyun 	struct amdgpu_device            *adev;
221*4882a593Smuzhiyun 	struct psp_ring                 km_ring;
222*4882a593Smuzhiyun 	struct psp_gfx_cmd_resp		*cmd;
223*4882a593Smuzhiyun 
224*4882a593Smuzhiyun 	const struct psp_funcs		*funcs;
225*4882a593Smuzhiyun 
226*4882a593Smuzhiyun 	/* firmware buffer */
227*4882a593Smuzhiyun 	struct amdgpu_bo		*fw_pri_bo;
228*4882a593Smuzhiyun 	uint64_t			fw_pri_mc_addr;
229*4882a593Smuzhiyun 	void				*fw_pri_buf;
230*4882a593Smuzhiyun 
231*4882a593Smuzhiyun 	/* sos firmware */
232*4882a593Smuzhiyun 	const struct firmware		*sos_fw;
233*4882a593Smuzhiyun 	uint32_t			sos_fw_version;
234*4882a593Smuzhiyun 	uint32_t			sos_feature_version;
235*4882a593Smuzhiyun 	uint32_t			sys_bin_size;
236*4882a593Smuzhiyun 	uint32_t			sos_bin_size;
237*4882a593Smuzhiyun 	uint32_t			toc_bin_size;
238*4882a593Smuzhiyun 	uint32_t			kdb_bin_size;
239*4882a593Smuzhiyun 	uint32_t			spl_bin_size;
240*4882a593Smuzhiyun 	uint8_t				*sys_start_addr;
241*4882a593Smuzhiyun 	uint8_t				*sos_start_addr;
242*4882a593Smuzhiyun 	uint8_t				*toc_start_addr;
243*4882a593Smuzhiyun 	uint8_t				*kdb_start_addr;
244*4882a593Smuzhiyun 	uint8_t				*spl_start_addr;
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun 	/* tmr buffer */
247*4882a593Smuzhiyun 	struct amdgpu_bo		*tmr_bo;
248*4882a593Smuzhiyun 	uint64_t			tmr_mc_addr;
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun 	/* asd firmware */
251*4882a593Smuzhiyun 	const struct firmware		*asd_fw;
252*4882a593Smuzhiyun 	uint32_t			asd_fw_version;
253*4882a593Smuzhiyun 	uint32_t			asd_feature_version;
254*4882a593Smuzhiyun 	uint32_t			asd_ucode_size;
255*4882a593Smuzhiyun 	uint8_t				*asd_start_addr;
256*4882a593Smuzhiyun 
257*4882a593Smuzhiyun 	/* fence buffer */
258*4882a593Smuzhiyun 	struct amdgpu_bo		*fence_buf_bo;
259*4882a593Smuzhiyun 	uint64_t			fence_buf_mc_addr;
260*4882a593Smuzhiyun 	void				*fence_buf;
261*4882a593Smuzhiyun 
262*4882a593Smuzhiyun 	/* cmd buffer */
263*4882a593Smuzhiyun 	struct amdgpu_bo		*cmd_buf_bo;
264*4882a593Smuzhiyun 	uint64_t			cmd_buf_mc_addr;
265*4882a593Smuzhiyun 	struct psp_gfx_cmd_resp		*cmd_buf_mem;
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun 	/* fence value associated with cmd buffer */
268*4882a593Smuzhiyun 	atomic_t			fence_value;
269*4882a593Smuzhiyun 	/* flag to mark whether gfx fw autoload is supported or not */
270*4882a593Smuzhiyun 	bool				autoload_supported;
271*4882a593Smuzhiyun 	/* flag to mark whether df cstate management centralized to PMFW */
272*4882a593Smuzhiyun 	bool				pmfw_centralized_cstate_management;
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun 	/* xgmi ta firmware and buffer */
275*4882a593Smuzhiyun 	const struct firmware		*ta_fw;
276*4882a593Smuzhiyun 	uint32_t			ta_fw_version;
277*4882a593Smuzhiyun 	uint32_t			ta_xgmi_ucode_version;
278*4882a593Smuzhiyun 	uint32_t			ta_xgmi_ucode_size;
279*4882a593Smuzhiyun 	uint8_t				*ta_xgmi_start_addr;
280*4882a593Smuzhiyun 	uint32_t			ta_ras_ucode_version;
281*4882a593Smuzhiyun 	uint32_t			ta_ras_ucode_size;
282*4882a593Smuzhiyun 	uint8_t				*ta_ras_start_addr;
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun 	uint32_t			ta_hdcp_ucode_version;
285*4882a593Smuzhiyun 	uint32_t			ta_hdcp_ucode_size;
286*4882a593Smuzhiyun 	uint8_t				*ta_hdcp_start_addr;
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun 	uint32_t			ta_dtm_ucode_version;
289*4882a593Smuzhiyun 	uint32_t			ta_dtm_ucode_size;
290*4882a593Smuzhiyun 	uint8_t				*ta_dtm_start_addr;
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun 	uint32_t			ta_rap_ucode_version;
293*4882a593Smuzhiyun 	uint32_t			ta_rap_ucode_size;
294*4882a593Smuzhiyun 	uint8_t				*ta_rap_start_addr;
295*4882a593Smuzhiyun 
296*4882a593Smuzhiyun 	struct psp_asd_context		asd_context;
297*4882a593Smuzhiyun 	struct psp_xgmi_context		xgmi_context;
298*4882a593Smuzhiyun 	struct psp_ras_context		ras;
299*4882a593Smuzhiyun 	struct psp_hdcp_context 	hdcp_context;
300*4882a593Smuzhiyun 	struct psp_dtm_context		dtm_context;
301*4882a593Smuzhiyun 	struct psp_rap_context		rap_context;
302*4882a593Smuzhiyun 	struct mutex			mutex;
303*4882a593Smuzhiyun 	struct psp_memory_training_context mem_train_ctx;
304*4882a593Smuzhiyun };
305*4882a593Smuzhiyun 
306*4882a593Smuzhiyun struct amdgpu_psp_funcs {
307*4882a593Smuzhiyun 	bool (*check_fw_loading_status)(struct amdgpu_device *adev,
308*4882a593Smuzhiyun 					enum AMDGPU_UCODE_ID);
309*4882a593Smuzhiyun };
310*4882a593Smuzhiyun 
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun #define psp_ring_init(psp, type) (psp)->funcs->ring_init((psp), (type))
313*4882a593Smuzhiyun #define psp_ring_create(psp, type) (psp)->funcs->ring_create((psp), (type))
314*4882a593Smuzhiyun #define psp_ring_stop(psp, type) (psp)->funcs->ring_stop((psp), (type))
315*4882a593Smuzhiyun #define psp_ring_destroy(psp, type) ((psp)->funcs->ring_destroy((psp), (type)))
316*4882a593Smuzhiyun #define psp_init_microcode(psp) \
317*4882a593Smuzhiyun 		((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0)
318*4882a593Smuzhiyun #define psp_bootloader_load_kdb(psp) \
319*4882a593Smuzhiyun 		((psp)->funcs->bootloader_load_kdb ? (psp)->funcs->bootloader_load_kdb((psp)) : 0)
320*4882a593Smuzhiyun #define psp_bootloader_load_spl(psp) \
321*4882a593Smuzhiyun 		((psp)->funcs->bootloader_load_spl ? (psp)->funcs->bootloader_load_spl((psp)) : 0)
322*4882a593Smuzhiyun #define psp_bootloader_load_sysdrv(psp) \
323*4882a593Smuzhiyun 		((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0)
324*4882a593Smuzhiyun #define psp_bootloader_load_sos(psp) \
325*4882a593Smuzhiyun 		((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0)
326*4882a593Smuzhiyun #define psp_smu_reload_quirk(psp) \
327*4882a593Smuzhiyun 		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
328*4882a593Smuzhiyun #define psp_mode1_reset(psp) \
329*4882a593Smuzhiyun 		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
330*4882a593Smuzhiyun #define psp_mem_training(psp, ops) \
331*4882a593Smuzhiyun 	((psp)->funcs->mem_training ? (psp)->funcs->mem_training((psp), (ops)) : 0)
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun #define psp_ring_get_wptr(psp) (psp)->funcs->ring_get_wptr((psp))
334*4882a593Smuzhiyun #define psp_ring_set_wptr(psp, value) (psp)->funcs->ring_set_wptr((psp), (value))
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun #define psp_load_usbc_pd_fw(psp, dma_addr) \
337*4882a593Smuzhiyun 	((psp)->funcs->load_usbc_pd_fw ? \
338*4882a593Smuzhiyun 	(psp)->funcs->load_usbc_pd_fw((psp), (dma_addr)) : -EINVAL)
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun #define psp_read_usbc_pd_fw(psp, fw_ver) \
341*4882a593Smuzhiyun 	((psp)->funcs->read_usbc_pd_fw ? \
342*4882a593Smuzhiyun 	(psp)->funcs->read_usbc_pd_fw((psp), fw_ver) : -EINVAL)
343*4882a593Smuzhiyun 
344*4882a593Smuzhiyun extern const struct amd_ip_funcs psp_ip_funcs;
345*4882a593Smuzhiyun 
346*4882a593Smuzhiyun extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
347*4882a593Smuzhiyun extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index,
348*4882a593Smuzhiyun 			uint32_t field_val, uint32_t mask, bool check_changed);
349*4882a593Smuzhiyun 
350*4882a593Smuzhiyun extern const struct amdgpu_ip_block_version psp_v10_0_ip_block;
351*4882a593Smuzhiyun extern const struct amdgpu_ip_block_version psp_v12_0_ip_block;
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun int psp_gpu_reset(struct amdgpu_device *adev);
354*4882a593Smuzhiyun int psp_update_vcn_sram(struct amdgpu_device *adev, int inst_idx,
355*4882a593Smuzhiyun 			uint64_t cmd_gpu_addr, int cmd_size);
356*4882a593Smuzhiyun 
357*4882a593Smuzhiyun int psp_xgmi_initialize(struct psp_context *psp);
358*4882a593Smuzhiyun int psp_xgmi_terminate(struct psp_context *psp);
359*4882a593Smuzhiyun int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
360*4882a593Smuzhiyun int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id);
361*4882a593Smuzhiyun int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id);
362*4882a593Smuzhiyun int psp_xgmi_get_topology_info(struct psp_context *psp,
363*4882a593Smuzhiyun 			       int number_devices,
364*4882a593Smuzhiyun 			       struct psp_xgmi_topology_info *topology);
365*4882a593Smuzhiyun int psp_xgmi_set_topology_info(struct psp_context *psp,
366*4882a593Smuzhiyun 			       int number_devices,
367*4882a593Smuzhiyun 			       struct psp_xgmi_topology_info *topology);
368*4882a593Smuzhiyun 
369*4882a593Smuzhiyun int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
370*4882a593Smuzhiyun int psp_ras_enable_features(struct psp_context *psp,
371*4882a593Smuzhiyun 		union ta_ras_cmd_input *info, bool enable);
372*4882a593Smuzhiyun int psp_ras_trigger_error(struct psp_context *psp,
373*4882a593Smuzhiyun 			  struct ta_ras_trigger_error_input *info);
374*4882a593Smuzhiyun 
375*4882a593Smuzhiyun int psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
376*4882a593Smuzhiyun int psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
377*4882a593Smuzhiyun int psp_rap_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
378*4882a593Smuzhiyun 
379*4882a593Smuzhiyun int psp_rlc_autoload_start(struct psp_context *psp);
380*4882a593Smuzhiyun 
381*4882a593Smuzhiyun extern const struct amdgpu_ip_block_version psp_v11_0_ip_block;
382*4882a593Smuzhiyun int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg,
383*4882a593Smuzhiyun 		uint32_t value);
384*4882a593Smuzhiyun int psp_ring_cmd_submit(struct psp_context *psp,
385*4882a593Smuzhiyun 			uint64_t cmd_buf_mc_addr,
386*4882a593Smuzhiyun 			uint64_t fence_mc_addr,
387*4882a593Smuzhiyun 			int index);
388*4882a593Smuzhiyun int psp_init_asd_microcode(struct psp_context *psp,
389*4882a593Smuzhiyun 			   const char *chip_name);
390*4882a593Smuzhiyun int psp_init_sos_microcode(struct psp_context *psp,
391*4882a593Smuzhiyun 			   const char *chip_name);
392*4882a593Smuzhiyun int psp_init_ta_microcode(struct psp_context *psp,
393*4882a593Smuzhiyun 			  const char *chip_name);
394*4882a593Smuzhiyun #endif
395