162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2019 Advanced Micro Devices, Inc.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
1262306a36Sopenharmony_ci * all copies or substantial portions of the Software.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#ifndef NVD_H
2562306a36Sopenharmony_ci#define NVD_H
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/**
2862306a36Sopenharmony_ci * Navi's PM4 definitions
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_ci#define	PACKET_TYPE0	0
3162306a36Sopenharmony_ci#define	PACKET_TYPE1	1
3262306a36Sopenharmony_ci#define	PACKET_TYPE2	2
3362306a36Sopenharmony_ci#define	PACKET_TYPE3	3
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define CP_PACKET_GET_TYPE(h) (((h) >> 30) & 3)
3662306a36Sopenharmony_ci#define CP_PACKET_GET_COUNT(h) (((h) >> 16) & 0x3FFF)
3762306a36Sopenharmony_ci#define CP_PACKET0_GET_REG(h) ((h) & 0xFFFF)
3862306a36Sopenharmony_ci#define CP_PACKET3_GET_OPCODE(h) (((h) >> 8) & 0xFF)
3962306a36Sopenharmony_ci#define PACKET0(reg, n)	((PACKET_TYPE0 << 30) |				\
4062306a36Sopenharmony_ci			 ((reg) & 0xFFFF) |			\
4162306a36Sopenharmony_ci			 ((n) & 0x3FFF) << 16)
4262306a36Sopenharmony_ci#define CP_PACKET2			0x80000000
4362306a36Sopenharmony_ci#define		PACKET2_PAD_SHIFT		0
4462306a36Sopenharmony_ci#define		PACKET2_PAD_MASK		(0x3fffffff << 0)
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define PACKET2(v)	(CP_PACKET2 | REG_SET(PACKET2_PAD, (v)))
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define PACKET3(op, n)	((PACKET_TYPE3 << 30) |				\
4962306a36Sopenharmony_ci			 (((op) & 0xFF) << 8) |				\
5062306a36Sopenharmony_ci			 ((n) & 0x3FFF) << 16)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define PACKET3_COMPUTE(op, n) (PACKET3(op, n) | 1 << 1)
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci/* Packet 3 types */
5562306a36Sopenharmony_ci#define	PACKET3_NOP					0x10
5662306a36Sopenharmony_ci#define	PACKET3_SET_BASE				0x11
5762306a36Sopenharmony_ci#define		PACKET3_BASE_INDEX(x)                  ((x) << 0)
5862306a36Sopenharmony_ci#define			CE_PARTITION_BASE		3
5962306a36Sopenharmony_ci#define	PACKET3_CLEAR_STATE				0x12
6062306a36Sopenharmony_ci#define	PACKET3_INDEX_BUFFER_SIZE			0x13
6162306a36Sopenharmony_ci#define	PACKET3_DISPATCH_DIRECT				0x15
6262306a36Sopenharmony_ci#define	PACKET3_DISPATCH_INDIRECT			0x16
6362306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER_END			0x17
6462306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER_CNST_END		0x19
6562306a36Sopenharmony_ci#define	PACKET3_ATOMIC_GDS				0x1D
6662306a36Sopenharmony_ci#define	PACKET3_ATOMIC_MEM				0x1E
6762306a36Sopenharmony_ci#define	PACKET3_OCCLUSION_QUERY				0x1F
6862306a36Sopenharmony_ci#define	PACKET3_SET_PREDICATION				0x20
6962306a36Sopenharmony_ci#define	PACKET3_REG_RMW					0x21
7062306a36Sopenharmony_ci#define	PACKET3_COND_EXEC				0x22
7162306a36Sopenharmony_ci#define	PACKET3_PRED_EXEC				0x23
7262306a36Sopenharmony_ci#define	PACKET3_DRAW_INDIRECT				0x24
7362306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_INDIRECT			0x25
7462306a36Sopenharmony_ci#define	PACKET3_INDEX_BASE				0x26
7562306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_2				0x27
7662306a36Sopenharmony_ci#define	PACKET3_CONTEXT_CONTROL				0x28
7762306a36Sopenharmony_ci#define	PACKET3_INDEX_TYPE				0x2A
7862306a36Sopenharmony_ci#define	PACKET3_DRAW_INDIRECT_MULTI			0x2C
7962306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_AUTO				0x2D
8062306a36Sopenharmony_ci#define	PACKET3_NUM_INSTANCES				0x2F
8162306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_MULTI_AUTO			0x30
8262306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER_PRIV			0x32
8362306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER_CNST			0x33
8462306a36Sopenharmony_ci#define	PACKET3_COND_INDIRECT_BUFFER_CNST		0x33
8562306a36Sopenharmony_ci#define	PACKET3_STRMOUT_BUFFER_UPDATE			0x34
8662306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_OFFSET_2			0x35
8762306a36Sopenharmony_ci#define	PACKET3_DRAW_PREAMBLE				0x36
8862306a36Sopenharmony_ci#define	PACKET3_WRITE_DATA				0x37
8962306a36Sopenharmony_ci#define		WRITE_DATA_DST_SEL(x)                   ((x) << 8)
9062306a36Sopenharmony_ci		/* 0 - register
9162306a36Sopenharmony_ci		 * 1 - memory (sync - via GRBM)
9262306a36Sopenharmony_ci		 * 2 - gl2
9362306a36Sopenharmony_ci		 * 3 - gds
9462306a36Sopenharmony_ci		 * 4 - reserved
9562306a36Sopenharmony_ci		 * 5 - memory (async - direct)
9662306a36Sopenharmony_ci		 */
9762306a36Sopenharmony_ci#define		WR_ONE_ADDR                             (1 << 16)
9862306a36Sopenharmony_ci#define		WR_CONFIRM                              (1 << 20)
9962306a36Sopenharmony_ci#define		WRITE_DATA_CACHE_POLICY(x)              ((x) << 25)
10062306a36Sopenharmony_ci		/* 0 - LRU
10162306a36Sopenharmony_ci		 * 1 - Stream
10262306a36Sopenharmony_ci		 */
10362306a36Sopenharmony_ci#define		WRITE_DATA_ENGINE_SEL(x)                ((x) << 30)
10462306a36Sopenharmony_ci		/* 0 - me
10562306a36Sopenharmony_ci		 * 1 - pfp
10662306a36Sopenharmony_ci		 * 2 - ce
10762306a36Sopenharmony_ci		 */
10862306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_INDIRECT_MULTI		0x38
10962306a36Sopenharmony_ci#define	PACKET3_MEM_SEMAPHORE				0x39
11062306a36Sopenharmony_ci#              define PACKET3_SEM_USE_MAILBOX       (0x1 << 16)
11162306a36Sopenharmony_ci#              define PACKET3_SEM_SEL_SIGNAL_TYPE   (0x1 << 20) /* 0 = increment, 1 = write 1 */
11262306a36Sopenharmony_ci#              define PACKET3_SEM_SEL_SIGNAL	    (0x6 << 29)
11362306a36Sopenharmony_ci#              define PACKET3_SEM_SEL_WAIT	    (0x7 << 29)
11462306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_MULTI_INST			0x3A
11562306a36Sopenharmony_ci#define	PACKET3_COPY_DW					0x3B
11662306a36Sopenharmony_ci#define	PACKET3_WAIT_REG_MEM				0x3C
11762306a36Sopenharmony_ci#define		WAIT_REG_MEM_FUNCTION(x)                ((x) << 0)
11862306a36Sopenharmony_ci		/* 0 - always
11962306a36Sopenharmony_ci		 * 1 - <
12062306a36Sopenharmony_ci		 * 2 - <=
12162306a36Sopenharmony_ci		 * 3 - ==
12262306a36Sopenharmony_ci		 * 4 - !=
12362306a36Sopenharmony_ci		 * 5 - >=
12462306a36Sopenharmony_ci		 * 6 - >
12562306a36Sopenharmony_ci		 */
12662306a36Sopenharmony_ci#define		WAIT_REG_MEM_MEM_SPACE(x)               ((x) << 4)
12762306a36Sopenharmony_ci		/* 0 - reg
12862306a36Sopenharmony_ci		 * 1 - mem
12962306a36Sopenharmony_ci		 */
13062306a36Sopenharmony_ci#define		WAIT_REG_MEM_OPERATION(x)               ((x) << 6)
13162306a36Sopenharmony_ci		/* 0 - wait_reg_mem
13262306a36Sopenharmony_ci		 * 1 - wr_wait_wr_reg
13362306a36Sopenharmony_ci		 */
13462306a36Sopenharmony_ci#define		WAIT_REG_MEM_ENGINE(x)                  ((x) << 8)
13562306a36Sopenharmony_ci		/* 0 - me
13662306a36Sopenharmony_ci		 * 1 - pfp
13762306a36Sopenharmony_ci		 */
13862306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER				0x3F
13962306a36Sopenharmony_ci#define		INDIRECT_BUFFER_VALID                   (1 << 23)
14062306a36Sopenharmony_ci#define		INDIRECT_BUFFER_CACHE_POLICY(x)         ((x) << 28)
14162306a36Sopenharmony_ci		/* 0 - LRU
14262306a36Sopenharmony_ci		 * 1 - Stream
14362306a36Sopenharmony_ci		 * 2 - Bypass
14462306a36Sopenharmony_ci		 */
14562306a36Sopenharmony_ci#define		INDIRECT_BUFFER_PRE_ENB(x)		((x) << 21)
14662306a36Sopenharmony_ci#define		INDIRECT_BUFFER_PRE_RESUME(x)           ((x) << 30)
14762306a36Sopenharmony_ci#define	PACKET3_COND_INDIRECT_BUFFER			0x3F
14862306a36Sopenharmony_ci#define	PACKET3_COPY_DATA				0x40
14962306a36Sopenharmony_ci#define	PACKET3_CP_DMA					0x41
15062306a36Sopenharmony_ci#define	PACKET3_PFP_SYNC_ME				0x42
15162306a36Sopenharmony_ci#define	PACKET3_SURFACE_SYNC				0x43
15262306a36Sopenharmony_ci#define	PACKET3_ME_INITIALIZE				0x44
15362306a36Sopenharmony_ci#define	PACKET3_COND_WRITE				0x45
15462306a36Sopenharmony_ci#define	PACKET3_EVENT_WRITE				0x46
15562306a36Sopenharmony_ci#define		EVENT_TYPE(x)                           ((x) << 0)
15662306a36Sopenharmony_ci#define		EVENT_INDEX(x)                          ((x) << 8)
15762306a36Sopenharmony_ci		/* 0 - any non-TS event
15862306a36Sopenharmony_ci		 * 1 - ZPASS_DONE, PIXEL_PIPE_STAT_*
15962306a36Sopenharmony_ci		 * 2 - SAMPLE_PIPELINESTAT
16062306a36Sopenharmony_ci		 * 3 - SAMPLE_STREAMOUTSTAT*
16162306a36Sopenharmony_ci		 * 4 - *S_PARTIAL_FLUSH
16262306a36Sopenharmony_ci		 */
16362306a36Sopenharmony_ci#define	PACKET3_EVENT_WRITE_EOP				0x47
16462306a36Sopenharmony_ci#define	PACKET3_EVENT_WRITE_EOS				0x48
16562306a36Sopenharmony_ci#define	PACKET3_RELEASE_MEM				0x49
16662306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_EVENT_TYPE(x)	((x) << 0)
16762306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_EVENT_INDEX(x)	((x) << 8)
16862306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GLM_WB		(1 << 12)
16962306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GLM_INV		(1 << 13)
17062306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GLV_INV		(1 << 14)
17162306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GL1_INV		(1 << 15)
17262306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GL2_US		(1 << 16)
17362306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GL2_RANGE	(1 << 17)
17462306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GL2_DISCARD	(1 << 19)
17562306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GL2_INV		(1 << 20)
17662306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_GL2_WB		(1 << 21)
17762306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_GCR_SEQ		(1 << 22)
17862306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_CACHE_POLICY(x)	((x) << 25)
17962306a36Sopenharmony_ci		/* 0 - cache_policy__me_release_mem__lru
18062306a36Sopenharmony_ci		 * 1 - cache_policy__me_release_mem__stream
18162306a36Sopenharmony_ci		 * 2 - cache_policy__me_release_mem__noa
18262306a36Sopenharmony_ci		 * 3 - cache_policy__me_release_mem__bypass
18362306a36Sopenharmony_ci		 */
18462306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_EXECUTE		(1 << 28)
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_DATA_SEL(x)		((x) << 29)
18762306a36Sopenharmony_ci		/* 0 - discard
18862306a36Sopenharmony_ci		 * 1 - send low 32bit data
18962306a36Sopenharmony_ci		 * 2 - send 64bit data
19062306a36Sopenharmony_ci		 * 3 - send 64bit GPU counter value
19162306a36Sopenharmony_ci		 * 4 - send 64bit sys counter value
19262306a36Sopenharmony_ci		 */
19362306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_INT_SEL(x)		((x) << 24)
19462306a36Sopenharmony_ci		/* 0 - none
19562306a36Sopenharmony_ci		 * 1 - interrupt only (DATA_SEL = 0)
19662306a36Sopenharmony_ci		 * 2 - interrupt when data write is confirmed
19762306a36Sopenharmony_ci		 */
19862306a36Sopenharmony_ci#define		PACKET3_RELEASE_MEM_DST_SEL(x)		((x) << 16)
19962306a36Sopenharmony_ci		/* 0 - MC
20062306a36Sopenharmony_ci		 * 1 - TC/L2
20162306a36Sopenharmony_ci		 */
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci#define	PACKET3_PREAMBLE_CNTL				0x4A
20662306a36Sopenharmony_ci#              define PACKET3_PREAMBLE_BEGIN_CLEAR_STATE     (2 << 28)
20762306a36Sopenharmony_ci#              define PACKET3_PREAMBLE_END_CLEAR_STATE       (3 << 28)
20862306a36Sopenharmony_ci#define	PACKET3_DMA_DATA				0x50
20962306a36Sopenharmony_ci/* 1. header
21062306a36Sopenharmony_ci * 2. CONTROL
21162306a36Sopenharmony_ci * 3. SRC_ADDR_LO or DATA [31:0]
21262306a36Sopenharmony_ci * 4. SRC_ADDR_HI [31:0]
21362306a36Sopenharmony_ci * 5. DST_ADDR_LO [31:0]
21462306a36Sopenharmony_ci * 6. DST_ADDR_HI [7:0]
21562306a36Sopenharmony_ci * 7. COMMAND [31:26] | BYTE_COUNT [25:0]
21662306a36Sopenharmony_ci */
21762306a36Sopenharmony_ci/* CONTROL */
21862306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_ENGINE(x)     ((x) << 0)
21962306a36Sopenharmony_ci		/* 0 - ME
22062306a36Sopenharmony_ci		 * 1 - PFP
22162306a36Sopenharmony_ci		 */
22262306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_SRC_CACHE_POLICY(x) ((x) << 13)
22362306a36Sopenharmony_ci		/* 0 - LRU
22462306a36Sopenharmony_ci		 * 1 - Stream
22562306a36Sopenharmony_ci		 */
22662306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_DST_SEL(x)  ((x) << 20)
22762306a36Sopenharmony_ci		/* 0 - DST_ADDR using DAS
22862306a36Sopenharmony_ci		 * 1 - GDS
22962306a36Sopenharmony_ci		 * 3 - DST_ADDR using L2
23062306a36Sopenharmony_ci		 */
23162306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_DST_CACHE_POLICY(x) ((x) << 25)
23262306a36Sopenharmony_ci		/* 0 - LRU
23362306a36Sopenharmony_ci		 * 1 - Stream
23462306a36Sopenharmony_ci		 */
23562306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_SRC_SEL(x)  ((x) << 29)
23662306a36Sopenharmony_ci		/* 0 - SRC_ADDR using SAS
23762306a36Sopenharmony_ci		 * 1 - GDS
23862306a36Sopenharmony_ci		 * 2 - DATA
23962306a36Sopenharmony_ci		 * 3 - SRC_ADDR using L2
24062306a36Sopenharmony_ci		 */
24162306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CP_SYNC     (1 << 31)
24262306a36Sopenharmony_ci/* COMMAND */
24362306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_SAS     (1 << 26)
24462306a36Sopenharmony_ci		/* 0 - memory
24562306a36Sopenharmony_ci		 * 1 - register
24662306a36Sopenharmony_ci		 */
24762306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_DAS     (1 << 27)
24862306a36Sopenharmony_ci		/* 0 - memory
24962306a36Sopenharmony_ci		 * 1 - register
25062306a36Sopenharmony_ci		 */
25162306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_SAIC    (1 << 28)
25262306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_DAIC    (1 << 29)
25362306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_RAW_WAIT  (1 << 30)
25462306a36Sopenharmony_ci#define	PACKET3_CONTEXT_REG_RMW				0x51
25562306a36Sopenharmony_ci#define	PACKET3_GFX_CNTX_UPDATE				0x52
25662306a36Sopenharmony_ci#define	PACKET3_BLK_CNTX_UPDATE				0x53
25762306a36Sopenharmony_ci#define	PACKET3_INCR_UPDT_STATE				0x55
25862306a36Sopenharmony_ci#define	PACKET3_ACQUIRE_MEM				0x58
25962306a36Sopenharmony_ci/* 1.  HEADER
26062306a36Sopenharmony_ci * 2.  COHER_CNTL [30:0]
26162306a36Sopenharmony_ci * 2.1 ENGINE_SEL [31:31]
26262306a36Sopenharmony_ci * 2.  COHER_SIZE [31:0]
26362306a36Sopenharmony_ci * 3.  COHER_SIZE_HI [7:0]
26462306a36Sopenharmony_ci * 4.  COHER_BASE_LO [31:0]
26562306a36Sopenharmony_ci * 5.  COHER_BASE_HI [23:0]
26662306a36Sopenharmony_ci * 7.  POLL_INTERVAL [15:0]
26762306a36Sopenharmony_ci * 8.  GCR_CNTL [18:0]
26862306a36Sopenharmony_ci */
26962306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GLI_INV(x) ((x) << 0)
27062306a36Sopenharmony_ci		/*
27162306a36Sopenharmony_ci		 * 0:NOP
27262306a36Sopenharmony_ci		 * 1:ALL
27362306a36Sopenharmony_ci		 * 2:RANGE
27462306a36Sopenharmony_ci		 * 3:FIRST_LAST
27562306a36Sopenharmony_ci		 */
27662306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GL1_RANGE(x) ((x) << 2)
27762306a36Sopenharmony_ci		/*
27862306a36Sopenharmony_ci		 * 0:ALL
27962306a36Sopenharmony_ci		 * 1:reserved
28062306a36Sopenharmony_ci		 * 2:RANGE
28162306a36Sopenharmony_ci		 * 3:FIRST_LAST
28262306a36Sopenharmony_ci		 */
28362306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GLM_WB(x) ((x) << 4)
28462306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GLM_INV(x) ((x) << 5)
28562306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GLK_WB(x) ((x) << 6)
28662306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GLK_INV(x) ((x) << 7)
28762306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GLV_INV(x) ((x) << 8)
28862306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GL1_INV(x) ((x) << 9)
28962306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GL2_US(x) ((x) << 10)
29062306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GL2_RANGE(x) ((x) << 11)
29162306a36Sopenharmony_ci		/*
29262306a36Sopenharmony_ci		 * 0:ALL
29362306a36Sopenharmony_ci		 * 1:VOL
29462306a36Sopenharmony_ci		 * 2:RANGE
29562306a36Sopenharmony_ci		 * 3:FIRST_LAST
29662306a36Sopenharmony_ci		 */
29762306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GL2_DISCARD(x)  ((x) << 13)
29862306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GL2_INV(x) ((x) << 14)
29962306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_GL2_WB(x) ((x) << 15)
30062306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_CNTL_SEQ(x) ((x) << 16)
30162306a36Sopenharmony_ci		/*
30262306a36Sopenharmony_ci		 * 0: PARALLEL
30362306a36Sopenharmony_ci		 * 1: FORWARD
30462306a36Sopenharmony_ci		 * 2: REVERSE
30562306a36Sopenharmony_ci		 */
30662306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_GCR_RANGE_IS_PA  (1 << 18)
30762306a36Sopenharmony_ci#define	PACKET3_REWIND					0x59
30862306a36Sopenharmony_ci#define	PACKET3_INTERRUPT				0x5A
30962306a36Sopenharmony_ci#define	PACKET3_GEN_PDEPTE				0x5B
31062306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER_PASID			0x5C
31162306a36Sopenharmony_ci#define	PACKET3_PRIME_UTCL2				0x5D
31262306a36Sopenharmony_ci#define	PACKET3_LOAD_UCONFIG_REG			0x5E
31362306a36Sopenharmony_ci#define	PACKET3_LOAD_SH_REG				0x5F
31462306a36Sopenharmony_ci#define	PACKET3_LOAD_CONFIG_REG				0x60
31562306a36Sopenharmony_ci#define	PACKET3_LOAD_CONTEXT_REG			0x61
31662306a36Sopenharmony_ci#define	PACKET3_LOAD_COMPUTE_STATE			0x62
31762306a36Sopenharmony_ci#define	PACKET3_LOAD_SH_REG_INDEX			0x63
31862306a36Sopenharmony_ci#define	PACKET3_SET_CONFIG_REG				0x68
31962306a36Sopenharmony_ci#define		PACKET3_SET_CONFIG_REG_START			0x00002000
32062306a36Sopenharmony_ci#define		PACKET3_SET_CONFIG_REG_END			0x00002c00
32162306a36Sopenharmony_ci#define	PACKET3_SET_CONTEXT_REG				0x69
32262306a36Sopenharmony_ci#define		PACKET3_SET_CONTEXT_REG_START			0x0000a000
32362306a36Sopenharmony_ci#define		PACKET3_SET_CONTEXT_REG_END			0x0000a400
32462306a36Sopenharmony_ci#define	PACKET3_SET_CONTEXT_REG_INDEX			0x6A
32562306a36Sopenharmony_ci#define	PACKET3_SET_VGPR_REG_DI_MULTI			0x71
32662306a36Sopenharmony_ci#define	PACKET3_SET_SH_REG_DI				0x72
32762306a36Sopenharmony_ci#define	PACKET3_SET_CONTEXT_REG_INDIRECT		0x73
32862306a36Sopenharmony_ci#define	PACKET3_SET_SH_REG_DI_MULTI			0x74
32962306a36Sopenharmony_ci#define	PACKET3_GFX_PIPE_LOCK				0x75
33062306a36Sopenharmony_ci#define	PACKET3_SET_SH_REG				0x76
33162306a36Sopenharmony_ci#define		PACKET3_SET_SH_REG_START			0x00002c00
33262306a36Sopenharmony_ci#define		PACKET3_SET_SH_REG_END				0x00003000
33362306a36Sopenharmony_ci#define	PACKET3_SET_SH_REG_OFFSET			0x77
33462306a36Sopenharmony_ci#define	PACKET3_SET_QUEUE_REG				0x78
33562306a36Sopenharmony_ci#define	PACKET3_SET_UCONFIG_REG				0x79
33662306a36Sopenharmony_ci#define		PACKET3_SET_UCONFIG_REG_START			0x0000c000
33762306a36Sopenharmony_ci#define		PACKET3_SET_UCONFIG_REG_END			0x0000c400
33862306a36Sopenharmony_ci#define	PACKET3_SET_UCONFIG_REG_INDEX			0x7A
33962306a36Sopenharmony_ci#define	PACKET3_FORWARD_HEADER				0x7C
34062306a36Sopenharmony_ci#define	PACKET3_SCRATCH_RAM_WRITE			0x7D
34162306a36Sopenharmony_ci#define	PACKET3_SCRATCH_RAM_READ			0x7E
34262306a36Sopenharmony_ci#define	PACKET3_LOAD_CONST_RAM				0x80
34362306a36Sopenharmony_ci#define	PACKET3_WRITE_CONST_RAM				0x81
34462306a36Sopenharmony_ci#define	PACKET3_DUMP_CONST_RAM				0x83
34562306a36Sopenharmony_ci#define	PACKET3_INCREMENT_CE_COUNTER			0x84
34662306a36Sopenharmony_ci#define	PACKET3_INCREMENT_DE_COUNTER			0x85
34762306a36Sopenharmony_ci#define	PACKET3_WAIT_ON_CE_COUNTER			0x86
34862306a36Sopenharmony_ci#define	PACKET3_WAIT_ON_DE_COUNTER_DIFF			0x88
34962306a36Sopenharmony_ci#define	PACKET3_SWITCH_BUFFER				0x8B
35062306a36Sopenharmony_ci#define	PACKET3_DISPATCH_DRAW_PREAMBLE			0x8C
35162306a36Sopenharmony_ci#define	PACKET3_DISPATCH_DRAW_PREAMBLE_ACE		0x8C
35262306a36Sopenharmony_ci#define	PACKET3_DISPATCH_DRAW				0x8D
35362306a36Sopenharmony_ci#define	PACKET3_DISPATCH_DRAW_ACE			0x8D
35462306a36Sopenharmony_ci#define	PACKET3_GET_LOD_STATS				0x8E
35562306a36Sopenharmony_ci#define	PACKET3_DRAW_MULTI_PREAMBLE			0x8F
35662306a36Sopenharmony_ci#define	PACKET3_FRAME_CONTROL				0x90
35762306a36Sopenharmony_ci#			define FRAME_TMZ	(1 << 0)
35862306a36Sopenharmony_ci#			define FRAME_CMD(x) ((x) << 28)
35962306a36Sopenharmony_ci			/*
36062306a36Sopenharmony_ci			 * x=0: tmz_begin
36162306a36Sopenharmony_ci			 * x=1: tmz_end
36262306a36Sopenharmony_ci			 */
36362306a36Sopenharmony_ci#define	PACKET3_INDEX_ATTRIBUTES_INDIRECT		0x91
36462306a36Sopenharmony_ci#define	PACKET3_WAIT_REG_MEM64				0x93
36562306a36Sopenharmony_ci#define	PACKET3_COND_PREEMPT				0x94
36662306a36Sopenharmony_ci#define	PACKET3_HDP_FLUSH				0x95
36762306a36Sopenharmony_ci#define	PACKET3_COPY_DATA_RB				0x96
36862306a36Sopenharmony_ci#define	PACKET3_INVALIDATE_TLBS				0x98
36962306a36Sopenharmony_ci#              define PACKET3_INVALIDATE_TLBS_DST_SEL(x)     ((x) << 0)
37062306a36Sopenharmony_ci#              define PACKET3_INVALIDATE_TLBS_ALL_HUB(x)     ((x) << 4)
37162306a36Sopenharmony_ci#              define PACKET3_INVALIDATE_TLBS_PASID(x)       ((x) << 5)
37262306a36Sopenharmony_ci#define	PACKET3_AQL_PACKET				0x99
37362306a36Sopenharmony_ci#define	PACKET3_DMA_DATA_FILL_MULTI			0x9A
37462306a36Sopenharmony_ci#define	PACKET3_SET_SH_REG_INDEX			0x9B
37562306a36Sopenharmony_ci#define	PACKET3_DRAW_INDIRECT_COUNT_MULTI		0x9C
37662306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_INDIRECT_COUNT_MULTI		0x9D
37762306a36Sopenharmony_ci#define	PACKET3_DUMP_CONST_RAM_OFFSET			0x9E
37862306a36Sopenharmony_ci#define	PACKET3_LOAD_CONTEXT_REG_INDEX			0x9F
37962306a36Sopenharmony_ci#define	PACKET3_SET_RESOURCES				0xA0
38062306a36Sopenharmony_ci/* 1. header
38162306a36Sopenharmony_ci * 2. CONTROL
38262306a36Sopenharmony_ci * 3. QUEUE_MASK_LO [31:0]
38362306a36Sopenharmony_ci * 4. QUEUE_MASK_HI [31:0]
38462306a36Sopenharmony_ci * 5. GWS_MASK_LO [31:0]
38562306a36Sopenharmony_ci * 6. GWS_MASK_HI [31:0]
38662306a36Sopenharmony_ci * 7. OAC_MASK [15:0]
38762306a36Sopenharmony_ci * 8. GDS_HEAP_SIZE [16:11] | GDS_HEAP_BASE [5:0]
38862306a36Sopenharmony_ci */
38962306a36Sopenharmony_ci#              define PACKET3_SET_RESOURCES_VMID_MASK(x)     ((x) << 0)
39062306a36Sopenharmony_ci#              define PACKET3_SET_RESOURCES_UNMAP_LATENTY(x) ((x) << 16)
39162306a36Sopenharmony_ci#              define PACKET3_SET_RESOURCES_QUEUE_TYPE(x)    ((x) << 29)
39262306a36Sopenharmony_ci#define PACKET3_MAP_PROCESS				0xA1
39362306a36Sopenharmony_ci#define PACKET3_MAP_QUEUES				0xA2
39462306a36Sopenharmony_ci/* 1. header
39562306a36Sopenharmony_ci * 2. CONTROL
39662306a36Sopenharmony_ci * 3. CONTROL2
39762306a36Sopenharmony_ci * 4. MQD_ADDR_LO [31:0]
39862306a36Sopenharmony_ci * 5. MQD_ADDR_HI [31:0]
39962306a36Sopenharmony_ci * 6. WPTR_ADDR_LO [31:0]
40062306a36Sopenharmony_ci * 7. WPTR_ADDR_HI [31:0]
40162306a36Sopenharmony_ci */
40262306a36Sopenharmony_ci/* CONTROL */
40362306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_QUEUE_SEL(x)       ((x) << 4)
40462306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_VMID(x)            ((x) << 8)
40562306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_QUEUE(x)           ((x) << 13)
40662306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_PIPE(x)            ((x) << 16)
40762306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_ME(x)              ((x) << 18)
40862306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_QUEUE_TYPE(x)      ((x) << 21)
40962306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_ALLOC_FORMAT(x)    ((x) << 24)
41062306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_ENGINE_SEL(x)      ((x) << 26)
41162306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_NUM_QUEUES(x)      ((x) << 29)
41262306a36Sopenharmony_ci/* CONTROL2 */
41362306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_CHECK_DISABLE(x)   ((x) << 1)
41462306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_DOORBELL_OFFSET(x) ((x) << 2)
41562306a36Sopenharmony_ci#define	PACKET3_UNMAP_QUEUES				0xA3
41662306a36Sopenharmony_ci/* 1. header
41762306a36Sopenharmony_ci * 2. CONTROL
41862306a36Sopenharmony_ci * 3. CONTROL2
41962306a36Sopenharmony_ci * 4. CONTROL3
42062306a36Sopenharmony_ci * 5. CONTROL4
42162306a36Sopenharmony_ci * 6. CONTROL5
42262306a36Sopenharmony_ci */
42362306a36Sopenharmony_ci/* CONTROL */
42462306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_ACTION(x)           ((x) << 0)
42562306a36Sopenharmony_ci		/* 0 - PREEMPT_QUEUES
42662306a36Sopenharmony_ci		 * 1 - RESET_QUEUES
42762306a36Sopenharmony_ci		 * 2 - DISABLE_PROCESS_QUEUES
42862306a36Sopenharmony_ci		 * 3 - PREEMPT_QUEUES_NO_UNMAP
42962306a36Sopenharmony_ci		 */
43062306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_QUEUE_SEL(x)        ((x) << 4)
43162306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_ENGINE_SEL(x)       ((x) << 26)
43262306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_NUM_QUEUES(x)       ((x) << 29)
43362306a36Sopenharmony_ci/* CONTROL2a */
43462306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_PASID(x)            ((x) << 0)
43562306a36Sopenharmony_ci/* CONTROL2b */
43662306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(x) ((x) << 2)
43762306a36Sopenharmony_ci/* CONTROL3a */
43862306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET1(x) ((x) << 2)
43962306a36Sopenharmony_ci/* CONTROL3b */
44062306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_RB_WPTR(x)          ((x) << 0)
44162306a36Sopenharmony_ci/* CONTROL4 */
44262306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET2(x) ((x) << 2)
44362306a36Sopenharmony_ci/* CONTROL5 */
44462306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET3(x) ((x) << 2)
44562306a36Sopenharmony_ci#define	PACKET3_QUERY_STATUS				0xA4
44662306a36Sopenharmony_ci/* 1. header
44762306a36Sopenharmony_ci * 2. CONTROL
44862306a36Sopenharmony_ci * 3. CONTROL2
44962306a36Sopenharmony_ci * 4. ADDR_LO [31:0]
45062306a36Sopenharmony_ci * 5. ADDR_HI [31:0]
45162306a36Sopenharmony_ci * 6. DATA_LO [31:0]
45262306a36Sopenharmony_ci * 7. DATA_HI [31:0]
45362306a36Sopenharmony_ci */
45462306a36Sopenharmony_ci/* CONTROL */
45562306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_CONTEXT_ID(x)       ((x) << 0)
45662306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_INTERRUPT_SEL(x)    ((x) << 28)
45762306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_COMMAND(x)          ((x) << 30)
45862306a36Sopenharmony_ci/* CONTROL2a */
45962306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_PASID(x)            ((x) << 0)
46062306a36Sopenharmony_ci/* CONTROL2b */
46162306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_DOORBELL_OFFSET(x)  ((x) << 2)
46262306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_ENG_SEL(x)          ((x) << 25)
46362306a36Sopenharmony_ci#define	PACKET3_RUN_LIST				0xA5
46462306a36Sopenharmony_ci#define	PACKET3_MAP_PROCESS_VM				0xA6
46562306a36Sopenharmony_ci/* GFX11 */
46662306a36Sopenharmony_ci#define	PACKET3_SET_Q_PREEMPTION_MODE			0xF0
46762306a36Sopenharmony_ci#              define PACKET3_SET_Q_PREEMPTION_MODE_IB_VMID(x)  ((x) << 0)
46862306a36Sopenharmony_ci#              define PACKET3_SET_Q_PREEMPTION_MODE_INIT_SHADOW_MEM    (1 << 0)
46962306a36Sopenharmony_ci
47062306a36Sopenharmony_ci#endif
471