1d722e3fbSopenharmony_ci/* 2d722e3fbSopenharmony_ci * Copyright © 2014 Broadcom 3d722e3fbSopenharmony_ci * 4d722e3fbSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5d722e3fbSopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6d722e3fbSopenharmony_ci * to deal in the Software without restriction, including without limitation 7d722e3fbSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8d722e3fbSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9d722e3fbSopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10d722e3fbSopenharmony_ci * 11d722e3fbSopenharmony_ci * The above copyright notice and this permission notice (including the next 12d722e3fbSopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13d722e3fbSopenharmony_ci * Software. 14d722e3fbSopenharmony_ci * 15d722e3fbSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16d722e3fbSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17d722e3fbSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18d722e3fbSopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19d722e3fbSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20d722e3fbSopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21d722e3fbSopenharmony_ci * IN THE SOFTWARE. 22d722e3fbSopenharmony_ci */ 23d722e3fbSopenharmony_ci 24d722e3fbSopenharmony_ci#ifndef VC4_QPU_DEFINES_H 25d722e3fbSopenharmony_ci#define VC4_QPU_DEFINES_H 26d722e3fbSopenharmony_ci 27d722e3fbSopenharmony_cienum qpu_op_add { 28d722e3fbSopenharmony_ci QPU_A_NOP, 29d722e3fbSopenharmony_ci QPU_A_FADD, 30d722e3fbSopenharmony_ci QPU_A_FSUB, 31d722e3fbSopenharmony_ci QPU_A_FMIN, 32d722e3fbSopenharmony_ci QPU_A_FMAX, 33d722e3fbSopenharmony_ci QPU_A_FMINABS, 34d722e3fbSopenharmony_ci QPU_A_FMAXABS, 35d722e3fbSopenharmony_ci QPU_A_FTOI, 36d722e3fbSopenharmony_ci QPU_A_ITOF, 37d722e3fbSopenharmony_ci QPU_A_ADD = 12, 38d722e3fbSopenharmony_ci QPU_A_SUB, 39d722e3fbSopenharmony_ci QPU_A_SHR, 40d722e3fbSopenharmony_ci QPU_A_ASR, 41d722e3fbSopenharmony_ci QPU_A_ROR, 42d722e3fbSopenharmony_ci QPU_A_SHL, 43d722e3fbSopenharmony_ci QPU_A_MIN, 44d722e3fbSopenharmony_ci QPU_A_MAX, 45d722e3fbSopenharmony_ci QPU_A_AND, 46d722e3fbSopenharmony_ci QPU_A_OR, 47d722e3fbSopenharmony_ci QPU_A_XOR, 48d722e3fbSopenharmony_ci QPU_A_NOT, 49d722e3fbSopenharmony_ci QPU_A_CLZ, 50d722e3fbSopenharmony_ci QPU_A_V8ADDS = 30, 51d722e3fbSopenharmony_ci QPU_A_V8SUBS = 31, 52d722e3fbSopenharmony_ci}; 53d722e3fbSopenharmony_ci 54d722e3fbSopenharmony_cienum qpu_op_mul { 55d722e3fbSopenharmony_ci QPU_M_NOP, 56d722e3fbSopenharmony_ci QPU_M_FMUL, 57d722e3fbSopenharmony_ci QPU_M_MUL24, 58d722e3fbSopenharmony_ci QPU_M_V8MULD, 59d722e3fbSopenharmony_ci QPU_M_V8MIN, 60d722e3fbSopenharmony_ci QPU_M_V8MAX, 61d722e3fbSopenharmony_ci QPU_M_V8ADDS, 62d722e3fbSopenharmony_ci QPU_M_V8SUBS, 63d722e3fbSopenharmony_ci}; 64d722e3fbSopenharmony_ci 65d722e3fbSopenharmony_cienum qpu_raddr { 66d722e3fbSopenharmony_ci QPU_R_FRAG_PAYLOAD_ZW = 15, /* W for A file, Z for B file */ 67d722e3fbSopenharmony_ci /* 0-31 are the plain regfile a or b fields */ 68d722e3fbSopenharmony_ci QPU_R_UNIF = 32, 69d722e3fbSopenharmony_ci QPU_R_VARY = 35, 70d722e3fbSopenharmony_ci QPU_R_ELEM_QPU = 38, 71d722e3fbSopenharmony_ci QPU_R_NOP, 72d722e3fbSopenharmony_ci QPU_R_XY_PIXEL_COORD = 41, 73d722e3fbSopenharmony_ci QPU_R_MS_REV_FLAGS = 42, 74d722e3fbSopenharmony_ci QPU_R_VPM = 48, 75d722e3fbSopenharmony_ci QPU_R_VPM_LD_BUSY, 76d722e3fbSopenharmony_ci QPU_R_VPM_LD_WAIT, 77d722e3fbSopenharmony_ci QPU_R_MUTEX_ACQUIRE, 78d722e3fbSopenharmony_ci}; 79d722e3fbSopenharmony_ci 80d722e3fbSopenharmony_cienum qpu_waddr { 81d722e3fbSopenharmony_ci /* 0-31 are the plain regfile a or b fields */ 82d722e3fbSopenharmony_ci QPU_W_ACC0 = 32, /* aka r0 */ 83d722e3fbSopenharmony_ci QPU_W_ACC1, 84d722e3fbSopenharmony_ci QPU_W_ACC2, 85d722e3fbSopenharmony_ci QPU_W_ACC3, 86d722e3fbSopenharmony_ci QPU_W_TMU_NOSWAP, 87d722e3fbSopenharmony_ci QPU_W_ACC5, 88d722e3fbSopenharmony_ci QPU_W_HOST_INT, 89d722e3fbSopenharmony_ci QPU_W_NOP, 90d722e3fbSopenharmony_ci QPU_W_UNIFORMS_ADDRESS, 91d722e3fbSopenharmony_ci QPU_W_QUAD_XY, /* X for regfile a, Y for regfile b */ 92d722e3fbSopenharmony_ci QPU_W_MS_FLAGS = 42, 93d722e3fbSopenharmony_ci QPU_W_REV_FLAG = 42, 94d722e3fbSopenharmony_ci QPU_W_TLB_STENCIL_SETUP = 43, 95d722e3fbSopenharmony_ci QPU_W_TLB_Z, 96d722e3fbSopenharmony_ci QPU_W_TLB_COLOR_MS, 97d722e3fbSopenharmony_ci QPU_W_TLB_COLOR_ALL, 98d722e3fbSopenharmony_ci QPU_W_TLB_ALPHA_MASK, 99d722e3fbSopenharmony_ci QPU_W_VPM, 100d722e3fbSopenharmony_ci QPU_W_VPMVCD_SETUP, /* LD for regfile a, ST for regfile b */ 101d722e3fbSopenharmony_ci QPU_W_VPM_ADDR, /* LD for regfile a, ST for regfile b */ 102d722e3fbSopenharmony_ci QPU_W_MUTEX_RELEASE, 103d722e3fbSopenharmony_ci QPU_W_SFU_RECIP, 104d722e3fbSopenharmony_ci QPU_W_SFU_RECIPSQRT, 105d722e3fbSopenharmony_ci QPU_W_SFU_EXP, 106d722e3fbSopenharmony_ci QPU_W_SFU_LOG, 107d722e3fbSopenharmony_ci QPU_W_TMU0_S, 108d722e3fbSopenharmony_ci QPU_W_TMU0_T, 109d722e3fbSopenharmony_ci QPU_W_TMU0_R, 110d722e3fbSopenharmony_ci QPU_W_TMU0_B, 111d722e3fbSopenharmony_ci QPU_W_TMU1_S, 112d722e3fbSopenharmony_ci QPU_W_TMU1_T, 113d722e3fbSopenharmony_ci QPU_W_TMU1_R, 114d722e3fbSopenharmony_ci QPU_W_TMU1_B, 115d722e3fbSopenharmony_ci}; 116d722e3fbSopenharmony_ci 117d722e3fbSopenharmony_cienum qpu_sig_bits { 118d722e3fbSopenharmony_ci QPU_SIG_SW_BREAKPOINT, 119d722e3fbSopenharmony_ci QPU_SIG_NONE, 120d722e3fbSopenharmony_ci QPU_SIG_THREAD_SWITCH, 121d722e3fbSopenharmony_ci QPU_SIG_PROG_END, 122d722e3fbSopenharmony_ci QPU_SIG_WAIT_FOR_SCOREBOARD, 123d722e3fbSopenharmony_ci QPU_SIG_SCOREBOARD_UNLOCK, 124d722e3fbSopenharmony_ci QPU_SIG_LAST_THREAD_SWITCH, 125d722e3fbSopenharmony_ci QPU_SIG_COVERAGE_LOAD, 126d722e3fbSopenharmony_ci QPU_SIG_COLOR_LOAD, 127d722e3fbSopenharmony_ci QPU_SIG_COLOR_LOAD_END, 128d722e3fbSopenharmony_ci QPU_SIG_LOAD_TMU0, 129d722e3fbSopenharmony_ci QPU_SIG_LOAD_TMU1, 130d722e3fbSopenharmony_ci QPU_SIG_ALPHA_MASK_LOAD, 131d722e3fbSopenharmony_ci QPU_SIG_SMALL_IMM, 132d722e3fbSopenharmony_ci QPU_SIG_LOAD_IMM, 133d722e3fbSopenharmony_ci QPU_SIG_BRANCH 134d722e3fbSopenharmony_ci}; 135d722e3fbSopenharmony_ci 136d722e3fbSopenharmony_cienum qpu_mux { 137d722e3fbSopenharmony_ci /* hardware mux values */ 138d722e3fbSopenharmony_ci QPU_MUX_R0, 139d722e3fbSopenharmony_ci QPU_MUX_R1, 140d722e3fbSopenharmony_ci QPU_MUX_R2, 141d722e3fbSopenharmony_ci QPU_MUX_R3, 142d722e3fbSopenharmony_ci QPU_MUX_R4, 143d722e3fbSopenharmony_ci QPU_MUX_R5, 144d722e3fbSopenharmony_ci QPU_MUX_A, 145d722e3fbSopenharmony_ci QPU_MUX_B, 146d722e3fbSopenharmony_ci 147d722e3fbSopenharmony_ci /** 148d722e3fbSopenharmony_ci * Non-hardware mux value, stores a small immediate field to be 149d722e3fbSopenharmony_ci * programmed into raddr_b in the qpu_reg.index. 150d722e3fbSopenharmony_ci */ 151d722e3fbSopenharmony_ci QPU_MUX_SMALL_IMM, 152d722e3fbSopenharmony_ci}; 153d722e3fbSopenharmony_ci 154d722e3fbSopenharmony_cienum qpu_cond { 155d722e3fbSopenharmony_ci QPU_COND_NEVER, 156d722e3fbSopenharmony_ci QPU_COND_ALWAYS, 157d722e3fbSopenharmony_ci QPU_COND_ZS, 158d722e3fbSopenharmony_ci QPU_COND_ZC, 159d722e3fbSopenharmony_ci QPU_COND_NS, 160d722e3fbSopenharmony_ci QPU_COND_NC, 161d722e3fbSopenharmony_ci QPU_COND_CS, 162d722e3fbSopenharmony_ci QPU_COND_CC, 163d722e3fbSopenharmony_ci}; 164d722e3fbSopenharmony_ci 165d722e3fbSopenharmony_cienum qpu_pack_mul { 166d722e3fbSopenharmony_ci QPU_PACK_MUL_NOP, 167d722e3fbSopenharmony_ci QPU_PACK_MUL_8888 = 3, /* replicated to each 8 bits of the 32-bit dst. */ 168d722e3fbSopenharmony_ci QPU_PACK_MUL_8A, 169d722e3fbSopenharmony_ci QPU_PACK_MUL_8B, 170d722e3fbSopenharmony_ci QPU_PACK_MUL_8C, 171d722e3fbSopenharmony_ci QPU_PACK_MUL_8D, 172d722e3fbSopenharmony_ci}; 173d722e3fbSopenharmony_ci 174d722e3fbSopenharmony_cienum qpu_pack_a { 175d722e3fbSopenharmony_ci QPU_PACK_A_NOP, 176d722e3fbSopenharmony_ci /* convert to 16 bit float if float input, or to int16. */ 177d722e3fbSopenharmony_ci QPU_PACK_A_16A, 178d722e3fbSopenharmony_ci QPU_PACK_A_16B, 179d722e3fbSopenharmony_ci /* replicated to each 8 bits of the 32-bit dst. */ 180d722e3fbSopenharmony_ci QPU_PACK_A_8888, 181d722e3fbSopenharmony_ci /* Convert to 8-bit unsigned int. */ 182d722e3fbSopenharmony_ci QPU_PACK_A_8A, 183d722e3fbSopenharmony_ci QPU_PACK_A_8B, 184d722e3fbSopenharmony_ci QPU_PACK_A_8C, 185d722e3fbSopenharmony_ci QPU_PACK_A_8D, 186d722e3fbSopenharmony_ci 187d722e3fbSopenharmony_ci /* Saturating variants of the previous instructions. */ 188d722e3fbSopenharmony_ci QPU_PACK_A_32_SAT, /* int-only */ 189d722e3fbSopenharmony_ci QPU_PACK_A_16A_SAT, /* int or float */ 190d722e3fbSopenharmony_ci QPU_PACK_A_16B_SAT, 191d722e3fbSopenharmony_ci QPU_PACK_A_8888_SAT, 192d722e3fbSopenharmony_ci QPU_PACK_A_8A_SAT, 193d722e3fbSopenharmony_ci QPU_PACK_A_8B_SAT, 194d722e3fbSopenharmony_ci QPU_PACK_A_8C_SAT, 195d722e3fbSopenharmony_ci QPU_PACK_A_8D_SAT, 196d722e3fbSopenharmony_ci}; 197d722e3fbSopenharmony_ci 198d722e3fbSopenharmony_cienum qpu_unpack { 199d722e3fbSopenharmony_ci QPU_UNPACK_NOP, 200d722e3fbSopenharmony_ci QPU_UNPACK_16A, 201d722e3fbSopenharmony_ci QPU_UNPACK_16B, 202d722e3fbSopenharmony_ci QPU_UNPACK_8D_REP, 203d722e3fbSopenharmony_ci QPU_UNPACK_8A, 204d722e3fbSopenharmony_ci QPU_UNPACK_8B, 205d722e3fbSopenharmony_ci QPU_UNPACK_8C, 206d722e3fbSopenharmony_ci QPU_UNPACK_8D, 207d722e3fbSopenharmony_ci}; 208d722e3fbSopenharmony_ci 209d722e3fbSopenharmony_ci#define QPU_MASK(high, low) ((((uint64_t)1<<((high)-(low)+1))-1)<<(low)) 210d722e3fbSopenharmony_ci/* Using the GNU statement expression extension */ 211d722e3fbSopenharmony_ci#define QPU_SET_FIELD(value, field) \ 212d722e3fbSopenharmony_ci ({ \ 213d722e3fbSopenharmony_ci uint64_t fieldval = (uint64_t)(value) << field ## _SHIFT; \ 214d722e3fbSopenharmony_ci assert((fieldval & ~ field ## _MASK) == 0); \ 215d722e3fbSopenharmony_ci fieldval & field ## _MASK; \ 216d722e3fbSopenharmony_ci }) 217d722e3fbSopenharmony_ci 218d722e3fbSopenharmony_ci#define QPU_GET_FIELD(word, field) ((uint32_t)(((word) & field ## _MASK) >> field ## _SHIFT)) 219d722e3fbSopenharmony_ci 220d722e3fbSopenharmony_ci#define QPU_UPDATE_FIELD(inst, value, field) \ 221d722e3fbSopenharmony_ci (((inst) & ~(field ## _MASK)) | QPU_SET_FIELD(value, field)) 222d722e3fbSopenharmony_ci 223d722e3fbSopenharmony_ci#define QPU_SIG_SHIFT 60 224d722e3fbSopenharmony_ci#define QPU_SIG_MASK QPU_MASK(63, 60) 225d722e3fbSopenharmony_ci 226d722e3fbSopenharmony_ci#define QPU_UNPACK_SHIFT 57 227d722e3fbSopenharmony_ci#define QPU_UNPACK_MASK QPU_MASK(59, 57) 228d722e3fbSopenharmony_ci 229d722e3fbSopenharmony_ci/** 230d722e3fbSopenharmony_ci * If set, the pack field means PACK_MUL or R4 packing, instead of normal 231d722e3fbSopenharmony_ci * regfile a packing. 232d722e3fbSopenharmony_ci */ 233d722e3fbSopenharmony_ci#define QPU_PM ((uint64_t)1 << 56) 234d722e3fbSopenharmony_ci 235d722e3fbSopenharmony_ci#define QPU_PACK_SHIFT 52 236d722e3fbSopenharmony_ci#define QPU_PACK_MASK QPU_MASK(55, 52) 237d722e3fbSopenharmony_ci 238d722e3fbSopenharmony_ci#define QPU_COND_ADD_SHIFT 49 239d722e3fbSopenharmony_ci#define QPU_COND_ADD_MASK QPU_MASK(51, 49) 240d722e3fbSopenharmony_ci#define QPU_COND_MUL_SHIFT 46 241d722e3fbSopenharmony_ci#define QPU_COND_MUL_MASK QPU_MASK(48, 46) 242d722e3fbSopenharmony_ci 243d722e3fbSopenharmony_ci#define QPU_SF ((uint64_t)1 << 45) 244d722e3fbSopenharmony_ci 245d722e3fbSopenharmony_ci#define QPU_WADDR_ADD_SHIFT 38 246d722e3fbSopenharmony_ci#define QPU_WADDR_ADD_MASK QPU_MASK(43, 38) 247d722e3fbSopenharmony_ci#define QPU_WADDR_MUL_SHIFT 32 248d722e3fbSopenharmony_ci#define QPU_WADDR_MUL_MASK QPU_MASK(37, 32) 249d722e3fbSopenharmony_ci 250d722e3fbSopenharmony_ci#define QPU_OP_MUL_SHIFT 29 251d722e3fbSopenharmony_ci#define QPU_OP_MUL_MASK QPU_MASK(31, 29) 252d722e3fbSopenharmony_ci 253d722e3fbSopenharmony_ci#define QPU_RADDR_A_SHIFT 18 254d722e3fbSopenharmony_ci#define QPU_RADDR_A_MASK QPU_MASK(23, 18) 255d722e3fbSopenharmony_ci#define QPU_RADDR_B_SHIFT 12 256d722e3fbSopenharmony_ci#define QPU_RADDR_B_MASK QPU_MASK(17, 12) 257d722e3fbSopenharmony_ci#define QPU_SMALL_IMM_SHIFT 12 258d722e3fbSopenharmony_ci#define QPU_SMALL_IMM_MASK QPU_MASK(17, 12) 259d722e3fbSopenharmony_ci 260d722e3fbSopenharmony_ci#define QPU_ADD_A_SHIFT 9 261d722e3fbSopenharmony_ci#define QPU_ADD_A_MASK QPU_MASK(11, 9) 262d722e3fbSopenharmony_ci#define QPU_ADD_B_SHIFT 6 263d722e3fbSopenharmony_ci#define QPU_ADD_B_MASK QPU_MASK(8, 6) 264d722e3fbSopenharmony_ci#define QPU_MUL_A_SHIFT 3 265d722e3fbSopenharmony_ci#define QPU_MUL_A_MASK QPU_MASK(5, 3) 266d722e3fbSopenharmony_ci#define QPU_MUL_B_SHIFT 0 267d722e3fbSopenharmony_ci#define QPU_MUL_B_MASK QPU_MASK(2, 0) 268d722e3fbSopenharmony_ci 269d722e3fbSopenharmony_ci#define QPU_WS ((uint64_t)1 << 44) 270d722e3fbSopenharmony_ci 271d722e3fbSopenharmony_ci#define QPU_OP_ADD_SHIFT 24 272d722e3fbSopenharmony_ci#define QPU_OP_ADD_MASK QPU_MASK(28, 24) 273d722e3fbSopenharmony_ci 274d722e3fbSopenharmony_ci#endif /* VC4_QPU_DEFINES_H */ 275