xref: /linux/drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h (revision 36ec807b627b4c0a0a382f0ae48eac7187d14b2b)
10e5ca0d1SHuang Rui /*
20e5ca0d1SHuang Rui  * Copyright 2017 Advanced Micro Devices, Inc.
30e5ca0d1SHuang Rui  *
40e5ca0d1SHuang Rui  * Permission is hereby granted, free of charge, to any person obtaining a
50e5ca0d1SHuang Rui  * copy of this software and associated documentation files (the "Software"),
60e5ca0d1SHuang Rui  * to deal in the Software without restriction, including without limitation
70e5ca0d1SHuang Rui  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80e5ca0d1SHuang Rui  * and/or sell copies of the Software, and to permit persons to whom the
90e5ca0d1SHuang Rui  * Software is furnished to do so, subject to the following conditions:
100e5ca0d1SHuang Rui  *
110e5ca0d1SHuang Rui  * The above copyright notice and this permission notice shall be included in
120e5ca0d1SHuang Rui  * all copies or substantial portions of the Software.
130e5ca0d1SHuang Rui  *
140e5ca0d1SHuang Rui  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
150e5ca0d1SHuang Rui  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
160e5ca0d1SHuang Rui  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
170e5ca0d1SHuang Rui  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
180e5ca0d1SHuang Rui  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
190e5ca0d1SHuang Rui  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
200e5ca0d1SHuang Rui  * OTHER DEALINGS IN THE SOFTWARE.
210e5ca0d1SHuang Rui  *
220e5ca0d1SHuang Rui  */
230e5ca0d1SHuang Rui 
240e5ca0d1SHuang Rui #ifndef _PSP_TEE_GFX_IF_H_
250e5ca0d1SHuang Rui #define _PSP_TEE_GFX_IF_H_
260e5ca0d1SHuang Rui 
270e5ca0d1SHuang Rui #define PSP_GFX_CMD_BUF_VERSION     0x00000001
280e5ca0d1SHuang Rui 
290e5ca0d1SHuang Rui #define GFX_CMD_STATUS_MASK         0x0000FFFF
300e5ca0d1SHuang Rui #define GFX_CMD_ID_MASK             0x000F0000
310e5ca0d1SHuang Rui #define GFX_CMD_RESERVED_MASK       0x7FF00000
320e5ca0d1SHuang Rui #define GFX_CMD_RESPONSE_MASK       0x80000000
330e5ca0d1SHuang Rui 
340dc93fd1SAndrey Grodzovsky /* USBC PD FW version retrieval command */
350dc93fd1SAndrey Grodzovsky #define C2PMSG_CMD_GFX_USB_PD_FW_VER 0x2000000
360dc93fd1SAndrey Grodzovsky 
370e5ca0d1SHuang Rui /* TEE Gfx Command IDs for the register interface.
380e5ca0d1SHuang Rui *  Command ID must be between 0x00010000 and 0x000F0000.
390e5ca0d1SHuang Rui */
400e5ca0d1SHuang Rui enum psp_gfx_crtl_cmd_id
410e5ca0d1SHuang Rui {
420e5ca0d1SHuang Rui     GFX_CTRL_CMD_ID_INIT_RBI_RING   = 0x00010000,   /* initialize RBI ring */
430e5ca0d1SHuang Rui     GFX_CTRL_CMD_ID_INIT_GPCOM_RING = 0x00020000,   /* initialize GPCOM ring */
440e5ca0d1SHuang Rui     GFX_CTRL_CMD_ID_DESTROY_RINGS   = 0x00030000,   /* destroy rings */
450e5ca0d1SHuang Rui     GFX_CTRL_CMD_ID_CAN_INIT_RINGS  = 0x00040000,   /* is it allowed to initialized the rings */
46cf671071SHuang Rui     GFX_CTRL_CMD_ID_ENABLE_INT      = 0x00050000,   /* enable PSP-to-Gfx interrupt */
47cf671071SHuang Rui     GFX_CTRL_CMD_ID_DISABLE_INT     = 0x00060000,   /* disable PSP-to-Gfx interrupt */
48cf671071SHuang Rui     GFX_CTRL_CMD_ID_MODE1_RST       = 0x00070000,   /* trigger the Mode 1 reset */
49516bc3d8SChristian König     GFX_CTRL_CMD_ID_GBR_IH_SET      = 0x00080000,   /* set Gbr IH_RB_CNTL registers */
50d1176dd5SVictor Zhao     GFX_CTRL_CMD_ID_CONSUME_CMD     = 0x00090000,   /* send interrupt to psp for updating write pointer of vf */
515ec996dfSXiangliang Yu     GFX_CTRL_CMD_ID_DESTROY_GPCOM_RING = 0x000C0000, /* destroy GPCOM ring */
520e5ca0d1SHuang Rui 
530e5ca0d1SHuang Rui     GFX_CTRL_CMD_ID_MAX             = 0x000F0000,   /* max command ID */
540e5ca0d1SHuang Rui };
550e5ca0d1SHuang Rui 
560e5ca0d1SHuang Rui 
57cf671071SHuang Rui /*-----------------------------------------------------------------------------
58cf671071SHuang Rui     NOTE:   All physical addresses used in this interface are actually
59cf671071SHuang Rui             GPU Virtual Addresses.
60cf671071SHuang Rui */
61cf671071SHuang Rui 
62cf671071SHuang Rui 
630e5ca0d1SHuang Rui /* Control registers of the TEE Gfx interface. These are located in
640e5ca0d1SHuang Rui *  SRBM-to-PSP mailbox registers (total 8 registers).
650e5ca0d1SHuang Rui */
660e5ca0d1SHuang Rui struct psp_gfx_ctrl
670e5ca0d1SHuang Rui {
680e5ca0d1SHuang Rui     volatile uint32_t   cmd_resp;         /* +0   Command/Response register for Gfx commands */
690e5ca0d1SHuang Rui     volatile uint32_t   rbi_wptr;         /* +4   Write pointer (index) of RBI ring */
700e5ca0d1SHuang Rui     volatile uint32_t   rbi_rptr;         /* +8   Read pointer (index) of RBI ring */
710e5ca0d1SHuang Rui     volatile uint32_t   gpcom_wptr;       /* +12  Write pointer (index) of GPCOM ring */
720e5ca0d1SHuang Rui     volatile uint32_t   gpcom_rptr;       /* +16  Read pointer (index) of GPCOM ring */
73cf671071SHuang Rui     volatile uint32_t   ring_addr_lo;     /* +20  bits [31:0] of GPU Virtual of ring buffer (VMID=0)*/
74cf671071SHuang Rui     volatile uint32_t   ring_addr_hi;     /* +24  bits [63:32] of GPU Virtual of ring buffer (VMID=0) */
750e5ca0d1SHuang Rui     volatile uint32_t   ring_buf_size;    /* +28  Ring buffer size (in bytes) */
760e5ca0d1SHuang Rui 
770e5ca0d1SHuang Rui };
780e5ca0d1SHuang Rui 
790e5ca0d1SHuang Rui 
800e5ca0d1SHuang Rui /* Response flag is set in the command when command is completed by PSP.
810e5ca0d1SHuang Rui *  Used in the GFX_CTRL.CmdResp.
820e5ca0d1SHuang Rui *  When PSP GFX I/F is initialized, the flag is set.
830e5ca0d1SHuang Rui */
840e5ca0d1SHuang Rui #define GFX_FLAG_RESPONSE               0x80000000
850e5ca0d1SHuang Rui 
860e5ca0d1SHuang Rui /* TEE Gfx Command IDs for the ring buffer interface. */
870e5ca0d1SHuang Rui enum psp_gfx_cmd_id
880e5ca0d1SHuang Rui {
890e5ca0d1SHuang Rui     GFX_CMD_ID_LOAD_TA            = 0x00000001,   /* load TA */
900e5ca0d1SHuang Rui     GFX_CMD_ID_UNLOAD_TA          = 0x00000002,   /* unload TA */
910e5ca0d1SHuang Rui     GFX_CMD_ID_INVOKE_CMD         = 0x00000003,   /* send command to TA */
920e5ca0d1SHuang Rui     GFX_CMD_ID_LOAD_ASD           = 0x00000004,   /* load ASD Driver */
930e5ca0d1SHuang Rui     GFX_CMD_ID_SETUP_TMR          = 0x00000005,   /* setup TMR region */
940e5ca0d1SHuang Rui     GFX_CMD_ID_LOAD_IP_FW         = 0x00000006,   /* load HW IP FW */
95cf671071SHuang Rui     GFX_CMD_ID_DESTROY_TMR        = 0x00000007,   /* destroy TMR region */
96cf671071SHuang Rui     GFX_CMD_ID_SAVE_RESTORE       = 0x00000008,   /* save/restore HW IP FW */
975ec996dfSXiangliang Yu     GFX_CMD_ID_SETUP_VMR          = 0x00000009,   /* setup VMR region */
985ec996dfSXiangliang Yu     GFX_CMD_ID_DESTROY_VMR        = 0x0000000A,   /* destroy VMR region */
993880369fSTrigger Huang     GFX_CMD_ID_PROG_REG           = 0x0000000B,   /* program regs */
10019ae3330SJohn Clements     GFX_CMD_ID_GET_FW_ATTESTATION = 0x0000000F,   /* Query GPUVA of the Fw Attestation DB */
1014414ec6dSHawking Zhang     /* IDs upto 0x1F are reserved for older programs (Raven, Vega 10/12/20) */
1024414ec6dSHawking Zhang     GFX_CMD_ID_LOAD_TOC           = 0x00000020,   /* Load TOC and obtain TMR size */
1034414ec6dSHawking Zhang     GFX_CMD_ID_AUTOLOAD_RLC       = 0x00000021,   /* Indicates all graphics fw loaded, start RLC autoload */
104e40889ecSJohn Clements     GFX_CMD_ID_BOOT_CFG           = 0x00000022,   /* Boot Config */
105ba08e9cbSLijo Lazar     GFX_CMD_ID_SRIOV_SPATIAL_PART = 0x00000027,   /* Configure spatial partitioning mode */
106e40889ecSJohn Clements };
107e40889ecSJohn Clements 
108e40889ecSJohn Clements /* PSP boot config sub-commands */
109e40889ecSJohn Clements enum psp_gfx_boot_config_cmd
110e40889ecSJohn Clements {
111e40889ecSJohn Clements     BOOTCFG_CMD_SET         = 1, /* Set boot configuration settings */
112e40889ecSJohn Clements     BOOTCFG_CMD_GET         = 2, /* Get boot configuration settings */
113e40889ecSJohn Clements     BOOTCFG_CMD_INVALIDATE  = 3  /* Reset current boot configuration settings to VBIOS defaults */
114e40889ecSJohn Clements };
115e40889ecSJohn Clements 
116e40889ecSJohn Clements /* PSP boot config bitmask values */
117e40889ecSJohn Clements enum psp_gfx_boot_config
118e40889ecSJohn Clements {
119e40889ecSJohn Clements     BOOT_CONFIG_GECC = 0x1,
1200e5ca0d1SHuang Rui };
1210e5ca0d1SHuang Rui 
1220e5ca0d1SHuang Rui /* Command to load Trusted Application binary into PSP OS. */
1230e5ca0d1SHuang Rui struct psp_gfx_cmd_load_ta
1240e5ca0d1SHuang Rui {
125cf671071SHuang Rui     uint32_t        app_phy_addr_lo;        /* bits [31:0] of the GPU Virtual address of the TA binary (must be 4 KB aligned) */
126cf671071SHuang Rui     uint32_t        app_phy_addr_hi;        /* bits [63:32] of the GPU Virtual address of the TA binary */
1270e5ca0d1SHuang Rui     uint32_t        app_len;                /* length of the TA binary in bytes */
128cf671071SHuang Rui     uint32_t        cmd_buf_phy_addr_lo;    /* bits [31:0] of the GPU Virtual address of CMD buffer (must be 4 KB aligned) */
129cf671071SHuang Rui     uint32_t        cmd_buf_phy_addr_hi;    /* bits [63:32] of the GPU Virtual address of CMD buffer */
1300e5ca0d1SHuang Rui     uint32_t        cmd_buf_len;            /* length of the CMD buffer in bytes; must be multiple of 4 KB */
1310e5ca0d1SHuang Rui 
1320e5ca0d1SHuang Rui     /* Note: CmdBufLen can be set to 0. In this case no persistent CMD buffer is provided
1330e5ca0d1SHuang Rui     *       for the TA. Each InvokeCommand can have dinamically mapped CMD buffer instead
1340e5ca0d1SHuang Rui     *       of using global persistent buffer.
1350e5ca0d1SHuang Rui     */
1360e5ca0d1SHuang Rui };
1370e5ca0d1SHuang Rui 
1380e5ca0d1SHuang Rui 
1390e5ca0d1SHuang Rui /* Command to Unload Trusted Application binary from PSP OS. */
1400e5ca0d1SHuang Rui struct psp_gfx_cmd_unload_ta
1410e5ca0d1SHuang Rui {
1420e5ca0d1SHuang Rui     uint32_t        session_id;          /* Session ID of the loaded TA to be unloaded */
1430e5ca0d1SHuang Rui 
1440e5ca0d1SHuang Rui };
1450e5ca0d1SHuang Rui 
1460e5ca0d1SHuang Rui 
1470e5ca0d1SHuang Rui /* Shared buffers for InvokeCommand.
1480e5ca0d1SHuang Rui */
1490e5ca0d1SHuang Rui struct psp_gfx_buf_desc
1500e5ca0d1SHuang Rui {
151cf671071SHuang Rui     uint32_t        buf_phy_addr_lo;       /* bits [31:0] of GPU Virtual address of the buffer (must be 4 KB aligned) */
152cf671071SHuang Rui     uint32_t        buf_phy_addr_hi;       /* bits [63:32] of GPU Virtual address of the buffer */
1530e5ca0d1SHuang Rui     uint32_t        buf_size;              /* buffer size in bytes (must be multiple of 4 KB and no bigger than 64 MB) */
1540e5ca0d1SHuang Rui 
1550e5ca0d1SHuang Rui };
1560e5ca0d1SHuang Rui 
1570e5ca0d1SHuang Rui /* Max number of descriptors for one shared buffer (in how many different
1580e5ca0d1SHuang Rui *  physical locations one shared buffer can be stored). If buffer is too much
1590e5ca0d1SHuang Rui *  fragmented, error will be returned.
1600e5ca0d1SHuang Rui */
1610e5ca0d1SHuang Rui #define GFX_BUF_MAX_DESC        64
1620e5ca0d1SHuang Rui 
1630e5ca0d1SHuang Rui struct psp_gfx_buf_list
1640e5ca0d1SHuang Rui {
1650e5ca0d1SHuang Rui     uint32_t                num_desc;                    /* number of buffer descriptors in the list */
1660e5ca0d1SHuang Rui     uint32_t                total_size;                  /* total size of all buffers in the list in bytes (must be multiple of 4 KB) */
1670e5ca0d1SHuang Rui     struct psp_gfx_buf_desc buf_desc[GFX_BUF_MAX_DESC];  /* list of buffer descriptors */
1680e5ca0d1SHuang Rui 
1690e5ca0d1SHuang Rui     /* total 776 bytes */
1700e5ca0d1SHuang Rui };
1710e5ca0d1SHuang Rui 
1720e5ca0d1SHuang Rui /* Command to execute InvokeCommand entry point of the TA. */
1730e5ca0d1SHuang Rui struct psp_gfx_cmd_invoke_cmd
1740e5ca0d1SHuang Rui {
1750e5ca0d1SHuang Rui     uint32_t                session_id;           /* Session ID of the TA to be executed */
1760e5ca0d1SHuang Rui     uint32_t                ta_cmd_id;            /* Command ID to be sent to TA */
1770e5ca0d1SHuang Rui     struct psp_gfx_buf_list buf;                  /* one indirect buffer (scatter/gather list) */
1780e5ca0d1SHuang Rui 
1790e5ca0d1SHuang Rui };
1800e5ca0d1SHuang Rui 
1810e5ca0d1SHuang Rui 
1820e5ca0d1SHuang Rui /* Command to setup TMR region. */
1830e5ca0d1SHuang Rui struct psp_gfx_cmd_setup_tmr
1840e5ca0d1SHuang Rui {
185cf671071SHuang Rui     uint32_t        buf_phy_addr_lo;       /* bits [31:0] of GPU Virtual address of TMR buffer (must be 4 KB aligned) */
186cf671071SHuang Rui     uint32_t        buf_phy_addr_hi;       /* bits [63:32] of GPU Virtual address of TMR buffer */
1870e5ca0d1SHuang Rui     uint32_t        buf_size;              /* buffer size in bytes (must be multiple of 4 KB) */
18836c08237SOak Zeng     union {
18936c08237SOak Zeng 	struct {
19036c08237SOak Zeng 		uint32_t	sriov_enabled:1; /* whether the device runs under SR-IOV*/
19136c08237SOak Zeng 		uint32_t	virt_phy_addr:1; /* driver passes both virtual and physical address to PSP*/
19236c08237SOak Zeng 		uint32_t	reserved:30;
19336c08237SOak Zeng 	} bitfield;
19436c08237SOak Zeng 	uint32_t        tmr_flags;
19536c08237SOak Zeng     };
19636c08237SOak Zeng     uint32_t        system_phy_addr_lo;        /* bits [31:0] of system physical address of TMR buffer (must be 4 KB aligned) */
19736c08237SOak Zeng     uint32_t        system_phy_addr_hi;        /* bits [63:32] of system physical address of TMR buffer */
1980e5ca0d1SHuang Rui 
1990e5ca0d1SHuang Rui };
2000e5ca0d1SHuang Rui 
2010e5ca0d1SHuang Rui /* FW types for GFX_CMD_ID_LOAD_IP_FW command. Limit 31. */
2024414ec6dSHawking Zhang enum psp_gfx_fw_type {
2034414ec6dSHawking Zhang 	GFX_FW_TYPE_NONE        = 0,    /* */
2044414ec6dSHawking Zhang 	GFX_FW_TYPE_CP_ME       = 1,    /* CP-ME                    VG + RV */
2054414ec6dSHawking Zhang 	GFX_FW_TYPE_CP_PFP      = 2,    /* CP-PFP                   VG + RV */
2064414ec6dSHawking Zhang 	GFX_FW_TYPE_CP_CE       = 3,    /* CP-CE                    VG + RV */
2074414ec6dSHawking Zhang 	GFX_FW_TYPE_CP_MEC      = 4,    /* CP-MEC FW                VG + RV */
2084414ec6dSHawking Zhang 	GFX_FW_TYPE_CP_MEC_ME1  = 5,    /* CP-MEC Jump Table 1      VG + RV */
2094414ec6dSHawking Zhang 	GFX_FW_TYPE_CP_MEC_ME2  = 6,    /* CP-MEC Jump Table 2      VG      */
2104414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_V       = 7,    /* RLC-V                    VG      */
2114414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_G       = 8,    /* RLC-G                    VG + RV */
2124414ec6dSHawking Zhang 	GFX_FW_TYPE_SDMA0       = 9,    /* SDMA0                    VG + RV */
2134414ec6dSHawking Zhang 	GFX_FW_TYPE_SDMA1       = 10,   /* SDMA1                    VG      */
2144414ec6dSHawking Zhang 	GFX_FW_TYPE_DMCU_ERAM   = 11,   /* DMCU-ERAM                VG + RV */
2154414ec6dSHawking Zhang 	GFX_FW_TYPE_DMCU_ISR    = 12,   /* DMCU-ISR                 VG + RV */
2164414ec6dSHawking Zhang 	GFX_FW_TYPE_VCN         = 13,   /* VCN                           RV */
2174414ec6dSHawking Zhang 	GFX_FW_TYPE_UVD         = 14,   /* UVD                      VG      */
2184414ec6dSHawking Zhang 	GFX_FW_TYPE_VCE         = 15,   /* VCE                      VG      */
2194414ec6dSHawking Zhang 	GFX_FW_TYPE_ISP         = 16,   /* ISP                           RV */
2204414ec6dSHawking Zhang 	GFX_FW_TYPE_ACP         = 17,   /* ACP                           RV */
2214414ec6dSHawking Zhang 	GFX_FW_TYPE_SMU         = 18,   /* SMU                      VG      */
2224414ec6dSHawking Zhang 	GFX_FW_TYPE_MMSCH       = 19,   /* MMSCH                    VG      */
2234414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_RESTORE_LIST_GPM_MEM        = 20,   /* RLC GPM                  VG + RV */
2244414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_RESTORE_LIST_SRM_MEM        = 21,   /* RLC SRM                  VG + RV */
2254414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_RESTORE_LIST_SRM_CNTL       = 22,   /* RLC CNTL                 VG + RV */
2264414ec6dSHawking Zhang 	GFX_FW_TYPE_UVD1        = 23,   /* UVD1                     VG-20   */
2274414ec6dSHawking Zhang 	GFX_FW_TYPE_TOC         = 24,   /* TOC                      NV-10   */
2284414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_P                           = 25,   /* RLC P                    NV      */
2295bab858eSLikun Gao 	GFX_FW_TYPE_RLC_IRAM                        = 26,   /* RLC_IRAM                 NV      */
2304414ec6dSHawking Zhang 	GFX_FW_TYPE_GLOBAL_TAP_DELAYS               = 27,   /* GLOBAL TAP DELAYS        NV      */
2314414ec6dSHawking Zhang 	GFX_FW_TYPE_SE0_TAP_DELAYS                  = 28,   /* SE0 TAP DELAYS           NV      */
2324414ec6dSHawking Zhang 	GFX_FW_TYPE_SE1_TAP_DELAYS                  = 29,   /* SE1 TAP DELAYS           NV      */
2334414ec6dSHawking Zhang 	GFX_FW_TYPE_GLOBAL_SE0_SE1_SKEW_DELAYS      = 30,   /* GLOBAL SE0/1 SKEW DELAYS NV      */
2344414ec6dSHawking Zhang 	GFX_FW_TYPE_SDMA0_JT                        = 31,   /* SDMA0 JT                 NV      */
2354414ec6dSHawking Zhang 	GFX_FW_TYPE_SDMA1_JT                        = 32,   /* SDNA1 JT                 NV      */
2364414ec6dSHawking Zhang 	GFX_FW_TYPE_CP_MES                          = 33,   /* CP MES                   NV      */
2374414ec6dSHawking Zhang 	GFX_FW_TYPE_MES_STACK                       = 34,   /* MES STACK                NV      */
2384414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_SRM_DRAM_SR                 = 35,   /* RLC SRM DRAM             NV      */
2394414ec6dSHawking Zhang 	GFX_FW_TYPE_RLCG_SCRATCH_SR                 = 36,   /* RLCG SCRATCH             NV      */
2404414ec6dSHawking Zhang 	GFX_FW_TYPE_RLCP_SCRATCH_SR                 = 37,   /* RLCP SCRATCH             NV      */
2414414ec6dSHawking Zhang 	GFX_FW_TYPE_RLCV_SCRATCH_SR                 = 38,   /* RLCV SCRATCH             NV      */
2424414ec6dSHawking Zhang 	GFX_FW_TYPE_RLX6_DRAM_SR                    = 39,   /* RLX6 DRAM                NV      */
2434414ec6dSHawking Zhang 	GFX_FW_TYPE_SDMA0_PG_CONTEXT                = 40,   /* SDMA0 PG CONTEXT         NV      */
2444414ec6dSHawking Zhang 	GFX_FW_TYPE_SDMA1_PG_CONTEXT                = 41,   /* SDMA1 PG CONTEXT         NV      */
2454414ec6dSHawking Zhang 	GFX_FW_TYPE_GLOBAL_MUX_SELECT_RAM           = 42,   /* GLOBAL MUX SEL RAM       NV      */
2464414ec6dSHawking Zhang 	GFX_FW_TYPE_SE0_MUX_SELECT_RAM              = 43,   /* SE0 MUX SEL RAM          NV      */
2474414ec6dSHawking Zhang 	GFX_FW_TYPE_SE1_MUX_SELECT_RAM              = 44,   /* SE1 MUX SEL RAM          NV      */
2484414ec6dSHawking Zhang 	GFX_FW_TYPE_ACCUM_CTRL_RAM                  = 45,   /* ACCUM CTRL RAM           NV      */
2494414ec6dSHawking Zhang 	GFX_FW_TYPE_RLCP_CAM                        = 46,   /* RLCP CAM                 NV      */
2504414ec6dSHawking Zhang 	GFX_FW_TYPE_RLC_SPP_CAM_EXT                 = 47,   /* RLC SPP CAM EXT          NV      */
2515bab858eSLikun Gao 	GFX_FW_TYPE_RLC_DRAM_BOOT                   = 48,   /* RLC DRAM BOOT            NV      */
252b86f8d8bSJohn Clements 	GFX_FW_TYPE_VCN0_RAM                        = 49,   /* VCN_RAM                  NV + RN */
253b86f8d8bSJohn Clements 	GFX_FW_TYPE_VCN1_RAM                        = 50,   /* VCN_RAM                  NV + RN */
254b86f8d8bSJohn Clements 	GFX_FW_TYPE_DMUB                            = 51,   /* DMUB                          RN */
255b86f8d8bSJohn Clements 	GFX_FW_TYPE_SDMA2                           = 52,   /* SDMA2                    MI      */
256b86f8d8bSJohn Clements 	GFX_FW_TYPE_SDMA3                           = 53,   /* SDMA3                    MI      */
257b86f8d8bSJohn Clements 	GFX_FW_TYPE_SDMA4                           = 54,   /* SDMA4                    MI      */
258b86f8d8bSJohn Clements 	GFX_FW_TYPE_SDMA5                           = 55,   /* SDMA5                    MI      */
259b86f8d8bSJohn Clements 	GFX_FW_TYPE_SDMA6                           = 56,   /* SDMA6                    MI      */
260b86f8d8bSJohn Clements 	GFX_FW_TYPE_SDMA7                           = 57,   /* SDMA7                    MI      */
261d83c7a07SJane Jian 	GFX_FW_TYPE_VCN1                            = 58,   /* VCN1                     MI      */
262c4381d0eSBokun Zhang 	GFX_FW_TYPE_CAP                             = 62,   /* CAP_FW                           */
2632207efddSChengming Gui 	GFX_FW_TYPE_SE2_TAP_DELAYS                  = 65,   /* SE2 TAP DELAYS           NV      */
2642207efddSChengming Gui 	GFX_FW_TYPE_SE3_TAP_DELAYS                  = 66,   /* SE3 TAP DELAYS           NV      */
265d74decc4SJohn Clements 	GFX_FW_TYPE_REG_LIST                        = 67,   /* REG_LIST                 MI      */
26647a20385SLikun Gao 	GFX_FW_TYPE_IMU_I                           = 68,   /* IMU Instruction FW       SOC21   */
26747a20385SLikun Gao 	GFX_FW_TYPE_IMU_D                           = 69,   /* IMU Data FW              SOC21   */
26847a20385SLikun Gao 	GFX_FW_TYPE_LSDMA                           = 70,   /* LSDMA FW                 SOC21   */
26947a20385SLikun Gao 	GFX_FW_TYPE_SDMA_UCODE_TH0                  = 71,   /* SDMA Thread 0/CTX        SOC21   */
27047a20385SLikun Gao 	GFX_FW_TYPE_SDMA_UCODE_TH1                  = 72,   /* SDMA Thread 1/CTL        SOC21   */
27147a20385SLikun Gao 	GFX_FW_TYPE_PPTABLE                         = 73,   /* PPTABLE                  SOC21   */
27247a20385SLikun Gao 	GFX_FW_TYPE_DISCRETE_USB4                   = 74,   /* dUSB4 FW                 SOC21   */
27347a20385SLikun Gao 	GFX_FW_TYPE_TA                              = 75,   /* SRIOV TA FW UUID         SOC21   */
27447a20385SLikun Gao 	GFX_FW_TYPE_RS64_MES                        = 76,   /* RS64 MES ucode           SOC21   */
27547a20385SLikun Gao 	GFX_FW_TYPE_RS64_MES_STACK                  = 77,   /* RS64 MES stack ucode     SOC21   */
27647a20385SLikun Gao 	GFX_FW_TYPE_RS64_KIQ                        = 78,   /* RS64 KIQ ucode           SOC21   */
27747a20385SLikun Gao 	GFX_FW_TYPE_RS64_KIQ_STACK                  = 79,   /* RS64 KIQ Heap stack      SOC21   */
27847a20385SLikun Gao 	GFX_FW_TYPE_ISP_DATA                        = 80,   /* ISP DATA                 SOC21   */
27947a20385SLikun Gao 	GFX_FW_TYPE_CP_MES_KIQ                      = 81,   /* MES KIQ ucode            SOC21   */
28047a20385SLikun Gao 	GFX_FW_TYPE_MES_KIQ_STACK                   = 82,   /* MES KIQ stack            SOC21   */
28147a20385SLikun Gao 	GFX_FW_TYPE_UMSCH_DATA                      = 83,   /* User Mode Scheduler Data SOC21   */
28247a20385SLikun Gao 	GFX_FW_TYPE_UMSCH_UCODE                     = 84,   /* User Mode Scheduler Ucode SOC21  */
28347a20385SLikun Gao 	GFX_FW_TYPE_UMSCH_CMD_BUFFER                = 85,   /* User Mode Scheduler Command Buffer SOC21 */
28447a20385SLikun Gao 	GFX_FW_TYPE_USB_DP_COMBO_PHY                = 86,   /* USB-Display port Combo   SOC21   */
28547a20385SLikun Gao 	GFX_FW_TYPE_RS64_PFP                        = 87,   /* RS64 PFP                 SOC21   */
28647a20385SLikun Gao 	GFX_FW_TYPE_RS64_ME                         = 88,   /* RS64 ME                  SOC21   */
28747a20385SLikun Gao 	GFX_FW_TYPE_RS64_MEC                        = 89,   /* RS64 MEC                 SOC21   */
28847a20385SLikun Gao 	GFX_FW_TYPE_RS64_PFP_P0_STACK               = 90,   /* RS64 PFP stack P0        SOC21   */
28947a20385SLikun Gao 	GFX_FW_TYPE_RS64_PFP_P1_STACK               = 91,   /* RS64 PFP stack P1        SOC21   */
29047a20385SLikun Gao 	GFX_FW_TYPE_RS64_ME_P0_STACK                = 92,   /* RS64 ME stack P0         SOC21   */
29147a20385SLikun Gao 	GFX_FW_TYPE_RS64_ME_P1_STACK                = 93,   /* RS64 ME stack P1         SOC21   */
29247a20385SLikun Gao 	GFX_FW_TYPE_RS64_MEC_P0_STACK               = 94,   /* RS64 MEC stack P0        SOC21   */
29347a20385SLikun Gao 	GFX_FW_TYPE_RS64_MEC_P1_STACK               = 95,   /* RS64 MEC stack P1        SOC21   */
29447a20385SLikun Gao 	GFX_FW_TYPE_RS64_MEC_P2_STACK               = 96,   /* RS64 MEC stack P2        SOC21   */
29547a20385SLikun Gao 	GFX_FW_TYPE_RS64_MEC_P3_STACK               = 97,   /* RS64 MEC stack P3        SOC21   */
296964a36d7SLang Yu 	GFX_FW_TYPE_VPEC_FW1                        = 100,  /* VPEC FW1 To Save         VPE     */
297964a36d7SLang Yu 	GFX_FW_TYPE_VPEC_FW2                        = 101,  /* VPEC FW2 To Save         VPE     */
298f9ecae9aSLang Yu 	GFX_FW_TYPE_VPE                             = 102,
299617efef4SSaleemkhan Jamadar 	GFX_FW_TYPE_JPEG_RAM                        = 128,  /**< JPEG Command buffer */
300cd21cb1fSLijo Lazar 	GFX_FW_TYPE_P2S_TABLE                       = 129,
3014414ec6dSHawking Zhang 	GFX_FW_TYPE_MAX
3020e5ca0d1SHuang Rui };
3030e5ca0d1SHuang Rui 
3040e5ca0d1SHuang Rui /* Command to load HW IP FW. */
3050e5ca0d1SHuang Rui struct psp_gfx_cmd_load_ip_fw
3060e5ca0d1SHuang Rui {
307cf671071SHuang Rui     uint32_t                fw_phy_addr_lo;    /* bits [31:0] of GPU Virtual address of FW location (must be 4 KB aligned) */
308cf671071SHuang Rui     uint32_t                fw_phy_addr_hi;    /* bits [63:32] of GPU Virtual address of FW location */
3090e5ca0d1SHuang Rui     uint32_t                fw_size;           /* FW buffer size in bytes */
3100e5ca0d1SHuang Rui     enum psp_gfx_fw_type    fw_type;           /* FW type */
3110e5ca0d1SHuang Rui 
3120e5ca0d1SHuang Rui };
3130e5ca0d1SHuang Rui 
314cf671071SHuang Rui /* Command to save/restore HW IP FW. */
315cf671071SHuang Rui struct psp_gfx_cmd_save_restore_ip_fw
316cf671071SHuang Rui {
317cf671071SHuang Rui     uint32_t                save_fw;              /* if set, command is used for saving fw otherwise for resetoring*/
318cf671071SHuang Rui     uint32_t                save_restore_addr_lo; /* bits [31:0] of FB address of GART memory used as save/restore buffer (must be 4 KB aligned) */
319cf671071SHuang Rui     uint32_t                save_restore_addr_hi; /* bits [63:32] of FB address of GART memory used as save/restore buffer */
320cf671071SHuang Rui     uint32_t                buf_size;             /* Size of the save/restore buffer in bytes */
321cf671071SHuang Rui     enum psp_gfx_fw_type    fw_type;              /* FW type */
322cf671071SHuang Rui };
3230e5ca0d1SHuang Rui 
3243880369fSTrigger Huang /* Command to setup register program */
3253880369fSTrigger Huang struct psp_gfx_cmd_reg_prog {
3263880369fSTrigger Huang 	uint32_t	reg_value;
3273880369fSTrigger Huang 	uint32_t	reg_id;
3283880369fSTrigger Huang };
3293880369fSTrigger Huang 
33046ea9501SHawking Zhang /* Command to load TOC */
33146ea9501SHawking Zhang struct psp_gfx_cmd_load_toc
33246ea9501SHawking Zhang {
33346ea9501SHawking Zhang     uint32_t        toc_phy_addr_lo;        /* bits [31:0] of GPU Virtual address of FW location (must be 4 KB aligned) */
33446ea9501SHawking Zhang     uint32_t        toc_phy_addr_hi;        /* bits [63:32] of GPU Virtual address of FW location */
33546ea9501SHawking Zhang     uint32_t        toc_size;               /* FW buffer size in bytes */
33646ea9501SHawking Zhang };
33746ea9501SHawking Zhang 
338e40889ecSJohn Clements /* Dynamic boot configuration */
339e40889ecSJohn Clements struct psp_gfx_cmd_boot_cfg
340e40889ecSJohn Clements {
341e40889ecSJohn Clements     uint32_t                        timestamp;            /* calendar time as number of seconds */
342e40889ecSJohn Clements     enum psp_gfx_boot_config_cmd    sub_cmd;              /* sub-command indicating how to process command data */
343e40889ecSJohn Clements     uint32_t                        boot_config;          /* dynamic boot configuration bitmask */
344e40889ecSJohn Clements     uint32_t                        boot_config_valid;    /* dynamic boot configuration valid bits bitmask */
345e40889ecSJohn Clements };
346e40889ecSJohn Clements 
347ba08e9cbSLijo Lazar struct psp_gfx_cmd_sriov_spatial_part {
348ba08e9cbSLijo Lazar 	uint32_t mode;
349ba08e9cbSLijo Lazar 	uint32_t override_ips;
350ba08e9cbSLijo Lazar 	uint32_t override_xcds_avail;
351ba08e9cbSLijo Lazar 	uint32_t override_this_aid;
352ba08e9cbSLijo Lazar };
353ba08e9cbSLijo Lazar 
3540e5ca0d1SHuang Rui /* All GFX ring buffer commands. */
3550e5ca0d1SHuang Rui union psp_gfx_commands
3560e5ca0d1SHuang Rui {
3570e5ca0d1SHuang Rui     struct psp_gfx_cmd_load_ta          cmd_load_ta;
3580e5ca0d1SHuang Rui     struct psp_gfx_cmd_unload_ta        cmd_unload_ta;
3590e5ca0d1SHuang Rui     struct psp_gfx_cmd_invoke_cmd       cmd_invoke_cmd;
3600e5ca0d1SHuang Rui     struct psp_gfx_cmd_setup_tmr        cmd_setup_tmr;
3610e5ca0d1SHuang Rui     struct psp_gfx_cmd_load_ip_fw       cmd_load_ip_fw;
362cf671071SHuang Rui     struct psp_gfx_cmd_save_restore_ip_fw cmd_save_restore_ip_fw;
3633880369fSTrigger Huang     struct psp_gfx_cmd_reg_prog       cmd_setup_reg_prog;
36446ea9501SHawking Zhang     struct psp_gfx_cmd_setup_tmr        cmd_setup_vmr;
36546ea9501SHawking Zhang     struct psp_gfx_cmd_load_toc         cmd_load_toc;
366e40889ecSJohn Clements     struct psp_gfx_cmd_boot_cfg         boot_cfg;
367ba08e9cbSLijo Lazar     struct psp_gfx_cmd_sriov_spatial_part cmd_spatial_part;
3680e5ca0d1SHuang Rui };
3690e5ca0d1SHuang Rui 
37019ae3330SJohn Clements struct psp_gfx_uresp_reserved
37119ae3330SJohn Clements {
37219ae3330SJohn Clements     uint32_t reserved[8];
37319ae3330SJohn Clements };
37419ae3330SJohn Clements 
37519ae3330SJohn Clements /* Command-specific response for Fw Attestation Db */
37619ae3330SJohn Clements struct psp_gfx_uresp_fwar_db_info
37719ae3330SJohn Clements {
37819ae3330SJohn Clements     uint32_t fwar_db_addr_lo;
37919ae3330SJohn Clements     uint32_t fwar_db_addr_hi;
38019ae3330SJohn Clements };
38119ae3330SJohn Clements 
382b08be120SHawking Zhang /* Command-specific response for boot config. */
383b08be120SHawking Zhang struct psp_gfx_uresp_bootcfg {
384b08be120SHawking Zhang 	uint32_t boot_cfg;	/* boot config data */
385b08be120SHawking Zhang };
386b08be120SHawking Zhang 
38719ae3330SJohn Clements /* Union of command-specific responses for GPCOM ring. */
388b08be120SHawking Zhang union psp_gfx_uresp {
38919ae3330SJohn Clements 	struct psp_gfx_uresp_reserved		reserved;
390b08be120SHawking Zhang 	struct psp_gfx_uresp_bootcfg		boot_cfg;
39119ae3330SJohn Clements 	struct psp_gfx_uresp_fwar_db_info	fwar_db_info;
39219ae3330SJohn Clements };
39319ae3330SJohn Clements 
3940e5ca0d1SHuang Rui /* Structure of GFX Response buffer.
3950e5ca0d1SHuang Rui * For GPCOM I/F it is part of GFX_CMD_RESP buffer, for RBI
3960e5ca0d1SHuang Rui * it is separate buffer.
3970e5ca0d1SHuang Rui */
3980e5ca0d1SHuang Rui struct psp_gfx_resp
3990e5ca0d1SHuang Rui {
4000e5ca0d1SHuang Rui     uint32_t	status;		/* +0  status of command execution */
4010e5ca0d1SHuang Rui     uint32_t	session_id;	/* +4  session ID in response to LoadTa command */
4020e5ca0d1SHuang Rui     uint32_t	fw_addr_lo;	/* +8  bits [31:0] of FW address within TMR (in response to cmd_load_ip_fw command) */
4030e5ca0d1SHuang Rui     uint32_t	fw_addr_hi;	/* +12 bits [63:32] of FW address within TMR (in response to cmd_load_ip_fw command) */
40446ea9501SHawking Zhang     uint32_t	tmr_size;	/* +16 size of the TMR to be reserved including MM fw and Gfx fw in response to cmd_load_toc command */
4050e5ca0d1SHuang Rui 
40619ae3330SJohn Clements     uint32_t	reserved[11];
4070e5ca0d1SHuang Rui 
40819ae3330SJohn Clements     union psp_gfx_uresp uresp;      /* +64 response union containing command-specific responses */
40919ae3330SJohn Clements 
41019ae3330SJohn Clements     /* total 96 bytes */
4110e5ca0d1SHuang Rui };
4120e5ca0d1SHuang Rui 
4130e5ca0d1SHuang Rui /* Structure of Command buffer pointed by psp_gfx_rb_frame.cmd_buf_addr_hi
4140e5ca0d1SHuang Rui *  and psp_gfx_rb_frame.cmd_buf_addr_lo.
4150e5ca0d1SHuang Rui */
4160e5ca0d1SHuang Rui struct psp_gfx_cmd_resp
4170e5ca0d1SHuang Rui {
4180e5ca0d1SHuang Rui     uint32_t        buf_size;           /* +0  total size of the buffer in bytes */
4190e5ca0d1SHuang Rui     uint32_t        buf_version;        /* +4  version of the buffer strusture; must be PSP_GFX_CMD_BUF_VERSION */
4200e5ca0d1SHuang Rui     uint32_t        cmd_id;             /* +8  command ID */
4210e5ca0d1SHuang Rui 
4220e5ca0d1SHuang Rui     /* These fields are used for RBI only. They are all 0 in GPCOM commands
4230e5ca0d1SHuang Rui     */
424cf671071SHuang Rui     uint32_t        resp_buf_addr_lo;   /* +12 bits [31:0] of GPU Virtual address of response buffer (must be 4 KB aligned) */
425cf671071SHuang Rui     uint32_t        resp_buf_addr_hi;   /* +16 bits [63:32] of GPU Virtual address of response buffer */
4260e5ca0d1SHuang Rui     uint32_t        resp_offset;        /* +20 offset within response buffer */
4270e5ca0d1SHuang Rui     uint32_t        resp_buf_size;      /* +24 total size of the response buffer in bytes */
4280e5ca0d1SHuang Rui 
4290e5ca0d1SHuang Rui     union psp_gfx_commands  cmd;        /* +28 command specific structures */
4300e5ca0d1SHuang Rui 
4310e5ca0d1SHuang Rui     uint8_t         reserved_1[864 - sizeof(union psp_gfx_commands) - 28];
4320e5ca0d1SHuang Rui 
4330e5ca0d1SHuang Rui     /* Note: Resp is part of this buffer for GPCOM ring. For RBI ring the response
4340e5ca0d1SHuang Rui     *        is separate buffer pointed by resp_buf_addr_hi and resp_buf_addr_lo.
4350e5ca0d1SHuang Rui     */
4360e5ca0d1SHuang Rui     struct psp_gfx_resp     resp;       /* +864 response */
4370e5ca0d1SHuang Rui 
4380e5ca0d1SHuang Rui     uint8_t         reserved_2[1024 - 864 - sizeof(struct psp_gfx_resp)];
4390e5ca0d1SHuang Rui 
4400e5ca0d1SHuang Rui     /* total size 1024 bytes */
4410e5ca0d1SHuang Rui };
4420e5ca0d1SHuang Rui 
4430e5ca0d1SHuang Rui 
4440e5ca0d1SHuang Rui #define FRAME_TYPE_DESTROY          1   /* frame sent by KMD driver when UMD Scheduler context is destroyed*/
4450e5ca0d1SHuang Rui 
4460e5ca0d1SHuang Rui /* Structure of the Ring Buffer Frame */
4470e5ca0d1SHuang Rui struct psp_gfx_rb_frame
4480e5ca0d1SHuang Rui {
449cf671071SHuang Rui     uint32_t    cmd_buf_addr_lo;    /* +0  bits [31:0] of GPU Virtual address of command buffer (must be 4 KB aligned) */
450cf671071SHuang Rui     uint32_t    cmd_buf_addr_hi;    /* +4  bits [63:32] of GPU Virtual address of command buffer */
4510e5ca0d1SHuang Rui     uint32_t    cmd_buf_size;       /* +8  command buffer size in bytes */
452cf671071SHuang Rui     uint32_t    fence_addr_lo;      /* +12 bits [31:0] of GPU Virtual address of Fence for this frame */
453cf671071SHuang Rui     uint32_t    fence_addr_hi;      /* +16 bits [63:32] of GPU Virtual address of Fence for this frame */
4540e5ca0d1SHuang Rui     uint32_t    fence_value;        /* +20 Fence value */
4550e5ca0d1SHuang Rui     uint32_t    sid_lo;             /* +24 bits [31:0] of SID value (used only for RBI frames) */
4560e5ca0d1SHuang Rui     uint32_t    sid_hi;             /* +28 bits [63:32] of SID value (used only for RBI frames) */
4570e5ca0d1SHuang Rui     uint8_t     vmid;               /* +32 VMID value used for mapping of all addresses for this frame */
4580e5ca0d1SHuang Rui     uint8_t     frame_type;         /* +33 1: destory context frame, 0: all other frames; used only for RBI frames */
4590e5ca0d1SHuang Rui     uint8_t     reserved1[2];       /* +34 reserved, must be 0 */
460cf671071SHuang Rui     uint32_t    reserved2[7];       /* +36 reserved, must be 0 */
4610e5ca0d1SHuang Rui                 /* total 64 bytes */
4620e5ca0d1SHuang Rui };
4630e5ca0d1SHuang Rui 
4643bda8acdSEmily Deng #define PSP_ERR_UNKNOWN_COMMAND 0x00000100
4653bda8acdSEmily Deng 
4663bda8acdSEmily Deng enum tee_error_code {
4673bda8acdSEmily Deng 	TEE_SUCCESS			= 0x00000000,
468*48880f96SLijo Lazar 	TEE_ERROR_CANCEL		= 0xFFFF0002,
4693bda8acdSEmily Deng 	TEE_ERROR_NOT_SUPPORTED		= 0xFFFF000A,
4703bda8acdSEmily Deng };
4713bda8acdSEmily Deng 
4720e5ca0d1SHuang Rui #endif /* _PSP_TEE_GFX_IF_H_ */
473