xref: /linux/drivers/gpu/drm/amd/amdgpu/soc15_common.h (revision b1bb8c0118b3b9d44a6a31ea5242bdd9ed040a9b)
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 hdp_flush_req_offset;
298e3153baSKen Wang 	u32 hdp_flush_done_offset;
308e3153baSKen Wang 	u32 ref_and_mask_cp0;
318e3153baSKen Wang 	u32 ref_and_mask_cp1;
328e3153baSKen Wang 	u32 ref_and_mask_cp2;
338e3153baSKen Wang 	u32 ref_and_mask_cp3;
348e3153baSKen Wang 	u32 ref_and_mask_cp4;
358e3153baSKen Wang 	u32 ref_and_mask_cp5;
368e3153baSKen Wang 	u32 ref_and_mask_cp6;
378e3153baSKen Wang 	u32 ref_and_mask_cp7;
388e3153baSKen Wang 	u32 ref_and_mask_cp8;
398e3153baSKen Wang 	u32 ref_and_mask_cp9;
408e3153baSKen Wang 	u32 ref_and_mask_sdma0;
418e3153baSKen Wang 	u32 ref_and_mask_sdma1;
428e3153baSKen Wang };
438e3153baSKen Wang 
448e3153baSKen Wang struct nbio_pcie_index_data {
458e3153baSKen Wang 	u32 index_offset;
468e3153baSKen Wang 	u32 data_offset;
478e3153baSKen Wang };
48*b1bb8c01STom St Denis 
49*b1bb8c01STom St Denis /* Register Access Macros */
508e3153baSKen Wang #define SOC15_REG_OFFSET(ip, inst, reg)       (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \
518e3153baSKen Wang                                                 (1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \
528e3153baSKen Wang                                                     (2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \
538e3153baSKen Wang                                                         (3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \
548e3153baSKen Wang                                                             (ip##_BASE__INST##inst##_SEG4 + reg)))))
558e3153baSKen Wang 
56*b1bb8c01STom St Denis #define WREG32_FIELD15(ip, idx, reg, field, val)	\
57*b1bb8c01STom St Denis 	WREG32(SOC15_REG_OFFSET(ip, idx, mm##reg), (RREG32(SOC15_REG_OFFSET(ip, idx, mm##reg)) & ~REG_FIELD_MASK(reg, field)) | (val) << REG_FIELD_SHIFT(reg, field))
58*b1bb8c01STom St Denis 
59*b1bb8c01STom St Denis #define RREG32_SOC15(ip, inst, reg) \
60*b1bb8c01STom St Denis 	RREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \
61*b1bb8c01STom St Denis 		(1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \
62*b1bb8c01STom St Denis 		(2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \
63*b1bb8c01STom St Denis 		(3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \
64*b1bb8c01STom St Denis 		(ip##_BASE__INST##inst##_SEG4 + reg))))))
65*b1bb8c01STom St Denis 
66*b1bb8c01STom St Denis #define WREG32_SOC15(ip, inst, reg, value) \
67*b1bb8c01STom St Denis 	WREG32( (0 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG0 + reg : \
68*b1bb8c01STom St Denis 		(1 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG1 + reg : \
69*b1bb8c01STom St Denis 		(2 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG2 + reg : \
70*b1bb8c01STom St Denis 		(3 == reg##_BASE_IDX ? ip##_BASE__INST##inst##_SEG3 + reg : \
71*b1bb8c01STom St Denis 		(ip##_BASE__INST##inst##_SEG4 + reg))))), value)
72*b1bb8c01STom St Denis 
738e3153baSKen Wang #endif
748e3153baSKen Wang 
758e3153baSKen Wang 
76