xref: /linux/drivers/gpu/drm/amd/amdgpu/soc15_common.h (revision cd29253f650a6ab27bae8c0b8c17fb8e71f864e8)
18e3153baSKen Wang /*
28e3153baSKen Wang  * Copyright 2016 Advanced Micro Devices, Inc.
38e3153baSKen Wang  *
48e3153baSKen Wang  * Permission is hereby granted, free of charge, to any person obtaining a
58e3153baSKen Wang  * copy of this software and associated documentation files (the "Software"),
68e3153baSKen Wang  * to deal in the Software without restriction, including without limitation
78e3153baSKen Wang  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88e3153baSKen Wang  * and/or sell copies of the Software, and to permit persons to whom the
98e3153baSKen Wang  * Software is furnished to do so, subject to the following conditions:
108e3153baSKen Wang  *
118e3153baSKen Wang  * The above copyright notice and this permission notice shall be included in
128e3153baSKen Wang  * all copies or substantial portions of the Software.
138e3153baSKen Wang  *
148e3153baSKen Wang  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158e3153baSKen Wang  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168e3153baSKen Wang  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178e3153baSKen Wang  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188e3153baSKen Wang  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198e3153baSKen Wang  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208e3153baSKen Wang  * OTHER DEALINGS IN THE SOFTWARE.
218e3153baSKen Wang  *
228e3153baSKen Wang  */
238e3153baSKen Wang 
248e3153baSKen Wang #ifndef __SOC15_COMMON_H__
258e3153baSKen Wang #define __SOC15_COMMON_H__
268e3153baSKen Wang 
278e3153baSKen Wang struct nbio_hdp_flush_reg {
288e3153baSKen Wang 	u32 ref_and_mask_cp0;
298e3153baSKen Wang 	u32 ref_and_mask_cp1;
308e3153baSKen Wang 	u32 ref_and_mask_cp2;
318e3153baSKen Wang 	u32 ref_and_mask_cp3;
328e3153baSKen Wang 	u32 ref_and_mask_cp4;
338e3153baSKen Wang 	u32 ref_and_mask_cp5;
348e3153baSKen Wang 	u32 ref_and_mask_cp6;
358e3153baSKen Wang 	u32 ref_and_mask_cp7;
368e3153baSKen Wang 	u32 ref_and_mask_cp8;
378e3153baSKen Wang 	u32 ref_and_mask_cp9;
388e3153baSKen Wang 	u32 ref_and_mask_sdma0;
398e3153baSKen Wang 	u32 ref_and_mask_sdma1;
408e3153baSKen Wang };
418e3153baSKen Wang 
42b1bb8c01STom St Denis 
43b1bb8c01STom St Denis /* Register Access Macros */
44*cd29253fSShaoyun Liu #define SOC15_REG_OFFSET(ip, inst, reg)	(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg)
458e3153baSKen Wang 
46b1bb8c01STom St Denis #define WREG32_FIELD15(ip, idx, reg, field, val)	\
47b466107eSShaoyun Liu 	WREG32(adev->reg_offset[ip##_HWIP][idx][mm##reg##_BASE_IDX] + mm##reg,	\
48b466107eSShaoyun Liu 	(RREG32(adev->reg_offset[ip##_HWIP][idx][mm##reg##_BASE_IDX] + mm##reg)	\
49b466107eSShaoyun Liu 	& ~REG_FIELD_MASK(reg, field)) | (val) << REG_FIELD_SHIFT(reg, field))
50b1bb8c01STom St Denis 
51b1bb8c01STom St Denis #define RREG32_SOC15(ip, inst, reg) \
52b466107eSShaoyun Liu 	RREG32(adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg)
53b1bb8c01STom St Denis 
54496828e7STom St Denis #define RREG32_SOC15_OFFSET(ip, inst, reg, offset) \
55b466107eSShaoyun Liu 	RREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) + offset)
56496828e7STom St Denis 
57b1bb8c01STom St Denis #define WREG32_SOC15(ip, inst, reg, value) \
58b466107eSShaoyun Liu 	WREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg), value)
59b1bb8c01STom St Denis 
60c708535eSShaoyun Liu #define WREG32_SOC15_NO_KIQ(ip, inst, reg, value) \
61b466107eSShaoyun Liu 	WREG32_NO_KIQ((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg), value)
62c708535eSShaoyun Liu 
63496828e7STom St Denis #define WREG32_SOC15_OFFSET(ip, inst, reg, offset, value) \
64b466107eSShaoyun Liu 	WREG32((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) + offset, value)
65496828e7STom St Denis 
668e3153baSKen Wang #endif
678e3153baSKen Wang 
688e3153baSKen Wang 
69