1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2013 Advanced Micro Devices, Inc. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub 8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci * 23bf215546Sopenharmony_ci * Authors: Marek Olšák <maraeo@gmail.com> 24bf215546Sopenharmony_ci */ 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#ifndef R600D_COMMON_H 27bf215546Sopenharmony_ci#define R600D_COMMON_H 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#define R600_CONFIG_REG_OFFSET 0x08000 30bf215546Sopenharmony_ci#define R600_CONTEXT_REG_OFFSET 0x28000 31bf215546Sopenharmony_ci#define SI_SH_REG_OFFSET 0x0000B000 32bf215546Sopenharmony_ci#define SI_SH_REG_END 0x0000C000 33bf215546Sopenharmony_ci#define CIK_UCONFIG_REG_OFFSET 0x00030000 34bf215546Sopenharmony_ci#define CIK_UCONFIG_REG_END 0x00038000 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#define PKT_TYPE_S(x) (((unsigned)(x) & 0x3) << 30) 37bf215546Sopenharmony_ci#define PKT_COUNT_S(x) (((unsigned)(x) & 0x3FFF) << 16) 38bf215546Sopenharmony_ci#define PKT3_IT_OPCODE_S(x) (((unsigned)(x) & 0xFF) << 8) 39bf215546Sopenharmony_ci#define PKT3_PREDICATE(x) (((x) >> 0) & 0x1) 40bf215546Sopenharmony_ci#define PKT3(op, count, predicate) (PKT_TYPE_S(3) | PKT_COUNT_S(count) | PKT3_IT_OPCODE_S(op) | PKT3_PREDICATE(predicate)) 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_ci#define PKT3_NOP 0x10 43bf215546Sopenharmony_ci#define PKT3_SET_PREDICATION 0x20 44bf215546Sopenharmony_ci#define PKT3_STRMOUT_BUFFER_UPDATE 0x34 45bf215546Sopenharmony_ci#define STRMOUT_STORE_BUFFER_FILLED_SIZE 1 46bf215546Sopenharmony_ci#define STRMOUT_OFFSET_SOURCE(x) (((unsigned)(x) & 0x3) << 1) 47bf215546Sopenharmony_ci#define STRMOUT_OFFSET_FROM_PACKET 0 48bf215546Sopenharmony_ci#define STRMOUT_OFFSET_FROM_VGT_FILLED_SIZE 1 49bf215546Sopenharmony_ci#define STRMOUT_OFFSET_FROM_MEM 2 50bf215546Sopenharmony_ci#define STRMOUT_OFFSET_NONE 3 51bf215546Sopenharmony_ci#define STRMOUT_SELECT_BUFFER(x) (((unsigned)(x) & 0x3) << 8) 52bf215546Sopenharmony_ci#define PKT3_WAIT_REG_MEM 0x3C 53bf215546Sopenharmony_ci#define WAIT_REG_MEM_EQUAL 3 54bf215546Sopenharmony_ci#define WAIT_REG_MEM_GEQUAL 5 55bf215546Sopenharmony_ci#define WAIT_REG_MEM_MEMORY (1 << 4) 56bf215546Sopenharmony_ci#define WAIT_REG_MEM_MEM_SPACE(x) (((unsigned)(x) & 0x3) << 4) 57bf215546Sopenharmony_ci#define PKT3_COPY_DATA 0x40 58bf215546Sopenharmony_ci#define COPY_DATA_SRC_SEL(x) ((x) & 0xf) 59bf215546Sopenharmony_ci#define COPY_DATA_REG 0 60bf215546Sopenharmony_ci#define COPY_DATA_MEM 1 61bf215546Sopenharmony_ci#define COPY_DATA_PERF 4 62bf215546Sopenharmony_ci#define COPY_DATA_IMM 5 63bf215546Sopenharmony_ci#define COPY_DATA_TIMESTAMP 9 64bf215546Sopenharmony_ci#define COPY_DATA_DST_SEL(x) (((unsigned)(x) & 0xf) << 8) 65bf215546Sopenharmony_ci#define COPY_DATA_MEM_ASYNC 5 66bf215546Sopenharmony_ci#define COPY_DATA_COUNT_SEL (1 << 16) 67bf215546Sopenharmony_ci#define COPY_DATA_WR_CONFIRM (1 << 20) 68bf215546Sopenharmony_ci#define PKT3_EVENT_WRITE 0x46 69bf215546Sopenharmony_ci#define PKT3_EVENT_WRITE_EOP 0x47 70bf215546Sopenharmony_ci#define EOP_INT_SEL(x) ((x) << 24) 71bf215546Sopenharmony_ci#define EOP_INT_SEL_NONE 0 72bf215546Sopenharmony_ci#define EOP_INT_SEL_SEND_DATA_AFTER_WR_CONFIRM 3 73bf215546Sopenharmony_ci#define EOP_DATA_SEL(x) ((x) << 29) 74bf215546Sopenharmony_ci#define EOP_DATA_SEL_DISCARD 0 75bf215546Sopenharmony_ci#define EOP_DATA_SEL_VALUE_32BIT 1 76bf215546Sopenharmony_ci#define EOP_DATA_SEL_VALUE_64BIT 2 77bf215546Sopenharmony_ci#define EOP_DATA_SEL_TIMESTAMP 3 78bf215546Sopenharmony_ci#define PKT3_RELEASE_MEM 0x49 /* GFX9+ */ 79bf215546Sopenharmony_ci#define PKT3_SET_CONFIG_REG 0x68 80bf215546Sopenharmony_ci#define PKT3_SET_CONTEXT_REG 0x69 81bf215546Sopenharmony_ci#define PKT3_STRMOUT_BASE_UPDATE 0x72 /* r700 only */ 82bf215546Sopenharmony_ci#define PKT3_SURFACE_BASE_UPDATE 0x73 /* r600 only */ 83bf215546Sopenharmony_ci#define SURFACE_BASE_UPDATE_DEPTH (1 << 0) 84bf215546Sopenharmony_ci#define SURFACE_BASE_UPDATE_COLOR(x) (2 << (x)) 85bf215546Sopenharmony_ci#define SURFACE_BASE_UPDATE_COLOR_NUM(x) (((1 << x) - 1) << 1) 86bf215546Sopenharmony_ci#define SURFACE_BASE_UPDATE_STRMOUT(x) (0x200 << (x)) 87bf215546Sopenharmony_ci#define PKT3_SET_SH_REG 0x76 /* SI and later */ 88bf215546Sopenharmony_ci#define PKT3_SET_UCONFIG_REG 0x79 /* GFX7 and later */ 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci#define EVENT_TYPE_SAMPLE_STREAMOUTSTATS1 0x1 /* EG and later */ 91bf215546Sopenharmony_ci#define EVENT_TYPE_SAMPLE_STREAMOUTSTATS2 0x2 /* EG and later */ 92bf215546Sopenharmony_ci#define EVENT_TYPE_SAMPLE_STREAMOUTSTATS3 0x3 /* EG and later */ 93bf215546Sopenharmony_ci#define EVENT_TYPE_PS_PARTIAL_FLUSH 0x10 94bf215546Sopenharmony_ci#define EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT 0x14 95bf215546Sopenharmony_ci#define EVENT_TYPE_ZPASS_DONE 0x15 96bf215546Sopenharmony_ci#define EVENT_TYPE_CACHE_FLUSH_AND_INV_EVENT 0x16 97bf215546Sopenharmony_ci#define EVENT_TYPE_PERFCOUNTER_START 0x17 98bf215546Sopenharmony_ci#define EVENT_TYPE_PERFCOUNTER_STOP 0x18 99bf215546Sopenharmony_ci#define EVENT_TYPE_PIPELINESTAT_START 25 100bf215546Sopenharmony_ci#define EVENT_TYPE_PIPELINESTAT_STOP 26 101bf215546Sopenharmony_ci#define EVENT_TYPE_PERFCOUNTER_SAMPLE 0x1B 102bf215546Sopenharmony_ci#define EVENT_TYPE_SAMPLE_PIPELINESTAT 30 103bf215546Sopenharmony_ci#define EVENT_TYPE_SO_VGTSTREAMOUT_FLUSH 0x1f 104bf215546Sopenharmony_ci#define EVENT_TYPE_SAMPLE_STREAMOUTSTATS 0x20 105bf215546Sopenharmony_ci#define EVENT_TYPE_BOTTOM_OF_PIPE_TS 40 106bf215546Sopenharmony_ci#define EVENT_TYPE_FLUSH_AND_INV_DB_META 0x2c /* supported on r700+ */ 107bf215546Sopenharmony_ci#define EVENT_TYPE_FLUSH_AND_INV_CB_META 46 /* supported on r700+ */ 108bf215546Sopenharmony_ci#define EVENT_TYPE(x) ((x) << 0) 109bf215546Sopenharmony_ci#define EVENT_INDEX(x) ((x) << 8) 110bf215546Sopenharmony_ci /* 0 - any non-TS event 111bf215546Sopenharmony_ci * 1 - ZPASS_DONE 112bf215546Sopenharmony_ci * 2 - SAMPLE_PIPELINESTAT 113bf215546Sopenharmony_ci * 3 - SAMPLE_STREAMOUTSTAT* 114bf215546Sopenharmony_ci * 4 - *S_PARTIAL_FLUSH 115bf215546Sopenharmony_ci * 5 - TS events 116bf215546Sopenharmony_ci */ 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_ci#define PREDICATION_OP_CLEAR 0x0 119bf215546Sopenharmony_ci#define PREDICATION_OP_ZPASS 0x1 120bf215546Sopenharmony_ci#define PREDICATION_OP_PRIMCOUNT 0x2 121bf215546Sopenharmony_ci#define PREDICATION_OP_BOOL64 0x3 122bf215546Sopenharmony_ci#define PRED_OP(x) ((x) << 16) 123bf215546Sopenharmony_ci#define PREDICATION_CONTINUE (1 << 31) 124bf215546Sopenharmony_ci#define PREDICATION_HINT_WAIT (0 << 12) 125bf215546Sopenharmony_ci#define PREDICATION_HINT_NOWAIT_DRAW (1 << 12) 126bf215546Sopenharmony_ci#define PREDICATION_DRAW_NOT_VISIBLE (0 << 8) 127bf215546Sopenharmony_ci#define PREDICATION_DRAW_VISIBLE (1 << 8) 128bf215546Sopenharmony_ci 129bf215546Sopenharmony_ci#define V_0280A0_SWAP_STD 0x00000000 130bf215546Sopenharmony_ci#define V_0280A0_SWAP_ALT 0x00000001 131bf215546Sopenharmony_ci#define V_0280A0_SWAP_STD_REV 0x00000002 132bf215546Sopenharmony_ci#define V_0280A0_SWAP_ALT_REV 0x00000003 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_ci#define EG_S_028C70_FAST_CLEAR(x) (((unsigned)(x) & 0x1) << 17) 135bf215546Sopenharmony_ci#define SI_S_028C70_FAST_CLEAR(x) (((unsigned)(x) & 0x1) << 13) 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_ci#endif 138