1 /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2 /* Copyright (c) 2023 Imagination Technologies Ltd. */
4 #ifndef PVR_ROGUE_FWIF_CLIENT_H
5 #define PVR_ROGUE_FWIF_CLIENT_H
7 #include <linux/bits.h>
8 #include <linux/kernel.h>
9 #include <linux/sizes.h>
10 #include <linux/types.h>
12 #include "pvr_rogue_fwif_shared.h"
15 * Page size used for Parameter Management.
17 #define ROGUE_PM_PAGE_SIZE SZ_4K
20 * Minimum/Maximum PB size.
22 * Base page size is dependent on core:
23 * S6/S6XT/S7 = 50 pages
25 * S8XE with BRN66011 fixed = 25 pages
27 * Minimum PB = Base Pages + (NUM_TE_PIPES-1)*16K + (NUM_VCE_PIPES-1)*64K +
28 * IF_PM_PREALLOC(NUM_TE_PIPES*16K + NUM_VCE_PIPES*16K)
30 * Maximum PB size must ensure that no PM address space can be fully used,
31 * because if the full address space was used it would wrap and corrupt itself.
32 * Since there are two freelists (local is always minimum sized) this can be
33 * described as following three conditions being met:
35 * (Minimum PB + Maximum PB) < ALIST PM address space size (16GB)
36 * (Minimum PB + Maximum PB) < TE PM address space size (16GB) / NUM_TE_PIPES
37 * (Minimum PB + Maximum PB) < VCE PM address space size (16GB) / NUM_VCE_PIPES
39 * Since the max of NUM_TE_PIPES and NUM_VCE_PIPES is 4, we have a hard limit
40 * of 4GB minus the Minimum PB. For convenience we take the smaller power-of-2
41 * value of 2GB. This is far more than any current applications use.
43 #define ROGUE_PM_MAX_FREELIST_SIZE SZ_2G
46 * Flags supported by the geometry DM command i.e. &struct rogue_fwif_cmd_geom.
49 #define ROGUE_GEOM_FLAGS_FIRSTKICK BIT_MASK(0)
50 #define ROGUE_GEOM_FLAGS_LASTKICK BIT_MASK(1)
51 /* Use single core in a multi core setup. */
52 #define ROGUE_GEOM_FLAGS_SINGLE_CORE BIT_MASK(3)
55 * Flags supported by the fragment DM command i.e. &struct rogue_fwif_cmd_frag.
58 /* Use single core in a multi core setup. */
59 #define ROGUE_FRAG_FLAGS_SINGLE_CORE BIT_MASK(3)
60 /* Indicates whether this render produces visibility results. */
61 #define ROGUE_FRAG_FLAGS_GET_VIS_RESULTS BIT_MASK(5)
62 /* Indicates whether a depth buffer is present. */
63 #define ROGUE_FRAG_FLAGS_DEPTHBUFFER BIT_MASK(7)
64 /* Indicates whether a stencil buffer is present. */
65 #define ROGUE_FRAG_FLAGS_STENCILBUFFER BIT_MASK(8)
66 /* Disable pixel merging for this render. */
67 #define ROGUE_FRAG_FLAGS_DISABLE_PIXELMERGE BIT_MASK(15)
68 /* Indicates whether a scratch buffer is present. */
69 #define ROGUE_FRAG_FLAGS_SCRATCHBUFFER BIT_MASK(19)
70 /* Disallow compute overlapped with this render. */
71 #define ROGUE_FRAG_FLAGS_PREVENT_CDM_OVERLAP BIT_MASK(26)
74 * Flags supported by the compute DM command i.e. &struct rogue_fwif_cmd_compute.
77 #define ROGUE_COMPUTE_FLAG_PREVENT_ALL_OVERLAP BIT_MASK(2)
78 /*!< Use single core in a multi core setup. */
79 #define ROGUE_COMPUTE_FLAG_SINGLE_CORE BIT_MASK(5)
82 * Flags supported by the transfer DM command i.e. &struct rogue_fwif_cmd_transfer.
85 /*!< Use single core in a multi core setup. */
86 #define ROGUE_TRANSFER_FLAGS_SINGLE_CORE BIT_MASK(1)
89 ************************************************
90 * Parameter/HWRTData control structures.
91 ************************************************
95 * Configuration registers which need to be loaded by the firmware before a geometry
98 struct rogue_fwif_geom_regs {
99 u64 vdm_ctrl_stream_base;
100 u64 tpu_border_colour_table;
102 /* Only used when feature VDM_DRAWINDIRECT present. */
103 u64 vdm_draw_indirect0;
104 /* Only used when feature VDM_DRAWINDIRECT present. */
105 u32 vdm_draw_indirect1;
109 /* Only used when BRN 49927 present. */
112 u32 vdm_context_resume_task0_size;
113 /* Only used when feature VDM_OBJECT_LEVEL_LLS present. */
114 u32 vdm_context_resume_task3_size;
116 /* Only used when BRN 56279 or BRN 67381 present. */
121 /* Only used when feature TESSELLATION present */
122 u32 pds_coeff_free_prog;
127 /* Only used when BRN 44455 or BRN 63027 present. */
128 struct rogue_fwif_dummy_rgnhdr_init_geom_regs {
129 u64 te_psgregion_addr;
133 * Represents a geometry command that can be used to tile a whole scene's objects as
136 struct rogue_fwif_cmd_geom {
138 * rogue_fwif_cmd_geom_frag_shared field must always be at the beginning of the
141 * The command struct (rogue_fwif_cmd_geom) is shared between Client and
142 * Firmware. Kernel is unable to perform read/write operations on the
143 * command struct, the SHARED region is the only exception from this rule.
144 * This region must be the first member so that Kernel can easily access it.
145 * For more info, see rogue_fwif_cmd_geom_frag_shared definition.
147 struct rogue_fwif_cmd_geom_frag_shared cmd_shared;
149 struct rogue_fwif_geom_regs regs __aligned(8);
150 u32 flags __aligned(8);
153 * Holds the geometry/fragment fence value to allow the fragment partial render command
156 struct rogue_fwif_ufo partial_render_geom_frag_fence;
158 /* Only used when BRN 44455 or BRN 63027 present. */
159 struct rogue_fwif_dummy_rgnhdr_init_geom_regs dummy_rgnhdr_init_geom_regs __aligned(8);
161 /* Only used when BRN 61484 or BRN 66333 present. */
162 u32 brn61484_66333_live_rt;
168 * Configuration registers which need to be loaded by the firmware before ISP
171 struct rogue_fwif_frag_regs {
172 u32 usc_pixel_output_ctrl;
174 #define ROGUE_MAXIMUM_OUTPUT_REGISTERS_PER_PIXEL 8U
175 u32 usc_clear_register[ROGUE_MAXIMUM_OUTPUT_REGISTERS_PER_PIXEL];
180 /* Only used when feature S7_TOP_INFRASTRUCTURE present. */
181 u32 isp_xtp_pipe_enable;
185 /* Only used when BRN 49927 present. */
188 u32 event_pixel_pds_info;
190 /* Only used when feature CLUSTER_GROUPING present. */
195 u32 event_pixel_pds_data;
197 /* Only used when BRN 65101 present. */
198 u32 brn65101_event_pixel_pds_data;
200 /* Only used when feature GPU_MULTICORE_SUPPORT or BRN 47217 present. */
201 u32 isp_oclqry_stride;
203 /* Only used when feature ZLS_SUBTILE present. */
206 /* Only used when feature ISP_ZLS_D24_S8_PACKING_OGL_MODE present. */
207 u32 rgx_cr_blackpearl_fix;
209 /* All values below the ALIGN(8) must be 64 bit. */
210 aligned_u64 isp_scissor_base;
214 u64 isp_zload_store_base;
215 u64 isp_stencil_load_store_base;
218 * Only used when feature FBCDC_ALGORITHM present and value < 3 or feature
219 * FB_CDC_V4 present. Additionally, BRNs 48754, 60227, 72310 and 72311 must
224 #define ROGUE_PBE_WORDS_REQUIRED_FOR_RENDERS 3U
225 u64 pbe_word[8U][ROGUE_PBE_WORDS_REQUIRED_FOR_RENDERS];
226 u64 tpu_border_colour_table;
229 /* Only used when BRN 65101 present. */
230 u64 pds_bgnd_brn65101[3U];
234 /* Only used when BRN 62850 or 62865 present. */
235 u64 isp_dummy_stencil_store_base;
237 /* Only used when BRN 66193 present. */
238 u64 isp_dummy_depth_store_base;
240 /* Only used when BRN 67182 present. */
241 u32 rgnhdr_single_rt_size;
242 /* Only used when BRN 67182 present. */
243 u32 rgnhdr_scratch_offset;
246 struct rogue_fwif_cmd_frag {
247 struct rogue_fwif_cmd_geom_frag_shared cmd_shared __aligned(8);
249 struct rogue_fwif_frag_regs regs __aligned(8);
250 /* command control flags. */
252 /* Stride IN BYTES for Z-Buffer in case of RTAs. */
254 /* Stride IN BYTES for S-Buffer in case of RTAs. */
257 /* Only used if feature GPU_MULTICORE_SUPPORT present. */
262 * Configuration registers which need to be loaded by the firmware before CDM
265 struct rogue_fwif_compute_regs {
266 u64 tpu_border_colour_table;
268 /* Only used when feature CDM_USER_MODE_QUEUE present. */
271 /* Only used when feature CDM_USER_MODE_QUEUE present. */
273 /* Only used when feature CDM_USER_MODE_QUEUE present. */
276 /* Only used when feature CDM_USER_MODE_QUEUE is not present. */
277 u64 cdm_ctrl_stream_base;
279 u64 cdm_context_state_base_addr;
281 /* Only used when BRN 49927 is present. */
285 /* Only used when feature COMPUTE_MORTON_CAPABLE present. */
288 /* Only used when feature CLUSTER_GROUPING present. */
291 /* Only used when feature TPU_DM_GLOBAL_REGISTERS present. */
292 u32 tpu_tag_cdm_ctrl;
297 struct rogue_fwif_cmd_compute {
298 /* Common command attributes */
299 struct rogue_fwif_cmd_common common __aligned(8);
302 struct rogue_fwif_compute_regs regs;
305 u32 flags __aligned(8);
307 /* Only used when feature UNIFIED_STORE_VIRTUAL_PARTITIONING present. */
308 u32 num_temp_regions;
310 /* Only used when feature CDM_USER_MODE_QUEUE present. */
311 u32 stream_start_offset;
313 /* Only used when feature GPU_MULTICORE_SUPPORT present. */
317 struct rogue_fwif_transfer_regs {
319 * All 32 bit values should be added in the top section. This then requires only a
320 * single RGXFW_ALIGN to align all the 64 bit values in the second section.
324 u32 usc_pixel_output_ctrl;
325 u32 usc_clear_register0;
326 u32 usc_clear_register1;
327 u32 usc_clear_register2;
328 u32 usc_clear_register3;
331 u32 isp_render_origin;
334 /* Only used when feature S7_TOP_INFRASTRUCTURE present. */
335 u32 isp_xtp_pipe_enable;
338 u32 event_pixel_pds_info;
340 u32 event_pixel_pds_code;
341 u32 event_pixel_pds_data;
346 /* Only used when feature GPU_MULTICORE_SUPPORT present. */
349 /* All values below the aligned_u64 must be 64 bit. */
350 aligned_u64 pds_bgnd0_base;
352 u64 pds_bgnd3_sizeinfo;
355 #define ROGUE_PBE_WORDS_REQUIRED_FOR_TQS 3
356 /* TQ_MAX_RENDER_TARGETS * PBE_STATE_SIZE */
357 u64 pbe_wordx_mrty[3U * ROGUE_PBE_WORDS_REQUIRED_FOR_TQS];
360 struct rogue_fwif_cmd_transfer {
361 /* Common command attributes */
362 struct rogue_fwif_cmd_common common __aligned(8);
364 struct rogue_fwif_transfer_regs regs __aligned(8);
371 #include "pvr_rogue_fwif_client_check.h"
373 #endif /* PVR_ROGUE_FWIF_CLIENT_H */