xref: /linux/drivers/gpu/drm/vc4/vc4_qpu_defines.h (revision f26e8817b235d8764363bffcc9cbfc61867371f2)
1463873d5SEric Anholt /*
2463873d5SEric Anholt  * Copyright © 2014 Broadcom
3463873d5SEric Anholt  *
4463873d5SEric Anholt  * Permission is hereby granted, free of charge, to any person obtaining a
5463873d5SEric Anholt  * copy of this software and associated documentation files (the "Software"),
6463873d5SEric Anholt  * to deal in the Software without restriction, including without limitation
7463873d5SEric Anholt  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8463873d5SEric Anholt  * and/or sell copies of the Software, and to permit persons to whom the
9463873d5SEric Anholt  * Software is furnished to do so, subject to the following conditions:
10463873d5SEric Anholt  *
11463873d5SEric Anholt  * The above copyright notice and this permission notice (including the next
12463873d5SEric Anholt  * paragraph) shall be included in all copies or substantial portions of the
13463873d5SEric Anholt  * Software.
14463873d5SEric Anholt  *
15463873d5SEric Anholt  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16463873d5SEric Anholt  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17463873d5SEric Anholt  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18463873d5SEric Anholt  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19463873d5SEric Anholt  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20463873d5SEric Anholt  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21463873d5SEric Anholt  * IN THE SOFTWARE.
22463873d5SEric Anholt  */
23463873d5SEric Anholt 
24463873d5SEric Anholt #ifndef VC4_QPU_DEFINES_H
25463873d5SEric Anholt #define VC4_QPU_DEFINES_H
26463873d5SEric Anholt 
27463873d5SEric Anholt enum qpu_op_add {
28463873d5SEric Anholt 	QPU_A_NOP,
29463873d5SEric Anholt 	QPU_A_FADD,
30463873d5SEric Anholt 	QPU_A_FSUB,
31463873d5SEric Anholt 	QPU_A_FMIN,
32463873d5SEric Anholt 	QPU_A_FMAX,
33463873d5SEric Anholt 	QPU_A_FMINABS,
34463873d5SEric Anholt 	QPU_A_FMAXABS,
35463873d5SEric Anholt 	QPU_A_FTOI,
36463873d5SEric Anholt 	QPU_A_ITOF,
37463873d5SEric Anholt 	QPU_A_ADD = 12,
38463873d5SEric Anholt 	QPU_A_SUB,
39463873d5SEric Anholt 	QPU_A_SHR,
40463873d5SEric Anholt 	QPU_A_ASR,
41463873d5SEric Anholt 	QPU_A_ROR,
42463873d5SEric Anholt 	QPU_A_SHL,
43463873d5SEric Anholt 	QPU_A_MIN,
44463873d5SEric Anholt 	QPU_A_MAX,
45463873d5SEric Anholt 	QPU_A_AND,
46463873d5SEric Anholt 	QPU_A_OR,
47463873d5SEric Anholt 	QPU_A_XOR,
48463873d5SEric Anholt 	QPU_A_NOT,
49463873d5SEric Anholt 	QPU_A_CLZ,
50463873d5SEric Anholt 	QPU_A_V8ADDS = 30,
51463873d5SEric Anholt 	QPU_A_V8SUBS = 31,
52463873d5SEric Anholt };
53463873d5SEric Anholt 
54463873d5SEric Anholt enum qpu_op_mul {
55463873d5SEric Anholt 	QPU_M_NOP,
56463873d5SEric Anholt 	QPU_M_FMUL,
57463873d5SEric Anholt 	QPU_M_MUL24,
58463873d5SEric Anholt 	QPU_M_V8MULD,
59463873d5SEric Anholt 	QPU_M_V8MIN,
60463873d5SEric Anholt 	QPU_M_V8MAX,
61463873d5SEric Anholt 	QPU_M_V8ADDS,
62463873d5SEric Anholt 	QPU_M_V8SUBS,
63463873d5SEric Anholt };
64463873d5SEric Anholt 
65463873d5SEric Anholt enum qpu_raddr {
66463873d5SEric Anholt 	QPU_R_FRAG_PAYLOAD_ZW = 15, /* W for A file, Z for B file */
67463873d5SEric Anholt 	/* 0-31 are the plain regfile a or b fields */
68463873d5SEric Anholt 	QPU_R_UNIF = 32,
69463873d5SEric Anholt 	QPU_R_VARY = 35,
70463873d5SEric Anholt 	QPU_R_ELEM_QPU = 38,
71463873d5SEric Anholt 	QPU_R_NOP,
72463873d5SEric Anholt 	QPU_R_XY_PIXEL_COORD = 41,
73*20e48fd6SEric Anholt 	QPU_R_MS_REV_FLAGS = 42,
74463873d5SEric Anholt 	QPU_R_VPM = 48,
75463873d5SEric Anholt 	QPU_R_VPM_LD_BUSY,
76463873d5SEric Anholt 	QPU_R_VPM_LD_WAIT,
77463873d5SEric Anholt 	QPU_R_MUTEX_ACQUIRE,
78463873d5SEric Anholt };
79463873d5SEric Anholt 
80463873d5SEric Anholt enum qpu_waddr {
81463873d5SEric Anholt 	/* 0-31 are the plain regfile a or b fields */
82463873d5SEric Anholt 	QPU_W_ACC0 = 32, /* aka r0 */
83463873d5SEric Anholt 	QPU_W_ACC1,
84463873d5SEric Anholt 	QPU_W_ACC2,
85463873d5SEric Anholt 	QPU_W_ACC3,
86463873d5SEric Anholt 	QPU_W_TMU_NOSWAP,
87463873d5SEric Anholt 	QPU_W_ACC5,
88463873d5SEric Anholt 	QPU_W_HOST_INT,
89463873d5SEric Anholt 	QPU_W_NOP,
90463873d5SEric Anholt 	QPU_W_UNIFORMS_ADDRESS,
91463873d5SEric Anholt 	QPU_W_QUAD_XY, /* X for regfile a, Y for regfile b */
92463873d5SEric Anholt 	QPU_W_MS_FLAGS = 42,
93463873d5SEric Anholt 	QPU_W_REV_FLAG = 42,
94463873d5SEric Anholt 	QPU_W_TLB_STENCIL_SETUP = 43,
95463873d5SEric Anholt 	QPU_W_TLB_Z,
96463873d5SEric Anholt 	QPU_W_TLB_COLOR_MS,
97463873d5SEric Anholt 	QPU_W_TLB_COLOR_ALL,
98463873d5SEric Anholt 	QPU_W_TLB_ALPHA_MASK,
99463873d5SEric Anholt 	QPU_W_VPM,
100463873d5SEric Anholt 	QPU_W_VPMVCD_SETUP, /* LD for regfile a, ST for regfile b */
101463873d5SEric Anholt 	QPU_W_VPM_ADDR, /* LD for regfile a, ST for regfile b */
102463873d5SEric Anholt 	QPU_W_MUTEX_RELEASE,
103463873d5SEric Anholt 	QPU_W_SFU_RECIP,
104463873d5SEric Anholt 	QPU_W_SFU_RECIPSQRT,
105463873d5SEric Anholt 	QPU_W_SFU_EXP,
106463873d5SEric Anholt 	QPU_W_SFU_LOG,
107463873d5SEric Anholt 	QPU_W_TMU0_S,
108463873d5SEric Anholt 	QPU_W_TMU0_T,
109463873d5SEric Anholt 	QPU_W_TMU0_R,
110463873d5SEric Anholt 	QPU_W_TMU0_B,
111463873d5SEric Anholt 	QPU_W_TMU1_S,
112463873d5SEric Anholt 	QPU_W_TMU1_T,
113463873d5SEric Anholt 	QPU_W_TMU1_R,
114463873d5SEric Anholt 	QPU_W_TMU1_B,
115463873d5SEric Anholt };
116463873d5SEric Anholt 
117463873d5SEric Anholt enum qpu_sig_bits {
118463873d5SEric Anholt 	QPU_SIG_SW_BREAKPOINT,
119463873d5SEric Anholt 	QPU_SIG_NONE,
120463873d5SEric Anholt 	QPU_SIG_THREAD_SWITCH,
121463873d5SEric Anholt 	QPU_SIG_PROG_END,
122463873d5SEric Anholt 	QPU_SIG_WAIT_FOR_SCOREBOARD,
123463873d5SEric Anholt 	QPU_SIG_SCOREBOARD_UNLOCK,
124463873d5SEric Anholt 	QPU_SIG_LAST_THREAD_SWITCH,
125463873d5SEric Anholt 	QPU_SIG_COVERAGE_LOAD,
126463873d5SEric Anholt 	QPU_SIG_COLOR_LOAD,
127463873d5SEric Anholt 	QPU_SIG_COLOR_LOAD_END,
128463873d5SEric Anholt 	QPU_SIG_LOAD_TMU0,
129463873d5SEric Anholt 	QPU_SIG_LOAD_TMU1,
130463873d5SEric Anholt 	QPU_SIG_ALPHA_MASK_LOAD,
131463873d5SEric Anholt 	QPU_SIG_SMALL_IMM,
132463873d5SEric Anholt 	QPU_SIG_LOAD_IMM,
133463873d5SEric Anholt 	QPU_SIG_BRANCH
134463873d5SEric Anholt };
135463873d5SEric Anholt 
136463873d5SEric Anholt enum qpu_mux {
137463873d5SEric Anholt 	/* hardware mux values */
138463873d5SEric Anholt 	QPU_MUX_R0,
139463873d5SEric Anholt 	QPU_MUX_R1,
140463873d5SEric Anholt 	QPU_MUX_R2,
141463873d5SEric Anholt 	QPU_MUX_R3,
142463873d5SEric Anholt 	QPU_MUX_R4,
143463873d5SEric Anholt 	QPU_MUX_R5,
144463873d5SEric Anholt 	QPU_MUX_A,
145463873d5SEric Anholt 	QPU_MUX_B,
146463873d5SEric Anholt 
147463873d5SEric Anholt 	/* non-hardware mux values */
148463873d5SEric Anholt 	QPU_MUX_IMM,
149463873d5SEric Anholt };
150463873d5SEric Anholt 
151463873d5SEric Anholt enum qpu_cond {
152463873d5SEric Anholt 	QPU_COND_NEVER,
153463873d5SEric Anholt 	QPU_COND_ALWAYS,
154463873d5SEric Anholt 	QPU_COND_ZS,
155463873d5SEric Anholt 	QPU_COND_ZC,
156463873d5SEric Anholt 	QPU_COND_NS,
157463873d5SEric Anholt 	QPU_COND_NC,
158463873d5SEric Anholt 	QPU_COND_CS,
159463873d5SEric Anholt 	QPU_COND_CC,
160463873d5SEric Anholt };
161463873d5SEric Anholt 
162463873d5SEric Anholt enum qpu_pack_mul {
163463873d5SEric Anholt 	QPU_PACK_MUL_NOP,
164463873d5SEric Anholt 	/* replicated to each 8 bits of the 32-bit dst. */
165463873d5SEric Anholt 	QPU_PACK_MUL_8888 = 3,
166463873d5SEric Anholt 	QPU_PACK_MUL_8A,
167463873d5SEric Anholt 	QPU_PACK_MUL_8B,
168463873d5SEric Anholt 	QPU_PACK_MUL_8C,
169463873d5SEric Anholt 	QPU_PACK_MUL_8D,
170463873d5SEric Anholt };
171463873d5SEric Anholt 
172463873d5SEric Anholt enum qpu_pack_a {
173463873d5SEric Anholt 	QPU_PACK_A_NOP,
174463873d5SEric Anholt 	/* convert to 16 bit float if float input, or to int16. */
175463873d5SEric Anholt 	QPU_PACK_A_16A,
176463873d5SEric Anholt 	QPU_PACK_A_16B,
177463873d5SEric Anholt 	/* replicated to each 8 bits of the 32-bit dst. */
178463873d5SEric Anholt 	QPU_PACK_A_8888,
179463873d5SEric Anholt 	/* Convert to 8-bit unsigned int. */
180463873d5SEric Anholt 	QPU_PACK_A_8A,
181463873d5SEric Anholt 	QPU_PACK_A_8B,
182463873d5SEric Anholt 	QPU_PACK_A_8C,
183463873d5SEric Anholt 	QPU_PACK_A_8D,
184463873d5SEric Anholt 
185463873d5SEric Anholt 	/* Saturating variants of the previous instructions. */
186463873d5SEric Anholt 	QPU_PACK_A_32_SAT, /* int-only */
187463873d5SEric Anholt 	QPU_PACK_A_16A_SAT, /* int or float */
188463873d5SEric Anholt 	QPU_PACK_A_16B_SAT,
189463873d5SEric Anholt 	QPU_PACK_A_8888_SAT,
190463873d5SEric Anholt 	QPU_PACK_A_8A_SAT,
191463873d5SEric Anholt 	QPU_PACK_A_8B_SAT,
192463873d5SEric Anholt 	QPU_PACK_A_8C_SAT,
193463873d5SEric Anholt 	QPU_PACK_A_8D_SAT,
194463873d5SEric Anholt };
195463873d5SEric Anholt 
196463873d5SEric Anholt enum qpu_unpack_r4 {
197463873d5SEric Anholt 	QPU_UNPACK_R4_NOP,
198463873d5SEric Anholt 	QPU_UNPACK_R4_F16A_TO_F32,
199463873d5SEric Anholt 	QPU_UNPACK_R4_F16B_TO_F32,
200463873d5SEric Anholt 	QPU_UNPACK_R4_8D_REP,
201463873d5SEric Anholt 	QPU_UNPACK_R4_8A,
202463873d5SEric Anholt 	QPU_UNPACK_R4_8B,
203463873d5SEric Anholt 	QPU_UNPACK_R4_8C,
204463873d5SEric Anholt 	QPU_UNPACK_R4_8D,
205463873d5SEric Anholt };
206463873d5SEric Anholt 
207463873d5SEric Anholt #define QPU_MASK(high, low) \
208463873d5SEric Anholt 	((((uint64_t)1 << ((high) - (low) + 1)) - 1) << (low))
209463873d5SEric Anholt 
210463873d5SEric Anholt #define QPU_GET_FIELD(word, field) \
211463873d5SEric Anholt 	((uint32_t)(((word)  & field ## _MASK) >> field ## _SHIFT))
212463873d5SEric Anholt 
213463873d5SEric Anholt #define QPU_SIG_SHIFT                   60
214463873d5SEric Anholt #define QPU_SIG_MASK                    QPU_MASK(63, 60)
215463873d5SEric Anholt 
216463873d5SEric Anholt #define QPU_UNPACK_SHIFT                57
217463873d5SEric Anholt #define QPU_UNPACK_MASK                 QPU_MASK(59, 57)
218463873d5SEric Anholt 
219463873d5SEric Anholt /**
220463873d5SEric Anholt  * If set, the pack field means PACK_MUL or R4 packing, instead of normal
221463873d5SEric Anholt  * regfile a packing.
222463873d5SEric Anholt  */
223463873d5SEric Anholt #define QPU_PM                          ((uint64_t)1 << 56)
224463873d5SEric Anholt 
225463873d5SEric Anholt #define QPU_PACK_SHIFT                  52
226463873d5SEric Anholt #define QPU_PACK_MASK                   QPU_MASK(55, 52)
227463873d5SEric Anholt 
228463873d5SEric Anholt #define QPU_COND_ADD_SHIFT              49
229463873d5SEric Anholt #define QPU_COND_ADD_MASK               QPU_MASK(51, 49)
230463873d5SEric Anholt #define QPU_COND_MUL_SHIFT              46
231463873d5SEric Anholt #define QPU_COND_MUL_MASK               QPU_MASK(48, 46)
232463873d5SEric Anholt 
23393aa9ae3SEric Anholt #define QPU_BRANCH_COND_SHIFT           52
23493aa9ae3SEric Anholt #define QPU_BRANCH_COND_MASK            QPU_MASK(55, 52)
23593aa9ae3SEric Anholt 
23693aa9ae3SEric Anholt #define QPU_BRANCH_REL                  ((uint64_t)1 << 51)
23793aa9ae3SEric Anholt #define QPU_BRANCH_REG                  ((uint64_t)1 << 50)
23893aa9ae3SEric Anholt 
23993aa9ae3SEric Anholt #define QPU_BRANCH_RADDR_A_SHIFT        45
24093aa9ae3SEric Anholt #define QPU_BRANCH_RADDR_A_MASK         QPU_MASK(49, 45)
24193aa9ae3SEric Anholt 
242463873d5SEric Anholt #define QPU_SF                          ((uint64_t)1 << 45)
243463873d5SEric Anholt 
244463873d5SEric Anholt #define QPU_WADDR_ADD_SHIFT             38
245463873d5SEric Anholt #define QPU_WADDR_ADD_MASK              QPU_MASK(43, 38)
246463873d5SEric Anholt #define QPU_WADDR_MUL_SHIFT             32
247463873d5SEric Anholt #define QPU_WADDR_MUL_MASK              QPU_MASK(37, 32)
248463873d5SEric Anholt 
249463873d5SEric Anholt #define QPU_OP_MUL_SHIFT                29
250463873d5SEric Anholt #define QPU_OP_MUL_MASK                 QPU_MASK(31, 29)
251463873d5SEric Anholt 
252463873d5SEric Anholt #define QPU_RADDR_A_SHIFT               18
253463873d5SEric Anholt #define QPU_RADDR_A_MASK                QPU_MASK(23, 18)
254463873d5SEric Anholt #define QPU_RADDR_B_SHIFT               12
255463873d5SEric Anholt #define QPU_RADDR_B_MASK                QPU_MASK(17, 12)
256463873d5SEric Anholt #define QPU_SMALL_IMM_SHIFT             12
257463873d5SEric Anholt #define QPU_SMALL_IMM_MASK              QPU_MASK(17, 12)
258463873d5SEric Anholt 
259463873d5SEric Anholt #define QPU_ADD_A_SHIFT                 9
260463873d5SEric Anholt #define QPU_ADD_A_MASK                  QPU_MASK(11, 9)
261463873d5SEric Anholt #define QPU_ADD_B_SHIFT                 6
262463873d5SEric Anholt #define QPU_ADD_B_MASK                  QPU_MASK(8, 6)
263463873d5SEric Anholt #define QPU_MUL_A_SHIFT                 3
264463873d5SEric Anholt #define QPU_MUL_A_MASK                  QPU_MASK(5, 3)
265463873d5SEric Anholt #define QPU_MUL_B_SHIFT                 0
266463873d5SEric Anholt #define QPU_MUL_B_MASK                  QPU_MASK(2, 0)
267463873d5SEric Anholt 
268463873d5SEric Anholt #define QPU_WS                          ((uint64_t)1 << 44)
269463873d5SEric Anholt 
270463873d5SEric Anholt #define QPU_OP_ADD_SHIFT                24
271463873d5SEric Anholt #define QPU_OP_ADD_MASK                 QPU_MASK(28, 24)
272463873d5SEric Anholt 
2736d45c81dSEric Anholt #define QPU_LOAD_IMM_SHIFT              0
2746d45c81dSEric Anholt #define QPU_LOAD_IMM_MASK               QPU_MASK(31, 0)
2756d45c81dSEric Anholt 
27693aa9ae3SEric Anholt #define QPU_BRANCH_TARGET_SHIFT         0
27793aa9ae3SEric Anholt #define QPU_BRANCH_TARGET_MASK          QPU_MASK(31, 0)
27893aa9ae3SEric Anholt 
279463873d5SEric Anholt #endif /* VC4_QPU_DEFINES_H */
280