1*a26f067fSSarah Walker /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
2*a26f067fSSarah Walker /* Copyright (c) 2023 Imagination Technologies Ltd. */
3*a26f067fSSarah Walker
4*a26f067fSSarah Walker #ifndef PVR_ROGUE_FWIF_H
5*a26f067fSSarah Walker #define PVR_ROGUE_FWIF_H
6*a26f067fSSarah Walker
7*a26f067fSSarah Walker #include <linux/bits.h>
8*a26f067fSSarah Walker #include <linux/build_bug.h>
9*a26f067fSSarah Walker #include <linux/compiler.h>
10*a26f067fSSarah Walker #include <linux/kernel.h>
11*a26f067fSSarah Walker #include <linux/types.h>
12*a26f067fSSarah Walker
13*a26f067fSSarah Walker #include "pvr_rogue_defs.h"
14*a26f067fSSarah Walker #include "pvr_rogue_fwif_common.h"
15*a26f067fSSarah Walker #include "pvr_rogue_fwif_shared.h"
16*a26f067fSSarah Walker
17*a26f067fSSarah Walker /*
18*a26f067fSSarah Walker ****************************************************************************
19*a26f067fSSarah Walker * Logging type
20*a26f067fSSarah Walker ****************************************************************************
21*a26f067fSSarah Walker */
22*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_NONE 0x00000000U
23*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_TRACE 0x00000001U
24*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_MAIN 0x00000002U
25*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_MTS 0x00000004U
26*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_CLEANUP 0x00000008U
27*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_CSW 0x00000010U
28*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_BIF 0x00000020U
29*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_PM 0x00000040U
30*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_RTD 0x00000080U
31*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_SPM 0x00000100U
32*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_POW 0x00000200U
33*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_HWR 0x00000400U
34*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_HWP 0x00000800U
35*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_RPM 0x00001000U
36*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_DMA 0x00002000U
37*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_MISC 0x00004000U
38*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_DEBUG 0x80000000U
39*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_GROUP_MASK 0x80007FFEU
40*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_TYPE_MASK 0x80007FFFU
41*a26f067fSSarah Walker
42*a26f067fSSarah Walker /* String used in pvrdebug -h output */
43*a26f067fSSarah Walker #define ROGUE_FWIF_LOG_GROUPS_STRING_LIST \
44*a26f067fSSarah Walker "main,mts,cleanup,csw,bif,pm,rtd,spm,pow,hwr,hwp,rpm,dma,misc,debug"
45*a26f067fSSarah Walker
46*a26f067fSSarah Walker /* Table entry to map log group strings to log type value */
47*a26f067fSSarah Walker struct rogue_fwif_log_group_map_entry {
48*a26f067fSSarah Walker const char *log_group_name;
49*a26f067fSSarah Walker u32 log_group_type;
50*a26f067fSSarah Walker };
51*a26f067fSSarah Walker
52*a26f067fSSarah Walker /*
53*a26f067fSSarah Walker ****************************************************************************
54*a26f067fSSarah Walker * ROGUE FW signature checks
55*a26f067fSSarah Walker ****************************************************************************
56*a26f067fSSarah Walker */
57*a26f067fSSarah Walker #define ROGUE_FW_SIG_BUFFER_SIZE_MIN (8192)
58*a26f067fSSarah Walker
59*a26f067fSSarah Walker #define ROGUE_FWIF_TIMEDIFF_ID ((0x1UL << 28) | ROGUE_CR_TIMER)
60*a26f067fSSarah Walker
61*a26f067fSSarah Walker /*
62*a26f067fSSarah Walker ****************************************************************************
63*a26f067fSSarah Walker * Trace Buffer
64*a26f067fSSarah Walker ****************************************************************************
65*a26f067fSSarah Walker */
66*a26f067fSSarah Walker
67*a26f067fSSarah Walker /* Default size of ROGUE_FWIF_TRACEBUF_SPACE in DWords */
68*a26f067fSSarah Walker #define ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS 12000U
69*a26f067fSSarah Walker #define ROGUE_FW_TRACE_BUFFER_ASSERT_SIZE 200U
70*a26f067fSSarah Walker #define ROGUE_FW_THREAD_NUM 1U
71*a26f067fSSarah Walker #define ROGUE_FW_THREAD_MAX 2U
72*a26f067fSSarah Walker
73*a26f067fSSarah Walker #define ROGUE_FW_POLL_TYPE_SET 0x80000000U
74*a26f067fSSarah Walker
75*a26f067fSSarah Walker struct rogue_fwif_file_info_buf {
76*a26f067fSSarah Walker char path[ROGUE_FW_TRACE_BUFFER_ASSERT_SIZE];
77*a26f067fSSarah Walker char info[ROGUE_FW_TRACE_BUFFER_ASSERT_SIZE];
78*a26f067fSSarah Walker u32 line_num;
79*a26f067fSSarah Walker u32 padding;
80*a26f067fSSarah Walker } __aligned(8);
81*a26f067fSSarah Walker
82*a26f067fSSarah Walker struct rogue_fwif_tracebuf_space {
83*a26f067fSSarah Walker u32 trace_pointer;
84*a26f067fSSarah Walker
85*a26f067fSSarah Walker u32 trace_buffer_fw_addr;
86*a26f067fSSarah Walker
87*a26f067fSSarah Walker /* To be used by host when reading from trace buffer */
88*a26f067fSSarah Walker u32 *trace_buffer;
89*a26f067fSSarah Walker
90*a26f067fSSarah Walker struct rogue_fwif_file_info_buf assert_buf;
91*a26f067fSSarah Walker } __aligned(8);
92*a26f067fSSarah Walker
93*a26f067fSSarah Walker /* Total number of FW fault logs stored */
94*a26f067fSSarah Walker #define ROGUE_FWIF_FWFAULTINFO_MAX (8U)
95*a26f067fSSarah Walker
96*a26f067fSSarah Walker struct rogue_fw_fault_info {
97*a26f067fSSarah Walker aligned_u64 cr_timer;
98*a26f067fSSarah Walker aligned_u64 os_timer;
99*a26f067fSSarah Walker
100*a26f067fSSarah Walker u32 data __aligned(8);
101*a26f067fSSarah Walker u32 reserved;
102*a26f067fSSarah Walker struct rogue_fwif_file_info_buf fault_buf;
103*a26f067fSSarah Walker } __aligned(8);
104*a26f067fSSarah Walker
105*a26f067fSSarah Walker enum rogue_fwif_pow_state {
106*a26f067fSSarah Walker ROGUE_FWIF_POW_OFF, /* idle and ready to full power down */
107*a26f067fSSarah Walker ROGUE_FWIF_POW_ON, /* running HW commands */
108*a26f067fSSarah Walker ROGUE_FWIF_POW_FORCED_IDLE, /* forced idle */
109*a26f067fSSarah Walker ROGUE_FWIF_POW_IDLE, /* idle waiting for host handshake */
110*a26f067fSSarah Walker };
111*a26f067fSSarah Walker
112*a26f067fSSarah Walker /* Firmware HWR states */
113*a26f067fSSarah Walker /* The HW state is ok or locked up */
114*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_HARDWARE_OK BIT(0)
115*a26f067fSSarah Walker /* Tells if a HWR reset is in progress */
116*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_RESET_IN_PROGRESS BIT(1)
117*a26f067fSSarah Walker /* A DM unrelated lockup has been detected */
118*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_GENERAL_LOCKUP BIT(3)
119*a26f067fSSarah Walker /* At least one DM is running without being close to a lockup */
120*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_DM_RUNNING_OK BIT(4)
121*a26f067fSSarah Walker /* At least one DM is close to lockup */
122*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_DM_STALLING BIT(5)
123*a26f067fSSarah Walker /* The FW has faulted and needs to restart */
124*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_FW_FAULT BIT(6)
125*a26f067fSSarah Walker /* The FW has requested the host to restart it */
126*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_RESTART_REQUESTED BIT(7)
127*a26f067fSSarah Walker
128*a26f067fSSarah Walker #define ROGUE_FWIF_PHR_STATE_SHIFT (8U)
129*a26f067fSSarah Walker /* The FW has requested the host to restart it, per PHR configuration */
130*a26f067fSSarah Walker #define ROGUE_FWIF_PHR_RESTART_REQUESTED ((1) << ROGUE_FWIF_PHR_STATE_SHIFT)
131*a26f067fSSarah Walker /* A PHR triggered GPU reset has just finished */
132*a26f067fSSarah Walker #define ROGUE_FWIF_PHR_RESTART_FINISHED ((2) << ROGUE_FWIF_PHR_STATE_SHIFT)
133*a26f067fSSarah Walker #define ROGUE_FWIF_PHR_RESTART_MASK \
134*a26f067fSSarah Walker (ROGUE_FWIF_PHR_RESTART_REQUESTED | ROGUE_FWIF_PHR_RESTART_FINISHED)
135*a26f067fSSarah Walker
136*a26f067fSSarah Walker #define ROGUE_FWIF_PHR_MODE_OFF (0UL)
137*a26f067fSSarah Walker #define ROGUE_FWIF_PHR_MODE_RD_RESET (1UL)
138*a26f067fSSarah Walker #define ROGUE_FWIF_PHR_MODE_FULL_RESET (2UL)
139*a26f067fSSarah Walker
140*a26f067fSSarah Walker /* Firmware per-DM HWR states */
141*a26f067fSSarah Walker /* DM is working if all flags are cleared */
142*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_WORKING (0)
143*a26f067fSSarah Walker /* DM is idle and ready for HWR */
144*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_READY_FOR_HWR BIT(0)
145*a26f067fSSarah Walker /* DM need to skip to next cmd before resuming processing */
146*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_NEEDS_SKIP BIT(2)
147*a26f067fSSarah Walker /* DM need partial render cleanup before resuming processing */
148*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_NEEDS_PR_CLEANUP BIT(3)
149*a26f067fSSarah Walker /* DM need to increment Recovery Count once fully recovered */
150*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_NEEDS_TRACE_CLEAR BIT(4)
151*a26f067fSSarah Walker /* DM was identified as locking up and causing HWR */
152*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_GUILTY_LOCKUP BIT(5)
153*a26f067fSSarah Walker /* DM was innocently affected by another lockup which caused HWR */
154*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_INNOCENT_LOCKUP BIT(6)
155*a26f067fSSarah Walker /* DM was identified as over-running and causing HWR */
156*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_GUILTY_OVERRUNING BIT(7)
157*a26f067fSSarah Walker /* DM was innocently affected by another DM over-running which caused HWR */
158*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_INNOCENT_OVERRUNING BIT(8)
159*a26f067fSSarah Walker /* DM was forced into HWR as it delayed more important workloads */
160*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_HARD_CONTEXT_SWITCH BIT(9)
161*a26f067fSSarah Walker /* DM was forced into HWR due to an uncorrected GPU ECC error */
162*a26f067fSSarah Walker #define ROGUE_FWIF_DM_STATE_GPU_ECC_HWR BIT(10)
163*a26f067fSSarah Walker
164*a26f067fSSarah Walker /* Firmware's connection state */
165*a26f067fSSarah Walker enum rogue_fwif_connection_fw_state {
166*a26f067fSSarah Walker /* Firmware is offline */
167*a26f067fSSarah Walker ROGUE_FW_CONNECTION_FW_OFFLINE = 0,
168*a26f067fSSarah Walker /* Firmware is initialised */
169*a26f067fSSarah Walker ROGUE_FW_CONNECTION_FW_READY,
170*a26f067fSSarah Walker /* Firmware connection is fully established */
171*a26f067fSSarah Walker ROGUE_FW_CONNECTION_FW_ACTIVE,
172*a26f067fSSarah Walker /* Firmware is clearing up connection data*/
173*a26f067fSSarah Walker ROGUE_FW_CONNECTION_FW_OFFLOADING,
174*a26f067fSSarah Walker ROGUE_FW_CONNECTION_FW_STATE_COUNT
175*a26f067fSSarah Walker };
176*a26f067fSSarah Walker
177*a26f067fSSarah Walker /* OS' connection state */
178*a26f067fSSarah Walker enum rogue_fwif_connection_os_state {
179*a26f067fSSarah Walker /* OS is offline */
180*a26f067fSSarah Walker ROGUE_FW_CONNECTION_OS_OFFLINE = 0,
181*a26f067fSSarah Walker /* OS's KM driver is setup and waiting */
182*a26f067fSSarah Walker ROGUE_FW_CONNECTION_OS_READY,
183*a26f067fSSarah Walker /* OS connection is fully established */
184*a26f067fSSarah Walker ROGUE_FW_CONNECTION_OS_ACTIVE,
185*a26f067fSSarah Walker ROGUE_FW_CONNECTION_OS_STATE_COUNT
186*a26f067fSSarah Walker };
187*a26f067fSSarah Walker
188*a26f067fSSarah Walker struct rogue_fwif_os_runtime_flags {
189*a26f067fSSarah Walker unsigned int os_state : 3;
190*a26f067fSSarah Walker unsigned int fl_ok : 1;
191*a26f067fSSarah Walker unsigned int fl_grow_pending : 1;
192*a26f067fSSarah Walker unsigned int isolated_os : 1;
193*a26f067fSSarah Walker unsigned int reserved : 26;
194*a26f067fSSarah Walker };
195*a26f067fSSarah Walker
196*a26f067fSSarah Walker #define PVR_SLR_LOG_ENTRIES 10
197*a26f067fSSarah Walker /* MAX_CLIENT_CCB_NAME not visible to this header */
198*a26f067fSSarah Walker #define PVR_SLR_LOG_STRLEN 30
199*a26f067fSSarah Walker
200*a26f067fSSarah Walker struct rogue_fwif_slr_entry {
201*a26f067fSSarah Walker aligned_u64 timestamp;
202*a26f067fSSarah Walker u32 fw_ctx_addr;
203*a26f067fSSarah Walker u32 num_ufos;
204*a26f067fSSarah Walker char ccb_name[PVR_SLR_LOG_STRLEN];
205*a26f067fSSarah Walker char padding[2];
206*a26f067fSSarah Walker } __aligned(8);
207*a26f067fSSarah Walker
208*a26f067fSSarah Walker #define MAX_THREAD_NUM 2
209*a26f067fSSarah Walker
210*a26f067fSSarah Walker /* firmware trace control data */
211*a26f067fSSarah Walker struct rogue_fwif_tracebuf {
212*a26f067fSSarah Walker u32 log_type;
213*a26f067fSSarah Walker struct rogue_fwif_tracebuf_space tracebuf[MAX_THREAD_NUM];
214*a26f067fSSarah Walker /*
215*a26f067fSSarah Walker * Member initialised only when sTraceBuf is actually allocated (in
216*a26f067fSSarah Walker * ROGUETraceBufferInitOnDemandResources)
217*a26f067fSSarah Walker */
218*a26f067fSSarah Walker u32 tracebuf_size_in_dwords;
219*a26f067fSSarah Walker /* Compatibility and other flags */
220*a26f067fSSarah Walker u32 tracebuf_flags;
221*a26f067fSSarah Walker } __aligned(8);
222*a26f067fSSarah Walker
223*a26f067fSSarah Walker /* firmware system data shared with the Host driver */
224*a26f067fSSarah Walker struct rogue_fwif_sysdata {
225*a26f067fSSarah Walker /* Configuration flags from host */
226*a26f067fSSarah Walker u32 config_flags;
227*a26f067fSSarah Walker /* Extended configuration flags from host */
228*a26f067fSSarah Walker u32 config_flags_ext;
229*a26f067fSSarah Walker enum rogue_fwif_pow_state pow_state;
230*a26f067fSSarah Walker u32 hw_perf_ridx;
231*a26f067fSSarah Walker u32 hw_perf_widx;
232*a26f067fSSarah Walker u32 hw_perf_wrap_count;
233*a26f067fSSarah Walker /* Constant after setup, needed in FW */
234*a26f067fSSarah Walker u32 hw_perf_size;
235*a26f067fSSarah Walker /* The number of times the FW drops a packet due to buffer full */
236*a26f067fSSarah Walker u32 hw_perf_drop_count;
237*a26f067fSSarah Walker
238*a26f067fSSarah Walker /*
239*a26f067fSSarah Walker * ui32HWPerfUt, ui32FirstDropOrdinal, ui32LastDropOrdinal only valid
240*a26f067fSSarah Walker * when FW is built with ROGUE_HWPERF_UTILIZATION &
241*a26f067fSSarah Walker * ROGUE_HWPERF_DROP_TRACKING defined in rogue_fw_hwperf.c
242*a26f067fSSarah Walker */
243*a26f067fSSarah Walker /* Buffer utilisation, high watermark of bytes in use */
244*a26f067fSSarah Walker u32 hw_perf_ut;
245*a26f067fSSarah Walker /* The ordinal of the first packet the FW dropped */
246*a26f067fSSarah Walker u32 first_drop_ordinal;
247*a26f067fSSarah Walker /* The ordinal of the last packet the FW dropped */
248*a26f067fSSarah Walker u32 last_drop_ordinal;
249*a26f067fSSarah Walker /* State flags for each Operating System mirrored from Fw coremem */
250*a26f067fSSarah Walker struct rogue_fwif_os_runtime_flags
251*a26f067fSSarah Walker os_runtime_flags_mirror[ROGUE_FW_MAX_NUM_OS];
252*a26f067fSSarah Walker
253*a26f067fSSarah Walker struct rogue_fw_fault_info fault_info[ROGUE_FWIF_FWFAULTINFO_MAX];
254*a26f067fSSarah Walker u32 fw_faults;
255*a26f067fSSarah Walker u32 cr_poll_addr[MAX_THREAD_NUM];
256*a26f067fSSarah Walker u32 cr_poll_mask[MAX_THREAD_NUM];
257*a26f067fSSarah Walker u32 cr_poll_count[MAX_THREAD_NUM];
258*a26f067fSSarah Walker aligned_u64 start_idle_time;
259*a26f067fSSarah Walker
260*a26f067fSSarah Walker #if defined(SUPPORT_ROGUE_FW_STATS_FRAMEWORK)
261*a26f067fSSarah Walker # define ROGUE_FWIF_STATS_FRAMEWORK_LINESIZE (8)
262*a26f067fSSarah Walker # define ROGUE_FWIF_STATS_FRAMEWORK_MAX \
263*a26f067fSSarah Walker (2048 * ROGUE_FWIF_STATS_FRAMEWORK_LINESIZE)
264*a26f067fSSarah Walker u32 fw_stats_buf[ROGUE_FWIF_STATS_FRAMEWORK_MAX] __aligned(8);
265*a26f067fSSarah Walker #endif
266*a26f067fSSarah Walker u32 hwr_state_flags;
267*a26f067fSSarah Walker u32 hwr_recovery_flags[PVR_FWIF_DM_MAX];
268*a26f067fSSarah Walker /* Compatibility and other flags */
269*a26f067fSSarah Walker u32 fw_sys_data_flags;
270*a26f067fSSarah Walker /* Identify whether MC config is P-P or P-S */
271*a26f067fSSarah Walker u32 mc_config;
272*a26f067fSSarah Walker } __aligned(8);
273*a26f067fSSarah Walker
274*a26f067fSSarah Walker /* per-os firmware shared data */
275*a26f067fSSarah Walker struct rogue_fwif_osdata {
276*a26f067fSSarah Walker /* Configuration flags from an OS */
277*a26f067fSSarah Walker u32 fw_os_config_flags;
278*a26f067fSSarah Walker /* Markers to signal that the host should perform a full sync check */
279*a26f067fSSarah Walker u32 fw_sync_check_mark;
280*a26f067fSSarah Walker u32 host_sync_check_mark;
281*a26f067fSSarah Walker
282*a26f067fSSarah Walker u32 forced_updates_requested;
283*a26f067fSSarah Walker u8 slr_log_wp;
284*a26f067fSSarah Walker struct rogue_fwif_slr_entry slr_log_first;
285*a26f067fSSarah Walker struct rogue_fwif_slr_entry slr_log[PVR_SLR_LOG_ENTRIES];
286*a26f067fSSarah Walker aligned_u64 last_forced_update_time;
287*a26f067fSSarah Walker
288*a26f067fSSarah Walker /* Interrupt count from Threads > */
289*a26f067fSSarah Walker u32 interrupt_count[MAX_THREAD_NUM];
290*a26f067fSSarah Walker u32 kccb_cmds_executed;
291*a26f067fSSarah Walker u32 power_sync_fw_addr;
292*a26f067fSSarah Walker /* Compatibility and other flags */
293*a26f067fSSarah Walker u32 fw_os_data_flags;
294*a26f067fSSarah Walker u32 padding;
295*a26f067fSSarah Walker } __aligned(8);
296*a26f067fSSarah Walker
297*a26f067fSSarah Walker /* Firmware trace time-stamp field breakup */
298*a26f067fSSarah Walker
299*a26f067fSSarah Walker /* ROGUE_CR_TIMER register read (48 bits) value*/
300*a26f067fSSarah Walker #define ROGUE_FWT_TIMESTAMP_TIME_SHIFT (0U)
301*a26f067fSSarah Walker #define ROGUE_FWT_TIMESTAMP_TIME_CLRMSK (0xFFFF000000000000ull)
302*a26f067fSSarah Walker
303*a26f067fSSarah Walker /* Extra debug-info (16 bits) */
304*a26f067fSSarah Walker #define ROGUE_FWT_TIMESTAMP_DEBUG_INFO_SHIFT (48U)
305*a26f067fSSarah Walker #define ROGUE_FWT_TIMESTAMP_DEBUG_INFO_CLRMSK ~ROGUE_FWT_TIMESTAMP_TIME_CLRMSK
306*a26f067fSSarah Walker
307*a26f067fSSarah Walker /* Debug-info sub-fields */
308*a26f067fSSarah Walker /*
309*a26f067fSSarah Walker * Bit 0: ROGUE_CR_EVENT_STATUS_MMU_PAGE_FAULT bit from ROGUE_CR_EVENT_STATUS
310*a26f067fSSarah Walker * register
311*a26f067fSSarah Walker */
312*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_MMU_PAGE_FAULT_SHIFT (0U)
313*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_MMU_PAGE_FAULT_SET \
314*a26f067fSSarah Walker BIT(ROGUE_FWT_DEBUG_INFO_MMU_PAGE_FAULT_SHIFT)
315*a26f067fSSarah Walker
316*a26f067fSSarah Walker /* Bit 1: ROGUE_CR_BIF_MMU_ENTRY_PENDING bit from ROGUE_CR_BIF_MMU_ENTRY register */
317*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_MMU_ENTRY_PENDING_SHIFT (1U)
318*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_MMU_ENTRY_PENDING_SET \
319*a26f067fSSarah Walker BIT(ROGUE_FWT_DEBUG_INFO_MMU_ENTRY_PENDING_SHIFT)
320*a26f067fSSarah Walker
321*a26f067fSSarah Walker /* Bit 2: ROGUE_CR_SLAVE_EVENT register is non-zero */
322*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_SLAVE_EVENTS_SHIFT (2U)
323*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_SLAVE_EVENTS_SET \
324*a26f067fSSarah Walker BIT(ROGUE_FWT_DEBUG_INFO_SLAVE_EVENTS_SHIFT)
325*a26f067fSSarah Walker
326*a26f067fSSarah Walker /* Bit 3-15: Unused bits */
327*a26f067fSSarah Walker
328*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_STR_MAXLEN 64
329*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_STR_PREPEND " (debug info: "
330*a26f067fSSarah Walker #define ROGUE_FWT_DEBUG_INFO_STR_APPEND ")"
331*a26f067fSSarah Walker
332*a26f067fSSarah Walker /*
333*a26f067fSSarah Walker ******************************************************************************
334*a26f067fSSarah Walker * HWR Data
335*a26f067fSSarah Walker ******************************************************************************
336*a26f067fSSarah Walker */
337*a26f067fSSarah Walker enum rogue_hwrtype {
338*a26f067fSSarah Walker ROGUE_HWRTYPE_UNKNOWNFAILURE = 0,
339*a26f067fSSarah Walker ROGUE_HWRTYPE_OVERRUN = 1,
340*a26f067fSSarah Walker ROGUE_HWRTYPE_POLLFAILURE = 2,
341*a26f067fSSarah Walker ROGUE_HWRTYPE_BIF0FAULT = 3,
342*a26f067fSSarah Walker ROGUE_HWRTYPE_BIF1FAULT = 4,
343*a26f067fSSarah Walker ROGUE_HWRTYPE_TEXASBIF0FAULT = 5,
344*a26f067fSSarah Walker ROGUE_HWRTYPE_MMUFAULT = 6,
345*a26f067fSSarah Walker ROGUE_HWRTYPE_MMUMETAFAULT = 7,
346*a26f067fSSarah Walker ROGUE_HWRTYPE_MIPSTLBFAULT = 8,
347*a26f067fSSarah Walker ROGUE_HWRTYPE_ECCFAULT = 9,
348*a26f067fSSarah Walker ROGUE_HWRTYPE_MMURISCVFAULT = 10,
349*a26f067fSSarah Walker };
350*a26f067fSSarah Walker
351*a26f067fSSarah Walker #define ROGUE_FWIF_HWRTYPE_BIF_BANK_GET(hwr_type) \
352*a26f067fSSarah Walker (((hwr_type) == ROGUE_HWRTYPE_BIF0FAULT) ? 0 : 1)
353*a26f067fSSarah Walker
354*a26f067fSSarah Walker #define ROGUE_FWIF_HWRTYPE_PAGE_FAULT_GET(hwr_type) \
355*a26f067fSSarah Walker ((((hwr_type) == ROGUE_HWRTYPE_BIF0FAULT) || \
356*a26f067fSSarah Walker ((hwr_type) == ROGUE_HWRTYPE_BIF1FAULT) || \
357*a26f067fSSarah Walker ((hwr_type) == ROGUE_HWRTYPE_TEXASBIF0FAULT) || \
358*a26f067fSSarah Walker ((hwr_type) == ROGUE_HWRTYPE_MMUFAULT) || \
359*a26f067fSSarah Walker ((hwr_type) == ROGUE_HWRTYPE_MMUMETAFAULT) || \
360*a26f067fSSarah Walker ((hwr_type) == ROGUE_HWRTYPE_MIPSTLBFAULT) || \
361*a26f067fSSarah Walker ((hwr_type) == ROGUE_HWRTYPE_MMURISCVFAULT)) \
362*a26f067fSSarah Walker ? true \
363*a26f067fSSarah Walker : false)
364*a26f067fSSarah Walker
365*a26f067fSSarah Walker struct rogue_bifinfo {
366*a26f067fSSarah Walker aligned_u64 bif_req_status;
367*a26f067fSSarah Walker aligned_u64 bif_mmu_status;
368*a26f067fSSarah Walker aligned_u64 pc_address; /* phys address of the page catalogue */
369*a26f067fSSarah Walker aligned_u64 reserved;
370*a26f067fSSarah Walker };
371*a26f067fSSarah Walker
372*a26f067fSSarah Walker struct rogue_eccinfo {
373*a26f067fSSarah Walker u32 fault_gpu;
374*a26f067fSSarah Walker };
375*a26f067fSSarah Walker
376*a26f067fSSarah Walker struct rogue_mmuinfo {
377*a26f067fSSarah Walker aligned_u64 mmu_status[2];
378*a26f067fSSarah Walker aligned_u64 pc_address; /* phys address of the page catalogue */
379*a26f067fSSarah Walker aligned_u64 reserved;
380*a26f067fSSarah Walker };
381*a26f067fSSarah Walker
382*a26f067fSSarah Walker struct rogue_pollinfo {
383*a26f067fSSarah Walker u32 thread_num;
384*a26f067fSSarah Walker u32 cr_poll_addr;
385*a26f067fSSarah Walker u32 cr_poll_mask;
386*a26f067fSSarah Walker u32 cr_poll_last_value;
387*a26f067fSSarah Walker aligned_u64 reserved;
388*a26f067fSSarah Walker } __aligned(8);
389*a26f067fSSarah Walker
390*a26f067fSSarah Walker struct rogue_tlbinfo {
391*a26f067fSSarah Walker u32 bad_addr;
392*a26f067fSSarah Walker u32 entry_lo;
393*a26f067fSSarah Walker };
394*a26f067fSSarah Walker
395*a26f067fSSarah Walker struct rogue_hwrinfo {
396*a26f067fSSarah Walker union {
397*a26f067fSSarah Walker struct rogue_bifinfo bif_info;
398*a26f067fSSarah Walker struct rogue_mmuinfo mmu_info;
399*a26f067fSSarah Walker struct rogue_pollinfo poll_info;
400*a26f067fSSarah Walker struct rogue_tlbinfo tlb_info;
401*a26f067fSSarah Walker struct rogue_eccinfo ecc_info;
402*a26f067fSSarah Walker } hwr_data;
403*a26f067fSSarah Walker
404*a26f067fSSarah Walker aligned_u64 cr_timer;
405*a26f067fSSarah Walker aligned_u64 os_timer;
406*a26f067fSSarah Walker u32 frame_num;
407*a26f067fSSarah Walker u32 pid;
408*a26f067fSSarah Walker u32 active_hwrt_data;
409*a26f067fSSarah Walker u32 hwr_number;
410*a26f067fSSarah Walker u32 event_status;
411*a26f067fSSarah Walker u32 hwr_recovery_flags;
412*a26f067fSSarah Walker enum rogue_hwrtype hwr_type;
413*a26f067fSSarah Walker u32 dm;
414*a26f067fSSarah Walker u32 core_id;
415*a26f067fSSarah Walker aligned_u64 cr_time_of_kick;
416*a26f067fSSarah Walker aligned_u64 cr_time_hw_reset_start;
417*a26f067fSSarah Walker aligned_u64 cr_time_hw_reset_finish;
418*a26f067fSSarah Walker aligned_u64 cr_time_freelist_ready;
419*a26f067fSSarah Walker aligned_u64 reserved[2];
420*a26f067fSSarah Walker } __aligned(8);
421*a26f067fSSarah Walker
422*a26f067fSSarah Walker /* Number of first HWR logs recorded (never overwritten by newer logs) */
423*a26f067fSSarah Walker #define ROGUE_FWIF_HWINFO_MAX_FIRST 8U
424*a26f067fSSarah Walker /* Number of latest HWR logs (older logs are overwritten by newer logs) */
425*a26f067fSSarah Walker #define ROGUE_FWIF_HWINFO_MAX_LAST 8U
426*a26f067fSSarah Walker /* Total number of HWR logs stored in a buffer */
427*a26f067fSSarah Walker #define ROGUE_FWIF_HWINFO_MAX \
428*a26f067fSSarah Walker (ROGUE_FWIF_HWINFO_MAX_FIRST + ROGUE_FWIF_HWINFO_MAX_LAST)
429*a26f067fSSarah Walker /* Index of the last log in the HWR log buffer */
430*a26f067fSSarah Walker #define ROGUE_FWIF_HWINFO_LAST_INDEX (ROGUE_FWIF_HWINFO_MAX - 1U)
431*a26f067fSSarah Walker
432*a26f067fSSarah Walker struct rogue_fwif_hwrinfobuf {
433*a26f067fSSarah Walker struct rogue_hwrinfo hwr_info[ROGUE_FWIF_HWINFO_MAX];
434*a26f067fSSarah Walker u32 hwr_counter;
435*a26f067fSSarah Walker u32 write_index;
436*a26f067fSSarah Walker u32 dd_req_count;
437*a26f067fSSarah Walker u32 hwr_info_buf_flags; /* Compatibility and other flags */
438*a26f067fSSarah Walker u32 hwr_dm_locked_up_count[PVR_FWIF_DM_MAX];
439*a26f067fSSarah Walker u32 hwr_dm_overran_count[PVR_FWIF_DM_MAX];
440*a26f067fSSarah Walker u32 hwr_dm_recovered_count[PVR_FWIF_DM_MAX];
441*a26f067fSSarah Walker u32 hwr_dm_false_detect_count[PVR_FWIF_DM_MAX];
442*a26f067fSSarah Walker } __aligned(8);
443*a26f067fSSarah Walker
444*a26f067fSSarah Walker #define ROGUE_FWIF_CTXSWITCH_PROFILE_FAST_EN (1)
445*a26f067fSSarah Walker #define ROGUE_FWIF_CTXSWITCH_PROFILE_MEDIUM_EN (2)
446*a26f067fSSarah Walker #define ROGUE_FWIF_CTXSWITCH_PROFILE_SLOW_EN (3)
447*a26f067fSSarah Walker #define ROGUE_FWIF_CTXSWITCH_PROFILE_NODELAY_EN (4)
448*a26f067fSSarah Walker
449*a26f067fSSarah Walker #define ROGUE_FWIF_CDM_ARBITRATION_TASK_DEMAND_EN (1)
450*a26f067fSSarah Walker #define ROGUE_FWIF_CDM_ARBITRATION_ROUND_ROBIN_EN (2)
451*a26f067fSSarah Walker
452*a26f067fSSarah Walker #define ROGUE_FWIF_ISP_SCHEDMODE_VER1_IPP (1)
453*a26f067fSSarah Walker #define ROGUE_FWIF_ISP_SCHEDMODE_VER2_ISP (2)
454*a26f067fSSarah Walker /*
455*a26f067fSSarah Walker ******************************************************************************
456*a26f067fSSarah Walker * ROGUE firmware Init Config Data
457*a26f067fSSarah Walker ******************************************************************************
458*a26f067fSSarah Walker */
459*a26f067fSSarah Walker
460*a26f067fSSarah Walker /* Flag definitions affecting the firmware globally */
461*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_MODE_RAND BIT(0)
462*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_SRESET_EN BIT(1)
463*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_HWPERF_EN BIT(2)
464*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_DM_KILL_MODE_RAND_EN BIT(3)
465*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_POW_RASCALDUST BIT(4)
466*a26f067fSSarah Walker /* Bit 5 is reserved. */
467*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_FBCDC_V3_1_EN BIT(6)
468*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CHECK_MLIST_EN BIT(7)
469*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_DISABLE_CLKGATING_EN BIT(8)
470*a26f067fSSarah Walker /* Bit 9 is reserved. */
471*a26f067fSSarah Walker /* Bit 10 is reserved. */
472*a26f067fSSarah Walker /* Bit 11 is reserved. */
473*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_REGCONFIG_EN BIT(12)
474*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ASSERT_ON_OUTOFMEMORY BIT(13)
475*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_HWP_DISABLE_FILTER BIT(14)
476*a26f067fSSarah Walker /* Bit 15 is reserved. */
477*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT (16)
478*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_FAST \
479*a26f067fSSarah Walker (ROGUE_FWIF_CTXSWITCH_PROFILE_FAST_EN \
480*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
481*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_MEDIUM \
482*a26f067fSSarah Walker (ROGUE_FWIF_CTXSWITCH_PROFILE_MEDIUM_EN \
483*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
484*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SLOW \
485*a26f067fSSarah Walker (ROGUE_FWIF_CTXSWITCH_PROFILE_SLOW_EN \
486*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
487*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_NODELAY \
488*a26f067fSSarah Walker (ROGUE_FWIF_CTXSWITCH_PROFILE_NODELAY_EN \
489*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
490*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_MASK \
491*a26f067fSSarah Walker (7 << ROGUE_FWIF_INICFG_CTXSWITCH_PROFILE_SHIFT)
492*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_DISABLE_DM_OVERLAP BIT(19)
493*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ASSERT_ON_HWR_TRIGGER BIT(20)
494*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_FABRIC_COHERENCY_ENABLED BIT(21)
495*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_VALIDATE_IRQ BIT(22)
496*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_DISABLE_PDP_EN BIT(23)
497*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_SPU_POWER_STATE_MASK_CHANGE_EN BIT(24)
498*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_WORKEST BIT(25)
499*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_PDVFS BIT(26)
500*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT (27)
501*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_TASK_DEMAND \
502*a26f067fSSarah Walker (ROGUE_FWIF_CDM_ARBITRATION_TASK_DEMAND_EN \
503*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT)
504*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_ROUND_ROBIN \
505*a26f067fSSarah Walker (ROGUE_FWIF_CDM_ARBITRATION_ROUND_ROBIN_EN \
506*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT)
507*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_CDM_ARBITRATION_MASK \
508*a26f067fSSarah Walker (3 << ROGUE_FWIF_INICFG_CDM_ARBITRATION_SHIFT)
509*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_SHIFT (29)
510*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_NONE (0)
511*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER1_IPP \
512*a26f067fSSarah Walker (ROGUE_FWIF_ISP_SCHEDMODE_VER1_IPP \
513*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_ISPSCHEDMODE_SHIFT)
514*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER2_ISP \
515*a26f067fSSarah Walker (ROGUE_FWIF_ISP_SCHEDMODE_VER2_ISP \
516*a26f067fSSarah Walker << ROGUE_FWIF_INICFG_ISPSCHEDMODE_SHIFT)
517*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ISPSCHEDMODE_MASK \
518*a26f067fSSarah Walker (ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER1_IPP | \
519*a26f067fSSarah Walker ROGUE_FWIF_INICFG_ISPSCHEDMODE_VER2_ISP)
520*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_VALIDATE_SOCUSC_TIMER BIT(31)
521*a26f067fSSarah Walker
522*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_ALL (0xFFFFFFFFU)
523*a26f067fSSarah Walker
524*a26f067fSSarah Walker /* Extended Flag definitions affecting the firmware globally */
525*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_EXT_TFBC_CONTROL_SHIFT (0)
526*a26f067fSSarah Walker /* [7] YUV10 override
527*a26f067fSSarah Walker * [6:4] Quality
528*a26f067fSSarah Walker * [3] Quality enable
529*a26f067fSSarah Walker * [2:1] Compression scheme
530*a26f067fSSarah Walker * [0] Lossy group
531*a26f067fSSarah Walker */
532*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_EXT_TFBC_CONTROL_MASK (0xFF)
533*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_EXT_ALL (ROGUE_FWIF_INICFG_EXT_TFBC_CONTROL_MASK)
534*a26f067fSSarah Walker
535*a26f067fSSarah Walker /* Flag definitions affecting only workloads submitted by a particular OS */
536*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_TDM_EN BIT(0)
537*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_GEOM_EN BIT(1)
538*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_FRAG_EN BIT(2)
539*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_CDM_EN BIT(3)
540*a26f067fSSarah Walker
541*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_TDM BIT(4)
542*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_GEOM BIT(5)
543*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_FRAG BIT(6)
544*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_LOW_PRIO_CS_CDM BIT(7)
545*a26f067fSSarah Walker
546*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_ALL (0xFF)
547*a26f067fSSarah Walker
548*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_DM_ALL \
549*a26f067fSSarah Walker (ROGUE_FWIF_INICFG_OS_CTXSWITCH_TDM_EN | \
550*a26f067fSSarah Walker ROGUE_FWIF_INICFG_OS_CTXSWITCH_GEOM_EN | \
551*a26f067fSSarah Walker ROGUE_FWIF_INICFG_OS_CTXSWITCH_FRAG_EN | \
552*a26f067fSSarah Walker ROGUE_FWIF_INICFG_OS_CTXSWITCH_CDM_EN)
553*a26f067fSSarah Walker
554*a26f067fSSarah Walker #define ROGUE_FWIF_INICFG_OS_CTXSWITCH_CLRMSK \
555*a26f067fSSarah Walker ~(ROGUE_FWIF_INICFG_OS_CTXSWITCH_DM_ALL)
556*a26f067fSSarah Walker
557*a26f067fSSarah Walker #define ROGUE_FWIF_FILTCFG_TRUNCATE_HALF BIT(3)
558*a26f067fSSarah Walker #define ROGUE_FWIF_FILTCFG_TRUNCATE_INT BIT(2)
559*a26f067fSSarah Walker #define ROGUE_FWIF_FILTCFG_NEW_FILTER_MODE BIT(1)
560*a26f067fSSarah Walker
561*a26f067fSSarah Walker enum rogue_activepm_conf {
562*a26f067fSSarah Walker ROGUE_ACTIVEPM_FORCE_OFF = 0,
563*a26f067fSSarah Walker ROGUE_ACTIVEPM_FORCE_ON = 1,
564*a26f067fSSarah Walker ROGUE_ACTIVEPM_DEFAULT = 2
565*a26f067fSSarah Walker };
566*a26f067fSSarah Walker
567*a26f067fSSarah Walker enum rogue_rd_power_island_conf {
568*a26f067fSSarah Walker ROGUE_RD_POWER_ISLAND_FORCE_OFF = 0,
569*a26f067fSSarah Walker ROGUE_RD_POWER_ISLAND_FORCE_ON = 1,
570*a26f067fSSarah Walker ROGUE_RD_POWER_ISLAND_DEFAULT = 2
571*a26f067fSSarah Walker };
572*a26f067fSSarah Walker
573*a26f067fSSarah Walker struct rogue_fw_register_list {
574*a26f067fSSarah Walker /* Register number */
575*a26f067fSSarah Walker u16 reg_num;
576*a26f067fSSarah Walker /* Indirect register number (or 0 if not used) */
577*a26f067fSSarah Walker u16 indirect_reg_num;
578*a26f067fSSarah Walker /* Start value for indirect register */
579*a26f067fSSarah Walker u16 indirect_start_val;
580*a26f067fSSarah Walker /* End value for indirect register */
581*a26f067fSSarah Walker u16 indirect_end_val;
582*a26f067fSSarah Walker };
583*a26f067fSSarah Walker
584*a26f067fSSarah Walker struct rogue_fwif_dllist_node {
585*a26f067fSSarah Walker u32 p;
586*a26f067fSSarah Walker u32 n;
587*a26f067fSSarah Walker };
588*a26f067fSSarah Walker
589*a26f067fSSarah Walker /*
590*a26f067fSSarah Walker * This number is used to represent an invalid page catalogue physical address
591*a26f067fSSarah Walker */
592*a26f067fSSarah Walker #define ROGUE_FWIF_INVALID_PC_PHYADDR 0xFFFFFFFFFFFFFFFFLLU
593*a26f067fSSarah Walker
594*a26f067fSSarah Walker /* This number is used to represent unallocated page catalog base register */
595*a26f067fSSarah Walker #define ROGUE_FW_BIF_INVALID_PCSET 0xFFFFFFFFU
596*a26f067fSSarah Walker
597*a26f067fSSarah Walker /* Firmware memory context. */
598*a26f067fSSarah Walker struct rogue_fwif_fwmemcontext {
599*a26f067fSSarah Walker /* device physical address of context's page catalogue */
600*a26f067fSSarah Walker aligned_u64 pc_dev_paddr;
601*a26f067fSSarah Walker /*
602*a26f067fSSarah Walker * associated page catalog base register (ROGUE_FW_BIF_INVALID_PCSET ==
603*a26f067fSSarah Walker * unallocated)
604*a26f067fSSarah Walker */
605*a26f067fSSarah Walker u32 page_cat_base_reg_set;
606*a26f067fSSarah Walker /* breakpoint address */
607*a26f067fSSarah Walker u32 breakpoint_addr;
608*a26f067fSSarah Walker /* breakpoint handler address */
609*a26f067fSSarah Walker u32 bp_handler_addr;
610*a26f067fSSarah Walker /* DM and enable control for BP */
611*a26f067fSSarah Walker u32 breakpoint_ctl;
612*a26f067fSSarah Walker /* Compatibility and other flags */
613*a26f067fSSarah Walker u32 fw_mem_ctx_flags;
614*a26f067fSSarah Walker u32 padding;
615*a26f067fSSarah Walker } __aligned(8);
616*a26f067fSSarah Walker
617*a26f067fSSarah Walker /*
618*a26f067fSSarah Walker * FW context state flags
619*a26f067fSSarah Walker */
620*a26f067fSSarah Walker #define ROGUE_FWIF_CONTEXT_FLAGS_NEED_RESUME (0x00000001U)
621*a26f067fSSarah Walker #define ROGUE_FWIF_CONTEXT_FLAGS_MC_NEED_RESUME_MASKFULL (0x000000FFU)
622*a26f067fSSarah Walker #define ROGUE_FWIF_CONTEXT_FLAGS_TDM_HEADER_STALE (0x00000100U)
623*a26f067fSSarah Walker #define ROGUE_FWIF_CONTEXT_FLAGS_LAST_KICK_SECURE (0x00000200U)
624*a26f067fSSarah Walker
625*a26f067fSSarah Walker #define ROGUE_NUM_GEOM_CORES_MAX 4
626*a26f067fSSarah Walker
627*a26f067fSSarah Walker /*
628*a26f067fSSarah Walker * FW-accessible TA state which must be written out to memory on context store
629*a26f067fSSarah Walker */
630*a26f067fSSarah Walker struct rogue_fwif_geom_ctx_state_per_geom {
631*a26f067fSSarah Walker /* To store in mid-TA */
632*a26f067fSSarah Walker aligned_u64 geom_reg_vdm_call_stack_pointer;
633*a26f067fSSarah Walker /* Initial value (in case is 'lost' due to a lock-up */
634*a26f067fSSarah Walker aligned_u64 geom_reg_vdm_call_stack_pointer_init;
635*a26f067fSSarah Walker u32 geom_reg_vbs_so_prim[4];
636*a26f067fSSarah Walker u16 geom_current_idx;
637*a26f067fSSarah Walker u16 padding[3];
638*a26f067fSSarah Walker } __aligned(8);
639*a26f067fSSarah Walker
640*a26f067fSSarah Walker struct rogue_fwif_geom_ctx_state {
641*a26f067fSSarah Walker /* FW-accessible TA state which must be written out to memory on context store */
642*a26f067fSSarah Walker struct rogue_fwif_geom_ctx_state_per_geom geom_core[ROGUE_NUM_GEOM_CORES_MAX];
643*a26f067fSSarah Walker } __aligned(8);
644*a26f067fSSarah Walker
645*a26f067fSSarah Walker /*
646*a26f067fSSarah Walker * FW-accessible ISP state which must be written out to memory on context store
647*a26f067fSSarah Walker */
648*a26f067fSSarah Walker struct rogue_fwif_frag_ctx_state {
649*a26f067fSSarah Walker u32 frag_reg_pm_deallocated_mask_status;
650*a26f067fSSarah Walker u32 frag_reg_dm_pds_mtilefree_status;
651*a26f067fSSarah Walker /* Compatibility and other flags */
652*a26f067fSSarah Walker u32 ctx_state_flags;
653*a26f067fSSarah Walker /*
654*a26f067fSSarah Walker * frag_reg_isp_store should be the last element of the structure as this
655*a26f067fSSarah Walker * is an array whose size is determined at runtime after detecting the
656*a26f067fSSarah Walker * ROGUE core
657*a26f067fSSarah Walker */
658*a26f067fSSarah Walker u32 frag_reg_isp_store[];
659*a26f067fSSarah Walker } __aligned(8);
660*a26f067fSSarah Walker
661*a26f067fSSarah Walker #define ROGUE_FWIF_CTX_USING_BUFFER_A (0)
662*a26f067fSSarah Walker #define ROGUE_FWIF_CTX_USING_BUFFER_B (1U)
663*a26f067fSSarah Walker
664*a26f067fSSarah Walker struct rogue_fwif_compute_ctx_state {
665*a26f067fSSarah Walker u32 ctx_state_flags; /* Target buffer and other flags */
666*a26f067fSSarah Walker };
667*a26f067fSSarah Walker
668*a26f067fSSarah Walker struct rogue_fwif_fwcommoncontext {
669*a26f067fSSarah Walker /* CCB details for this firmware context */
670*a26f067fSSarah Walker u32 ccbctl_fw_addr; /* CCB control */
671*a26f067fSSarah Walker u32 ccb_fw_addr; /* CCB base */
672*a26f067fSSarah Walker struct rogue_fwif_dma_addr ccb_meta_dma_addr;
673*a26f067fSSarah Walker
674*a26f067fSSarah Walker /* Context suspend state */
675*a26f067fSSarah Walker /* geom/frag context suspend state, read/written by FW */
676*a26f067fSSarah Walker u32 context_state_addr __aligned(8);
677*a26f067fSSarah Walker
678*a26f067fSSarah Walker /* Flags e.g. for context switching */
679*a26f067fSSarah Walker u32 fw_com_ctx_flags;
680*a26f067fSSarah Walker u32 priority;
681*a26f067fSSarah Walker u32 priority_seq_num;
682*a26f067fSSarah Walker
683*a26f067fSSarah Walker /* Framework state */
684*a26f067fSSarah Walker /* Register updates for Framework */
685*a26f067fSSarah Walker u32 rf_cmd_addr __aligned(8);
686*a26f067fSSarah Walker
687*a26f067fSSarah Walker /* Statistic updates waiting to be passed back to the host... */
688*a26f067fSSarah Walker /* True when some stats are pending */
689*a26f067fSSarah Walker bool stats_pending __aligned(4);
690*a26f067fSSarah Walker /* Number of stores on this context since last update */
691*a26f067fSSarah Walker s32 stats_num_stores;
692*a26f067fSSarah Walker /* Number of OOMs on this context since last update */
693*a26f067fSSarah Walker s32 stats_num_out_of_memory;
694*a26f067fSSarah Walker /* Number of PRs on this context since last update */
695*a26f067fSSarah Walker s32 stats_num_partial_renders;
696*a26f067fSSarah Walker /* Data Master type */
697*a26f067fSSarah Walker u32 dm;
698*a26f067fSSarah Walker /* Device Virtual Address of the signal the context is waiting on */
699*a26f067fSSarah Walker aligned_u64 wait_signal_address;
700*a26f067fSSarah Walker /* List entry for the wait-signal list */
701*a26f067fSSarah Walker struct rogue_fwif_dllist_node wait_signal_node __aligned(8);
702*a26f067fSSarah Walker /* List entry for the buffer stalled list */
703*a26f067fSSarah Walker struct rogue_fwif_dllist_node buf_stalled_node __aligned(8);
704*a26f067fSSarah Walker /* Address of the circular buffer queue pointers */
705*a26f067fSSarah Walker aligned_u64 cbuf_queue_ctrl_addr;
706*a26f067fSSarah Walker
707*a26f067fSSarah Walker aligned_u64 robustness_address;
708*a26f067fSSarah Walker /* Max HWR deadline limit in ms */
709*a26f067fSSarah Walker u32 max_deadline_ms;
710*a26f067fSSarah Walker /* Following HWR circular buffer read-offset needs resetting */
711*a26f067fSSarah Walker bool read_offset_needs_reset;
712*a26f067fSSarah Walker
713*a26f067fSSarah Walker /* List entry for the waiting list */
714*a26f067fSSarah Walker struct rogue_fwif_dllist_node waiting_node __aligned(8);
715*a26f067fSSarah Walker /* List entry for the run list */
716*a26f067fSSarah Walker struct rogue_fwif_dllist_node run_node __aligned(8);
717*a26f067fSSarah Walker /* UFO that last failed (or NULL) */
718*a26f067fSSarah Walker struct rogue_fwif_ufo last_failed_ufo;
719*a26f067fSSarah Walker
720*a26f067fSSarah Walker /* Memory context */
721*a26f067fSSarah Walker u32 fw_mem_context_fw_addr;
722*a26f067fSSarah Walker
723*a26f067fSSarah Walker /* References to the host side originators */
724*a26f067fSSarah Walker /* the Server Common Context */
725*a26f067fSSarah Walker u32 server_common_context_id;
726*a26f067fSSarah Walker /* associated process ID */
727*a26f067fSSarah Walker u32 pid;
728*a26f067fSSarah Walker
729*a26f067fSSarah Walker /* True when Geom DM OOM is not allowed */
730*a26f067fSSarah Walker bool geom_oom_disabled __aligned(4);
731*a26f067fSSarah Walker } __aligned(8);
732*a26f067fSSarah Walker
733*a26f067fSSarah Walker /* Firmware render context. */
734*a26f067fSSarah Walker struct rogue_fwif_fwrendercontext {
735*a26f067fSSarah Walker /* Geometry firmware context. */
736*a26f067fSSarah Walker struct rogue_fwif_fwcommoncontext geom_context;
737*a26f067fSSarah Walker /* Fragment firmware context. */
738*a26f067fSSarah Walker struct rogue_fwif_fwcommoncontext frag_context;
739*a26f067fSSarah Walker
740*a26f067fSSarah Walker struct rogue_fwif_static_rendercontext_state static_render_context_state;
741*a26f067fSSarah Walker
742*a26f067fSSarah Walker /* Number of commands submitted to the WorkEst FW CCB */
743*a26f067fSSarah Walker u32 work_est_ccb_submitted;
744*a26f067fSSarah Walker
745*a26f067fSSarah Walker /* Compatibility and other flags */
746*a26f067fSSarah Walker u32 fw_render_ctx_flags;
747*a26f067fSSarah Walker } __aligned(8);
748*a26f067fSSarah Walker
749*a26f067fSSarah Walker /* Firmware compute context. */
750*a26f067fSSarah Walker struct rogue_fwif_fwcomputecontext {
751*a26f067fSSarah Walker /* Firmware context for the CDM */
752*a26f067fSSarah Walker struct rogue_fwif_fwcommoncontext cdm_context;
753*a26f067fSSarah Walker
754*a26f067fSSarah Walker struct rogue_fwif_static_computecontext_state
755*a26f067fSSarah Walker static_compute_context_state;
756*a26f067fSSarah Walker
757*a26f067fSSarah Walker /* Number of commands submitted to the WorkEst FW CCB */
758*a26f067fSSarah Walker u32 work_est_ccb_submitted;
759*a26f067fSSarah Walker
760*a26f067fSSarah Walker /* Compatibility and other flags */
761*a26f067fSSarah Walker u32 compute_ctx_flags;
762*a26f067fSSarah Walker
763*a26f067fSSarah Walker u32 wgp_state;
764*a26f067fSSarah Walker u32 wgp_checksum;
765*a26f067fSSarah Walker u32 core_mask_a;
766*a26f067fSSarah Walker u32 core_mask_b;
767*a26f067fSSarah Walker } __aligned(8);
768*a26f067fSSarah Walker
769*a26f067fSSarah Walker /* Firmware TDM context. */
770*a26f067fSSarah Walker struct rogue_fwif_fwtdmcontext {
771*a26f067fSSarah Walker /* Firmware context for the TDM */
772*a26f067fSSarah Walker struct rogue_fwif_fwcommoncontext tdm_context;
773*a26f067fSSarah Walker
774*a26f067fSSarah Walker /* Number of commands submitted to the WorkEst FW CCB */
775*a26f067fSSarah Walker u32 work_est_ccb_submitted;
776*a26f067fSSarah Walker } __aligned(8);
777*a26f067fSSarah Walker
778*a26f067fSSarah Walker /* Firmware TQ3D context. */
779*a26f067fSSarah Walker struct rogue_fwif_fwtransfercontext {
780*a26f067fSSarah Walker /* Firmware context for TQ3D. */
781*a26f067fSSarah Walker struct rogue_fwif_fwcommoncontext tq_context;
782*a26f067fSSarah Walker } __aligned(8);
783*a26f067fSSarah Walker
784*a26f067fSSarah Walker /*
785*a26f067fSSarah Walker ******************************************************************************
786*a26f067fSSarah Walker * Defines for CMD_TYPE corruption detection and forward compatibility check
787*a26f067fSSarah Walker ******************************************************************************
788*a26f067fSSarah Walker */
789*a26f067fSSarah Walker
790*a26f067fSSarah Walker /*
791*a26f067fSSarah Walker * CMD_TYPE 32bit contains:
792*a26f067fSSarah Walker * 31:16 Reserved for magic value to detect corruption (16 bits)
793*a26f067fSSarah Walker * 15 Reserved for ROGUE_CCB_TYPE_TASK (1 bit)
794*a26f067fSSarah Walker * 14:0 Bits available for CMD_TYPEs (15 bits)
795*a26f067fSSarah Walker */
796*a26f067fSSarah Walker
797*a26f067fSSarah Walker /* Magic value to detect corruption */
798*a26f067fSSarah Walker #define ROGUE_CMD_MAGIC_DWORD (0x2ABC)
799*a26f067fSSarah Walker #define ROGUE_CMD_MAGIC_DWORD_MASK (0xFFFF0000U)
800*a26f067fSSarah Walker #define ROGUE_CMD_MAGIC_DWORD_SHIFT (16U)
801*a26f067fSSarah Walker #define ROGUE_CMD_MAGIC_DWORD_SHIFTED \
802*a26f067fSSarah Walker (ROGUE_CMD_MAGIC_DWORD << ROGUE_CMD_MAGIC_DWORD_SHIFT)
803*a26f067fSSarah Walker
804*a26f067fSSarah Walker /* Kernel CCB control for ROGUE */
805*a26f067fSSarah Walker struct rogue_fwif_ccb_ctl {
806*a26f067fSSarah Walker /* write offset into array of commands (MUST be aligned to 16 bytes!) */
807*a26f067fSSarah Walker u32 write_offset;
808*a26f067fSSarah Walker /* Padding to ensure read and write offsets are in separate cache lines. */
809*a26f067fSSarah Walker u8 padding[128 - sizeof(u32)];
810*a26f067fSSarah Walker /* read offset into array of commands */
811*a26f067fSSarah Walker u32 read_offset;
812*a26f067fSSarah Walker /* Offset wrapping mask (Total capacity of the CCB - 1) */
813*a26f067fSSarah Walker u32 wrap_mask;
814*a26f067fSSarah Walker /* size of each command in bytes */
815*a26f067fSSarah Walker u32 cmd_size;
816*a26f067fSSarah Walker u32 padding2;
817*a26f067fSSarah Walker } __aligned(8);
818*a26f067fSSarah Walker
819*a26f067fSSarah Walker /* Kernel CCB command structure for ROGUE */
820*a26f067fSSarah Walker
821*a26f067fSSarah Walker #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PT (0x1U) /* MMU_CTRL_INVAL_PT_EN */
822*a26f067fSSarah Walker #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PD (0x2U) /* MMU_CTRL_INVAL_PD_EN */
823*a26f067fSSarah Walker #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PC (0x4U) /* MMU_CTRL_INVAL_PC_EN */
824*a26f067fSSarah Walker
825*a26f067fSSarah Walker /*
826*a26f067fSSarah Walker * can't use PM_TLB0 bit from BIFPM_CTRL reg because it collides with PT
827*a26f067fSSarah Walker * bit from BIF_CTRL reg
828*a26f067fSSarah Walker */
829*a26f067fSSarah Walker #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_PMTLB (0x10)
830*a26f067fSSarah Walker /* BIF_CTRL_INVAL_TLB1_EN */
831*a26f067fSSarah Walker #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_TLB \
832*a26f067fSSarah Walker (ROGUE_FWIF_MMUCACHEDATA_FLAGS_PMTLB | 0x8)
833*a26f067fSSarah Walker /* MMU_CTRL_INVAL_ALL_CONTEXTS_EN */
834*a26f067fSSarah Walker #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_CTX_ALL (0x800)
835*a26f067fSSarah Walker
836*a26f067fSSarah Walker /* indicates FW should interrupt the host */
837*a26f067fSSarah Walker #define ROGUE_FWIF_MMUCACHEDATA_FLAGS_INTERRUPT (0x4000000U)
838*a26f067fSSarah Walker
839*a26f067fSSarah Walker struct rogue_fwif_mmucachedata {
840*a26f067fSSarah Walker u32 cache_flags;
841*a26f067fSSarah Walker u32 mmu_cache_sync_fw_addr;
842*a26f067fSSarah Walker u32 mmu_cache_sync_update_value;
843*a26f067fSSarah Walker };
844*a26f067fSSarah Walker
845*a26f067fSSarah Walker #define ROGUE_FWIF_BPDATA_FLAGS_ENABLE BIT(0)
846*a26f067fSSarah Walker #define ROGUE_FWIF_BPDATA_FLAGS_WRITE BIT(1)
847*a26f067fSSarah Walker #define ROGUE_FWIF_BPDATA_FLAGS_CTL BIT(2)
848*a26f067fSSarah Walker #define ROGUE_FWIF_BPDATA_FLAGS_REGS BIT(3)
849*a26f067fSSarah Walker
850*a26f067fSSarah Walker struct rogue_fwif_bpdata {
851*a26f067fSSarah Walker /* Memory context */
852*a26f067fSSarah Walker u32 fw_mem_context_fw_addr;
853*a26f067fSSarah Walker /* Breakpoint address */
854*a26f067fSSarah Walker u32 bp_addr;
855*a26f067fSSarah Walker /* Breakpoint handler */
856*a26f067fSSarah Walker u32 bp_handler_addr;
857*a26f067fSSarah Walker /* Breakpoint control */
858*a26f067fSSarah Walker u32 bp_dm;
859*a26f067fSSarah Walker u32 bp_data_flags;
860*a26f067fSSarah Walker /* Number of temporary registers to overallocate */
861*a26f067fSSarah Walker u32 temp_regs;
862*a26f067fSSarah Walker /* Number of shared registers to overallocate */
863*a26f067fSSarah Walker u32 shared_regs;
864*a26f067fSSarah Walker /* DM associated with the breakpoint */
865*a26f067fSSarah Walker u32 dm;
866*a26f067fSSarah Walker };
867*a26f067fSSarah Walker
868*a26f067fSSarah Walker #define ROGUE_FWIF_KCCB_CMD_KICK_DATA_MAX_NUM_CLEANUP_CTLS \
869*a26f067fSSarah Walker (ROGUE_FWIF_PRBUFFER_MAXSUPPORTED + 1U) /* +1 is RTDATASET cleanup */
870*a26f067fSSarah Walker
871*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_kick_data {
872*a26f067fSSarah Walker /* address of the firmware context */
873*a26f067fSSarah Walker u32 context_fw_addr;
874*a26f067fSSarah Walker /* Client CCB woff update */
875*a26f067fSSarah Walker u32 client_woff_update;
876*a26f067fSSarah Walker /* Client CCB wrap mask update after CCCB growth */
877*a26f067fSSarah Walker u32 client_wrap_mask_update;
878*a26f067fSSarah Walker /* number of CleanupCtl pointers attached */
879*a26f067fSSarah Walker u32 num_cleanup_ctl;
880*a26f067fSSarah Walker /* CleanupCtl structures associated with command */
881*a26f067fSSarah Walker u32 cleanup_ctl_fw_addr
882*a26f067fSSarah Walker [ROGUE_FWIF_KCCB_CMD_KICK_DATA_MAX_NUM_CLEANUP_CTLS];
883*a26f067fSSarah Walker /*
884*a26f067fSSarah Walker * offset to the CmdHeader which houses the workload estimation kick
885*a26f067fSSarah Walker * data.
886*a26f067fSSarah Walker */
887*a26f067fSSarah Walker u32 work_est_cmd_header_offset;
888*a26f067fSSarah Walker };
889*a26f067fSSarah Walker
890*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_combined_geom_frag_kick_data {
891*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_kick_data geom_cmd_kick_data;
892*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_kick_data frag_cmd_kick_data;
893*a26f067fSSarah Walker };
894*a26f067fSSarah Walker
895*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_force_update_data {
896*a26f067fSSarah Walker /* address of the firmware context */
897*a26f067fSSarah Walker u32 context_fw_addr;
898*a26f067fSSarah Walker /* Client CCB fence offset */
899*a26f067fSSarah Walker u32 ccb_fence_offset;
900*a26f067fSSarah Walker };
901*a26f067fSSarah Walker
902*a26f067fSSarah Walker enum rogue_fwif_cleanup_type {
903*a26f067fSSarah Walker /* FW common context cleanup */
904*a26f067fSSarah Walker ROGUE_FWIF_CLEANUP_FWCOMMONCONTEXT,
905*a26f067fSSarah Walker /* FW HW RT data cleanup */
906*a26f067fSSarah Walker ROGUE_FWIF_CLEANUP_HWRTDATA,
907*a26f067fSSarah Walker /* FW freelist cleanup */
908*a26f067fSSarah Walker ROGUE_FWIF_CLEANUP_FREELIST,
909*a26f067fSSarah Walker /* FW ZS Buffer cleanup */
910*a26f067fSSarah Walker ROGUE_FWIF_CLEANUP_ZSBUFFER,
911*a26f067fSSarah Walker };
912*a26f067fSSarah Walker
913*a26f067fSSarah Walker struct rogue_fwif_cleanup_request {
914*a26f067fSSarah Walker /* Cleanup type */
915*a26f067fSSarah Walker enum rogue_fwif_cleanup_type cleanup_type;
916*a26f067fSSarah Walker union {
917*a26f067fSSarah Walker /* FW common context to cleanup */
918*a26f067fSSarah Walker u32 context_fw_addr;
919*a26f067fSSarah Walker /* HW RT to cleanup */
920*a26f067fSSarah Walker u32 hwrt_data_fw_addr;
921*a26f067fSSarah Walker /* Freelist to cleanup */
922*a26f067fSSarah Walker u32 freelist_fw_addr;
923*a26f067fSSarah Walker /* ZS Buffer to cleanup */
924*a26f067fSSarah Walker u32 zs_buffer_fw_addr;
925*a26f067fSSarah Walker } cleanup_data;
926*a26f067fSSarah Walker };
927*a26f067fSSarah Walker
928*a26f067fSSarah Walker enum rogue_fwif_power_type {
929*a26f067fSSarah Walker ROGUE_FWIF_POW_OFF_REQ = 1,
930*a26f067fSSarah Walker ROGUE_FWIF_POW_FORCED_IDLE_REQ,
931*a26f067fSSarah Walker ROGUE_FWIF_POW_NUM_UNITS_CHANGE,
932*a26f067fSSarah Walker ROGUE_FWIF_POW_APM_LATENCY_CHANGE
933*a26f067fSSarah Walker };
934*a26f067fSSarah Walker
935*a26f067fSSarah Walker enum rogue_fwif_power_force_idle_type {
936*a26f067fSSarah Walker ROGUE_FWIF_POWER_FORCE_IDLE = 1,
937*a26f067fSSarah Walker ROGUE_FWIF_POWER_CANCEL_FORCED_IDLE,
938*a26f067fSSarah Walker ROGUE_FWIF_POWER_HOST_TIMEOUT,
939*a26f067fSSarah Walker };
940*a26f067fSSarah Walker
941*a26f067fSSarah Walker struct rogue_fwif_power_request {
942*a26f067fSSarah Walker /* Type of power request */
943*a26f067fSSarah Walker enum rogue_fwif_power_type pow_type;
944*a26f067fSSarah Walker union {
945*a26f067fSSarah Walker /* Number of active Dusts */
946*a26f067fSSarah Walker u32 num_of_dusts;
947*a26f067fSSarah Walker /* If the operation is mandatory */
948*a26f067fSSarah Walker bool forced __aligned(4);
949*a26f067fSSarah Walker /*
950*a26f067fSSarah Walker * Type of Request. Consolidating Force Idle, Cancel Forced
951*a26f067fSSarah Walker * Idle, Host Timeout
952*a26f067fSSarah Walker */
953*a26f067fSSarah Walker enum rogue_fwif_power_force_idle_type pow_request_type;
954*a26f067fSSarah Walker } power_req_data;
955*a26f067fSSarah Walker };
956*a26f067fSSarah Walker
957*a26f067fSSarah Walker struct rogue_fwif_slcflushinvaldata {
958*a26f067fSSarah Walker /* Context to fence on (only useful when bDMContext == TRUE) */
959*a26f067fSSarah Walker u32 context_fw_addr;
960*a26f067fSSarah Walker /* Invalidate the cache as well as flushing */
961*a26f067fSSarah Walker bool inval __aligned(4);
962*a26f067fSSarah Walker /* The data to flush/invalidate belongs to a specific DM context */
963*a26f067fSSarah Walker bool dm_context __aligned(4);
964*a26f067fSSarah Walker /* Optional address of range (only useful when bDMContext == FALSE) */
965*a26f067fSSarah Walker aligned_u64 address;
966*a26f067fSSarah Walker /* Optional size of range (only useful when bDMContext == FALSE) */
967*a26f067fSSarah Walker aligned_u64 size;
968*a26f067fSSarah Walker };
969*a26f067fSSarah Walker
970*a26f067fSSarah Walker enum rogue_fwif_hwperf_update_config {
971*a26f067fSSarah Walker ROGUE_FWIF_HWPERF_CTRL_TOGGLE = 0,
972*a26f067fSSarah Walker ROGUE_FWIF_HWPERF_CTRL_SET = 1,
973*a26f067fSSarah Walker ROGUE_FWIF_HWPERF_CTRL_EMIT_FEATURES_EV = 2
974*a26f067fSSarah Walker };
975*a26f067fSSarah Walker
976*a26f067fSSarah Walker struct rogue_fwif_hwperf_ctrl {
977*a26f067fSSarah Walker enum rogue_fwif_hwperf_update_config opcode; /* Control operation code */
978*a26f067fSSarah Walker aligned_u64 mask; /* Mask of events to toggle */
979*a26f067fSSarah Walker };
980*a26f067fSSarah Walker
981*a26f067fSSarah Walker struct rogue_fwif_hwperf_config_enable_blks {
982*a26f067fSSarah Walker /* Number of ROGUE_HWPERF_CONFIG_MUX_CNTBLK in the array */
983*a26f067fSSarah Walker u32 num_blocks;
984*a26f067fSSarah Walker /* Address of the ROGUE_HWPERF_CONFIG_MUX_CNTBLK array */
985*a26f067fSSarah Walker u32 block_configs_fw_addr;
986*a26f067fSSarah Walker };
987*a26f067fSSarah Walker
988*a26f067fSSarah Walker struct rogue_fwif_hwperf_config_da_blks {
989*a26f067fSSarah Walker /* Number of ROGUE_HWPERF_CONFIG_CNTBLK in the array */
990*a26f067fSSarah Walker u32 num_blocks;
991*a26f067fSSarah Walker /* Address of the ROGUE_HWPERF_CONFIG_CNTBLK array */
992*a26f067fSSarah Walker u32 block_configs_fw_addr;
993*a26f067fSSarah Walker };
994*a26f067fSSarah Walker
995*a26f067fSSarah Walker struct rogue_fwif_coreclkspeedchange_data {
996*a26f067fSSarah Walker u32 new_clock_speed; /* New clock speed */
997*a26f067fSSarah Walker };
998*a26f067fSSarah Walker
999*a26f067fSSarah Walker #define ROGUE_FWIF_HWPERF_CTRL_BLKS_MAX 16
1000*a26f067fSSarah Walker
1001*a26f067fSSarah Walker struct rogue_fwif_hwperf_ctrl_blks {
1002*a26f067fSSarah Walker bool enable;
1003*a26f067fSSarah Walker /* Number of block IDs in the array */
1004*a26f067fSSarah Walker u32 num_blocks;
1005*a26f067fSSarah Walker /* Array of ROGUE_HWPERF_CNTBLK_ID values */
1006*a26f067fSSarah Walker u16 block_ids[ROGUE_FWIF_HWPERF_CTRL_BLKS_MAX];
1007*a26f067fSSarah Walker };
1008*a26f067fSSarah Walker
1009*a26f067fSSarah Walker struct rogue_fwif_hwperf_select_custom_cntrs {
1010*a26f067fSSarah Walker u16 custom_block;
1011*a26f067fSSarah Walker u16 num_counters;
1012*a26f067fSSarah Walker u32 custom_counter_ids_fw_addr;
1013*a26f067fSSarah Walker };
1014*a26f067fSSarah Walker
1015*a26f067fSSarah Walker struct rogue_fwif_zsbuffer_backing_data {
1016*a26f067fSSarah Walker u32 zs_buffer_fw_addr; /* ZS-Buffer FW address */
1017*a26f067fSSarah Walker
1018*a26f067fSSarah Walker bool done __aligned(4); /* action backing/unbacking succeeded */
1019*a26f067fSSarah Walker };
1020*a26f067fSSarah Walker
1021*a26f067fSSarah Walker struct rogue_fwif_freelist_gs_data {
1022*a26f067fSSarah Walker /* Freelist FW address */
1023*a26f067fSSarah Walker u32 freelist_fw_addr;
1024*a26f067fSSarah Walker /* Amount of the Freelist change */
1025*a26f067fSSarah Walker u32 delta_pages;
1026*a26f067fSSarah Walker /* New amount of pages on the freelist (including ready pages) */
1027*a26f067fSSarah Walker u32 new_pages;
1028*a26f067fSSarah Walker /* Number of ready pages to be held in reserve until OOM */
1029*a26f067fSSarah Walker u32 ready_pages;
1030*a26f067fSSarah Walker };
1031*a26f067fSSarah Walker
1032*a26f067fSSarah Walker #define MAX_FREELISTS_SIZE 3
1033*a26f067fSSarah Walker #define MAX_HW_GEOM_FRAG_CONTEXTS_SIZE 3
1034*a26f067fSSarah Walker
1035*a26f067fSSarah Walker #define ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT \
1036*a26f067fSSarah Walker (MAX_HW_GEOM_FRAG_CONTEXTS_SIZE * MAX_FREELISTS_SIZE * 2U)
1037*a26f067fSSarah Walker #define ROGUE_FWIF_FREELISTS_RECONSTRUCTION_FAILED_FLAG 0x80000000U
1038*a26f067fSSarah Walker
1039*a26f067fSSarah Walker struct rogue_fwif_freelists_reconstruction_data {
1040*a26f067fSSarah Walker u32 freelist_count;
1041*a26f067fSSarah Walker u32 freelist_ids[ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT];
1042*a26f067fSSarah Walker };
1043*a26f067fSSarah Walker
1044*a26f067fSSarah Walker struct rogue_fwif_write_offset_update_data {
1045*a26f067fSSarah Walker /*
1046*a26f067fSSarah Walker * Context to that may need to be resumed following write offset update
1047*a26f067fSSarah Walker */
1048*a26f067fSSarah Walker u32 context_fw_addr;
1049*a26f067fSSarah Walker } __aligned(8);
1050*a26f067fSSarah Walker
1051*a26f067fSSarah Walker /*
1052*a26f067fSSarah Walker ******************************************************************************
1053*a26f067fSSarah Walker * Proactive DVFS Structures
1054*a26f067fSSarah Walker ******************************************************************************
1055*a26f067fSSarah Walker */
1056*a26f067fSSarah Walker #define NUM_OPP_VALUES 16
1057*a26f067fSSarah Walker
1058*a26f067fSSarah Walker struct pdvfs_opp {
1059*a26f067fSSarah Walker u32 volt; /* V */
1060*a26f067fSSarah Walker u32 freq; /* Hz */
1061*a26f067fSSarah Walker } __aligned(8);
1062*a26f067fSSarah Walker
1063*a26f067fSSarah Walker struct rogue_fwif_pdvfs_opp {
1064*a26f067fSSarah Walker struct pdvfs_opp opp_values[NUM_OPP_VALUES];
1065*a26f067fSSarah Walker u32 min_opp_point;
1066*a26f067fSSarah Walker u32 max_opp_point;
1067*a26f067fSSarah Walker } __aligned(8);
1068*a26f067fSSarah Walker
1069*a26f067fSSarah Walker struct rogue_fwif_pdvfs_max_freq_data {
1070*a26f067fSSarah Walker u32 max_opp_point;
1071*a26f067fSSarah Walker } __aligned(8);
1072*a26f067fSSarah Walker
1073*a26f067fSSarah Walker struct rogue_fwif_pdvfs_min_freq_data {
1074*a26f067fSSarah Walker u32 min_opp_point;
1075*a26f067fSSarah Walker } __aligned(8);
1076*a26f067fSSarah Walker
1077*a26f067fSSarah Walker /*
1078*a26f067fSSarah Walker ******************************************************************************
1079*a26f067fSSarah Walker * Register configuration structures
1080*a26f067fSSarah Walker ******************************************************************************
1081*a26f067fSSarah Walker */
1082*a26f067fSSarah Walker
1083*a26f067fSSarah Walker #define ROGUE_FWIF_REG_CFG_MAX_SIZE 512
1084*a26f067fSSarah Walker
1085*a26f067fSSarah Walker enum rogue_fwif_regdata_cmd_type {
1086*a26f067fSSarah Walker ROGUE_FWIF_REGCFG_CMD_ADD = 101,
1087*a26f067fSSarah Walker ROGUE_FWIF_REGCFG_CMD_CLEAR = 102,
1088*a26f067fSSarah Walker ROGUE_FWIF_REGCFG_CMD_ENABLE = 103,
1089*a26f067fSSarah Walker ROGUE_FWIF_REGCFG_CMD_DISABLE = 104
1090*a26f067fSSarah Walker };
1091*a26f067fSSarah Walker
1092*a26f067fSSarah Walker enum rogue_fwif_reg_cfg_type {
1093*a26f067fSSarah Walker /* Sidekick power event */
1094*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_PWR_ON = 0,
1095*a26f067fSSarah Walker /* Rascal / dust power event */
1096*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_DUST_CHANGE,
1097*a26f067fSSarah Walker /* Geometry kick */
1098*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_GEOM,
1099*a26f067fSSarah Walker /* Fragment kick */
1100*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_FRAG,
1101*a26f067fSSarah Walker /* Compute kick */
1102*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_CDM,
1103*a26f067fSSarah Walker /* TLA kick */
1104*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_TLA,
1105*a26f067fSSarah Walker /* TDM kick */
1106*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_TDM,
1107*a26f067fSSarah Walker /* Applies to all types. Keep as last element */
1108*a26f067fSSarah Walker ROGUE_FWIF_REG_CFG_TYPE_ALL
1109*a26f067fSSarah Walker };
1110*a26f067fSSarah Walker
1111*a26f067fSSarah Walker struct rogue_fwif_reg_cfg_rec {
1112*a26f067fSSarah Walker u64 sddr;
1113*a26f067fSSarah Walker u64 mask;
1114*a26f067fSSarah Walker u64 value;
1115*a26f067fSSarah Walker };
1116*a26f067fSSarah Walker
1117*a26f067fSSarah Walker struct rogue_fwif_regconfig_data {
1118*a26f067fSSarah Walker enum rogue_fwif_regdata_cmd_type cmd_type;
1119*a26f067fSSarah Walker enum rogue_fwif_reg_cfg_type reg_config_type;
1120*a26f067fSSarah Walker struct rogue_fwif_reg_cfg_rec reg_config __aligned(8);
1121*a26f067fSSarah Walker };
1122*a26f067fSSarah Walker
1123*a26f067fSSarah Walker struct rogue_fwif_reg_cfg {
1124*a26f067fSSarah Walker /*
1125*a26f067fSSarah Walker * PDump WRW command write granularity is 32 bits.
1126*a26f067fSSarah Walker * Add padding to ensure array size is 32 bit granular.
1127*a26f067fSSarah Walker */
1128*a26f067fSSarah Walker u8 num_regs_type[ALIGN((u32)ROGUE_FWIF_REG_CFG_TYPE_ALL,
1129*a26f067fSSarah Walker sizeof(u32))] __aligned(8);
1130*a26f067fSSarah Walker struct rogue_fwif_reg_cfg_rec
1131*a26f067fSSarah Walker reg_configs[ROGUE_FWIF_REG_CFG_MAX_SIZE] __aligned(8);
1132*a26f067fSSarah Walker } __aligned(8);
1133*a26f067fSSarah Walker
1134*a26f067fSSarah Walker enum rogue_fwif_os_state_change {
1135*a26f067fSSarah Walker ROGUE_FWIF_OS_ONLINE = 1,
1136*a26f067fSSarah Walker ROGUE_FWIF_OS_OFFLINE
1137*a26f067fSSarah Walker };
1138*a26f067fSSarah Walker
1139*a26f067fSSarah Walker struct rogue_fwif_os_state_change_data {
1140*a26f067fSSarah Walker u32 osid;
1141*a26f067fSSarah Walker enum rogue_fwif_os_state_change new_os_state;
1142*a26f067fSSarah Walker } __aligned(8);
1143*a26f067fSSarah Walker
1144*a26f067fSSarah Walker enum rogue_fwif_counter_dump_request {
1145*a26f067fSSarah Walker ROGUE_FWIF_PWR_COUNTER_DUMP_START = 1,
1146*a26f067fSSarah Walker ROGUE_FWIF_PWR_COUNTER_DUMP_STOP,
1147*a26f067fSSarah Walker ROGUE_FWIF_PWR_COUNTER_DUMP_SAMPLE,
1148*a26f067fSSarah Walker };
1149*a26f067fSSarah Walker
1150*a26f067fSSarah Walker struct rogue_fwif_counter_dump_data {
1151*a26f067fSSarah Walker enum rogue_fwif_counter_dump_request counter_dump_request;
1152*a26f067fSSarah Walker } __aligned(8);
1153*a26f067fSSarah Walker
1154*a26f067fSSarah Walker enum rogue_fwif_kccb_cmd_type {
1155*a26f067fSSarah Walker /* Common commands */
1156*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_KICK = 101U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1157*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_MMUCACHE = 102U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1158*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_BP = 103U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1159*a26f067fSSarah Walker /* SLC flush and invalidation request */
1160*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_SLCFLUSHINVAL = 105U |
1161*a26f067fSSarah Walker ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1162*a26f067fSSarah Walker /*
1163*a26f067fSSarah Walker * Requests cleanup of a FW resource (type specified in the command
1164*a26f067fSSarah Walker * data)
1165*a26f067fSSarah Walker */
1166*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_CLEANUP = 106U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1167*a26f067fSSarah Walker /* Power request */
1168*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_POW = 107U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1169*a26f067fSSarah Walker /* Backing for on-demand ZS-Buffer done */
1170*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_ZSBUFFER_BACKING_UPDATE =
1171*a26f067fSSarah Walker 108U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1172*a26f067fSSarah Walker /* Unbacking for on-demand ZS-Buffer done */
1173*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_ZSBUFFER_UNBACKING_UPDATE =
1174*a26f067fSSarah Walker 109U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1175*a26f067fSSarah Walker /* Freelist Grow done */
1176*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_FREELIST_GROW_UPDATE =
1177*a26f067fSSarah Walker 110U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1178*a26f067fSSarah Walker /* Freelists Reconstruction done */
1179*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_FREELISTS_RECONSTRUCTION_UPDATE =
1180*a26f067fSSarah Walker 112U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1181*a26f067fSSarah Walker /*
1182*a26f067fSSarah Walker * Informs the firmware that the host has added more data to a CDM2
1183*a26f067fSSarah Walker * Circular Buffer
1184*a26f067fSSarah Walker */
1185*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_NOTIFY_WRITE_OFFSET_UPDATE =
1186*a26f067fSSarah Walker 114U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1187*a26f067fSSarah Walker /* Health check request */
1188*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_HEALTH_CHECK = 115U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1189*a26f067fSSarah Walker /* Forcing signalling of all unmet UFOs for a given CCB offset */
1190*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_FORCE_UPDATE = 116U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1191*a26f067fSSarah Walker
1192*a26f067fSSarah Walker /* There is a geometry and a fragment command in this single kick */
1193*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_COMBINED_GEOM_FRAG_KICK = 117U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1194*a26f067fSSarah Walker /* Informs the FW that a Guest OS has come online / offline. */
1195*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_OS_ONLINE_STATE_CONFIGURE = 118U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1196*a26f067fSSarah Walker
1197*a26f067fSSarah Walker /* Commands only permitted to the native or host OS */
1198*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_REGCONFIG = 200U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1199*a26f067fSSarah Walker
1200*a26f067fSSarah Walker /* Configure HWPerf events (to be generated) and HWPerf buffer address (if required) */
1201*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_HWPERF_UPDATE_CONFIG = 201U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1202*a26f067fSSarah Walker
1203*a26f067fSSarah Walker /* Enable or disable multiple HWPerf blocks (reusing existing configuration) */
1204*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_HWPERF_CTRL_BLKS = 203U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1205*a26f067fSSarah Walker /* Core clock speed change event */
1206*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_CORECLKSPEEDCHANGE = 204U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1207*a26f067fSSarah Walker
1208*a26f067fSSarah Walker /*
1209*a26f067fSSarah Walker * Ask the firmware to update its cached ui32LogType value from the (shared)
1210*a26f067fSSarah Walker * tracebuf control structure
1211*a26f067fSSarah Walker */
1212*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_LOGTYPE_UPDATE = 206U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1213*a26f067fSSarah Walker /* Set a maximum frequency/OPP point */
1214*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_PDVFS_LIMIT_MAX_FREQ = 207U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1215*a26f067fSSarah Walker /*
1216*a26f067fSSarah Walker * Changes the relative scheduling priority for a particular OSid. It can
1217*a26f067fSSarah Walker * only be serviced for the Host DDK
1218*a26f067fSSarah Walker */
1219*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_OSID_PRIORITY_CHANGE = 208U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1220*a26f067fSSarah Walker /* Set or clear firmware state flags */
1221*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_STATEFLAGS_CTRL = 209U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1222*a26f067fSSarah Walker
1223*a26f067fSSarah Walker /* Set a minimum frequency/OPP point */
1224*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_PDVFS_LIMIT_MIN_FREQ = 212U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1225*a26f067fSSarah Walker /* Configure Periodic Hardware Reset behaviour */
1226*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_PHR_CFG = 213U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1227*a26f067fSSarah Walker
1228*a26f067fSSarah Walker /* Configure Safety Firmware Watchdog */
1229*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_WDG_CFG = 215U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1230*a26f067fSSarah Walker /* Controls counter dumping in the FW */
1231*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_COUNTER_DUMP = 216U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1232*a26f067fSSarah Walker /* Configure, clear and enable multiple HWPerf blocks */
1233*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_HWPERF_CONFIG_ENABLE_BLKS = 217U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1234*a26f067fSSarah Walker /* Configure the custom counters for HWPerf */
1235*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_HWPERF_SELECT_CUSTOM_CNTRS = 218U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1236*a26f067fSSarah Walker
1237*a26f067fSSarah Walker /* Configure directly addressable counters for HWPerf */
1238*a26f067fSSarah Walker ROGUE_FWIF_KCCB_CMD_HWPERF_CONFIG_BLKS = 220U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1239*a26f067fSSarah Walker };
1240*a26f067fSSarah Walker
1241*a26f067fSSarah Walker #define ROGUE_FWIF_LAST_ALLOWED_GUEST_KCCB_CMD \
1242*a26f067fSSarah Walker (ROGUE_FWIF_KCCB_CMD_REGCONFIG - 1)
1243*a26f067fSSarah Walker
1244*a26f067fSSarah Walker /* Kernel CCB command packet */
1245*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd {
1246*a26f067fSSarah Walker /* Command type */
1247*a26f067fSSarah Walker enum rogue_fwif_kccb_cmd_type cmd_type;
1248*a26f067fSSarah Walker /* Compatibility and other flags */
1249*a26f067fSSarah Walker u32 kccb_flags;
1250*a26f067fSSarah Walker
1251*a26f067fSSarah Walker /*
1252*a26f067fSSarah Walker * NOTE: Make sure that uCmdData is the last member of this struct
1253*a26f067fSSarah Walker * This is to calculate actual command size for device mem copy.
1254*a26f067fSSarah Walker * (Refer ROGUEGetCmdMemCopySize())
1255*a26f067fSSarah Walker */
1256*a26f067fSSarah Walker union {
1257*a26f067fSSarah Walker /* Data for Kick command */
1258*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_kick_data cmd_kick_data;
1259*a26f067fSSarah Walker /* Data for combined geom/frag Kick command */
1260*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_combined_geom_frag_kick_data
1261*a26f067fSSarah Walker combined_geom_frag_cmd_kick_data;
1262*a26f067fSSarah Walker /* Data for MMU cache command */
1263*a26f067fSSarah Walker struct rogue_fwif_mmucachedata mmu_cache_data;
1264*a26f067fSSarah Walker /* Data for Breakpoint Commands */
1265*a26f067fSSarah Walker struct rogue_fwif_bpdata bp_data;
1266*a26f067fSSarah Walker /* Data for SLC Flush/Inval commands */
1267*a26f067fSSarah Walker struct rogue_fwif_slcflushinvaldata slc_flush_inval_data;
1268*a26f067fSSarah Walker /* Data for cleanup commands */
1269*a26f067fSSarah Walker struct rogue_fwif_cleanup_request cleanup_data;
1270*a26f067fSSarah Walker /* Data for power request commands */
1271*a26f067fSSarah Walker struct rogue_fwif_power_request pow_data;
1272*a26f067fSSarah Walker /* Data for HWPerf control command */
1273*a26f067fSSarah Walker struct rogue_fwif_hwperf_ctrl hw_perf_ctrl;
1274*a26f067fSSarah Walker /*
1275*a26f067fSSarah Walker * Data for HWPerf configure, clear and enable performance
1276*a26f067fSSarah Walker * counter block command
1277*a26f067fSSarah Walker */
1278*a26f067fSSarah Walker struct rogue_fwif_hwperf_config_enable_blks
1279*a26f067fSSarah Walker hw_perf_cfg_enable_blks;
1280*a26f067fSSarah Walker /*
1281*a26f067fSSarah Walker * Data for HWPerf enable or disable performance counter block
1282*a26f067fSSarah Walker * commands
1283*a26f067fSSarah Walker */
1284*a26f067fSSarah Walker struct rogue_fwif_hwperf_ctrl_blks hw_perf_ctrl_blks;
1285*a26f067fSSarah Walker /* Data for HWPerf configure the custom counters to read */
1286*a26f067fSSarah Walker struct rogue_fwif_hwperf_select_custom_cntrs
1287*a26f067fSSarah Walker hw_perf_select_cstm_cntrs;
1288*a26f067fSSarah Walker /* Data for HWPerf configure Directly Addressable blocks */
1289*a26f067fSSarah Walker struct rogue_fwif_hwperf_config_da_blks hw_perf_cfg_da_blks;
1290*a26f067fSSarah Walker /* Data for core clock speed change */
1291*a26f067fSSarah Walker struct rogue_fwif_coreclkspeedchange_data
1292*a26f067fSSarah Walker core_clk_speed_change_data;
1293*a26f067fSSarah Walker /* Feedback for Z/S Buffer backing/unbacking */
1294*a26f067fSSarah Walker struct rogue_fwif_zsbuffer_backing_data zs_buffer_backing_data;
1295*a26f067fSSarah Walker /* Feedback for Freelist grow/shrink */
1296*a26f067fSSarah Walker struct rogue_fwif_freelist_gs_data free_list_gs_data;
1297*a26f067fSSarah Walker /* Feedback for Freelists reconstruction*/
1298*a26f067fSSarah Walker struct rogue_fwif_freelists_reconstruction_data
1299*a26f067fSSarah Walker free_lists_reconstruction_data;
1300*a26f067fSSarah Walker /* Data for custom register configuration */
1301*a26f067fSSarah Walker struct rogue_fwif_regconfig_data reg_config_data;
1302*a26f067fSSarah Walker /* Data for informing the FW about the write offset update */
1303*a26f067fSSarah Walker struct rogue_fwif_write_offset_update_data
1304*a26f067fSSarah Walker write_offset_update_data;
1305*a26f067fSSarah Walker /* Data for setting the max frequency/OPP */
1306*a26f067fSSarah Walker struct rogue_fwif_pdvfs_max_freq_data pdvfs_max_freq_data;
1307*a26f067fSSarah Walker /* Data for setting the min frequency/OPP */
1308*a26f067fSSarah Walker struct rogue_fwif_pdvfs_min_freq_data pdvfs_min_freq_data;
1309*a26f067fSSarah Walker /* Data for updating the Guest Online states */
1310*a26f067fSSarah Walker struct rogue_fwif_os_state_change_data cmd_os_online_state_data;
1311*a26f067fSSarah Walker /* Dev address for TBI buffer allocated on demand */
1312*a26f067fSSarah Walker u32 tbi_buffer_fw_addr;
1313*a26f067fSSarah Walker /* Data for dumping of register ranges */
1314*a26f067fSSarah Walker struct rogue_fwif_counter_dump_data counter_dump_config_data;
1315*a26f067fSSarah Walker /* Data for signalling all unmet fences for a given CCB */
1316*a26f067fSSarah Walker struct rogue_fwif_kccb_cmd_force_update_data force_update_data;
1317*a26f067fSSarah Walker } cmd_data __aligned(8);
1318*a26f067fSSarah Walker } __aligned(8);
1319*a26f067fSSarah Walker
1320*a26f067fSSarah Walker PVR_FW_STRUCT_SIZE_ASSERT(struct rogue_fwif_kccb_cmd);
1321*a26f067fSSarah Walker
1322*a26f067fSSarah Walker /*
1323*a26f067fSSarah Walker ******************************************************************************
1324*a26f067fSSarah Walker * Firmware CCB command structure for ROGUE
1325*a26f067fSSarah Walker ******************************************************************************
1326*a26f067fSSarah Walker */
1327*a26f067fSSarah Walker
1328*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_zsbuffer_backing_data {
1329*a26f067fSSarah Walker u32 zs_buffer_id;
1330*a26f067fSSarah Walker };
1331*a26f067fSSarah Walker
1332*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_freelist_gs_data {
1333*a26f067fSSarah Walker u32 freelist_id;
1334*a26f067fSSarah Walker };
1335*a26f067fSSarah Walker
1336*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_freelists_reconstruction_data {
1337*a26f067fSSarah Walker u32 freelist_count;
1338*a26f067fSSarah Walker u32 hwr_counter;
1339*a26f067fSSarah Walker u32 freelist_ids[ROGUE_FWIF_MAX_FREELISTS_TO_RECONSTRUCT];
1340*a26f067fSSarah Walker };
1341*a26f067fSSarah Walker
1342*a26f067fSSarah Walker /* 1 if a page fault happened */
1343*a26f067fSSarah Walker #define ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_FLAG_PF BIT(0)
1344*a26f067fSSarah Walker /* 1 if applicable to all contexts */
1345*a26f067fSSarah Walker #define ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_FLAG_ALL_CTXS BIT(1)
1346*a26f067fSSarah Walker
1347*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_context_reset_data {
1348*a26f067fSSarah Walker /* Context affected by the reset */
1349*a26f067fSSarah Walker u32 server_common_context_id;
1350*a26f067fSSarah Walker /* Reason for reset */
1351*a26f067fSSarah Walker enum rogue_context_reset_reason reset_reason;
1352*a26f067fSSarah Walker /* Data Master affected by the reset */
1353*a26f067fSSarah Walker u32 dm;
1354*a26f067fSSarah Walker /* Job ref running at the time of reset */
1355*a26f067fSSarah Walker u32 reset_job_ref;
1356*a26f067fSSarah Walker /* ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_FLAG bitfield */
1357*a26f067fSSarah Walker u32 flags;
1358*a26f067fSSarah Walker /* At what page catalog address */
1359*a26f067fSSarah Walker aligned_u64 pc_address;
1360*a26f067fSSarah Walker /* Page fault address (only when applicable) */
1361*a26f067fSSarah Walker aligned_u64 fault_address;
1362*a26f067fSSarah Walker };
1363*a26f067fSSarah Walker
1364*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_fw_pagefault_data {
1365*a26f067fSSarah Walker /* Page fault address */
1366*a26f067fSSarah Walker u64 fw_fault_addr;
1367*a26f067fSSarah Walker };
1368*a26f067fSSarah Walker
1369*a26f067fSSarah Walker enum rogue_fwif_fwccb_cmd_type {
1370*a26f067fSSarah Walker /* Requests ZSBuffer to be backed with physical pages */
1371*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_ZSBUFFER_BACKING = 101U |
1372*a26f067fSSarah Walker ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1373*a26f067fSSarah Walker /* Requests ZSBuffer to be unbacked */
1374*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_ZSBUFFER_UNBACKING = 102U |
1375*a26f067fSSarah Walker ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1376*a26f067fSSarah Walker /* Requests an on-demand freelist grow/shrink */
1377*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_FREELIST_GROW = 103U |
1378*a26f067fSSarah Walker ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1379*a26f067fSSarah Walker /* Requests freelists reconstruction */
1380*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_FREELISTS_RECONSTRUCTION =
1381*a26f067fSSarah Walker 104U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1382*a26f067fSSarah Walker /* Notifies host of a HWR event on a context */
1383*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_CONTEXT_RESET_NOTIFICATION =
1384*a26f067fSSarah Walker 105U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1385*a26f067fSSarah Walker /* Requests an on-demand debug dump */
1386*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_DEBUG_DUMP = 106U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1387*a26f067fSSarah Walker /* Requests an on-demand update on process stats */
1388*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_UPDATE_STATS = 107U |
1389*a26f067fSSarah Walker ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1390*a26f067fSSarah Walker
1391*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_CORE_CLK_RATE_CHANGE =
1392*a26f067fSSarah Walker 108U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1393*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_REQUEST_GPU_RESTART =
1394*a26f067fSSarah Walker 109U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1395*a26f067fSSarah Walker
1396*a26f067fSSarah Walker /* Notifies host of a FW pagefault */
1397*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_CONTEXT_FW_PF_NOTIFICATION =
1398*a26f067fSSarah Walker 112U | ROGUE_CMD_MAGIC_DWORD_SHIFTED,
1399*a26f067fSSarah Walker };
1400*a26f067fSSarah Walker
1401*a26f067fSSarah Walker enum rogue_fwif_fwccb_cmd_update_stats_type {
1402*a26f067fSSarah Walker /*
1403*a26f067fSSarah Walker * PVRSRVStatsUpdateRenderContextStats should increase the value of the
1404*a26f067fSSarah Walker * ui32TotalNumPartialRenders stat
1405*a26f067fSSarah Walker */
1406*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_PARTIAL_RENDERS = 1,
1407*a26f067fSSarah Walker /*
1408*a26f067fSSarah Walker * PVRSRVStatsUpdateRenderContextStats should increase the value of the
1409*a26f067fSSarah Walker * ui32TotalNumOutOfMemory stat
1410*a26f067fSSarah Walker */
1411*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_OUT_OF_MEMORY,
1412*a26f067fSSarah Walker /*
1413*a26f067fSSarah Walker * PVRSRVStatsUpdateRenderContextStats should increase the value of the
1414*a26f067fSSarah Walker * ui32NumGeomStores stat
1415*a26f067fSSarah Walker */
1416*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_GEOM_STORES,
1417*a26f067fSSarah Walker /*
1418*a26f067fSSarah Walker * PVRSRVStatsUpdateRenderContextStats should increase the value of the
1419*a26f067fSSarah Walker * ui32NumFragStores stat
1420*a26f067fSSarah Walker */
1421*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_FRAG_STORES,
1422*a26f067fSSarah Walker /*
1423*a26f067fSSarah Walker * PVRSRVStatsUpdateRenderContextStats should increase the value of the
1424*a26f067fSSarah Walker * ui32NumCDMStores stat
1425*a26f067fSSarah Walker */
1426*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_CDM_STORES,
1427*a26f067fSSarah Walker /*
1428*a26f067fSSarah Walker * PVRSRVStatsUpdateRenderContextStats should increase the value of the
1429*a26f067fSSarah Walker * ui32NumTDMStores stat
1430*a26f067fSSarah Walker */
1431*a26f067fSSarah Walker ROGUE_FWIF_FWCCB_CMD_UPDATE_NUM_TDM_STORES
1432*a26f067fSSarah Walker };
1433*a26f067fSSarah Walker
1434*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_update_stats_data {
1435*a26f067fSSarah Walker /* Element to update */
1436*a26f067fSSarah Walker enum rogue_fwif_fwccb_cmd_update_stats_type element_to_update;
1437*a26f067fSSarah Walker /* The pid of the process whose stats are being updated */
1438*a26f067fSSarah Walker u32 pid_owner;
1439*a26f067fSSarah Walker /* Adjustment to be made to the statistic */
1440*a26f067fSSarah Walker s32 adjustment_value;
1441*a26f067fSSarah Walker };
1442*a26f067fSSarah Walker
1443*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_core_clk_rate_change_data {
1444*a26f067fSSarah Walker u32 core_clk_rate;
1445*a26f067fSSarah Walker } __aligned(8);
1446*a26f067fSSarah Walker
1447*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd {
1448*a26f067fSSarah Walker /* Command type */
1449*a26f067fSSarah Walker enum rogue_fwif_fwccb_cmd_type cmd_type;
1450*a26f067fSSarah Walker /* Compatibility and other flags */
1451*a26f067fSSarah Walker u32 fwccb_flags;
1452*a26f067fSSarah Walker
1453*a26f067fSSarah Walker union {
1454*a26f067fSSarah Walker /* Data for Z/S-Buffer on-demand (un)backing*/
1455*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_zsbuffer_backing_data
1456*a26f067fSSarah Walker cmd_zs_buffer_backing;
1457*a26f067fSSarah Walker /* Data for on-demand freelist grow/shrink */
1458*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_freelist_gs_data cmd_free_list_gs;
1459*a26f067fSSarah Walker /* Data for freelists reconstruction */
1460*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_freelists_reconstruction_data
1461*a26f067fSSarah Walker cmd_freelists_reconstruction;
1462*a26f067fSSarah Walker /* Data for context reset notification */
1463*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_context_reset_data
1464*a26f067fSSarah Walker cmd_context_reset_notification;
1465*a26f067fSSarah Walker /* Data for updating process stats */
1466*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_update_stats_data
1467*a26f067fSSarah Walker cmd_update_stats_data;
1468*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_core_clk_rate_change_data
1469*a26f067fSSarah Walker cmd_core_clk_rate_change;
1470*a26f067fSSarah Walker struct rogue_fwif_fwccb_cmd_fw_pagefault_data cmd_fw_pagefault;
1471*a26f067fSSarah Walker } cmd_data __aligned(8);
1472*a26f067fSSarah Walker } __aligned(8);
1473*a26f067fSSarah Walker
1474*a26f067fSSarah Walker PVR_FW_STRUCT_SIZE_ASSERT(struct rogue_fwif_fwccb_cmd);
1475*a26f067fSSarah Walker
1476*a26f067fSSarah Walker /*
1477*a26f067fSSarah Walker ******************************************************************************
1478*a26f067fSSarah Walker * Workload estimation Firmware CCB command structure for ROGUE
1479*a26f067fSSarah Walker ******************************************************************************
1480*a26f067fSSarah Walker */
1481*a26f067fSSarah Walker struct rogue_fwif_workest_fwccb_cmd {
1482*a26f067fSSarah Walker /* Index for return data array */
1483*a26f067fSSarah Walker u16 return_data_index;
1484*a26f067fSSarah Walker /* The cycles the workload took on the hardware */
1485*a26f067fSSarah Walker u32 cycles_taken;
1486*a26f067fSSarah Walker };
1487*a26f067fSSarah Walker
1488*a26f067fSSarah Walker /*
1489*a26f067fSSarah Walker ******************************************************************************
1490*a26f067fSSarah Walker * Client CCB commands for ROGUE
1491*a26f067fSSarah Walker ******************************************************************************
1492*a26f067fSSarah Walker */
1493*a26f067fSSarah Walker
1494*a26f067fSSarah Walker /*
1495*a26f067fSSarah Walker * Required memory alignment for 64-bit variables accessible by Meta
1496*a26f067fSSarah Walker * (The gcc meta aligns 64-bit variables to 64-bit; therefore, memory shared
1497*a26f067fSSarah Walker * between the host and meta that contains 64-bit variables has to maintain
1498*a26f067fSSarah Walker * this alignment)
1499*a26f067fSSarah Walker */
1500*a26f067fSSarah Walker #define ROGUE_FWIF_FWALLOC_ALIGN sizeof(u64)
1501*a26f067fSSarah Walker
1502*a26f067fSSarah Walker #define ROGUE_CCB_TYPE_TASK BIT(15)
1503*a26f067fSSarah Walker #define ROGUE_CCB_FWALLOC_ALIGN(size) \
1504*a26f067fSSarah Walker (((size) + (ROGUE_FWIF_FWALLOC_ALIGN - 1)) & \
1505*a26f067fSSarah Walker ~(ROGUE_FWIF_FWALLOC_ALIGN - 1))
1506*a26f067fSSarah Walker
1507*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_GEOM \
1508*a26f067fSSarah Walker (201U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1509*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_TQ_3D \
1510*a26f067fSSarah Walker (202U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1511*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_FRAG \
1512*a26f067fSSarah Walker (203U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1513*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_FRAG_PR \
1514*a26f067fSSarah Walker (204U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1515*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_CDM \
1516*a26f067fSSarah Walker (205U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1517*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_TQ_TDM \
1518*a26f067fSSarah Walker (206U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1519*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_FBSC_INVALIDATE \
1520*a26f067fSSarah Walker (207U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1521*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_TQ_2D \
1522*a26f067fSSarah Walker (208U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1523*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_PRE_TIMESTAMP \
1524*a26f067fSSarah Walker (209U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1525*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_NULL \
1526*a26f067fSSarah Walker (210U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1527*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_ABORT \
1528*a26f067fSSarah Walker (211U | ROGUE_CMD_MAGIC_DWORD_SHIFTED | ROGUE_CCB_TYPE_TASK)
1529*a26f067fSSarah Walker
1530*a26f067fSSarah Walker /* Leave a gap between CCB specific commands and generic commands */
1531*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_FENCE (212U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1532*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_UPDATE (213U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1533*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_RMW_UPDATE \
1534*a26f067fSSarah Walker (214U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1535*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_FENCE_PR (215U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1536*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_PRIORITY (216U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1537*a26f067fSSarah Walker /*
1538*a26f067fSSarah Walker * Pre and Post timestamp commands are supposed to sandwich the DM cmd. The
1539*a26f067fSSarah Walker * padding code with the CCB wrap upsets the FW if we don't have the task type
1540*a26f067fSSarah Walker * bit cleared for POST_TIMESTAMPs. That's why we have 2 different cmd types.
1541*a26f067fSSarah Walker */
1542*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_POST_TIMESTAMP \
1543*a26f067fSSarah Walker (217U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1544*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_UNFENCED_UPDATE \
1545*a26f067fSSarah Walker (218U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1546*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_UNFENCED_RMW_UPDATE \
1547*a26f067fSSarah Walker (219U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1548*a26f067fSSarah Walker
1549*a26f067fSSarah Walker #define ROGUE_FWIF_CCB_CMD_TYPE_PADDING (221U | ROGUE_CMD_MAGIC_DWORD_SHIFTED)
1550*a26f067fSSarah Walker
1551*a26f067fSSarah Walker struct rogue_fwif_workest_kick_data {
1552*a26f067fSSarah Walker /* Index for the KM Workload estimation return data array */
1553*a26f067fSSarah Walker u16 return_data_index __aligned(8);
1554*a26f067fSSarah Walker /* Predicted time taken to do the work in cycles */
1555*a26f067fSSarah Walker u32 cycles_prediction __aligned(8);
1556*a26f067fSSarah Walker /* Deadline for the workload */
1557*a26f067fSSarah Walker aligned_u64 deadline;
1558*a26f067fSSarah Walker };
1559*a26f067fSSarah Walker
1560*a26f067fSSarah Walker struct rogue_fwif_ccb_cmd_header {
1561*a26f067fSSarah Walker u32 cmd_type;
1562*a26f067fSSarah Walker u32 cmd_size;
1563*a26f067fSSarah Walker /*
1564*a26f067fSSarah Walker * external job reference - provided by client and used in debug for
1565*a26f067fSSarah Walker * tracking submitted work
1566*a26f067fSSarah Walker */
1567*a26f067fSSarah Walker u32 ext_job_ref;
1568*a26f067fSSarah Walker /*
1569*a26f067fSSarah Walker * internal job reference - generated by services and used in debug for
1570*a26f067fSSarah Walker * tracking submitted work
1571*a26f067fSSarah Walker */
1572*a26f067fSSarah Walker u32 int_job_ref;
1573*a26f067fSSarah Walker /* Workload Estimation - Workload Estimation Data */
1574*a26f067fSSarah Walker struct rogue_fwif_workest_kick_data work_est_kick_data __aligned(8);
1575*a26f067fSSarah Walker };
1576*a26f067fSSarah Walker
1577*a26f067fSSarah Walker /*
1578*a26f067fSSarah Walker ******************************************************************************
1579*a26f067fSSarah Walker * Client CCB commands which are only required by the kernel
1580*a26f067fSSarah Walker ******************************************************************************
1581*a26f067fSSarah Walker */
1582*a26f067fSSarah Walker struct rogue_fwif_cmd_priority {
1583*a26f067fSSarah Walker s32 priority;
1584*a26f067fSSarah Walker };
1585*a26f067fSSarah Walker
1586*a26f067fSSarah Walker /*
1587*a26f067fSSarah Walker ******************************************************************************
1588*a26f067fSSarah Walker * Signature and Checksums Buffer
1589*a26f067fSSarah Walker ******************************************************************************
1590*a26f067fSSarah Walker */
1591*a26f067fSSarah Walker struct rogue_fwif_sigbuf_ctl {
1592*a26f067fSSarah Walker /* Ptr to Signature Buffer memory */
1593*a26f067fSSarah Walker u32 buffer_fw_addr;
1594*a26f067fSSarah Walker /* Amount of space left for storing regs in the buffer */
1595*a26f067fSSarah Walker u32 left_size_in_regs;
1596*a26f067fSSarah Walker } __aligned(8);
1597*a26f067fSSarah Walker
1598*a26f067fSSarah Walker struct rogue_fwif_counter_dump_ctl {
1599*a26f067fSSarah Walker /* Ptr to counter dump buffer */
1600*a26f067fSSarah Walker u32 buffer_fw_addr;
1601*a26f067fSSarah Walker /* Amount of space for storing in the buffer */
1602*a26f067fSSarah Walker u32 size_in_dwords;
1603*a26f067fSSarah Walker } __aligned(8);
1604*a26f067fSSarah Walker
1605*a26f067fSSarah Walker struct rogue_fwif_firmware_gcov_ctl {
1606*a26f067fSSarah Walker /* Ptr to firmware gcov buffer */
1607*a26f067fSSarah Walker u32 buffer_fw_addr;
1608*a26f067fSSarah Walker /* Amount of space for storing in the buffer */
1609*a26f067fSSarah Walker u32 size;
1610*a26f067fSSarah Walker } __aligned(8);
1611*a26f067fSSarah Walker
1612*a26f067fSSarah Walker /*
1613*a26f067fSSarah Walker *****************************************************************************
1614*a26f067fSSarah Walker * ROGUE Compatibility checks
1615*a26f067fSSarah Walker *****************************************************************************
1616*a26f067fSSarah Walker */
1617*a26f067fSSarah Walker
1618*a26f067fSSarah Walker /*
1619*a26f067fSSarah Walker * WARNING: Whenever the layout of ROGUE_FWIF_COMPCHECKS_BVNC changes, the
1620*a26f067fSSarah Walker * following define should be increased by 1 to indicate to the compatibility
1621*a26f067fSSarah Walker * logic that layout has changed.
1622*a26f067fSSarah Walker */
1623*a26f067fSSarah Walker #define ROGUE_FWIF_COMPCHECKS_LAYOUT_VERSION 3
1624*a26f067fSSarah Walker
1625*a26f067fSSarah Walker struct rogue_fwif_compchecks_bvnc {
1626*a26f067fSSarah Walker /* WARNING: This field must be defined as first one in this structure */
1627*a26f067fSSarah Walker u32 layout_version;
1628*a26f067fSSarah Walker aligned_u64 bvnc;
1629*a26f067fSSarah Walker } __aligned(8);
1630*a26f067fSSarah Walker
1631*a26f067fSSarah Walker struct rogue_fwif_init_options {
1632*a26f067fSSarah Walker u8 os_count_support;
1633*a26f067fSSarah Walker u8 padding[7];
1634*a26f067fSSarah Walker } __aligned(8);
1635*a26f067fSSarah Walker
1636*a26f067fSSarah Walker #define ROGUE_FWIF_COMPCHECKS_BVNC_DECLARE_AND_INIT(name) \
1637*a26f067fSSarah Walker struct rogue_fwif_compchecks_bvnc(name) = { \
1638*a26f067fSSarah Walker ROGUE_FWIF_COMPCHECKS_LAYOUT_VERSION, \
1639*a26f067fSSarah Walker 0, \
1640*a26f067fSSarah Walker }
1641*a26f067fSSarah Walker
rogue_fwif_compchecks_bvnc_init(struct rogue_fwif_compchecks_bvnc * compchecks)1642*a26f067fSSarah Walker static inline void rogue_fwif_compchecks_bvnc_init(struct rogue_fwif_compchecks_bvnc *compchecks)
1643*a26f067fSSarah Walker {
1644*a26f067fSSarah Walker compchecks->layout_version = ROGUE_FWIF_COMPCHECKS_LAYOUT_VERSION;
1645*a26f067fSSarah Walker compchecks->bvnc = 0;
1646*a26f067fSSarah Walker }
1647*a26f067fSSarah Walker
1648*a26f067fSSarah Walker struct rogue_fwif_compchecks {
1649*a26f067fSSarah Walker /* hardware BVNC (from the ROGUE registers) */
1650*a26f067fSSarah Walker struct rogue_fwif_compchecks_bvnc hw_bvnc;
1651*a26f067fSSarah Walker /* firmware BVNC */
1652*a26f067fSSarah Walker struct rogue_fwif_compchecks_bvnc fw_bvnc;
1653*a26f067fSSarah Walker /* identifier of the FW processor version */
1654*a26f067fSSarah Walker u32 fw_processor_version;
1655*a26f067fSSarah Walker /* software DDK version */
1656*a26f067fSSarah Walker u32 ddk_version;
1657*a26f067fSSarah Walker /* software DDK build no. */
1658*a26f067fSSarah Walker u32 ddk_build;
1659*a26f067fSSarah Walker /* build options bit-field */
1660*a26f067fSSarah Walker u32 build_options;
1661*a26f067fSSarah Walker /* initialisation options bit-field */
1662*a26f067fSSarah Walker struct rogue_fwif_init_options init_options;
1663*a26f067fSSarah Walker /* Information is valid */
1664*a26f067fSSarah Walker bool updated __aligned(4);
1665*a26f067fSSarah Walker u32 padding;
1666*a26f067fSSarah Walker } __aligned(8);
1667*a26f067fSSarah Walker
1668*a26f067fSSarah Walker /*
1669*a26f067fSSarah Walker ******************************************************************************
1670*a26f067fSSarah Walker * Updated configuration post FW data init.
1671*a26f067fSSarah Walker ******************************************************************************
1672*a26f067fSSarah Walker */
1673*a26f067fSSarah Walker struct rogue_fwif_runtime_cfg {
1674*a26f067fSSarah Walker /* APM latency in ms before signalling IDLE to the host */
1675*a26f067fSSarah Walker u32 active_pm_latency_ms;
1676*a26f067fSSarah Walker /* Compatibility and other flags */
1677*a26f067fSSarah Walker u32 runtime_cfg_flags;
1678*a26f067fSSarah Walker /*
1679*a26f067fSSarah Walker * If set, APM latency does not reset to system default each GPU power
1680*a26f067fSSarah Walker * transition
1681*a26f067fSSarah Walker */
1682*a26f067fSSarah Walker bool active_pm_latency_persistant __aligned(4);
1683*a26f067fSSarah Walker /* Core clock speed, currently only used to calculate timer ticks */
1684*a26f067fSSarah Walker u32 core_clock_speed;
1685*a26f067fSSarah Walker /* Last number of dusts change requested by the host */
1686*a26f067fSSarah Walker u32 default_dusts_num_init;
1687*a26f067fSSarah Walker /* Periodic Hardware Reset configuration values */
1688*a26f067fSSarah Walker u32 phr_mode;
1689*a26f067fSSarah Walker /* New number of milliseconds C/S is allowed to last */
1690*a26f067fSSarah Walker u32 hcs_deadline_ms;
1691*a26f067fSSarah Walker /* The watchdog period in microseconds */
1692*a26f067fSSarah Walker u32 wdg_period_us;
1693*a26f067fSSarah Walker /* Array of priorities per OS */
1694*a26f067fSSarah Walker u32 osid_priority[ROGUE_FW_MAX_NUM_OS];
1695*a26f067fSSarah Walker /* On-demand allocated HWPerf buffer address, to be passed to the FW */
1696*a26f067fSSarah Walker u32 hwperf_buf_fw_addr;
1697*a26f067fSSarah Walker
1698*a26f067fSSarah Walker bool padding __aligned(4);
1699*a26f067fSSarah Walker };
1700*a26f067fSSarah Walker
1701*a26f067fSSarah Walker /*
1702*a26f067fSSarah Walker *****************************************************************************
1703*a26f067fSSarah Walker * Control data for ROGUE
1704*a26f067fSSarah Walker *****************************************************************************
1705*a26f067fSSarah Walker */
1706*a26f067fSSarah Walker
1707*a26f067fSSarah Walker #define ROGUE_FWIF_HWR_DEBUG_DUMP_ALL (99999U)
1708*a26f067fSSarah Walker
1709*a26f067fSSarah Walker enum rogue_fwif_tpu_dm {
1710*a26f067fSSarah Walker ROGUE_FWIF_TPU_DM_PDM = 0,
1711*a26f067fSSarah Walker ROGUE_FWIF_TPU_DM_VDM = 1,
1712*a26f067fSSarah Walker ROGUE_FWIF_TPU_DM_CDM = 2,
1713*a26f067fSSarah Walker ROGUE_FWIF_TPU_DM_TDM = 3,
1714*a26f067fSSarah Walker ROGUE_FWIF_TPU_DM_LAST
1715*a26f067fSSarah Walker };
1716*a26f067fSSarah Walker
1717*a26f067fSSarah Walker enum rogue_fwif_gpio_val_mode {
1718*a26f067fSSarah Walker /* No GPIO validation */
1719*a26f067fSSarah Walker ROGUE_FWIF_GPIO_VAL_OFF = 0,
1720*a26f067fSSarah Walker /*
1721*a26f067fSSarah Walker * Simple test case that initiates by sending data via the GPIO and then
1722*a26f067fSSarah Walker * sends back any data received over the GPIO
1723*a26f067fSSarah Walker */
1724*a26f067fSSarah Walker ROGUE_FWIF_GPIO_VAL_GENERAL = 1,
1725*a26f067fSSarah Walker /*
1726*a26f067fSSarah Walker * More complex test case that writes and reads data across the entire
1727*a26f067fSSarah Walker * GPIO AP address range.
1728*a26f067fSSarah Walker */
1729*a26f067fSSarah Walker ROGUE_FWIF_GPIO_VAL_AP = 2,
1730*a26f067fSSarah Walker /* Validates the GPIO Testbench. */
1731*a26f067fSSarah Walker ROGUE_FWIF_GPIO_VAL_TESTBENCH = 5,
1732*a26f067fSSarah Walker /* Send and then receive each byte in the range 0-255. */
1733*a26f067fSSarah Walker ROGUE_FWIF_GPIO_VAL_LOOPBACK = 6,
1734*a26f067fSSarah Walker /* Send and then receive each power-of-2 byte in the range 0-255. */
1735*a26f067fSSarah Walker ROGUE_FWIF_GPIO_VAL_LOOPBACK_LITE = 7,
1736*a26f067fSSarah Walker ROGUE_FWIF_GPIO_VAL_LAST
1737*a26f067fSSarah Walker };
1738*a26f067fSSarah Walker
1739*a26f067fSSarah Walker enum fw_perf_conf {
1740*a26f067fSSarah Walker FW_PERF_CONF_NONE = 0,
1741*a26f067fSSarah Walker FW_PERF_CONF_ICACHE = 1,
1742*a26f067fSSarah Walker FW_PERF_CONF_DCACHE = 2,
1743*a26f067fSSarah Walker FW_PERF_CONF_JTLB_INSTR = 5,
1744*a26f067fSSarah Walker FW_PERF_CONF_INSTRUCTIONS = 6
1745*a26f067fSSarah Walker };
1746*a26f067fSSarah Walker
1747*a26f067fSSarah Walker enum fw_boot_stage {
1748*a26f067fSSarah Walker FW_BOOT_STAGE_TLB_INIT_FAILURE = -2,
1749*a26f067fSSarah Walker FW_BOOT_STAGE_NOT_AVAILABLE = -1,
1750*a26f067fSSarah Walker FW_BOOT_NOT_STARTED = 0,
1751*a26f067fSSarah Walker FW_BOOT_BLDR_STARTED = 1,
1752*a26f067fSSarah Walker FW_BOOT_CACHE_DONE,
1753*a26f067fSSarah Walker FW_BOOT_TLB_DONE,
1754*a26f067fSSarah Walker FW_BOOT_MAIN_STARTED,
1755*a26f067fSSarah Walker FW_BOOT_ALIGNCHECKS_DONE,
1756*a26f067fSSarah Walker FW_BOOT_INIT_DONE,
1757*a26f067fSSarah Walker };
1758*a26f067fSSarah Walker
1759*a26f067fSSarah Walker /*
1760*a26f067fSSarah Walker * Kernel CCB return slot responses. Usage of bit-fields instead of bare
1761*a26f067fSSarah Walker * integers allows FW to possibly pack-in several responses for each single kCCB
1762*a26f067fSSarah Walker * command.
1763*a26f067fSSarah Walker */
1764*a26f067fSSarah Walker /* Command executed (return status from FW) */
1765*a26f067fSSarah Walker #define ROGUE_FWIF_KCCB_RTN_SLOT_CMD_EXECUTED BIT(0)
1766*a26f067fSSarah Walker /* A cleanup was requested but resource busy */
1767*a26f067fSSarah Walker #define ROGUE_FWIF_KCCB_RTN_SLOT_CLEANUP_BUSY BIT(1)
1768*a26f067fSSarah Walker /* Poll failed in FW for a HW operation to complete */
1769*a26f067fSSarah Walker #define ROGUE_FWIF_KCCB_RTN_SLOT_POLL_FAILURE BIT(2)
1770*a26f067fSSarah Walker /* Reset value of a kCCB return slot (set by host) */
1771*a26f067fSSarah Walker #define ROGUE_FWIF_KCCB_RTN_SLOT_NO_RESPONSE 0x0U
1772*a26f067fSSarah Walker
1773*a26f067fSSarah Walker struct rogue_fwif_connection_ctl {
1774*a26f067fSSarah Walker /* Fw-Os connection states */
1775*a26f067fSSarah Walker enum rogue_fwif_connection_fw_state connection_fw_state;
1776*a26f067fSSarah Walker enum rogue_fwif_connection_os_state connection_os_state;
1777*a26f067fSSarah Walker u32 alive_fw_token;
1778*a26f067fSSarah Walker u32 alive_os_token;
1779*a26f067fSSarah Walker } __aligned(8);
1780*a26f067fSSarah Walker
1781*a26f067fSSarah Walker struct rogue_fwif_osinit {
1782*a26f067fSSarah Walker /* Kernel CCB */
1783*a26f067fSSarah Walker u32 kernel_ccbctl_fw_addr;
1784*a26f067fSSarah Walker u32 kernel_ccb_fw_addr;
1785*a26f067fSSarah Walker u32 kernel_ccb_rtn_slots_fw_addr;
1786*a26f067fSSarah Walker
1787*a26f067fSSarah Walker /* Firmware CCB */
1788*a26f067fSSarah Walker u32 firmware_ccbctl_fw_addr;
1789*a26f067fSSarah Walker u32 firmware_ccb_fw_addr;
1790*a26f067fSSarah Walker
1791*a26f067fSSarah Walker /* Workload Estimation Firmware CCB */
1792*a26f067fSSarah Walker u32 work_est_firmware_ccbctl_fw_addr;
1793*a26f067fSSarah Walker u32 work_est_firmware_ccb_fw_addr;
1794*a26f067fSSarah Walker
1795*a26f067fSSarah Walker u32 rogue_fwif_hwr_info_buf_ctl_fw_addr;
1796*a26f067fSSarah Walker
1797*a26f067fSSarah Walker u32 hwr_debug_dump_limit;
1798*a26f067fSSarah Walker
1799*a26f067fSSarah Walker u32 fw_os_data_fw_addr;
1800*a26f067fSSarah Walker
1801*a26f067fSSarah Walker /* Compatibility checks to be populated by the Firmware */
1802*a26f067fSSarah Walker struct rogue_fwif_compchecks rogue_comp_checks;
1803*a26f067fSSarah Walker } __aligned(8);
1804*a26f067fSSarah Walker
1805*a26f067fSSarah Walker /* BVNC Features */
1806*a26f067fSSarah Walker struct rogue_hwperf_bvnc_block {
1807*a26f067fSSarah Walker /* Counter block ID, see ROGUE_HWPERF_CNTBLK_ID */
1808*a26f067fSSarah Walker u16 block_id;
1809*a26f067fSSarah Walker
1810*a26f067fSSarah Walker /* Number of counters in this block type */
1811*a26f067fSSarah Walker u16 num_counters;
1812*a26f067fSSarah Walker
1813*a26f067fSSarah Walker /* Number of blocks of this type */
1814*a26f067fSSarah Walker u16 num_blocks;
1815*a26f067fSSarah Walker
1816*a26f067fSSarah Walker u16 reserved;
1817*a26f067fSSarah Walker };
1818*a26f067fSSarah Walker
1819*a26f067fSSarah Walker #define ROGUE_HWPERF_MAX_BVNC_LEN (24)
1820*a26f067fSSarah Walker
1821*a26f067fSSarah Walker #define ROGUE_HWPERF_MAX_BVNC_BLOCK_LEN (16U)
1822*a26f067fSSarah Walker
1823*a26f067fSSarah Walker /* BVNC Features */
1824*a26f067fSSarah Walker struct rogue_hwperf_bvnc {
1825*a26f067fSSarah Walker /* BVNC string */
1826*a26f067fSSarah Walker char bvnc_string[ROGUE_HWPERF_MAX_BVNC_LEN];
1827*a26f067fSSarah Walker /* See ROGUE_HWPERF_FEATURE_FLAGS */
1828*a26f067fSSarah Walker u32 bvnc_km_feature_flags;
1829*a26f067fSSarah Walker /* Number of blocks described in aBvncBlocks */
1830*a26f067fSSarah Walker u16 num_bvnc_blocks;
1831*a26f067fSSarah Walker /* Number of GPU cores present */
1832*a26f067fSSarah Walker u16 bvnc_gpu_cores;
1833*a26f067fSSarah Walker /* Supported Performance Blocks for BVNC */
1834*a26f067fSSarah Walker struct rogue_hwperf_bvnc_block
1835*a26f067fSSarah Walker bvnc_blocks[ROGUE_HWPERF_MAX_BVNC_BLOCK_LEN];
1836*a26f067fSSarah Walker };
1837*a26f067fSSarah Walker
1838*a26f067fSSarah Walker PVR_FW_STRUCT_SIZE_ASSERT(struct rogue_hwperf_bvnc);
1839*a26f067fSSarah Walker
1840*a26f067fSSarah Walker struct rogue_fwif_sysinit {
1841*a26f067fSSarah Walker /* Fault read address */
1842*a26f067fSSarah Walker aligned_u64 fault_phys_addr;
1843*a26f067fSSarah Walker
1844*a26f067fSSarah Walker /* PDS execution base */
1845*a26f067fSSarah Walker aligned_u64 pds_exec_base;
1846*a26f067fSSarah Walker /* UCS execution base */
1847*a26f067fSSarah Walker aligned_u64 usc_exec_base;
1848*a26f067fSSarah Walker /* FBCDC bindless texture state table base */
1849*a26f067fSSarah Walker aligned_u64 fbcdc_state_table_base;
1850*a26f067fSSarah Walker aligned_u64 fbcdc_large_state_table_base;
1851*a26f067fSSarah Walker /* Texture state base */
1852*a26f067fSSarah Walker aligned_u64 texture_heap_base;
1853*a26f067fSSarah Walker
1854*a26f067fSSarah Walker /* Event filter for Firmware events */
1855*a26f067fSSarah Walker u64 hw_perf_filter;
1856*a26f067fSSarah Walker
1857*a26f067fSSarah Walker aligned_u64 slc3_fence_dev_addr;
1858*a26f067fSSarah Walker
1859*a26f067fSSarah Walker u32 tpu_trilinear_frac_mask[ROGUE_FWIF_TPU_DM_LAST] __aligned(8);
1860*a26f067fSSarah Walker
1861*a26f067fSSarah Walker /* Signature and Checksum Buffers for DMs */
1862*a26f067fSSarah Walker struct rogue_fwif_sigbuf_ctl sigbuf_ctl[PVR_FWIF_DM_MAX];
1863*a26f067fSSarah Walker
1864*a26f067fSSarah Walker struct rogue_fwif_pdvfs_opp pdvfs_opp_info;
1865*a26f067fSSarah Walker
1866*a26f067fSSarah Walker struct rogue_fwif_dma_addr coremem_data_store;
1867*a26f067fSSarah Walker
1868*a26f067fSSarah Walker struct rogue_fwif_counter_dump_ctl counter_dump_ctl;
1869*a26f067fSSarah Walker
1870*a26f067fSSarah Walker u32 filter_flags;
1871*a26f067fSSarah Walker
1872*a26f067fSSarah Walker u32 runtime_cfg_fw_addr;
1873*a26f067fSSarah Walker
1874*a26f067fSSarah Walker u32 trace_buf_ctl_fw_addr;
1875*a26f067fSSarah Walker u32 fw_sys_data_fw_addr;
1876*a26f067fSSarah Walker
1877*a26f067fSSarah Walker u32 gpu_util_fw_cb_ctl_fw_addr;
1878*a26f067fSSarah Walker u32 reg_cfg_fw_addr;
1879*a26f067fSSarah Walker u32 hwperf_ctl_fw_addr;
1880*a26f067fSSarah Walker
1881*a26f067fSSarah Walker u32 align_checks;
1882*a26f067fSSarah Walker
1883*a26f067fSSarah Walker /* Core clock speed at FW boot time */
1884*a26f067fSSarah Walker u32 initial_core_clock_speed;
1885*a26f067fSSarah Walker
1886*a26f067fSSarah Walker /* APM latency in ms before signalling IDLE to the host */
1887*a26f067fSSarah Walker u32 active_pm_latency_ms;
1888*a26f067fSSarah Walker
1889*a26f067fSSarah Walker /* Flag to be set by the Firmware after successful start */
1890*a26f067fSSarah Walker bool firmware_started __aligned(4);
1891*a26f067fSSarah Walker
1892*a26f067fSSarah Walker /* Host/FW Trace synchronisation Partition Marker */
1893*a26f067fSSarah Walker u32 marker_val;
1894*a26f067fSSarah Walker
1895*a26f067fSSarah Walker /* Firmware initialization complete time */
1896*a26f067fSSarah Walker u32 firmware_started_timestamp;
1897*a26f067fSSarah Walker
1898*a26f067fSSarah Walker u32 jones_disable_mask;
1899*a26f067fSSarah Walker
1900*a26f067fSSarah Walker /* Firmware performance counter config */
1901*a26f067fSSarah Walker enum fw_perf_conf firmware_perf;
1902*a26f067fSSarah Walker
1903*a26f067fSSarah Walker /*
1904*a26f067fSSarah Walker * FW Pointer to memory containing core clock rate in Hz.
1905*a26f067fSSarah Walker * Firmware (PDVFS) updates the memory when running on non primary FW
1906*a26f067fSSarah Walker * thread to communicate to host driver.
1907*a26f067fSSarah Walker */
1908*a26f067fSSarah Walker u32 core_clock_rate_fw_addr;
1909*a26f067fSSarah Walker
1910*a26f067fSSarah Walker enum rogue_fwif_gpio_val_mode gpio_validation_mode;
1911*a26f067fSSarah Walker
1912*a26f067fSSarah Walker /* Used in HWPerf for decoding BVNC Features */
1913*a26f067fSSarah Walker struct rogue_hwperf_bvnc bvnc_km_feature_flags;
1914*a26f067fSSarah Walker
1915*a26f067fSSarah Walker /* Value to write into ROGUE_CR_TFBC_COMPRESSION_CONTROL */
1916*a26f067fSSarah Walker u32 tfbc_compression_control;
1917*a26f067fSSarah Walker } __aligned(8);
1918*a26f067fSSarah Walker
1919*a26f067fSSarah Walker /*
1920*a26f067fSSarah Walker *****************************************************************************
1921*a26f067fSSarah Walker * Timer correlation shared data and defines
1922*a26f067fSSarah Walker *****************************************************************************
1923*a26f067fSSarah Walker */
1924*a26f067fSSarah Walker
1925*a26f067fSSarah Walker struct rogue_fwif_time_corr {
1926*a26f067fSSarah Walker aligned_u64 os_timestamp;
1927*a26f067fSSarah Walker aligned_u64 os_mono_timestamp;
1928*a26f067fSSarah Walker aligned_u64 cr_timestamp;
1929*a26f067fSSarah Walker
1930*a26f067fSSarah Walker /*
1931*a26f067fSSarah Walker * Utility variable used to convert CR timer deltas to OS timer deltas
1932*a26f067fSSarah Walker * (nS), where the deltas are relative to the timestamps above:
1933*a26f067fSSarah Walker * deltaOS = (deltaCR * K) >> decimal_shift, see full explanation below
1934*a26f067fSSarah Walker */
1935*a26f067fSSarah Walker aligned_u64 cr_delta_to_os_delta_kns;
1936*a26f067fSSarah Walker
1937*a26f067fSSarah Walker u32 core_clock_speed;
1938*a26f067fSSarah Walker u32 reserved;
1939*a26f067fSSarah Walker } __aligned(8);
1940*a26f067fSSarah Walker
1941*a26f067fSSarah Walker /*
1942*a26f067fSSarah Walker * The following macros are used to help converting FW timestamps to the Host
1943*a26f067fSSarah Walker * time domain. On the FW the ROGUE_CR_TIMER counter is used to keep track of
1944*a26f067fSSarah Walker * time; it increments by 1 every 256 GPU clock ticks, so the general
1945*a26f067fSSarah Walker * formula to perform the conversion is:
1946*a26f067fSSarah Walker *
1947*a26f067fSSarah Walker * [ GPU clock speed in Hz, if (scale == 10^9) then deltaOS is in nS,
1948*a26f067fSSarah Walker * otherwise if (scale == 10^6) then deltaOS is in uS ]
1949*a26f067fSSarah Walker *
1950*a26f067fSSarah Walker * deltaCR * 256 256 * scale
1951*a26f067fSSarah Walker * deltaOS = --------------- * scale = deltaCR * K [ K = --------------- ]
1952*a26f067fSSarah Walker * GPUclockspeed GPUclockspeed
1953*a26f067fSSarah Walker *
1954*a26f067fSSarah Walker * The actual K is multiplied by 2^20 (and deltaCR * K is divided by 2^20)
1955*a26f067fSSarah Walker * to get some better accuracy and to avoid returning 0 in the integer
1956*a26f067fSSarah Walker * division 256000000/GPUfreq if GPUfreq is greater than 256MHz.
1957*a26f067fSSarah Walker * This is the same as keeping K as a decimal number.
1958*a26f067fSSarah Walker *
1959*a26f067fSSarah Walker * The maximum deltaOS is slightly more than 5hrs for all GPU frequencies
1960*a26f067fSSarah Walker * (deltaCR * K is more or less a constant), and it's relative to the base
1961*a26f067fSSarah Walker * OS timestamp sampled as a part of the timer correlation data.
1962*a26f067fSSarah Walker * This base is refreshed on GPU power-on, DVFS transition and periodic
1963*a26f067fSSarah Walker * frequency calibration (executed every few seconds if the FW is doing
1964*a26f067fSSarah Walker * some work), so as long as the GPU is doing something and one of these
1965*a26f067fSSarah Walker * events is triggered then deltaCR * K will not overflow and deltaOS will be
1966*a26f067fSSarah Walker * correct.
1967*a26f067fSSarah Walker */
1968*a26f067fSSarah Walker
1969*a26f067fSSarah Walker #define ROGUE_FWIF_CRDELTA_TO_OSDELTA_ACCURACY_SHIFT (20)
1970*a26f067fSSarah Walker
1971*a26f067fSSarah Walker #define ROGUE_FWIF_GET_DELTA_OSTIME_NS(delta_cr, k) \
1972*a26f067fSSarah Walker (((delta_cr) * (k)) >> ROGUE_FWIF_CRDELTA_TO_OSDELTA_ACCURACY_SHIFT)
1973*a26f067fSSarah Walker
1974*a26f067fSSarah Walker /*
1975*a26f067fSSarah Walker ******************************************************************************
1976*a26f067fSSarah Walker * GPU Utilisation
1977*a26f067fSSarah Walker ******************************************************************************
1978*a26f067fSSarah Walker */
1979*a26f067fSSarah Walker
1980*a26f067fSSarah Walker /* See rogue_common.h for a list of GPU states */
1981*a26f067fSSarah Walker #define ROGUE_FWIF_GPU_UTIL_TIME_MASK \
1982*a26f067fSSarah Walker (0xFFFFFFFFFFFFFFFFull & ~ROGUE_FWIF_GPU_UTIL_STATE_MASK)
1983*a26f067fSSarah Walker
1984*a26f067fSSarah Walker #define ROGUE_FWIF_GPU_UTIL_GET_TIME(word) \
1985*a26f067fSSarah Walker ((word)(&ROGUE_FWIF_GPU_UTIL_TIME_MASK))
1986*a26f067fSSarah Walker #define ROGUE_FWIF_GPU_UTIL_GET_STATE(word) \
1987*a26f067fSSarah Walker ((word)(&ROGUE_FWIF_GPU_UTIL_STATE_MASK))
1988*a26f067fSSarah Walker
1989*a26f067fSSarah Walker /*
1990*a26f067fSSarah Walker * The OS timestamps computed by the FW are approximations of the real time,
1991*a26f067fSSarah Walker * which means they could be slightly behind or ahead the real timer on the
1992*a26f067fSSarah Walker * Host. In some cases we can perform subtractions between FW approximated
1993*a26f067fSSarah Walker * timestamps and real OS timestamps, so we need a form of protection against
1994*a26f067fSSarah Walker * negative results if for instance the FW one is a bit ahead of time.
1995*a26f067fSSarah Walker */
1996*a26f067fSSarah Walker #define ROGUE_FWIF_GPU_UTIL_GET_PERIOD(newtime, oldtime) \
1997*a26f067fSSarah Walker (((newtime) > (oldtime)) ? ((newtime) - (oldtime)) : 0U)
1998*a26f067fSSarah Walker
1999*a26f067fSSarah Walker #define ROGUE_FWIF_GPU_UTIL_MAKE_WORD(time, state) \
2000*a26f067fSSarah Walker (ROGUE_FWIF_GPU_UTIL_GET_TIME(time) | \
2001*a26f067fSSarah Walker ROGUE_FWIF_GPU_UTIL_GET_STATE(state))
2002*a26f067fSSarah Walker
2003*a26f067fSSarah Walker /*
2004*a26f067fSSarah Walker * The timer correlation array must be big enough to ensure old entries won't be
2005*a26f067fSSarah Walker * overwritten before all the HWPerf events linked to those entries are
2006*a26f067fSSarah Walker * processed by the MISR. The update frequency of this array depends on how fast
2007*a26f067fSSarah Walker * the system can change state (basically how small the APM latency is) and
2008*a26f067fSSarah Walker * perform DVFS transitions.
2009*a26f067fSSarah Walker *
2010*a26f067fSSarah Walker * The minimum size is 2 (not 1) to avoid race conditions between the FW reading
2011*a26f067fSSarah Walker * an entry while the Host is updating it. With 2 entries in the worst case the
2012*a26f067fSSarah Walker * FW will read old data, which is still quite ok if the Host is updating the
2013*a26f067fSSarah Walker * timer correlation at that time.
2014*a26f067fSSarah Walker */
2015*a26f067fSSarah Walker #define ROGUE_FWIF_TIME_CORR_ARRAY_SIZE 256U
2016*a26f067fSSarah Walker #define ROGUE_FWIF_TIME_CORR_CURR_INDEX(seqcount) \
2017*a26f067fSSarah Walker ((seqcount) % ROGUE_FWIF_TIME_CORR_ARRAY_SIZE)
2018*a26f067fSSarah Walker
2019*a26f067fSSarah Walker /* Make sure the timer correlation array size is a power of 2 */
2020*a26f067fSSarah Walker static_assert((ROGUE_FWIF_TIME_CORR_ARRAY_SIZE &
2021*a26f067fSSarah Walker (ROGUE_FWIF_TIME_CORR_ARRAY_SIZE - 1U)) == 0U,
2022*a26f067fSSarah Walker "ROGUE_FWIF_TIME_CORR_ARRAY_SIZE must be a power of two");
2023*a26f067fSSarah Walker
2024*a26f067fSSarah Walker struct rogue_fwif_gpu_util_fwcb {
2025*a26f067fSSarah Walker struct rogue_fwif_time_corr time_corr[ROGUE_FWIF_TIME_CORR_ARRAY_SIZE];
2026*a26f067fSSarah Walker u32 time_corr_seq_count;
2027*a26f067fSSarah Walker
2028*a26f067fSSarah Walker /* Compatibility and other flags */
2029*a26f067fSSarah Walker u32 gpu_util_flags;
2030*a26f067fSSarah Walker
2031*a26f067fSSarah Walker /* Last GPU state + OS time of the last state update */
2032*a26f067fSSarah Walker aligned_u64 last_word;
2033*a26f067fSSarah Walker
2034*a26f067fSSarah Walker /* Counters for the amount of time the GPU was active/idle/blocked */
2035*a26f067fSSarah Walker aligned_u64 stats_counters[PVR_FWIF_GPU_UTIL_STATE_NUM];
2036*a26f067fSSarah Walker } __aligned(8);
2037*a26f067fSSarah Walker
2038*a26f067fSSarah Walker struct rogue_fwif_rta_ctl {
2039*a26f067fSSarah Walker /* Render number */
2040*a26f067fSSarah Walker u32 render_target_index;
2041*a26f067fSSarah Walker /* index in RTA */
2042*a26f067fSSarah Walker u32 current_render_target;
2043*a26f067fSSarah Walker /* total active RTs */
2044*a26f067fSSarah Walker u32 active_render_targets;
2045*a26f067fSSarah Walker /* total active RTs from the first TA kick, for OOM */
2046*a26f067fSSarah Walker u32 cumul_active_render_targets;
2047*a26f067fSSarah Walker /* Array of valid RT indices */
2048*a26f067fSSarah Walker u32 valid_render_targets_fw_addr;
2049*a26f067fSSarah Walker /* Array of number of occurred partial renders per render target */
2050*a26f067fSSarah Walker u32 rta_num_partial_renders_fw_addr;
2051*a26f067fSSarah Walker /* Number of render targets in the array */
2052*a26f067fSSarah Walker u32 max_rts;
2053*a26f067fSSarah Walker /* Compatibility and other flags */
2054*a26f067fSSarah Walker u32 rta_ctl_flags;
2055*a26f067fSSarah Walker } __aligned(8);
2056*a26f067fSSarah Walker
2057*a26f067fSSarah Walker struct rogue_fwif_freelist {
2058*a26f067fSSarah Walker aligned_u64 freelist_dev_addr;
2059*a26f067fSSarah Walker aligned_u64 current_dev_addr;
2060*a26f067fSSarah Walker u32 current_stack_top;
2061*a26f067fSSarah Walker u32 max_pages;
2062*a26f067fSSarah Walker u32 grow_pages;
2063*a26f067fSSarah Walker /* HW pages */
2064*a26f067fSSarah Walker u32 current_pages;
2065*a26f067fSSarah Walker u32 allocated_page_count;
2066*a26f067fSSarah Walker u32 allocated_mmu_page_count;
2067*a26f067fSSarah Walker u32 freelist_id;
2068*a26f067fSSarah Walker
2069*a26f067fSSarah Walker bool grow_pending __aligned(4);
2070*a26f067fSSarah Walker /* Pages that should be used only when OOM is reached */
2071*a26f067fSSarah Walker u32 ready_pages;
2072*a26f067fSSarah Walker /* Compatibility and other flags */
2073*a26f067fSSarah Walker u32 freelist_flags;
2074*a26f067fSSarah Walker /* PM Global PB on which Freelist is loaded */
2075*a26f067fSSarah Walker u32 pm_global_pb;
2076*a26f067fSSarah Walker u32 padding;
2077*a26f067fSSarah Walker } __aligned(8);
2078*a26f067fSSarah Walker
2079*a26f067fSSarah Walker /*
2080*a26f067fSSarah Walker ******************************************************************************
2081*a26f067fSSarah Walker * HWRTData
2082*a26f067fSSarah Walker ******************************************************************************
2083*a26f067fSSarah Walker */
2084*a26f067fSSarah Walker
2085*a26f067fSSarah Walker /* HWRTData flags */
2086*a26f067fSSarah Walker /* Deprecated flags 1:0 */
2087*a26f067fSSarah Walker #define HWRTDATA_HAS_LAST_GEOM BIT(2)
2088*a26f067fSSarah Walker #define HWRTDATA_PARTIAL_RENDERED BIT(3)
2089*a26f067fSSarah Walker #define HWRTDATA_DISABLE_TILE_REORDERING BIT(4)
2090*a26f067fSSarah Walker #define HWRTDATA_NEED_BRN65101_BLIT BIT(5)
2091*a26f067fSSarah Walker #define HWRTDATA_FIRST_BRN65101_STRIP BIT(6)
2092*a26f067fSSarah Walker #define HWRTDATA_NEED_BRN67182_2ND_RENDER BIT(7)
2093*a26f067fSSarah Walker
2094*a26f067fSSarah Walker enum rogue_fwif_rtdata_state {
2095*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_NONE = 0,
2096*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_KICK_GEOM,
2097*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_KICK_GEOM_FIRST,
2098*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_GEOM_FINISHED,
2099*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_KICK_FRAG,
2100*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_FRAG_FINISHED,
2101*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_FRAG_CONTEXT_STORED,
2102*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_GEOM_OUTOFMEM,
2103*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_PARTIALRENDERFINISHED,
2104*a26f067fSSarah Walker /*
2105*a26f067fSSarah Walker * In case of HWR, we can't set the RTDATA state to NONE, as this will
2106*a26f067fSSarah Walker * cause any TA to become a first TA. To ensure all related TA's are
2107*a26f067fSSarah Walker * skipped, we use the HWR state
2108*a26f067fSSarah Walker */
2109*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_HWR,
2110*a26f067fSSarah Walker ROGUE_FWIF_RTDATA_STATE_UNKNOWN = 0x7FFFFFFFU
2111*a26f067fSSarah Walker };
2112*a26f067fSSarah Walker
2113*a26f067fSSarah Walker struct rogue_fwif_hwrtdata_common {
2114*a26f067fSSarah Walker bool geom_caches_need_zeroing __aligned(4);
2115*a26f067fSSarah Walker
2116*a26f067fSSarah Walker u32 screen_pixel_max;
2117*a26f067fSSarah Walker aligned_u64 multi_sample_ctl;
2118*a26f067fSSarah Walker u64 flipped_multi_sample_ctl;
2119*a26f067fSSarah Walker u32 tpc_stride;
2120*a26f067fSSarah Walker u32 tpc_size;
2121*a26f067fSSarah Walker u32 te_screen;
2122*a26f067fSSarah Walker u32 mtile_stride;
2123*a26f067fSSarah Walker u32 teaa;
2124*a26f067fSSarah Walker u32 te_mtile1;
2125*a26f067fSSarah Walker u32 te_mtile2;
2126*a26f067fSSarah Walker u32 isp_merge_lower_x;
2127*a26f067fSSarah Walker u32 isp_merge_lower_y;
2128*a26f067fSSarah Walker u32 isp_merge_upper_x;
2129*a26f067fSSarah Walker u32 isp_merge_upper_y;
2130*a26f067fSSarah Walker u32 isp_merge_scale_x;
2131*a26f067fSSarah Walker u32 isp_merge_scale_y;
2132*a26f067fSSarah Walker u32 rgn_header_size;
2133*a26f067fSSarah Walker u32 isp_mtile_size;
2134*a26f067fSSarah Walker u32 padding;
2135*a26f067fSSarah Walker } __aligned(8);
2136*a26f067fSSarah Walker
2137*a26f067fSSarah Walker struct rogue_fwif_hwrtdata {
2138*a26f067fSSarah Walker /* MList Data Store */
2139*a26f067fSSarah Walker aligned_u64 pm_mlist_dev_addr;
2140*a26f067fSSarah Walker
2141*a26f067fSSarah Walker aligned_u64 vce_cat_base[4];
2142*a26f067fSSarah Walker aligned_u64 vce_last_cat_base[4];
2143*a26f067fSSarah Walker aligned_u64 te_cat_base[4];
2144*a26f067fSSarah Walker aligned_u64 te_last_cat_base[4];
2145*a26f067fSSarah Walker aligned_u64 alist_cat_base;
2146*a26f067fSSarah Walker aligned_u64 alist_last_cat_base;
2147*a26f067fSSarah Walker
2148*a26f067fSSarah Walker aligned_u64 pm_alist_stack_pointer;
2149*a26f067fSSarah Walker u32 pm_mlist_stack_pointer;
2150*a26f067fSSarah Walker
2151*a26f067fSSarah Walker u32 hwrt_data_common_fw_addr;
2152*a26f067fSSarah Walker
2153*a26f067fSSarah Walker u32 hwrt_data_flags;
2154*a26f067fSSarah Walker enum rogue_fwif_rtdata_state state;
2155*a26f067fSSarah Walker
2156*a26f067fSSarah Walker u32 freelists_fw_addr[MAX_FREELISTS_SIZE] __aligned(8);
2157*a26f067fSSarah Walker u32 freelist_hwr_snapshot[MAX_FREELISTS_SIZE];
2158*a26f067fSSarah Walker
2159*a26f067fSSarah Walker aligned_u64 vheap_table_dev_addr;
2160*a26f067fSSarah Walker
2161*a26f067fSSarah Walker struct rogue_fwif_rta_ctl rta_ctl;
2162*a26f067fSSarah Walker
2163*a26f067fSSarah Walker aligned_u64 tail_ptrs_dev_addr;
2164*a26f067fSSarah Walker aligned_u64 macrotile_array_dev_addr;
2165*a26f067fSSarah Walker aligned_u64 rgn_header_dev_addr;
2166*a26f067fSSarah Walker aligned_u64 rtc_dev_addr;
2167*a26f067fSSarah Walker
2168*a26f067fSSarah Walker u32 owner_geom_not_used_by_host __aligned(8);
2169*a26f067fSSarah Walker
2170*a26f067fSSarah Walker bool geom_caches_need_zeroing __aligned(4);
2171*a26f067fSSarah Walker
2172*a26f067fSSarah Walker struct rogue_fwif_cleanup_ctl cleanup_state __aligned(64);
2173*a26f067fSSarah Walker } __aligned(8);
2174*a26f067fSSarah Walker
2175*a26f067fSSarah Walker /*
2176*a26f067fSSarah Walker ******************************************************************************
2177*a26f067fSSarah Walker * Sync checkpoints
2178*a26f067fSSarah Walker ******************************************************************************
2179*a26f067fSSarah Walker */
2180*a26f067fSSarah Walker
2181*a26f067fSSarah Walker #define PVR_SYNC_CHECKPOINT_UNDEF 0x000
2182*a26f067fSSarah Walker #define PVR_SYNC_CHECKPOINT_ACTIVE 0xac1 /* Checkpoint has not signaled. */
2183*a26f067fSSarah Walker #define PVR_SYNC_CHECKPOINT_SIGNALED 0x519 /* Checkpoint has signaled. */
2184*a26f067fSSarah Walker #define PVR_SYNC_CHECKPOINT_ERRORED 0xeff /* Checkpoint has been errored. */
2185*a26f067fSSarah Walker
2186*a26f067fSSarah Walker #include "pvr_rogue_fwif_check.h"
2187*a26f067fSSarah Walker
2188*a26f067fSSarah Walker #endif /* PVR_ROGUE_FWIF_H */
2189