18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2012 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * Authors: Alex Deucher
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci#ifndef CIK_H
258c2ecf20Sopenharmony_ci#define CIK_H
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__MASK	0xf0000000
288c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__GDDR1  0x10000000
298c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__DDR2   0x20000000
308c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__GDDR3  0x30000000
318c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__GDDR4  0x40000000
328c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__GDDR5  0x50000000
338c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__HBM    0x60000000
348c2ecf20Sopenharmony_ci#define MC_SEQ_MISC0__MT__DDR3   0xB0000000
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define CP_ME_TABLE_SIZE    96
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* display controller offsets used for crtc/cur/lut/grph/viewport/etc. */
398c2ecf20Sopenharmony_ci#define CRTC0_REGISTER_OFFSET                 (0x1b7c - 0x1b7c)
408c2ecf20Sopenharmony_ci#define CRTC1_REGISTER_OFFSET                 (0x1e7c - 0x1b7c)
418c2ecf20Sopenharmony_ci#define CRTC2_REGISTER_OFFSET                 (0x417c - 0x1b7c)
428c2ecf20Sopenharmony_ci#define CRTC3_REGISTER_OFFSET                 (0x447c - 0x1b7c)
438c2ecf20Sopenharmony_ci#define CRTC4_REGISTER_OFFSET                 (0x477c - 0x1b7c)
448c2ecf20Sopenharmony_ci#define CRTC5_REGISTER_OFFSET                 (0x4a7c - 0x1b7c)
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* hpd instance offsets */
478c2ecf20Sopenharmony_ci#define HPD0_REGISTER_OFFSET                 (0x1807 - 0x1807)
488c2ecf20Sopenharmony_ci#define HPD1_REGISTER_OFFSET                 (0x180a - 0x1807)
498c2ecf20Sopenharmony_ci#define HPD2_REGISTER_OFFSET                 (0x180d - 0x1807)
508c2ecf20Sopenharmony_ci#define HPD3_REGISTER_OFFSET                 (0x1810 - 0x1807)
518c2ecf20Sopenharmony_ci#define HPD4_REGISTER_OFFSET                 (0x1813 - 0x1807)
528c2ecf20Sopenharmony_ci#define HPD5_REGISTER_OFFSET                 (0x1816 - 0x1807)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define BONAIRE_GB_ADDR_CONFIG_GOLDEN        0x12010001
558c2ecf20Sopenharmony_ci#define HAWAII_GB_ADDR_CONFIG_GOLDEN         0x12011003
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci#define		PIPEID(x)					((x) << 0)
588c2ecf20Sopenharmony_ci#define		MEID(x)						((x) << 2)
598c2ecf20Sopenharmony_ci#define		VMID(x)						((x) << 4)
608c2ecf20Sopenharmony_ci#define		QUEUEID(x)					((x) << 8)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define mmCC_DRM_ID_STRAPS				0x1559
638c2ecf20Sopenharmony_ci#define CC_DRM_ID_STRAPS__ATI_REV_ID_MASK		0xf0000000
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define mmCHUB_CONTROL					0x619
668c2ecf20Sopenharmony_ci#define		BYPASS_VM					(1 << 0)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci#define		SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU	(0 << 5)
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define mmGRPH_LUT_10BIT_BYPASS_CONTROL			0x1a02
718c2ecf20Sopenharmony_ci#define		LUT_10BIT_BYPASS_EN			(1 << 8)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#       define CURSOR_MONO                    0
748c2ecf20Sopenharmony_ci#       define CURSOR_24_1                    1
758c2ecf20Sopenharmony_ci#       define CURSOR_24_8_PRE_MULT           2
768c2ecf20Sopenharmony_ci#       define CURSOR_24_8_UNPRE_MULT         3
778c2ecf20Sopenharmony_ci#       define CURSOR_URGENT_ALWAYS           0
788c2ecf20Sopenharmony_ci#       define CURSOR_URGENT_1_8              1
798c2ecf20Sopenharmony_ci#       define CURSOR_URGENT_1_4              2
808c2ecf20Sopenharmony_ci#       define CURSOR_URGENT_3_8              3
818c2ecf20Sopenharmony_ci#       define CURSOR_URGENT_1_2              4
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci#       define GRPH_DEPTH_8BPP                0
848c2ecf20Sopenharmony_ci#       define GRPH_DEPTH_16BPP               1
858c2ecf20Sopenharmony_ci#       define GRPH_DEPTH_32BPP               2
868c2ecf20Sopenharmony_ci/* 8 BPP */
878c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_INDEXED            0
888c2ecf20Sopenharmony_ci/* 16 BPP */
898c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_ARGB1555           0
908c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_ARGB565            1
918c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_ARGB4444           2
928c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_AI88               3
938c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_MONO16             4
948c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_BGRA5551           5
958c2ecf20Sopenharmony_ci/* 32 BPP */
968c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_ARGB8888           0
978c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_ARGB2101010        1
988c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_32BPP_DIG          2
998c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_8B_ARGB2101010     3
1008c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_BGRA1010102        4
1018c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_8B_BGRA1010102     5
1028c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_RGB111110          6
1038c2ecf20Sopenharmony_ci#       define GRPH_FORMAT_BGR101111          7
1048c2ecf20Sopenharmony_ci#       define ADDR_SURF_MACRO_TILE_ASPECT_1  0
1058c2ecf20Sopenharmony_ci#       define ADDR_SURF_MACRO_TILE_ASPECT_2  1
1068c2ecf20Sopenharmony_ci#       define ADDR_SURF_MACRO_TILE_ASPECT_4  2
1078c2ecf20Sopenharmony_ci#       define ADDR_SURF_MACRO_TILE_ASPECT_8  3
1088c2ecf20Sopenharmony_ci#       define GRPH_ARRAY_LINEAR_GENERAL      0
1098c2ecf20Sopenharmony_ci#       define GRPH_ARRAY_LINEAR_ALIGNED      1
1108c2ecf20Sopenharmony_ci#       define GRPH_ARRAY_1D_TILED_THIN1      2
1118c2ecf20Sopenharmony_ci#       define GRPH_ARRAY_2D_TILED_THIN1      4
1128c2ecf20Sopenharmony_ci#       define DISPLAY_MICRO_TILING          0
1138c2ecf20Sopenharmony_ci#       define THIN_MICRO_TILING             1
1148c2ecf20Sopenharmony_ci#       define DEPTH_MICRO_TILING            2
1158c2ecf20Sopenharmony_ci#       define ROTATED_MICRO_TILING          4
1168c2ecf20Sopenharmony_ci#       define GRPH_ENDIAN_NONE               0
1178c2ecf20Sopenharmony_ci#       define GRPH_ENDIAN_8IN16              1
1188c2ecf20Sopenharmony_ci#       define GRPH_ENDIAN_8IN32              2
1198c2ecf20Sopenharmony_ci#       define GRPH_ENDIAN_8IN64              3
1208c2ecf20Sopenharmony_ci#       define GRPH_RED_SEL_R                 0
1218c2ecf20Sopenharmony_ci#       define GRPH_RED_SEL_G                 1
1228c2ecf20Sopenharmony_ci#       define GRPH_RED_SEL_B                 2
1238c2ecf20Sopenharmony_ci#       define GRPH_RED_SEL_A                 3
1248c2ecf20Sopenharmony_ci#       define GRPH_GREEN_SEL_G               0
1258c2ecf20Sopenharmony_ci#       define GRPH_GREEN_SEL_B               1
1268c2ecf20Sopenharmony_ci#       define GRPH_GREEN_SEL_A               2
1278c2ecf20Sopenharmony_ci#       define GRPH_GREEN_SEL_R               3
1288c2ecf20Sopenharmony_ci#       define GRPH_BLUE_SEL_B                0
1298c2ecf20Sopenharmony_ci#       define GRPH_BLUE_SEL_A                1
1308c2ecf20Sopenharmony_ci#       define GRPH_BLUE_SEL_R                2
1318c2ecf20Sopenharmony_ci#       define GRPH_BLUE_SEL_G                3
1328c2ecf20Sopenharmony_ci#       define GRPH_ALPHA_SEL_A               0
1338c2ecf20Sopenharmony_ci#       define GRPH_ALPHA_SEL_R               1
1348c2ecf20Sopenharmony_ci#       define GRPH_ALPHA_SEL_G               2
1358c2ecf20Sopenharmony_ci#       define GRPH_ALPHA_SEL_B               3
1368c2ecf20Sopenharmony_ci#       define INPUT_GAMMA_USE_LUT                  0
1378c2ecf20Sopenharmony_ci#       define INPUT_GAMMA_BYPASS                   1
1388c2ecf20Sopenharmony_ci#       define INPUT_GAMMA_SRGB_24                  2
1398c2ecf20Sopenharmony_ci#       define INPUT_GAMMA_XVYCC_222                3
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#       define INPUT_CSC_BYPASS                     0
1428c2ecf20Sopenharmony_ci#       define INPUT_CSC_PROG_COEFF                 1
1438c2ecf20Sopenharmony_ci#       define INPUT_CSC_PROG_SHARED_MATRIXA        2
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci#       define OUTPUT_CSC_BYPASS                    0
1468c2ecf20Sopenharmony_ci#       define OUTPUT_CSC_TV_RGB                    1
1478c2ecf20Sopenharmony_ci#       define OUTPUT_CSC_YCBCR_601                 2
1488c2ecf20Sopenharmony_ci#       define OUTPUT_CSC_YCBCR_709                 3
1498c2ecf20Sopenharmony_ci#       define OUTPUT_CSC_PROG_COEFF                4
1508c2ecf20Sopenharmony_ci#       define OUTPUT_CSC_PROG_SHARED_MATRIXB       5
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci#       define DEGAMMA_BYPASS                       0
1538c2ecf20Sopenharmony_ci#       define DEGAMMA_SRGB_24                      1
1548c2ecf20Sopenharmony_ci#       define DEGAMMA_XVYCC_222                    2
1558c2ecf20Sopenharmony_ci#       define GAMUT_REMAP_BYPASS                   0
1568c2ecf20Sopenharmony_ci#       define GAMUT_REMAP_PROG_COEFF               1
1578c2ecf20Sopenharmony_ci#       define GAMUT_REMAP_PROG_SHARED_MATRIXA      2
1588c2ecf20Sopenharmony_ci#       define GAMUT_REMAP_PROG_SHARED_MATRIXB      3
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#       define REGAMMA_BYPASS                       0
1618c2ecf20Sopenharmony_ci#       define REGAMMA_SRGB_24                      1
1628c2ecf20Sopenharmony_ci#       define REGAMMA_XVYCC_222                    2
1638c2ecf20Sopenharmony_ci#       define REGAMMA_PROG_A                       3
1648c2ecf20Sopenharmony_ci#       define REGAMMA_PROG_B                       4
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#       define FMT_CLAMP_6BPC                0
1678c2ecf20Sopenharmony_ci#       define FMT_CLAMP_8BPC                1
1688c2ecf20Sopenharmony_ci#       define FMT_CLAMP_10BPC               2
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#       define HDMI_24BIT_DEEP_COLOR         0
1718c2ecf20Sopenharmony_ci#       define HDMI_30BIT_DEEP_COLOR         1
1728c2ecf20Sopenharmony_ci#       define HDMI_36BIT_DEEP_COLOR         2
1738c2ecf20Sopenharmony_ci#       define HDMI_ACR_HW                   0
1748c2ecf20Sopenharmony_ci#       define HDMI_ACR_32                   1
1758c2ecf20Sopenharmony_ci#       define HDMI_ACR_44                   2
1768c2ecf20Sopenharmony_ci#       define HDMI_ACR_48                   3
1778c2ecf20Sopenharmony_ci#       define HDMI_ACR_X1                   1
1788c2ecf20Sopenharmony_ci#       define HDMI_ACR_X2                   2
1798c2ecf20Sopenharmony_ci#       define HDMI_ACR_X4                   4
1808c2ecf20Sopenharmony_ci#       define AFMT_AVI_INFO_Y_RGB           0
1818c2ecf20Sopenharmony_ci#       define AFMT_AVI_INFO_Y_YCBCR422      1
1828c2ecf20Sopenharmony_ci#       define AFMT_AVI_INFO_Y_YCBCR444      2
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci#define			NO_AUTO						0
1858c2ecf20Sopenharmony_ci#define			ES_AUTO						1
1868c2ecf20Sopenharmony_ci#define			GS_AUTO						2
1878c2ecf20Sopenharmony_ci#define			ES_AND_GS_AUTO					3
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci#       define ARRAY_MODE(x)					((x) << 2)
1908c2ecf20Sopenharmony_ci#       define PIPE_CONFIG(x)					((x) << 6)
1918c2ecf20Sopenharmony_ci#       define TILE_SPLIT(x)					((x) << 11)
1928c2ecf20Sopenharmony_ci#       define MICRO_TILE_MODE_NEW(x)				((x) << 22)
1938c2ecf20Sopenharmony_ci#       define SAMPLE_SPLIT(x)					((x) << 25)
1948c2ecf20Sopenharmony_ci#       define BANK_WIDTH(x)					((x) << 0)
1958c2ecf20Sopenharmony_ci#       define BANK_HEIGHT(x)					((x) << 2)
1968c2ecf20Sopenharmony_ci#       define MACRO_TILE_ASPECT(x)				((x) << 4)
1978c2ecf20Sopenharmony_ci#       define NUM_BANKS(x)					((x) << 6)
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define		MSG_ENTER_RLC_SAFE_MODE			1
2008c2ecf20Sopenharmony_ci#define		MSG_EXIT_RLC_SAFE_MODE			0
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci/*
2038c2ecf20Sopenharmony_ci * PM4
2048c2ecf20Sopenharmony_ci */
2058c2ecf20Sopenharmony_ci#define	PACKET_TYPE0	0
2068c2ecf20Sopenharmony_ci#define	PACKET_TYPE1	1
2078c2ecf20Sopenharmony_ci#define	PACKET_TYPE2	2
2088c2ecf20Sopenharmony_ci#define	PACKET_TYPE3	3
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci#define CP_PACKET_GET_TYPE(h) (((h) >> 30) & 3)
2118c2ecf20Sopenharmony_ci#define CP_PACKET_GET_COUNT(h) (((h) >> 16) & 0x3FFF)
2128c2ecf20Sopenharmony_ci#define CP_PACKET0_GET_REG(h) ((h) & 0xFFFF)
2138c2ecf20Sopenharmony_ci#define CP_PACKET3_GET_OPCODE(h) (((h) >> 8) & 0xFF)
2148c2ecf20Sopenharmony_ci#define PACKET0(reg, n)	((PACKET_TYPE0 << 30) |				\
2158c2ecf20Sopenharmony_ci			 ((reg) & 0xFFFF) |			\
2168c2ecf20Sopenharmony_ci			 ((n) & 0x3FFF) << 16)
2178c2ecf20Sopenharmony_ci#define CP_PACKET2			0x80000000
2188c2ecf20Sopenharmony_ci#define		PACKET2_PAD_SHIFT		0
2198c2ecf20Sopenharmony_ci#define		PACKET2_PAD_MASK		(0x3fffffff << 0)
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci#define PACKET2(v)	(CP_PACKET2 | REG_SET(PACKET2_PAD, (v)))
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci#define PACKET3(op, n)	((PACKET_TYPE3 << 30) |				\
2248c2ecf20Sopenharmony_ci			 (((op) & 0xFF) << 8) |				\
2258c2ecf20Sopenharmony_ci			 ((n) & 0x3FFF) << 16)
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci#define PACKET3_COMPUTE(op, n) (PACKET3(op, n) | 1 << 1)
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/* Packet 3 types */
2308c2ecf20Sopenharmony_ci#define	PACKET3_NOP					0x10
2318c2ecf20Sopenharmony_ci#define	PACKET3_SET_BASE				0x11
2328c2ecf20Sopenharmony_ci#define		PACKET3_BASE_INDEX(x)                  ((x) << 0)
2338c2ecf20Sopenharmony_ci#define			CE_PARTITION_BASE		3
2348c2ecf20Sopenharmony_ci#define	PACKET3_CLEAR_STATE				0x12
2358c2ecf20Sopenharmony_ci#define	PACKET3_INDEX_BUFFER_SIZE			0x13
2368c2ecf20Sopenharmony_ci#define	PACKET3_DISPATCH_DIRECT				0x15
2378c2ecf20Sopenharmony_ci#define	PACKET3_DISPATCH_INDIRECT			0x16
2388c2ecf20Sopenharmony_ci#define	PACKET3_ATOMIC_GDS				0x1D
2398c2ecf20Sopenharmony_ci#define	PACKET3_ATOMIC_MEM				0x1E
2408c2ecf20Sopenharmony_ci#define	PACKET3_OCCLUSION_QUERY				0x1F
2418c2ecf20Sopenharmony_ci#define	PACKET3_SET_PREDICATION				0x20
2428c2ecf20Sopenharmony_ci#define	PACKET3_REG_RMW					0x21
2438c2ecf20Sopenharmony_ci#define	PACKET3_COND_EXEC				0x22
2448c2ecf20Sopenharmony_ci#define	PACKET3_PRED_EXEC				0x23
2458c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDIRECT				0x24
2468c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDEX_INDIRECT			0x25
2478c2ecf20Sopenharmony_ci#define	PACKET3_INDEX_BASE				0x26
2488c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDEX_2				0x27
2498c2ecf20Sopenharmony_ci#define	PACKET3_CONTEXT_CONTROL				0x28
2508c2ecf20Sopenharmony_ci#define	PACKET3_INDEX_TYPE				0x2A
2518c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDIRECT_MULTI			0x2C
2528c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDEX_AUTO				0x2D
2538c2ecf20Sopenharmony_ci#define	PACKET3_NUM_INSTANCES				0x2F
2548c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDEX_MULTI_AUTO			0x30
2558c2ecf20Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER_CONST			0x33
2568c2ecf20Sopenharmony_ci#define	PACKET3_STRMOUT_BUFFER_UPDATE			0x34
2578c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDEX_OFFSET_2			0x35
2588c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_PREAMBLE				0x36
2598c2ecf20Sopenharmony_ci#define	PACKET3_WRITE_DATA				0x37
2608c2ecf20Sopenharmony_ci#define		WRITE_DATA_DST_SEL(x)                   ((x) << 8)
2618c2ecf20Sopenharmony_ci		/* 0 - register
2628c2ecf20Sopenharmony_ci		 * 1 - memory (sync - via GRBM)
2638c2ecf20Sopenharmony_ci		 * 2 - gl2
2648c2ecf20Sopenharmony_ci		 * 3 - gds
2658c2ecf20Sopenharmony_ci		 * 4 - reserved
2668c2ecf20Sopenharmony_ci		 * 5 - memory (async - direct)
2678c2ecf20Sopenharmony_ci		 */
2688c2ecf20Sopenharmony_ci#define		WR_ONE_ADDR                             (1 << 16)
2698c2ecf20Sopenharmony_ci#define		WR_CONFIRM                              (1 << 20)
2708c2ecf20Sopenharmony_ci#define		WRITE_DATA_CACHE_POLICY(x)              ((x) << 25)
2718c2ecf20Sopenharmony_ci		/* 0 - LRU
2728c2ecf20Sopenharmony_ci		 * 1 - Stream
2738c2ecf20Sopenharmony_ci		 */
2748c2ecf20Sopenharmony_ci#define		WRITE_DATA_ENGINE_SEL(x)                ((x) << 30)
2758c2ecf20Sopenharmony_ci		/* 0 - me
2768c2ecf20Sopenharmony_ci		 * 1 - pfp
2778c2ecf20Sopenharmony_ci		 * 2 - ce
2788c2ecf20Sopenharmony_ci		 */
2798c2ecf20Sopenharmony_ci#define	PACKET3_DRAW_INDEX_INDIRECT_MULTI		0x38
2808c2ecf20Sopenharmony_ci#define	PACKET3_MEM_SEMAPHORE				0x39
2818c2ecf20Sopenharmony_ci#              define PACKET3_SEM_USE_MAILBOX       (0x1 << 16)
2828c2ecf20Sopenharmony_ci#              define PACKET3_SEM_SEL_SIGNAL_TYPE   (0x1 << 20) /* 0 = increment, 1 = write 1 */
2838c2ecf20Sopenharmony_ci#              define PACKET3_SEM_CLIENT_CODE	    ((x) << 24) /* 0 = CP, 1 = CB, 2 = DB */
2848c2ecf20Sopenharmony_ci#              define PACKET3_SEM_SEL_SIGNAL	    (0x6 << 29)
2858c2ecf20Sopenharmony_ci#              define PACKET3_SEM_SEL_WAIT	    (0x7 << 29)
2868c2ecf20Sopenharmony_ci#define	PACKET3_COPY_DW					0x3B
2878c2ecf20Sopenharmony_ci#define	PACKET3_WAIT_REG_MEM				0x3C
2888c2ecf20Sopenharmony_ci#define		WAIT_REG_MEM_FUNCTION(x)                ((x) << 0)
2898c2ecf20Sopenharmony_ci		/* 0 - always
2908c2ecf20Sopenharmony_ci		 * 1 - <
2918c2ecf20Sopenharmony_ci		 * 2 - <=
2928c2ecf20Sopenharmony_ci		 * 3 - ==
2938c2ecf20Sopenharmony_ci		 * 4 - !=
2948c2ecf20Sopenharmony_ci		 * 5 - >=
2958c2ecf20Sopenharmony_ci		 * 6 - >
2968c2ecf20Sopenharmony_ci		 */
2978c2ecf20Sopenharmony_ci#define		WAIT_REG_MEM_MEM_SPACE(x)               ((x) << 4)
2988c2ecf20Sopenharmony_ci		/* 0 - reg
2998c2ecf20Sopenharmony_ci		 * 1 - mem
3008c2ecf20Sopenharmony_ci		 */
3018c2ecf20Sopenharmony_ci#define		WAIT_REG_MEM_OPERATION(x)               ((x) << 6)
3028c2ecf20Sopenharmony_ci		/* 0 - wait_reg_mem
3038c2ecf20Sopenharmony_ci		 * 1 - wr_wait_wr_reg
3048c2ecf20Sopenharmony_ci		 */
3058c2ecf20Sopenharmony_ci#define		WAIT_REG_MEM_ENGINE(x)                  ((x) << 8)
3068c2ecf20Sopenharmony_ci		/* 0 - me
3078c2ecf20Sopenharmony_ci		 * 1 - pfp
3088c2ecf20Sopenharmony_ci		 */
3098c2ecf20Sopenharmony_ci#define	PACKET3_INDIRECT_BUFFER				0x3F
3108c2ecf20Sopenharmony_ci#define		INDIRECT_BUFFER_TCL2_VOLATILE           (1 << 22)
3118c2ecf20Sopenharmony_ci#define		INDIRECT_BUFFER_VALID                   (1 << 23)
3128c2ecf20Sopenharmony_ci#define		INDIRECT_BUFFER_CACHE_POLICY(x)         ((x) << 28)
3138c2ecf20Sopenharmony_ci		/* 0 - LRU
3148c2ecf20Sopenharmony_ci		 * 1 - Stream
3158c2ecf20Sopenharmony_ci		 * 2 - Bypass
3168c2ecf20Sopenharmony_ci		 */
3178c2ecf20Sopenharmony_ci#define	PACKET3_COPY_DATA				0x40
3188c2ecf20Sopenharmony_ci#define	PACKET3_PFP_SYNC_ME				0x42
3198c2ecf20Sopenharmony_ci#define	PACKET3_SURFACE_SYNC				0x43
3208c2ecf20Sopenharmony_ci#              define PACKET3_DEST_BASE_0_ENA      (1 << 0)
3218c2ecf20Sopenharmony_ci#              define PACKET3_DEST_BASE_1_ENA      (1 << 1)
3228c2ecf20Sopenharmony_ci#              define PACKET3_CB0_DEST_BASE_ENA    (1 << 6)
3238c2ecf20Sopenharmony_ci#              define PACKET3_CB1_DEST_BASE_ENA    (1 << 7)
3248c2ecf20Sopenharmony_ci#              define PACKET3_CB2_DEST_BASE_ENA    (1 << 8)
3258c2ecf20Sopenharmony_ci#              define PACKET3_CB3_DEST_BASE_ENA    (1 << 9)
3268c2ecf20Sopenharmony_ci#              define PACKET3_CB4_DEST_BASE_ENA    (1 << 10)
3278c2ecf20Sopenharmony_ci#              define PACKET3_CB5_DEST_BASE_ENA    (1 << 11)
3288c2ecf20Sopenharmony_ci#              define PACKET3_CB6_DEST_BASE_ENA    (1 << 12)
3298c2ecf20Sopenharmony_ci#              define PACKET3_CB7_DEST_BASE_ENA    (1 << 13)
3308c2ecf20Sopenharmony_ci#              define PACKET3_DB_DEST_BASE_ENA     (1 << 14)
3318c2ecf20Sopenharmony_ci#              define PACKET3_TCL1_VOL_ACTION_ENA  (1 << 15)
3328c2ecf20Sopenharmony_ci#              define PACKET3_TC_VOL_ACTION_ENA    (1 << 16) /* L2 */
3338c2ecf20Sopenharmony_ci#              define PACKET3_TC_WB_ACTION_ENA     (1 << 18) /* L2 */
3348c2ecf20Sopenharmony_ci#              define PACKET3_DEST_BASE_2_ENA      (1 << 19)
3358c2ecf20Sopenharmony_ci#              define PACKET3_DEST_BASE_3_ENA      (1 << 21)
3368c2ecf20Sopenharmony_ci#              define PACKET3_TCL1_ACTION_ENA      (1 << 22)
3378c2ecf20Sopenharmony_ci#              define PACKET3_TC_ACTION_ENA        (1 << 23) /* L2 */
3388c2ecf20Sopenharmony_ci#              define PACKET3_CB_ACTION_ENA        (1 << 25)
3398c2ecf20Sopenharmony_ci#              define PACKET3_DB_ACTION_ENA        (1 << 26)
3408c2ecf20Sopenharmony_ci#              define PACKET3_SH_KCACHE_ACTION_ENA (1 << 27)
3418c2ecf20Sopenharmony_ci#              define PACKET3_SH_KCACHE_VOL_ACTION_ENA (1 << 28)
3428c2ecf20Sopenharmony_ci#              define PACKET3_SH_ICACHE_ACTION_ENA (1 << 29)
3438c2ecf20Sopenharmony_ci#define	PACKET3_COND_WRITE				0x45
3448c2ecf20Sopenharmony_ci#define	PACKET3_EVENT_WRITE				0x46
3458c2ecf20Sopenharmony_ci#define		EVENT_TYPE(x)                           ((x) << 0)
3468c2ecf20Sopenharmony_ci#define		EVENT_INDEX(x)                          ((x) << 8)
3478c2ecf20Sopenharmony_ci		/* 0 - any non-TS event
3488c2ecf20Sopenharmony_ci		 * 1 - ZPASS_DONE, PIXEL_PIPE_STAT_*
3498c2ecf20Sopenharmony_ci		 * 2 - SAMPLE_PIPELINESTAT
3508c2ecf20Sopenharmony_ci		 * 3 - SAMPLE_STREAMOUTSTAT*
3518c2ecf20Sopenharmony_ci		 * 4 - *S_PARTIAL_FLUSH
3528c2ecf20Sopenharmony_ci		 * 5 - EOP events
3538c2ecf20Sopenharmony_ci		 * 6 - EOS events
3548c2ecf20Sopenharmony_ci		 */
3558c2ecf20Sopenharmony_ci#define	PACKET3_EVENT_WRITE_EOP				0x47
3568c2ecf20Sopenharmony_ci#define		EOP_TCL1_VOL_ACTION_EN                  (1 << 12)
3578c2ecf20Sopenharmony_ci#define		EOP_TC_VOL_ACTION_EN                    (1 << 13) /* L2 */
3588c2ecf20Sopenharmony_ci#define		EOP_TC_WB_ACTION_EN                     (1 << 15) /* L2 */
3598c2ecf20Sopenharmony_ci#define		EOP_TCL1_ACTION_EN                      (1 << 16)
3608c2ecf20Sopenharmony_ci#define		EOP_TC_ACTION_EN                        (1 << 17) /* L2 */
3618c2ecf20Sopenharmony_ci#define		EOP_TCL2_VOLATILE                       (1 << 24)
3628c2ecf20Sopenharmony_ci#define		EOP_CACHE_POLICY(x)                     ((x) << 25)
3638c2ecf20Sopenharmony_ci		/* 0 - LRU
3648c2ecf20Sopenharmony_ci		 * 1 - Stream
3658c2ecf20Sopenharmony_ci		 * 2 - Bypass
3668c2ecf20Sopenharmony_ci		 */
3678c2ecf20Sopenharmony_ci#define		DATA_SEL(x)                             ((x) << 29)
3688c2ecf20Sopenharmony_ci		/* 0 - discard
3698c2ecf20Sopenharmony_ci		 * 1 - send low 32bit data
3708c2ecf20Sopenharmony_ci		 * 2 - send 64bit data
3718c2ecf20Sopenharmony_ci		 * 3 - send 64bit GPU counter value
3728c2ecf20Sopenharmony_ci		 * 4 - send 64bit sys counter value
3738c2ecf20Sopenharmony_ci		 */
3748c2ecf20Sopenharmony_ci#define		INT_SEL(x)                              ((x) << 24)
3758c2ecf20Sopenharmony_ci		/* 0 - none
3768c2ecf20Sopenharmony_ci		 * 1 - interrupt only (DATA_SEL = 0)
3778c2ecf20Sopenharmony_ci		 * 2 - interrupt when data write is confirmed
3788c2ecf20Sopenharmony_ci		 */
3798c2ecf20Sopenharmony_ci#define		DST_SEL(x)                              ((x) << 16)
3808c2ecf20Sopenharmony_ci		/* 0 - MC
3818c2ecf20Sopenharmony_ci		 * 1 - TC/L2
3828c2ecf20Sopenharmony_ci		 */
3838c2ecf20Sopenharmony_ci#define	PACKET3_EVENT_WRITE_EOS				0x48
3848c2ecf20Sopenharmony_ci#define	PACKET3_RELEASE_MEM				0x49
3858c2ecf20Sopenharmony_ci#define	PACKET3_PREAMBLE_CNTL				0x4A
3868c2ecf20Sopenharmony_ci#              define PACKET3_PREAMBLE_BEGIN_CLEAR_STATE     (2 << 28)
3878c2ecf20Sopenharmony_ci#              define PACKET3_PREAMBLE_END_CLEAR_STATE       (3 << 28)
3888c2ecf20Sopenharmony_ci#define	PACKET3_DMA_DATA				0x50
3898c2ecf20Sopenharmony_ci/* 1. header
3908c2ecf20Sopenharmony_ci * 2. CONTROL
3918c2ecf20Sopenharmony_ci * 3. SRC_ADDR_LO or DATA [31:0]
3928c2ecf20Sopenharmony_ci * 4. SRC_ADDR_HI [31:0]
3938c2ecf20Sopenharmony_ci * 5. DST_ADDR_LO [31:0]
3948c2ecf20Sopenharmony_ci * 6. DST_ADDR_HI [7:0]
3958c2ecf20Sopenharmony_ci * 7. COMMAND [30:21] | BYTE_COUNT [20:0]
3968c2ecf20Sopenharmony_ci */
3978c2ecf20Sopenharmony_ci/* CONTROL */
3988c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_ENGINE(x)     ((x) << 0)
3998c2ecf20Sopenharmony_ci		/* 0 - ME
4008c2ecf20Sopenharmony_ci		 * 1 - PFP
4018c2ecf20Sopenharmony_ci		 */
4028c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_SRC_CACHE_POLICY(x) ((x) << 13)
4038c2ecf20Sopenharmony_ci		/* 0 - LRU
4048c2ecf20Sopenharmony_ci		 * 1 - Stream
4058c2ecf20Sopenharmony_ci		 * 2 - Bypass
4068c2ecf20Sopenharmony_ci		 */
4078c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_SRC_VOLATILE (1 << 15)
4088c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_DST_SEL(x)  ((x) << 20)
4098c2ecf20Sopenharmony_ci		/* 0 - DST_ADDR using DAS
4108c2ecf20Sopenharmony_ci		 * 1 - GDS
4118c2ecf20Sopenharmony_ci		 * 3 - DST_ADDR using L2
4128c2ecf20Sopenharmony_ci		 */
4138c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_DST_CACHE_POLICY(x) ((x) << 25)
4148c2ecf20Sopenharmony_ci		/* 0 - LRU
4158c2ecf20Sopenharmony_ci		 * 1 - Stream
4168c2ecf20Sopenharmony_ci		 * 2 - Bypass
4178c2ecf20Sopenharmony_ci		 */
4188c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_DST_VOLATILE (1 << 27)
4198c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_SRC_SEL(x)  ((x) << 29)
4208c2ecf20Sopenharmony_ci		/* 0 - SRC_ADDR using SAS
4218c2ecf20Sopenharmony_ci		 * 1 - GDS
4228c2ecf20Sopenharmony_ci		 * 2 - DATA
4238c2ecf20Sopenharmony_ci		 * 3 - SRC_ADDR using L2
4248c2ecf20Sopenharmony_ci		 */
4258c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CP_SYNC     (1 << 31)
4268c2ecf20Sopenharmony_ci/* COMMAND */
4278c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_DIS_WC      (1 << 21)
4288c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_SRC_SWAP(x) ((x) << 22)
4298c2ecf20Sopenharmony_ci		/* 0 - none
4308c2ecf20Sopenharmony_ci		 * 1 - 8 in 16
4318c2ecf20Sopenharmony_ci		 * 2 - 8 in 32
4328c2ecf20Sopenharmony_ci		 * 3 - 8 in 64
4338c2ecf20Sopenharmony_ci		 */
4348c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_DST_SWAP(x) ((x) << 24)
4358c2ecf20Sopenharmony_ci		/* 0 - none
4368c2ecf20Sopenharmony_ci		 * 1 - 8 in 16
4378c2ecf20Sopenharmony_ci		 * 2 - 8 in 32
4388c2ecf20Sopenharmony_ci		 * 3 - 8 in 64
4398c2ecf20Sopenharmony_ci		 */
4408c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_SAS     (1 << 26)
4418c2ecf20Sopenharmony_ci		/* 0 - memory
4428c2ecf20Sopenharmony_ci		 * 1 - register
4438c2ecf20Sopenharmony_ci		 */
4448c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_DAS     (1 << 27)
4458c2ecf20Sopenharmony_ci		/* 0 - memory
4468c2ecf20Sopenharmony_ci		 * 1 - register
4478c2ecf20Sopenharmony_ci		 */
4488c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_SAIC    (1 << 28)
4498c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_DAIC    (1 << 29)
4508c2ecf20Sopenharmony_ci#              define PACKET3_DMA_DATA_CMD_RAW_WAIT  (1 << 30)
4518c2ecf20Sopenharmony_ci#define	PACKET3_ACQUIRE_MEM				0x58
4528c2ecf20Sopenharmony_ci#define	PACKET3_REWIND					0x59
4538c2ecf20Sopenharmony_ci#define	PACKET3_LOAD_UCONFIG_REG			0x5E
4548c2ecf20Sopenharmony_ci#define	PACKET3_LOAD_SH_REG				0x5F
4558c2ecf20Sopenharmony_ci#define	PACKET3_LOAD_CONFIG_REG				0x60
4568c2ecf20Sopenharmony_ci#define	PACKET3_LOAD_CONTEXT_REG			0x61
4578c2ecf20Sopenharmony_ci#define	PACKET3_SET_CONFIG_REG				0x68
4588c2ecf20Sopenharmony_ci#define		PACKET3_SET_CONFIG_REG_START			0x00002000
4598c2ecf20Sopenharmony_ci#define		PACKET3_SET_CONFIG_REG_END			0x00002c00
4608c2ecf20Sopenharmony_ci#define	PACKET3_SET_CONTEXT_REG				0x69
4618c2ecf20Sopenharmony_ci#define		PACKET3_SET_CONTEXT_REG_START			0x0000a000
4628c2ecf20Sopenharmony_ci#define		PACKET3_SET_CONTEXT_REG_END			0x0000a400
4638c2ecf20Sopenharmony_ci#define	PACKET3_SET_CONTEXT_REG_INDIRECT		0x73
4648c2ecf20Sopenharmony_ci#define	PACKET3_SET_SH_REG				0x76
4658c2ecf20Sopenharmony_ci#define		PACKET3_SET_SH_REG_START			0x00002c00
4668c2ecf20Sopenharmony_ci#define		PACKET3_SET_SH_REG_END				0x00003000
4678c2ecf20Sopenharmony_ci#define	PACKET3_SET_SH_REG_OFFSET			0x77
4688c2ecf20Sopenharmony_ci#define	PACKET3_SET_QUEUE_REG				0x78
4698c2ecf20Sopenharmony_ci#define	PACKET3_SET_UCONFIG_REG				0x79
4708c2ecf20Sopenharmony_ci#define		PACKET3_SET_UCONFIG_REG_START			0x0000c000
4718c2ecf20Sopenharmony_ci#define		PACKET3_SET_UCONFIG_REG_END			0x0000c400
4728c2ecf20Sopenharmony_ci#define	PACKET3_SCRATCH_RAM_WRITE			0x7D
4738c2ecf20Sopenharmony_ci#define	PACKET3_SCRATCH_RAM_READ			0x7E
4748c2ecf20Sopenharmony_ci#define	PACKET3_LOAD_CONST_RAM				0x80
4758c2ecf20Sopenharmony_ci#define	PACKET3_WRITE_CONST_RAM				0x81
4768c2ecf20Sopenharmony_ci#define	PACKET3_DUMP_CONST_RAM				0x83
4778c2ecf20Sopenharmony_ci#define	PACKET3_INCREMENT_CE_COUNTER			0x84
4788c2ecf20Sopenharmony_ci#define	PACKET3_INCREMENT_DE_COUNTER			0x85
4798c2ecf20Sopenharmony_ci#define	PACKET3_WAIT_ON_CE_COUNTER			0x86
4808c2ecf20Sopenharmony_ci#define	PACKET3_WAIT_ON_DE_COUNTER_DIFF			0x88
4818c2ecf20Sopenharmony_ci#define	PACKET3_SWITCH_BUFFER				0x8B
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ci/* SDMA - first instance at 0xd000, second at 0xd800 */
4848c2ecf20Sopenharmony_ci#define SDMA0_REGISTER_OFFSET                             0x0 /* not a register */
4858c2ecf20Sopenharmony_ci#define SDMA1_REGISTER_OFFSET                             0x200 /* not a register */
4868c2ecf20Sopenharmony_ci#define SDMA_MAX_INSTANCE 2
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci#define SDMA_PACKET(op, sub_op, e)	((((e) & 0xFFFF) << 16) |	\
4898c2ecf20Sopenharmony_ci					 (((sub_op) & 0xFF) << 8) |	\
4908c2ecf20Sopenharmony_ci					 (((op) & 0xFF) << 0))
4918c2ecf20Sopenharmony_ci/* sDMA opcodes */
4928c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_NOP					  0
4938c2ecf20Sopenharmony_ci#	define SDMA_NOP_COUNT(x)			  (((x) & 0x3FFF) << 16)
4948c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_COPY				  1
4958c2ecf20Sopenharmony_ci#       define SDMA_COPY_SUB_OPCODE_LINEAR                0
4968c2ecf20Sopenharmony_ci#       define SDMA_COPY_SUB_OPCODE_TILED                 1
4978c2ecf20Sopenharmony_ci#       define SDMA_COPY_SUB_OPCODE_SOA                   3
4988c2ecf20Sopenharmony_ci#       define SDMA_COPY_SUB_OPCODE_LINEAR_SUB_WINDOW     4
4998c2ecf20Sopenharmony_ci#       define SDMA_COPY_SUB_OPCODE_TILED_SUB_WINDOW      5
5008c2ecf20Sopenharmony_ci#       define SDMA_COPY_SUB_OPCODE_T2T_SUB_WINDOW        6
5018c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_WRITE				  2
5028c2ecf20Sopenharmony_ci#       define SDMA_WRITE_SUB_OPCODE_LINEAR               0
5038c2ecf20Sopenharmony_ci#       define SDMA_WRITE_SUB_OPCODE_TILED                1
5048c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_INDIRECT_BUFFER			  4
5058c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_FENCE				  5
5068c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_TRAP				  6
5078c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_SEMAPHORE				  7
5088c2ecf20Sopenharmony_ci#       define SDMA_SEMAPHORE_EXTRA_O                     (1 << 13)
5098c2ecf20Sopenharmony_ci		/* 0 - increment
5108c2ecf20Sopenharmony_ci		 * 1 - write 1
5118c2ecf20Sopenharmony_ci		 */
5128c2ecf20Sopenharmony_ci#       define SDMA_SEMAPHORE_EXTRA_S                     (1 << 14)
5138c2ecf20Sopenharmony_ci		/* 0 - wait
5148c2ecf20Sopenharmony_ci		 * 1 - signal
5158c2ecf20Sopenharmony_ci		 */
5168c2ecf20Sopenharmony_ci#       define SDMA_SEMAPHORE_EXTRA_M                     (1 << 15)
5178c2ecf20Sopenharmony_ci		/* mailbox */
5188c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_POLL_REG_MEM			  8
5198c2ecf20Sopenharmony_ci#       define SDMA_POLL_REG_MEM_EXTRA_OP(x)              ((x) << 10)
5208c2ecf20Sopenharmony_ci		/* 0 - wait_reg_mem
5218c2ecf20Sopenharmony_ci		 * 1 - wr_wait_wr_reg
5228c2ecf20Sopenharmony_ci		 */
5238c2ecf20Sopenharmony_ci#       define SDMA_POLL_REG_MEM_EXTRA_FUNC(x)            ((x) << 12)
5248c2ecf20Sopenharmony_ci		/* 0 - always
5258c2ecf20Sopenharmony_ci		 * 1 - <
5268c2ecf20Sopenharmony_ci		 * 2 - <=
5278c2ecf20Sopenharmony_ci		 * 3 - ==
5288c2ecf20Sopenharmony_ci		 * 4 - !=
5298c2ecf20Sopenharmony_ci		 * 5 - >=
5308c2ecf20Sopenharmony_ci		 * 6 - >
5318c2ecf20Sopenharmony_ci		 */
5328c2ecf20Sopenharmony_ci#       define SDMA_POLL_REG_MEM_EXTRA_M                  (1 << 15)
5338c2ecf20Sopenharmony_ci		/* 0 = register
5348c2ecf20Sopenharmony_ci		 * 1 = memory
5358c2ecf20Sopenharmony_ci		 */
5368c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_COND_EXEC				  9
5378c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_CONSTANT_FILL			  11
5388c2ecf20Sopenharmony_ci#       define SDMA_CONSTANT_FILL_EXTRA_SIZE(x)           ((x) << 14)
5398c2ecf20Sopenharmony_ci		/* 0 = byte fill
5408c2ecf20Sopenharmony_ci		 * 2 = DW fill
5418c2ecf20Sopenharmony_ci		 */
5428c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_GENERATE_PTE_PDE			  12
5438c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_TIMESTAMP				  13
5448c2ecf20Sopenharmony_ci#       define SDMA_TIMESTAMP_SUB_OPCODE_SET_LOCAL        0
5458c2ecf20Sopenharmony_ci#       define SDMA_TIMESTAMP_SUB_OPCODE_GET_LOCAL        1
5468c2ecf20Sopenharmony_ci#       define SDMA_TIMESTAMP_SUB_OPCODE_GET_GLOBAL       2
5478c2ecf20Sopenharmony_ci#define	SDMA_OPCODE_SRBM_WRITE				  14
5488c2ecf20Sopenharmony_ci#       define SDMA_SRBM_WRITE_EXTRA_BYTE_ENABLE(x)       ((x) << 12)
5498c2ecf20Sopenharmony_ci		/* byte mask */
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ci#define VCE_CMD_NO_OP		0x00000000
5528c2ecf20Sopenharmony_ci#define VCE_CMD_END		0x00000001
5538c2ecf20Sopenharmony_ci#define VCE_CMD_IB		0x00000002
5548c2ecf20Sopenharmony_ci#define VCE_CMD_FENCE		0x00000003
5558c2ecf20Sopenharmony_ci#define VCE_CMD_TRAP		0x00000004
5568c2ecf20Sopenharmony_ci#define VCE_CMD_IB_AUTO		0x00000005
5578c2ecf20Sopenharmony_ci#define VCE_CMD_SEMAPHORE	0x00000006
5588c2ecf20Sopenharmony_ci
5598c2ecf20Sopenharmony_ci/* if PTR32, these are the bases for scratch and lds */
5608c2ecf20Sopenharmony_ci#define	PRIVATE_BASE(x)	((x) << 0) /* scratch */
5618c2ecf20Sopenharmony_ci#define	SHARED_BASE(x)	((x) << 16) /* LDS */
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci#define KFD_CIK_SDMA_QUEUE_OFFSET (mmSDMA0_RLC1_RB_CNTL - mmSDMA0_RLC0_RB_CNTL)
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci/* valid for both DEFAULT_MTYPE and APE1_MTYPE */
5668c2ecf20Sopenharmony_cienum {
5678c2ecf20Sopenharmony_ci	MTYPE_CACHED = 0,
5688c2ecf20Sopenharmony_ci	MTYPE_NONCACHED = 3
5698c2ecf20Sopenharmony_ci};
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ci/* mmPA_SC_RASTER_CONFIG mask */
5728c2ecf20Sopenharmony_ci#define RB_MAP_PKR0(x)				((x) << 0)
5738c2ecf20Sopenharmony_ci#define RB_MAP_PKR0_MASK			(0x3 << 0)
5748c2ecf20Sopenharmony_ci#define RB_MAP_PKR1(x)				((x) << 2)
5758c2ecf20Sopenharmony_ci#define RB_MAP_PKR1_MASK			(0x3 << 2)
5768c2ecf20Sopenharmony_ci#define RB_XSEL2(x)				((x) << 4)
5778c2ecf20Sopenharmony_ci#define RB_XSEL2_MASK				(0x3 << 4)
5788c2ecf20Sopenharmony_ci#define RB_XSEL					(1 << 6)
5798c2ecf20Sopenharmony_ci#define RB_YSEL					(1 << 7)
5808c2ecf20Sopenharmony_ci#define PKR_MAP(x)				((x) << 8)
5818c2ecf20Sopenharmony_ci#define PKR_MAP_MASK				(0x3 << 8)
5828c2ecf20Sopenharmony_ci#define PKR_XSEL(x)				((x) << 10)
5838c2ecf20Sopenharmony_ci#define PKR_XSEL_MASK				(0x3 << 10)
5848c2ecf20Sopenharmony_ci#define PKR_YSEL(x)				((x) << 12)
5858c2ecf20Sopenharmony_ci#define PKR_YSEL_MASK				(0x3 << 12)
5868c2ecf20Sopenharmony_ci#define SC_MAP(x)				((x) << 16)
5878c2ecf20Sopenharmony_ci#define SC_MAP_MASK				(0x3 << 16)
5888c2ecf20Sopenharmony_ci#define SC_XSEL(x)				((x) << 18)
5898c2ecf20Sopenharmony_ci#define SC_XSEL_MASK				(0x3 << 18)
5908c2ecf20Sopenharmony_ci#define SC_YSEL(x)				((x) << 20)
5918c2ecf20Sopenharmony_ci#define SC_YSEL_MASK				(0x3 << 20)
5928c2ecf20Sopenharmony_ci#define SE_MAP(x)				((x) << 24)
5938c2ecf20Sopenharmony_ci#define SE_MAP_MASK				(0x3 << 24)
5948c2ecf20Sopenharmony_ci#define SE_XSEL(x)				((x) << 26)
5958c2ecf20Sopenharmony_ci#define SE_XSEL_MASK				(0x3 << 26)
5968c2ecf20Sopenharmony_ci#define SE_YSEL(x)				((x) << 28)
5978c2ecf20Sopenharmony_ci#define SE_YSEL_MASK				(0x3 << 28)
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci/* mmPA_SC_RASTER_CONFIG_1 mask */
6008c2ecf20Sopenharmony_ci#define SE_PAIR_MAP(x)				((x) << 0)
6018c2ecf20Sopenharmony_ci#define SE_PAIR_MAP_MASK			(0x3 << 0)
6028c2ecf20Sopenharmony_ci#define SE_PAIR_XSEL(x)				((x) << 2)
6038c2ecf20Sopenharmony_ci#define SE_PAIR_XSEL_MASK			(0x3 << 2)
6048c2ecf20Sopenharmony_ci#define SE_PAIR_YSEL(x)				((x) << 4)
6058c2ecf20Sopenharmony_ci#define SE_PAIR_YSEL_MASK			(0x3 << 4)
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci#endif
608