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