xref: /linux/drivers/gpu/drm/imagination/pvr_rogue_defs.h (revision b41ae495207eaab1363ac3d424e67f3f354ca2ce)
1*b41ae495SSarah Walker /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2*b41ae495SSarah Walker /* Copyright (c) 2023 Imagination Technologies Ltd. */
3*b41ae495SSarah Walker 
4*b41ae495SSarah Walker #ifndef PVR_ROGUE_DEFS_H
5*b41ae495SSarah Walker #define PVR_ROGUE_DEFS_H
6*b41ae495SSarah Walker 
7*b41ae495SSarah Walker #include "pvr_rogue_cr_defs.h"
8*b41ae495SSarah Walker 
9*b41ae495SSarah Walker #include <linux/bits.h>
10*b41ae495SSarah Walker 
11*b41ae495SSarah Walker /*
12*b41ae495SSarah Walker  ******************************************************************************
13*b41ae495SSarah Walker  * ROGUE Defines
14*b41ae495SSarah Walker  ******************************************************************************
15*b41ae495SSarah Walker  */
16*b41ae495SSarah Walker 
17*b41ae495SSarah Walker #define ROGUE_FW_MAX_NUM_OS (8U)
18*b41ae495SSarah Walker #define ROGUE_FW_HOST_OS (0U)
19*b41ae495SSarah Walker #define ROGUE_FW_GUEST_OSID_START (1U)
20*b41ae495SSarah Walker 
21*b41ae495SSarah Walker #define ROGUE_FW_THREAD_0 (0U)
22*b41ae495SSarah Walker #define ROGUE_FW_THREAD_1 (1U)
23*b41ae495SSarah Walker 
24*b41ae495SSarah Walker #define GET_ROGUE_CACHE_LINE_SIZE(x) ((((s32)(x)) > 0) ? ((x) / 8) : (0))
25*b41ae495SSarah Walker 
26*b41ae495SSarah Walker #define MAX_HW_GEOM_FRAG_CONTEXTS 2U
27*b41ae495SSarah Walker 
28*b41ae495SSarah Walker #define ROGUE_CR_CLK_CTRL_ALL_ON \
29*b41ae495SSarah Walker 	(0x5555555555555555ull & ROGUE_CR_CLK_CTRL_MASKFULL)
30*b41ae495SSarah Walker #define ROGUE_CR_CLK_CTRL_ALL_AUTO \
31*b41ae495SSarah Walker 	(0xaaaaaaaaaaaaaaaaull & ROGUE_CR_CLK_CTRL_MASKFULL)
32*b41ae495SSarah Walker #define ROGUE_CR_CLK_CTRL2_ALL_ON \
33*b41ae495SSarah Walker 	(0x5555555555555555ull & ROGUE_CR_CLK_CTRL2_MASKFULL)
34*b41ae495SSarah Walker #define ROGUE_CR_CLK_CTRL2_ALL_AUTO \
35*b41ae495SSarah Walker 	(0xaaaaaaaaaaaaaaaaull & ROGUE_CR_CLK_CTRL2_MASKFULL)
36*b41ae495SSarah Walker 
37*b41ae495SSarah Walker #define ROGUE_CR_SOFT_RESET_DUST_n_CORE_EN    \
38*b41ae495SSarah Walker 	(ROGUE_CR_SOFT_RESET_DUST_A_CORE_EN | \
39*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_B_CORE_EN | \
40*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_C_CORE_EN | \
41*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_D_CORE_EN | \
42*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_E_CORE_EN | \
43*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_F_CORE_EN | \
44*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_G_CORE_EN | \
45*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_H_CORE_EN)
46*b41ae495SSarah Walker 
47*b41ae495SSarah Walker /* SOFT_RESET Rascal and DUSTs bits */
48*b41ae495SSarah Walker #define ROGUE_CR_SOFT_RESET_RASCALDUSTS_EN    \
49*b41ae495SSarah Walker 	(ROGUE_CR_SOFT_RESET_RASCAL_CORE_EN | \
50*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_DUST_n_CORE_EN)
51*b41ae495SSarah Walker 
52*b41ae495SSarah Walker /* SOFT_RESET steps as defined in the TRM */
53*b41ae495SSarah Walker #define ROGUE_S7_SOFT_RESET_DUSTS (ROGUE_CR_SOFT_RESET_DUST_n_CORE_EN)
54*b41ae495SSarah Walker 
55*b41ae495SSarah Walker #define ROGUE_S7_SOFT_RESET_JONES                                 \
56*b41ae495SSarah Walker 	(ROGUE_CR_SOFT_RESET_PM_EN | ROGUE_CR_SOFT_RESET_VDM_EN | \
57*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_ISP_EN)
58*b41ae495SSarah Walker 
59*b41ae495SSarah Walker #define ROGUE_S7_SOFT_RESET_JONES_ALL                             \
60*b41ae495SSarah Walker 	(ROGUE_S7_SOFT_RESET_JONES | ROGUE_CR_SOFT_RESET_BIF_EN | \
61*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET_SLC_EN | ROGUE_CR_SOFT_RESET_GARTEN_EN)
62*b41ae495SSarah Walker 
63*b41ae495SSarah Walker #define ROGUE_S7_SOFT_RESET2                                                  \
64*b41ae495SSarah Walker 	(ROGUE_CR_SOFT_RESET2_BLACKPEARL_EN | ROGUE_CR_SOFT_RESET2_PIXEL_EN | \
65*b41ae495SSarah Walker 	 ROGUE_CR_SOFT_RESET2_CDM_EN | ROGUE_CR_SOFT_RESET2_VERTEX_EN)
66*b41ae495SSarah Walker 
67*b41ae495SSarah Walker #define ROGUE_BIF_PM_PHYSICAL_PAGE_ALIGNSHIFT (12U)
68*b41ae495SSarah Walker #define ROGUE_BIF_PM_PHYSICAL_PAGE_SIZE \
69*b41ae495SSarah Walker 	BIT(ROGUE_BIF_PM_PHYSICAL_PAGE_ALIGNSHIFT)
70*b41ae495SSarah Walker 
71*b41ae495SSarah Walker #define ROGUE_BIF_PM_VIRTUAL_PAGE_ALIGNSHIFT (14U)
72*b41ae495SSarah Walker #define ROGUE_BIF_PM_VIRTUAL_PAGE_SIZE BIT(ROGUE_BIF_PM_VIRTUAL_PAGE_ALIGNSHIFT)
73*b41ae495SSarah Walker 
74*b41ae495SSarah Walker #define ROGUE_BIF_PM_FREELIST_BASE_ADDR_ALIGNSIZE (16U)
75*b41ae495SSarah Walker 
76*b41ae495SSarah Walker /*
77*b41ae495SSarah Walker  * To get the number of required Dusts, divide the number of
78*b41ae495SSarah Walker  * clusters by 2 and round up
79*b41ae495SSarah Walker  */
80*b41ae495SSarah Walker #define ROGUE_REQ_NUM_DUSTS(CLUSTERS) (((CLUSTERS) + 1U) / 2U)
81*b41ae495SSarah Walker 
82*b41ae495SSarah Walker /*
83*b41ae495SSarah Walker  * To get the number of required Bernado/Phantom(s), divide
84*b41ae495SSarah Walker  * the number of clusters by 4 and round up
85*b41ae495SSarah Walker  */
86*b41ae495SSarah Walker #define ROGUE_REQ_NUM_PHANTOMS(CLUSTERS) (((CLUSTERS) + 3U) / 4U)
87*b41ae495SSarah Walker #define ROGUE_REQ_NUM_BERNADOS(CLUSTERS) (((CLUSTERS) + 3U) / 4U)
88*b41ae495SSarah Walker #define ROGUE_REQ_NUM_BLACKPEARLS(CLUSTERS) (((CLUSTERS) + 3U) / 4U)
89*b41ae495SSarah Walker 
90*b41ae495SSarah Walker /*
91*b41ae495SSarah Walker  * FW MMU contexts
92*b41ae495SSarah Walker  */
93*b41ae495SSarah Walker #define MMU_CONTEXT_MAPPING_FWPRIV (0x0) /* FW code/private data */
94*b41ae495SSarah Walker #define MMU_CONTEXT_MAPPING_FWIF (0x0) /* Host/FW data */
95*b41ae495SSarah Walker 
96*b41ae495SSarah Walker /*
97*b41ae495SSarah Walker  * Utility macros to calculate CAT_BASE register addresses
98*b41ae495SSarah Walker  */
99*b41ae495SSarah Walker #define BIF_CAT_BASEX(n)          \
100*b41ae495SSarah Walker 	(ROGUE_CR_BIF_CAT_BASE0 + \
101*b41ae495SSarah Walker 	 (n) * (ROGUE_CR_BIF_CAT_BASE1 - ROGUE_CR_BIF_CAT_BASE0))
102*b41ae495SSarah Walker 
103*b41ae495SSarah Walker #define FWCORE_MEM_CAT_BASEX(n)                 \
104*b41ae495SSarah Walker 	(ROGUE_CR_FWCORE_MEM_CAT_BASE0 +        \
105*b41ae495SSarah Walker 	 (n) * (ROGUE_CR_FWCORE_MEM_CAT_BASE1 - \
106*b41ae495SSarah Walker 		ROGUE_CR_FWCORE_MEM_CAT_BASE0))
107*b41ae495SSarah Walker 
108*b41ae495SSarah Walker /*
109*b41ae495SSarah Walker  * FWCORE wrapper register defines
110*b41ae495SSarah Walker  */
111*b41ae495SSarah Walker #define FWCORE_ADDR_REMAP_CONFIG0_MMU_CONTEXT_SHIFT \
112*b41ae495SSarah Walker 	ROGUE_CR_FWCORE_ADDR_REMAP_CONFIG0_CBASE_SHIFT
113*b41ae495SSarah Walker #define FWCORE_ADDR_REMAP_CONFIG0_MMU_CONTEXT_CLRMSK \
114*b41ae495SSarah Walker 	ROGUE_CR_FWCORE_ADDR_REMAP_CONFIG0_CBASE_CLRMSK
115*b41ae495SSarah Walker #define FWCORE_ADDR_REMAP_CONFIG0_SIZE_ALIGNSHIFT (12U)
116*b41ae495SSarah Walker 
117*b41ae495SSarah Walker #define ROGUE_MAX_COMPUTE_SHARED_REGISTERS (2 * 1024)
118*b41ae495SSarah Walker #define ROGUE_MAX_VERTEX_SHARED_REGISTERS 1024
119*b41ae495SSarah Walker #define ROGUE_MAX_PIXEL_SHARED_REGISTERS 1024
120*b41ae495SSarah Walker #define ROGUE_CSRM_LINE_SIZE_IN_DWORDS (64 * 4 * 4)
121*b41ae495SSarah Walker 
122*b41ae495SSarah Walker #define ROGUE_CDMCTRL_USC_COMMON_SIZE_ALIGNSIZE 64
123*b41ae495SSarah Walker #define ROGUE_CDMCTRL_USC_COMMON_SIZE_UPPER 256
124*b41ae495SSarah Walker 
125*b41ae495SSarah Walker /*
126*b41ae495SSarah Walker  * The maximum amount of local memory which can be allocated by a single kernel
127*b41ae495SSarah Walker  * (in dwords/32-bit registers).
128*b41ae495SSarah Walker  *
129*b41ae495SSarah Walker  * ROGUE_CDMCTRL_USC_COMMON_SIZE_ALIGNSIZE is in bytes so we divide by four.
130*b41ae495SSarah Walker  */
131*b41ae495SSarah Walker #define ROGUE_MAX_PER_KERNEL_LOCAL_MEM_SIZE_REGS ((ROGUE_CDMCTRL_USC_COMMON_SIZE_ALIGNSIZE * \
132*b41ae495SSarah Walker 						   ROGUE_CDMCTRL_USC_COMMON_SIZE_UPPER) >> 2)
133*b41ae495SSarah Walker 
134*b41ae495SSarah Walker /*
135*b41ae495SSarah Walker  ******************************************************************************
136*b41ae495SSarah Walker  * WA HWBRNs
137*b41ae495SSarah Walker  ******************************************************************************
138*b41ae495SSarah Walker  */
139*b41ae495SSarah Walker 
140*b41ae495SSarah Walker /* GPU CR timer tick in GPU cycles */
141*b41ae495SSarah Walker #define ROGUE_CRTIME_TICK_IN_CYCLES (256U)
142*b41ae495SSarah Walker 
143*b41ae495SSarah Walker /* for nohw multicore return max cores possible to client */
144*b41ae495SSarah Walker #define ROGUE_MULTICORE_MAX_NOHW_CORES (4U)
145*b41ae495SSarah Walker 
146*b41ae495SSarah Walker /*
147*b41ae495SSarah Walker  * If the size of the SLC is less than this value then the TPU bypasses the SLC.
148*b41ae495SSarah Walker  */
149*b41ae495SSarah Walker #define ROGUE_TPU_CACHED_SLC_SIZE_THRESHOLD (128U * 1024U)
150*b41ae495SSarah Walker 
151*b41ae495SSarah Walker /*
152*b41ae495SSarah Walker  * If the size of the SLC is bigger than this value then the TCU must not be
153*b41ae495SSarah Walker  * bypassed in the SLC.
154*b41ae495SSarah Walker  * In XE_MEMORY_HIERARCHY cores, the TCU is bypassed by default.
155*b41ae495SSarah Walker  */
156*b41ae495SSarah Walker #define ROGUE_TCU_CACHED_SLC_SIZE_THRESHOLD (32U * 1024U)
157*b41ae495SSarah Walker 
158*b41ae495SSarah Walker /*
159*b41ae495SSarah Walker  * Register used by the FW to track the current boot stage (not used in MIPS)
160*b41ae495SSarah Walker  */
161*b41ae495SSarah Walker #define ROGUE_FW_BOOT_STAGE_REGISTER (ROGUE_CR_POWER_ESTIMATE_RESULT)
162*b41ae495SSarah Walker 
163*b41ae495SSarah Walker /*
164*b41ae495SSarah Walker  * Virtualisation definitions
165*b41ae495SSarah Walker  */
166*b41ae495SSarah Walker #define ROGUE_VIRTUALISATION_REG_SIZE_PER_OS \
167*b41ae495SSarah Walker 	(ROGUE_CR_MTS_SCHEDULE1 - ROGUE_CR_MTS_SCHEDULE)
168*b41ae495SSarah Walker 
169*b41ae495SSarah Walker /*
170*b41ae495SSarah Walker  * Macro used to indicate which version of HWPerf is active
171*b41ae495SSarah Walker  */
172*b41ae495SSarah Walker #define ROGUE_FEATURE_HWPERF_ROGUE
173*b41ae495SSarah Walker 
174*b41ae495SSarah Walker /*
175*b41ae495SSarah Walker  * Maximum number of cores supported by TRP
176*b41ae495SSarah Walker  */
177*b41ae495SSarah Walker #define ROGUE_TRP_MAX_NUM_CORES (4U)
178*b41ae495SSarah Walker 
179*b41ae495SSarah Walker #endif /* PVR_ROGUE_DEFS_H */
180