162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2014 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#ifndef SOC15_H
2462306a36Sopenharmony_ci#define SOC15_H
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#define GFX9_NUM_GFX_RINGS     1
2762306a36Sopenharmony_ci#define GFX9_NUM_COMPUTE_RINGS 8
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/*
3062306a36Sopenharmony_ci * PM4
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci#define	PACKET_TYPE0	0
3362306a36Sopenharmony_ci#define	PACKET_TYPE1	1
3462306a36Sopenharmony_ci#define	PACKET_TYPE2	2
3562306a36Sopenharmony_ci#define	PACKET_TYPE3	3
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#define CP_PACKET_GET_TYPE(h) (((h) >> 30) & 3)
3862306a36Sopenharmony_ci#define CP_PACKET_GET_COUNT(h) (((h) >> 16) & 0x3FFF)
3962306a36Sopenharmony_ci#define CP_PACKET0_GET_REG(h) ((h) & 0xFFFF)
4062306a36Sopenharmony_ci#define CP_PACKET3_GET_OPCODE(h) (((h) >> 8) & 0xFF)
4162306a36Sopenharmony_ci#define PACKET0(reg, n)	((PACKET_TYPE0 << 30) |				\
4262306a36Sopenharmony_ci			 ((reg) & 0xFFFF) |			\
4362306a36Sopenharmony_ci			 ((n) & 0x3FFF) << 16)
4462306a36Sopenharmony_ci#define CP_PACKET2			0x80000000
4562306a36Sopenharmony_ci#define		PACKET2_PAD_SHIFT		0
4662306a36Sopenharmony_ci#define		PACKET2_PAD_MASK		(0x3fffffff << 0)
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci#define PACKET2(v)	(CP_PACKET2 | REG_SET(PACKET2_PAD, (v)))
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define PACKET3(op, n)	((PACKET_TYPE3 << 30) |				\
5162306a36Sopenharmony_ci			 (((op) & 0xFF) << 8) |				\
5262306a36Sopenharmony_ci			 ((n) & 0x3FFF) << 16)
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define PACKET3_COMPUTE(op, n) (PACKET3(op, n) | 1 << 1)
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK0	0
5762306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK1	1
5862306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK2	2
5962306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK3	3
6062306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK4	4
6162306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK5	5
6262306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK6	6
6362306a36Sopenharmony_ci#define	PACKETJ_CONDITION_CHECK7	7
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define	PACKETJ_TYPE0	0
6662306a36Sopenharmony_ci#define	PACKETJ_TYPE1	1
6762306a36Sopenharmony_ci#define	PACKETJ_TYPE2	2
6862306a36Sopenharmony_ci#define	PACKETJ_TYPE3	3
6962306a36Sopenharmony_ci#define	PACKETJ_TYPE4	4
7062306a36Sopenharmony_ci#define	PACKETJ_TYPE5	5
7162306a36Sopenharmony_ci#define	PACKETJ_TYPE6	6
7262306a36Sopenharmony_ci#define	PACKETJ_TYPE7	7
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define PACKETJ(reg, r, cond, type)	((reg & 0x3FFFF) |			\
7562306a36Sopenharmony_ci			 ((r & 0x3F) << 18) |			\
7662306a36Sopenharmony_ci			 ((cond & 0xF) << 24) |				\
7762306a36Sopenharmony_ci			 ((type & 0xF) << 28))
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci/* Packet 3 types */
8062306a36Sopenharmony_ci#define	PACKET3_NOP					0x10
8162306a36Sopenharmony_ci#define	PACKET3_SET_BASE				0x11
8262306a36Sopenharmony_ci#define		PACKET3_BASE_INDEX(x)                  ((x) << 0)
8362306a36Sopenharmony_ci#define			CE_PARTITION_BASE		3
8462306a36Sopenharmony_ci#define	PACKET3_CLEAR_STATE				0x12
8562306a36Sopenharmony_ci#define	PACKET3_INDEX_BUFFER_SIZE			0x13
8662306a36Sopenharmony_ci#define	PACKET3_DISPATCH_DIRECT				0x15
8762306a36Sopenharmony_ci#define	PACKET3_DISPATCH_INDIRECT			0x16
8862306a36Sopenharmony_ci#define	PACKET3_ATOMIC_GDS				0x1D
8962306a36Sopenharmony_ci#define	PACKET3_ATOMIC_MEM				0x1E
9062306a36Sopenharmony_ci#define	PACKET3_OCCLUSION_QUERY				0x1F
9162306a36Sopenharmony_ci#define	PACKET3_SET_PREDICATION				0x20
9262306a36Sopenharmony_ci#define	PACKET3_REG_RMW					0x21
9362306a36Sopenharmony_ci#define	PACKET3_COND_EXEC				0x22
9462306a36Sopenharmony_ci#define	PACKET3_PRED_EXEC				0x23
9562306a36Sopenharmony_ci#define	PACKET3_DRAW_INDIRECT				0x24
9662306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_INDIRECT			0x25
9762306a36Sopenharmony_ci#define	PACKET3_INDEX_BASE				0x26
9862306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_2				0x27
9962306a36Sopenharmony_ci#define	PACKET3_CONTEXT_CONTROL				0x28
10062306a36Sopenharmony_ci#define	PACKET3_INDEX_TYPE				0x2A
10162306a36Sopenharmony_ci#define	PACKET3_DRAW_INDIRECT_MULTI			0x2C
10262306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_AUTO				0x2D
10362306a36Sopenharmony_ci#define	PACKET3_NUM_INSTANCES				0x2F
10462306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_MULTI_AUTO			0x30
10562306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER_CONST			0x33
10662306a36Sopenharmony_ci#define	PACKET3_STRMOUT_BUFFER_UPDATE			0x34
10762306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_OFFSET_2			0x35
10862306a36Sopenharmony_ci#define	PACKET3_DRAW_PREAMBLE				0x36
10962306a36Sopenharmony_ci#define	PACKET3_WRITE_DATA				0x37
11062306a36Sopenharmony_ci#define		WRITE_DATA_DST_SEL(x)                   ((x) << 8)
11162306a36Sopenharmony_ci		/* 0 - register
11262306a36Sopenharmony_ci		 * 1 - memory (sync - via GRBM)
11362306a36Sopenharmony_ci		 * 2 - gl2
11462306a36Sopenharmony_ci		 * 3 - gds
11562306a36Sopenharmony_ci		 * 4 - reserved
11662306a36Sopenharmony_ci		 * 5 - memory (async - direct)
11762306a36Sopenharmony_ci		 */
11862306a36Sopenharmony_ci#define		WR_ONE_ADDR                             (1 << 16)
11962306a36Sopenharmony_ci#define		WR_CONFIRM                              (1 << 20)
12062306a36Sopenharmony_ci#define		WRITE_DATA_CACHE_POLICY(x)              ((x) << 25)
12162306a36Sopenharmony_ci		/* 0 - LRU
12262306a36Sopenharmony_ci		 * 1 - Stream
12362306a36Sopenharmony_ci		 */
12462306a36Sopenharmony_ci#define		WRITE_DATA_ENGINE_SEL(x)                ((x) << 30)
12562306a36Sopenharmony_ci		/* 0 - me
12662306a36Sopenharmony_ci		 * 1 - pfp
12762306a36Sopenharmony_ci		 * 2 - ce
12862306a36Sopenharmony_ci		 */
12962306a36Sopenharmony_ci#define	PACKET3_DRAW_INDEX_INDIRECT_MULTI		0x38
13062306a36Sopenharmony_ci#define	PACKET3_MEM_SEMAPHORE				0x39
13162306a36Sopenharmony_ci#              define PACKET3_SEM_USE_MAILBOX       (0x1 << 16)
13262306a36Sopenharmony_ci#              define PACKET3_SEM_SEL_SIGNAL_TYPE   (0x1 << 20) /* 0 = increment, 1 = write 1 */
13362306a36Sopenharmony_ci#              define PACKET3_SEM_SEL_SIGNAL	    (0x6 << 29)
13462306a36Sopenharmony_ci#              define PACKET3_SEM_SEL_WAIT	    (0x7 << 29)
13562306a36Sopenharmony_ci#define	PACKET3_WAIT_REG_MEM				0x3C
13662306a36Sopenharmony_ci#define		WAIT_REG_MEM_FUNCTION(x)                ((x) << 0)
13762306a36Sopenharmony_ci		/* 0 - always
13862306a36Sopenharmony_ci		 * 1 - <
13962306a36Sopenharmony_ci		 * 2 - <=
14062306a36Sopenharmony_ci		 * 3 - ==
14162306a36Sopenharmony_ci		 * 4 - !=
14262306a36Sopenharmony_ci		 * 5 - >=
14362306a36Sopenharmony_ci		 * 6 - >
14462306a36Sopenharmony_ci		 */
14562306a36Sopenharmony_ci#define		WAIT_REG_MEM_MEM_SPACE(x)               ((x) << 4)
14662306a36Sopenharmony_ci		/* 0 - reg
14762306a36Sopenharmony_ci		 * 1 - mem
14862306a36Sopenharmony_ci		 */
14962306a36Sopenharmony_ci#define		WAIT_REG_MEM_OPERATION(x)               ((x) << 6)
15062306a36Sopenharmony_ci		/* 0 - wait_reg_mem
15162306a36Sopenharmony_ci		 * 1 - wr_wait_wr_reg
15262306a36Sopenharmony_ci		 */
15362306a36Sopenharmony_ci#define		WAIT_REG_MEM_ENGINE(x)                  ((x) << 8)
15462306a36Sopenharmony_ci		/* 0 - me
15562306a36Sopenharmony_ci		 * 1 - pfp
15662306a36Sopenharmony_ci		 */
15762306a36Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER				0x3F
15862306a36Sopenharmony_ci#define		INDIRECT_BUFFER_VALID                   (1 << 23)
15962306a36Sopenharmony_ci#define		INDIRECT_BUFFER_CACHE_POLICY(x)         ((x) << 28)
16062306a36Sopenharmony_ci		/* 0 - LRU
16162306a36Sopenharmony_ci		 * 1 - Stream
16262306a36Sopenharmony_ci		 * 2 - Bypass
16362306a36Sopenharmony_ci		 */
16462306a36Sopenharmony_ci#define     INDIRECT_BUFFER_PRE_ENB(x)		 ((x) << 21)
16562306a36Sopenharmony_ci#define     INDIRECT_BUFFER_PRE_RESUME(x)               ((x) << 30)
16662306a36Sopenharmony_ci#define	PACKET3_COPY_DATA				0x40
16762306a36Sopenharmony_ci#define	PACKET3_PFP_SYNC_ME				0x42
16862306a36Sopenharmony_ci#define	PACKET3_COND_WRITE				0x45
16962306a36Sopenharmony_ci#define	PACKET3_EVENT_WRITE				0x46
17062306a36Sopenharmony_ci#define		EVENT_TYPE(x)                           ((x) << 0)
17162306a36Sopenharmony_ci#define		EVENT_INDEX(x)                          ((x) << 8)
17262306a36Sopenharmony_ci		/* 0 - any non-TS event
17362306a36Sopenharmony_ci		 * 1 - ZPASS_DONE, PIXEL_PIPE_STAT_*
17462306a36Sopenharmony_ci		 * 2 - SAMPLE_PIPELINESTAT
17562306a36Sopenharmony_ci		 * 3 - SAMPLE_STREAMOUTSTAT*
17662306a36Sopenharmony_ci		 * 4 - *S_PARTIAL_FLUSH
17762306a36Sopenharmony_ci		 */
17862306a36Sopenharmony_ci#define	PACKET3_RELEASE_MEM				0x49
17962306a36Sopenharmony_ci#define		EVENT_TYPE(x)                           ((x) << 0)
18062306a36Sopenharmony_ci#define		EVENT_INDEX(x)                          ((x) << 8)
18162306a36Sopenharmony_ci#define		EOP_TCL1_VOL_ACTION_EN                  (1 << 12)
18262306a36Sopenharmony_ci#define		EOP_TC_VOL_ACTION_EN                    (1 << 13) /* L2 */
18362306a36Sopenharmony_ci#define		EOP_TC_WB_ACTION_EN                     (1 << 15) /* L2 */
18462306a36Sopenharmony_ci#define		EOP_TCL1_ACTION_EN                      (1 << 16)
18562306a36Sopenharmony_ci#define		EOP_TC_ACTION_EN                        (1 << 17) /* L2 */
18662306a36Sopenharmony_ci#define		EOP_TC_NC_ACTION_EN			(1 << 19)
18762306a36Sopenharmony_ci#define		EOP_TC_MD_ACTION_EN			(1 << 21) /* L2 metadata */
18862306a36Sopenharmony_ci#define		EOP_EXEC				(1 << 28) /* For Trailing Fence */
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci#define		DATA_SEL(x)                             ((x) << 29)
19162306a36Sopenharmony_ci		/* 0 - discard
19262306a36Sopenharmony_ci		 * 1 - send low 32bit data
19362306a36Sopenharmony_ci		 * 2 - send 64bit data
19462306a36Sopenharmony_ci		 * 3 - send 64bit GPU counter value
19562306a36Sopenharmony_ci		 * 4 - send 64bit sys counter value
19662306a36Sopenharmony_ci		 */
19762306a36Sopenharmony_ci#define		INT_SEL(x)                              ((x) << 24)
19862306a36Sopenharmony_ci		/* 0 - none
19962306a36Sopenharmony_ci		 * 1 - interrupt only (DATA_SEL = 0)
20062306a36Sopenharmony_ci		 * 2 - interrupt when data write is confirmed
20162306a36Sopenharmony_ci		 */
20262306a36Sopenharmony_ci#define		DST_SEL(x)                              ((x) << 16)
20362306a36Sopenharmony_ci		/* 0 - MC
20462306a36Sopenharmony_ci		 * 1 - TC/L2
20562306a36Sopenharmony_ci		 */
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci#define	PACKET3_PREAMBLE_CNTL				0x4A
21062306a36Sopenharmony_ci#              define PACKET3_PREAMBLE_BEGIN_CLEAR_STATE     (2 << 28)
21162306a36Sopenharmony_ci#              define PACKET3_PREAMBLE_END_CLEAR_STATE       (3 << 28)
21262306a36Sopenharmony_ci#define	PACKET3_DMA_DATA				0x50
21362306a36Sopenharmony_ci/* 1. header
21462306a36Sopenharmony_ci * 2. CONTROL
21562306a36Sopenharmony_ci * 3. SRC_ADDR_LO or DATA [31:0]
21662306a36Sopenharmony_ci * 4. SRC_ADDR_HI [31:0]
21762306a36Sopenharmony_ci * 5. DST_ADDR_LO [31:0]
21862306a36Sopenharmony_ci * 6. DST_ADDR_HI [7:0]
21962306a36Sopenharmony_ci * 7. COMMAND [30:21] | BYTE_COUNT [20:0]
22062306a36Sopenharmony_ci */
22162306a36Sopenharmony_ci/* CONTROL */
22262306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_ENGINE(x)     ((x) << 0)
22362306a36Sopenharmony_ci		/* 0 - ME
22462306a36Sopenharmony_ci		 * 1 - PFP
22562306a36Sopenharmony_ci		 */
22662306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_SRC_CACHE_POLICY(x) ((x) << 13)
22762306a36Sopenharmony_ci		/* 0 - LRU
22862306a36Sopenharmony_ci		 * 1 - Stream
22962306a36Sopenharmony_ci		 */
23062306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_DST_SEL(x)  ((x) << 20)
23162306a36Sopenharmony_ci		/* 0 - DST_ADDR using DAS
23262306a36Sopenharmony_ci		 * 1 - GDS
23362306a36Sopenharmony_ci		 * 3 - DST_ADDR using L2
23462306a36Sopenharmony_ci		 */
23562306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_DST_CACHE_POLICY(x) ((x) << 25)
23662306a36Sopenharmony_ci		/* 0 - LRU
23762306a36Sopenharmony_ci		 * 1 - Stream
23862306a36Sopenharmony_ci		 */
23962306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_SRC_SEL(x)  ((x) << 29)
24062306a36Sopenharmony_ci		/* 0 - SRC_ADDR using SAS
24162306a36Sopenharmony_ci		 * 1 - GDS
24262306a36Sopenharmony_ci		 * 2 - DATA
24362306a36Sopenharmony_ci		 * 3 - SRC_ADDR using L2
24462306a36Sopenharmony_ci		 */
24562306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CP_SYNC     (1 << 31)
24662306a36Sopenharmony_ci/* COMMAND */
24762306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_SAS     (1 << 26)
24862306a36Sopenharmony_ci		/* 0 - memory
24962306a36Sopenharmony_ci		 * 1 - register
25062306a36Sopenharmony_ci		 */
25162306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_DAS     (1 << 27)
25262306a36Sopenharmony_ci		/* 0 - memory
25362306a36Sopenharmony_ci		 * 1 - register
25462306a36Sopenharmony_ci		 */
25562306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_SAIC    (1 << 28)
25662306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_DAIC    (1 << 29)
25762306a36Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_RAW_WAIT  (1 << 30)
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 * 3.  COHER_SIZE [31:0]
26362306a36Sopenharmony_ci * 4.  COHER_SIZE_HI [7:0]
26462306a36Sopenharmony_ci * 5.  COHER_BASE_LO [31:0]
26562306a36Sopenharmony_ci * 6.  COHER_BASE_HI [23:0]
26662306a36Sopenharmony_ci * 7.  POLL_INTERVAL [15:0]
26762306a36Sopenharmony_ci */
26862306a36Sopenharmony_ci/* COHER_CNTL fields for CP_COHER_CNTL */
26962306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_TC_NC_ACTION_ENA(x) ((x) << 3)
27062306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_TC_WC_ACTION_ENA(x) ((x) << 4)
27162306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_TC_INV_METADATA_ACTION_ENA(x) ((x) << 5)
27262306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_TCL1_VOL_ACTION_ENA(x) ((x) << 15)
27362306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_TC_WB_ACTION_ENA(x) ((x) << 18)
27462306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_TCL1_ACTION_ENA(x) ((x) << 22)
27562306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_TC_ACTION_ENA(x) ((x) << 23)
27662306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_CB_ACTION_ENA(x) ((x) << 25)
27762306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_DB_ACTION_ENA(x) ((x) << 26)
27862306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_SH_KCACHE_ACTION_ENA(x) ((x) << 27)
27962306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_SH_KCACHE_VOL_ACTION_ENA(x) ((x) << 28)
28062306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_SH_ICACHE_ACTION_ENA(x) ((x) << 29)
28162306a36Sopenharmony_ci#define 	PACKET3_ACQUIRE_MEM_CP_COHER_CNTL_SH_KCACHE_WB_ACTION_ENA(x) ((x) << 30)
28262306a36Sopenharmony_ci#define	PACKET3_REWIND					0x59
28362306a36Sopenharmony_ci#define	PACKET3_LOAD_UCONFIG_REG			0x5E
28462306a36Sopenharmony_ci#define	PACKET3_LOAD_SH_REG				0x5F
28562306a36Sopenharmony_ci#define	PACKET3_LOAD_CONFIG_REG				0x60
28662306a36Sopenharmony_ci#define	PACKET3_LOAD_CONTEXT_REG			0x61
28762306a36Sopenharmony_ci#define	PACKET3_SET_CONFIG_REG				0x68
28862306a36Sopenharmony_ci#define		PACKET3_SET_CONFIG_REG_START			0x00002000
28962306a36Sopenharmony_ci#define		PACKET3_SET_CONFIG_REG_END			0x00002c00
29062306a36Sopenharmony_ci#define	PACKET3_SET_CONTEXT_REG				0x69
29162306a36Sopenharmony_ci#define		PACKET3_SET_CONTEXT_REG_START			0x0000a000
29262306a36Sopenharmony_ci#define		PACKET3_SET_CONTEXT_REG_END			0x0000a400
29362306a36Sopenharmony_ci#define	PACKET3_SET_CONTEXT_REG_INDIRECT		0x73
29462306a36Sopenharmony_ci#define	PACKET3_SET_SH_REG				0x76
29562306a36Sopenharmony_ci#define		PACKET3_SET_SH_REG_START			0x00002c00
29662306a36Sopenharmony_ci#define		PACKET3_SET_SH_REG_END				0x00003000
29762306a36Sopenharmony_ci#define	PACKET3_SET_SH_REG_OFFSET			0x77
29862306a36Sopenharmony_ci#define	PACKET3_SET_QUEUE_REG				0x78
29962306a36Sopenharmony_ci#define	PACKET3_SET_UCONFIG_REG				0x79
30062306a36Sopenharmony_ci#define		PACKET3_SET_UCONFIG_REG_START			0x0000c000
30162306a36Sopenharmony_ci#define		PACKET3_SET_UCONFIG_REG_END			0x0000c400
30262306a36Sopenharmony_ci#define		PACKET3_SET_UCONFIG_REG_INDEX_TYPE		(2 << 28)
30362306a36Sopenharmony_ci#define	PACKET3_SCRATCH_RAM_WRITE			0x7D
30462306a36Sopenharmony_ci#define	PACKET3_SCRATCH_RAM_READ			0x7E
30562306a36Sopenharmony_ci#define	PACKET3_LOAD_CONST_RAM				0x80
30662306a36Sopenharmony_ci#define	PACKET3_WRITE_CONST_RAM				0x81
30762306a36Sopenharmony_ci#define	PACKET3_DUMP_CONST_RAM				0x83
30862306a36Sopenharmony_ci#define	PACKET3_INCREMENT_CE_COUNTER			0x84
30962306a36Sopenharmony_ci#define	PACKET3_INCREMENT_DE_COUNTER			0x85
31062306a36Sopenharmony_ci#define	PACKET3_WAIT_ON_CE_COUNTER			0x86
31162306a36Sopenharmony_ci#define	PACKET3_WAIT_ON_DE_COUNTER_DIFF			0x88
31262306a36Sopenharmony_ci#define	PACKET3_SWITCH_BUFFER				0x8B
31362306a36Sopenharmony_ci#define PACKET3_FRAME_CONTROL				0x90
31462306a36Sopenharmony_ci#			define FRAME_TMZ	(1 << 0)
31562306a36Sopenharmony_ci#			define FRAME_CMD(x) ((x) << 28)
31662306a36Sopenharmony_ci			/*
31762306a36Sopenharmony_ci			 * x=0: tmz_begin
31862306a36Sopenharmony_ci			 * x=1: tmz_end
31962306a36Sopenharmony_ci			 */
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci#define	PACKET3_INVALIDATE_TLBS				0x98
32262306a36Sopenharmony_ci#              define PACKET3_INVALIDATE_TLBS_DST_SEL(x)     ((x) << 0)
32362306a36Sopenharmony_ci#              define PACKET3_INVALIDATE_TLBS_ALL_HUB(x)     ((x) << 4)
32462306a36Sopenharmony_ci#              define PACKET3_INVALIDATE_TLBS_PASID(x)       ((x) << 5)
32562306a36Sopenharmony_ci#              define PACKET3_INVALIDATE_TLBS_FLUSH_TYPE(x)  ((x) << 29)
32662306a36Sopenharmony_ci#define PACKET3_SET_RESOURCES				0xA0
32762306a36Sopenharmony_ci/* 1. header
32862306a36Sopenharmony_ci * 2. CONTROL
32962306a36Sopenharmony_ci * 3. QUEUE_MASK_LO [31:0]
33062306a36Sopenharmony_ci * 4. QUEUE_MASK_HI [31:0]
33162306a36Sopenharmony_ci * 5. GWS_MASK_LO [31:0]
33262306a36Sopenharmony_ci * 6. GWS_MASK_HI [31:0]
33362306a36Sopenharmony_ci * 7. OAC_MASK [15:0]
33462306a36Sopenharmony_ci * 8. GDS_HEAP_SIZE [16:11] | GDS_HEAP_BASE [5:0]
33562306a36Sopenharmony_ci */
33662306a36Sopenharmony_ci#              define PACKET3_SET_RESOURCES_VMID_MASK(x)     ((x) << 0)
33762306a36Sopenharmony_ci#              define PACKET3_SET_RESOURCES_UNMAP_LATENTY(x) ((x) << 16)
33862306a36Sopenharmony_ci#              define PACKET3_SET_RESOURCES_QUEUE_TYPE(x)    ((x) << 29)
33962306a36Sopenharmony_ci#define PACKET3_MAP_QUEUES				0xA2
34062306a36Sopenharmony_ci/* 1. header
34162306a36Sopenharmony_ci * 2. CONTROL
34262306a36Sopenharmony_ci * 3. CONTROL2
34362306a36Sopenharmony_ci * 4. MQD_ADDR_LO [31:0]
34462306a36Sopenharmony_ci * 5. MQD_ADDR_HI [31:0]
34562306a36Sopenharmony_ci * 6. WPTR_ADDR_LO [31:0]
34662306a36Sopenharmony_ci * 7. WPTR_ADDR_HI [31:0]
34762306a36Sopenharmony_ci */
34862306a36Sopenharmony_ci/* CONTROL */
34962306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_QUEUE_SEL(x)       ((x) << 4)
35062306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_VMID(x)            ((x) << 8)
35162306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_QUEUE(x)           ((x) << 13)
35262306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_PIPE(x)            ((x) << 16)
35362306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_ME(x)              ((x) << 18)
35462306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_QUEUE_TYPE(x)      ((x) << 21)
35562306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_ALLOC_FORMAT(x)    ((x) << 24)
35662306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_ENGINE_SEL(x)      ((x) << 26)
35762306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_NUM_QUEUES(x)      ((x) << 29)
35862306a36Sopenharmony_ci/* CONTROL2 */
35962306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_CHECK_DISABLE(x)   ((x) << 1)
36062306a36Sopenharmony_ci#              define PACKET3_MAP_QUEUES_DOORBELL_OFFSET(x) ((x) << 2)
36162306a36Sopenharmony_ci#define	PACKET3_UNMAP_QUEUES				0xA3
36262306a36Sopenharmony_ci/* 1. header
36362306a36Sopenharmony_ci * 2. CONTROL
36462306a36Sopenharmony_ci * 3. CONTROL2
36562306a36Sopenharmony_ci * 4. CONTROL3
36662306a36Sopenharmony_ci * 5. CONTROL4
36762306a36Sopenharmony_ci * 6. CONTROL5
36862306a36Sopenharmony_ci */
36962306a36Sopenharmony_ci/* CONTROL */
37062306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_ACTION(x)           ((x) << 0)
37162306a36Sopenharmony_ci		/* 0 - PREEMPT_QUEUES
37262306a36Sopenharmony_ci		 * 1 - RESET_QUEUES
37362306a36Sopenharmony_ci		 * 2 - DISABLE_PROCESS_QUEUES
37462306a36Sopenharmony_ci		 * 3 - PREEMPT_QUEUES_NO_UNMAP
37562306a36Sopenharmony_ci		 */
37662306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_QUEUE_SEL(x)        ((x) << 4)
37762306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_ENGINE_SEL(x)       ((x) << 26)
37862306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_NUM_QUEUES(x)       ((x) << 29)
37962306a36Sopenharmony_ci/* CONTROL2a */
38062306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_PASID(x)            ((x) << 0)
38162306a36Sopenharmony_ci/* CONTROL2b */
38262306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET0(x) ((x) << 2)
38362306a36Sopenharmony_ci/* CONTROL3a */
38462306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET1(x) ((x) << 2)
38562306a36Sopenharmony_ci/* CONTROL3b */
38662306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_RB_WPTR(x)          ((x) << 0)
38762306a36Sopenharmony_ci/* CONTROL4 */
38862306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET2(x) ((x) << 2)
38962306a36Sopenharmony_ci/* CONTROL5 */
39062306a36Sopenharmony_ci#              define PACKET3_UNMAP_QUEUES_DOORBELL_OFFSET3(x) ((x) << 2)
39162306a36Sopenharmony_ci#define	PACKET3_QUERY_STATUS				0xA4
39262306a36Sopenharmony_ci/* 1. header
39362306a36Sopenharmony_ci * 2. CONTROL
39462306a36Sopenharmony_ci * 3. CONTROL2
39562306a36Sopenharmony_ci * 4. ADDR_LO [31:0]
39662306a36Sopenharmony_ci * 5. ADDR_HI [31:0]
39762306a36Sopenharmony_ci * 6. DATA_LO [31:0]
39862306a36Sopenharmony_ci * 7. DATA_HI [31:0]
39962306a36Sopenharmony_ci */
40062306a36Sopenharmony_ci/* CONTROL */
40162306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_CONTEXT_ID(x)       ((x) << 0)
40262306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_INTERRUPT_SEL(x)    ((x) << 28)
40362306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_COMMAND(x)          ((x) << 30)
40462306a36Sopenharmony_ci/* CONTROL2a */
40562306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_PASID(x)            ((x) << 0)
40662306a36Sopenharmony_ci/* CONTROL2b */
40762306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_DOORBELL_OFFSET(x)  ((x) << 2)
40862306a36Sopenharmony_ci#              define PACKET3_QUERY_STATUS_ENG_SEL(x)          ((x) << 25)
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_ci
41162306a36Sopenharmony_ci#define VCE_CMD_NO_OP		0x00000000
41262306a36Sopenharmony_ci#define VCE_CMD_END		0x00000001
41362306a36Sopenharmony_ci#define VCE_CMD_IB		0x00000002
41462306a36Sopenharmony_ci#define VCE_CMD_FENCE		0x00000003
41562306a36Sopenharmony_ci#define VCE_CMD_TRAP		0x00000004
41662306a36Sopenharmony_ci#define VCE_CMD_IB_AUTO 	0x00000005
41762306a36Sopenharmony_ci#define VCE_CMD_SEMAPHORE	0x00000006
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_ci#define VCE_CMD_IB_VM           0x00000102
42062306a36Sopenharmony_ci#define VCE_CMD_WAIT_GE         0x00000106
42162306a36Sopenharmony_ci#define VCE_CMD_UPDATE_PTB      0x00000107
42262306a36Sopenharmony_ci#define VCE_CMD_FLUSH_TLB       0x00000108
42362306a36Sopenharmony_ci#define VCE_CMD_REG_WRITE       0x00000109
42462306a36Sopenharmony_ci#define VCE_CMD_REG_WAIT        0x0000010a
42562306a36Sopenharmony_ci
42662306a36Sopenharmony_ci#define HEVC_ENC_CMD_NO_OP		0x00000000
42762306a36Sopenharmony_ci#define HEVC_ENC_CMD_END		0x00000001
42862306a36Sopenharmony_ci#define HEVC_ENC_CMD_FENCE		0x00000003
42962306a36Sopenharmony_ci#define HEVC_ENC_CMD_TRAP		0x00000004
43062306a36Sopenharmony_ci#define HEVC_ENC_CMD_IB_VM		0x00000102
43162306a36Sopenharmony_ci#define HEVC_ENC_CMD_REG_WRITE		0x00000109
43262306a36Sopenharmony_ci#define HEVC_ENC_CMD_REG_WAIT		0x0000010a
43362306a36Sopenharmony_ci
43462306a36Sopenharmony_ci#endif
435