xref: /dflybsd-src/sys/dev/drm/amd/amdgpu/nbio_v7_0.c (revision b843c749addef9340ee7d4e250b09fdd492602a1)
1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev  * Copyright 2016 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev  *
4*b843c749SSergey Zigachev  * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev  * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev  * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev  * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev  * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev  *
11*b843c749SSergey Zigachev  * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev  * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev  *
14*b843c749SSergey Zigachev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*b843c749SSergey Zigachev  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev  * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev  *
22*b843c749SSergey Zigachev  */
23*b843c749SSergey Zigachev #include "amdgpu.h"
24*b843c749SSergey Zigachev #include "amdgpu_atombios.h"
25*b843c749SSergey Zigachev #include "nbio_v7_0.h"
26*b843c749SSergey Zigachev 
27*b843c749SSergey Zigachev #include "nbio/nbio_7_0_default.h"
28*b843c749SSergey Zigachev #include "nbio/nbio_7_0_offset.h"
29*b843c749SSergey Zigachev #include "nbio/nbio_7_0_sh_mask.h"
30*b843c749SSergey Zigachev #include "vega10_enum.h"
31*b843c749SSergey Zigachev 
32*b843c749SSergey Zigachev #define smnNBIF_MGCG_CTRL_LCLK	0x1013a05c
33*b843c749SSergey Zigachev 
34*b843c749SSergey Zigachev #define smnCPM_CONTROL                                                                                  0x11180460
35*b843c749SSergey Zigachev #define smnPCIE_CNTL2                                                                                   0x11180070
36*b843c749SSergey Zigachev 
37*b843c749SSergey Zigachev /* vega20 */
38*b843c749SSergey Zigachev #define mmRCC_DEV0_EPF0_STRAP0_VG20                                                                         0x0011
39*b843c749SSergey Zigachev #define mmRCC_DEV0_EPF0_STRAP0_VG20_BASE_IDX                                                                2
40*b843c749SSergey Zigachev 
nbio_v7_0_get_rev_id(struct amdgpu_device * adev)41*b843c749SSergey Zigachev static u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev)
42*b843c749SSergey Zigachev {
43*b843c749SSergey Zigachev         u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
44*b843c749SSergey Zigachev 
45*b843c749SSergey Zigachev 	if (adev->asic_type == CHIP_VEGA20)
46*b843c749SSergey Zigachev 		tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0_VG20);
47*b843c749SSergey Zigachev 	else
48*b843c749SSergey Zigachev 		tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
49*b843c749SSergey Zigachev 
50*b843c749SSergey Zigachev 	tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK;
51*b843c749SSergey Zigachev 	tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT;
52*b843c749SSergey Zigachev 
53*b843c749SSergey Zigachev 	return tmp;
54*b843c749SSergey Zigachev }
55*b843c749SSergey Zigachev 
nbio_v7_0_mc_access_enable(struct amdgpu_device * adev,bool enable)56*b843c749SSergey Zigachev static void nbio_v7_0_mc_access_enable(struct amdgpu_device *adev, bool enable)
57*b843c749SSergey Zigachev {
58*b843c749SSergey Zigachev 	if (enable)
59*b843c749SSergey Zigachev 		WREG32_SOC15(NBIO, 0, mmBIF_FB_EN,
60*b843c749SSergey Zigachev 			BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK);
61*b843c749SSergey Zigachev 	else
62*b843c749SSergey Zigachev 		WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0);
63*b843c749SSergey Zigachev }
64*b843c749SSergey Zigachev 
nbio_v7_0_hdp_flush(struct amdgpu_device * adev,struct amdgpu_ring * ring)65*b843c749SSergey Zigachev static void nbio_v7_0_hdp_flush(struct amdgpu_device *adev,
66*b843c749SSergey Zigachev 				struct amdgpu_ring *ring)
67*b843c749SSergey Zigachev {
68*b843c749SSergey Zigachev 	if (!ring || !ring->funcs->emit_wreg)
69*b843c749SSergey Zigachev 		WREG32_SOC15_NO_KIQ(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL, 0);
70*b843c749SSergey Zigachev 	else
71*b843c749SSergey Zigachev 		amdgpu_ring_emit_wreg(ring, SOC15_REG_OFFSET(
72*b843c749SSergey Zigachev 			NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL), 0);
73*b843c749SSergey Zigachev }
74*b843c749SSergey Zigachev 
nbio_v7_0_get_memsize(struct amdgpu_device * adev)75*b843c749SSergey Zigachev static u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev)
76*b843c749SSergey Zigachev {
77*b843c749SSergey Zigachev 	return RREG32_SOC15(NBIO, 0, mmRCC_CONFIG_MEMSIZE);
78*b843c749SSergey Zigachev }
79*b843c749SSergey Zigachev 
nbio_v7_0_sdma_doorbell_range(struct amdgpu_device * adev,int instance,bool use_doorbell,int doorbell_index)80*b843c749SSergey Zigachev static void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instance,
81*b843c749SSergey Zigachev 					  bool use_doorbell, int doorbell_index)
82*b843c749SSergey Zigachev {
83*b843c749SSergey Zigachev 	u32 reg = instance == 0 ? SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA0_DOORBELL_RANGE) :
84*b843c749SSergey Zigachev 			SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE);
85*b843c749SSergey Zigachev 
86*b843c749SSergey Zigachev 	u32 doorbell_range = RREG32(reg);
87*b843c749SSergey Zigachev 	u32 range = 2;
88*b843c749SSergey Zigachev 
89*b843c749SSergey Zigachev 	if (adev->asic_type == CHIP_VEGA20)
90*b843c749SSergey Zigachev 		range = 8;
91*b843c749SSergey Zigachev 
92*b843c749SSergey Zigachev 	if (use_doorbell) {
93*b843c749SSergey Zigachev 		doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index);
94*b843c749SSergey Zigachev 		doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, range);
95*b843c749SSergey Zigachev 	} else
96*b843c749SSergey Zigachev 		doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0);
97*b843c749SSergey Zigachev 
98*b843c749SSergey Zigachev 	WREG32(reg, doorbell_range);
99*b843c749SSergey Zigachev }
100*b843c749SSergey Zigachev 
nbio_v7_0_enable_doorbell_aperture(struct amdgpu_device * adev,bool enable)101*b843c749SSergey Zigachev static void nbio_v7_0_enable_doorbell_aperture(struct amdgpu_device *adev,
102*b843c749SSergey Zigachev 					       bool enable)
103*b843c749SSergey Zigachev {
104*b843c749SSergey Zigachev 	WREG32_FIELD15(NBIO, 0, RCC_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, enable ? 1 : 0);
105*b843c749SSergey Zigachev }
106*b843c749SSergey Zigachev 
nbio_v7_0_enable_doorbell_selfring_aperture(struct amdgpu_device * adev,bool enable)107*b843c749SSergey Zigachev static void nbio_v7_0_enable_doorbell_selfring_aperture(struct amdgpu_device *adev,
108*b843c749SSergey Zigachev 							bool enable)
109*b843c749SSergey Zigachev {
110*b843c749SSergey Zigachev 
111*b843c749SSergey Zigachev }
112*b843c749SSergey Zigachev 
nbio_v7_0_ih_doorbell_range(struct amdgpu_device * adev,bool use_doorbell,int doorbell_index)113*b843c749SSergey Zigachev static void nbio_v7_0_ih_doorbell_range(struct amdgpu_device *adev,
114*b843c749SSergey Zigachev 					bool use_doorbell, int doorbell_index)
115*b843c749SSergey Zigachev {
116*b843c749SSergey Zigachev 	u32 ih_doorbell_range = RREG32_SOC15(NBIO, 0 , mmBIF_IH_DOORBELL_RANGE);
117*b843c749SSergey Zigachev 
118*b843c749SSergey Zigachev 	if (use_doorbell) {
119*b843c749SSergey Zigachev 		ih_doorbell_range = REG_SET_FIELD(ih_doorbell_range, BIF_IH_DOORBELL_RANGE, OFFSET, doorbell_index);
120*b843c749SSergey Zigachev 		ih_doorbell_range = REG_SET_FIELD(ih_doorbell_range, BIF_IH_DOORBELL_RANGE, SIZE, 2);
121*b843c749SSergey Zigachev 	} else
122*b843c749SSergey Zigachev 		ih_doorbell_range = REG_SET_FIELD(ih_doorbell_range, BIF_IH_DOORBELL_RANGE, SIZE, 0);
123*b843c749SSergey Zigachev 
124*b843c749SSergey Zigachev 	WREG32_SOC15(NBIO, 0, mmBIF_IH_DOORBELL_RANGE, ih_doorbell_range);
125*b843c749SSergey Zigachev }
126*b843c749SSergey Zigachev 
nbio_7_0_read_syshub_ind_mmr(struct amdgpu_device * adev,uint32_t offset)127*b843c749SSergey Zigachev static uint32_t nbio_7_0_read_syshub_ind_mmr(struct amdgpu_device *adev, uint32_t offset)
128*b843c749SSergey Zigachev {
129*b843c749SSergey Zigachev 	uint32_t data;
130*b843c749SSergey Zigachev 
131*b843c749SSergey Zigachev 	WREG32_SOC15(NBIO, 0, mmSYSHUB_INDEX, offset);
132*b843c749SSergey Zigachev 	data = RREG32_SOC15(NBIO, 0, mmSYSHUB_DATA);
133*b843c749SSergey Zigachev 
134*b843c749SSergey Zigachev 	return data;
135*b843c749SSergey Zigachev }
136*b843c749SSergey Zigachev 
nbio_7_0_write_syshub_ind_mmr(struct amdgpu_device * adev,uint32_t offset,uint32_t data)137*b843c749SSergey Zigachev static void nbio_7_0_write_syshub_ind_mmr(struct amdgpu_device *adev, uint32_t offset,
138*b843c749SSergey Zigachev 				       uint32_t data)
139*b843c749SSergey Zigachev {
140*b843c749SSergey Zigachev 	WREG32_SOC15(NBIO, 0, mmSYSHUB_INDEX, offset);
141*b843c749SSergey Zigachev 	WREG32_SOC15(NBIO, 0, mmSYSHUB_DATA, data);
142*b843c749SSergey Zigachev }
143*b843c749SSergey Zigachev 
nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device * adev,bool enable)144*b843c749SSergey Zigachev static void nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device *adev,
145*b843c749SSergey Zigachev 						       bool enable)
146*b843c749SSergey Zigachev {
147*b843c749SSergey Zigachev 	uint32_t def, data;
148*b843c749SSergey Zigachev 
149*b843c749SSergey Zigachev 	if (adev->asic_type == CHIP_VEGA20)
150*b843c749SSergey Zigachev 		return;
151*b843c749SSergey Zigachev 
152*b843c749SSergey Zigachev 	/* NBIF_MGCG_CTRL_LCLK */
153*b843c749SSergey Zigachev 	def = data = RREG32_PCIE(smnNBIF_MGCG_CTRL_LCLK);
154*b843c749SSergey Zigachev 
155*b843c749SSergey Zigachev 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG))
156*b843c749SSergey Zigachev 		data |= NBIF_MGCG_CTRL_LCLK__NBIF_MGCG_EN_LCLK_MASK;
157*b843c749SSergey Zigachev 	else
158*b843c749SSergey Zigachev 		data &= ~NBIF_MGCG_CTRL_LCLK__NBIF_MGCG_EN_LCLK_MASK;
159*b843c749SSergey Zigachev 
160*b843c749SSergey Zigachev 	if (def != data)
161*b843c749SSergey Zigachev 		WREG32_PCIE(smnNBIF_MGCG_CTRL_LCLK, data);
162*b843c749SSergey Zigachev 
163*b843c749SSergey Zigachev 	/* SYSHUB_MGCG_CTRL_SOCCLK */
164*b843c749SSergey Zigachev 	def = data = nbio_7_0_read_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SOCCLK);
165*b843c749SSergey Zigachev 
166*b843c749SSergey Zigachev 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG))
167*b843c749SSergey Zigachev 		data |= SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SOCCLK__SYSHUB_MGCG_EN_SOCCLK_MASK;
168*b843c749SSergey Zigachev 	else
169*b843c749SSergey Zigachev 		data &= ~SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SOCCLK__SYSHUB_MGCG_EN_SOCCLK_MASK;
170*b843c749SSergey Zigachev 
171*b843c749SSergey Zigachev 	if (def != data)
172*b843c749SSergey Zigachev 		nbio_7_0_write_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SOCCLK, data);
173*b843c749SSergey Zigachev 
174*b843c749SSergey Zigachev 	/* SYSHUB_MGCG_CTRL_SHUBCLK */
175*b843c749SSergey Zigachev 	def = data = nbio_7_0_read_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SHUBCLK);
176*b843c749SSergey Zigachev 
177*b843c749SSergey Zigachev 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG))
178*b843c749SSergey Zigachev 		data |= SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SHUBCLK__SYSHUB_MGCG_EN_SHUBCLK_MASK;
179*b843c749SSergey Zigachev 	else
180*b843c749SSergey Zigachev 		data &= ~SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SHUBCLK__SYSHUB_MGCG_EN_SHUBCLK_MASK;
181*b843c749SSergey Zigachev 
182*b843c749SSergey Zigachev 	if (def != data)
183*b843c749SSergey Zigachev 		nbio_7_0_write_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SHUBCLK, data);
184*b843c749SSergey Zigachev }
185*b843c749SSergey Zigachev 
nbio_v7_0_update_medium_grain_light_sleep(struct amdgpu_device * adev,bool enable)186*b843c749SSergey Zigachev static void nbio_v7_0_update_medium_grain_light_sleep(struct amdgpu_device *adev,
187*b843c749SSergey Zigachev 						      bool enable)
188*b843c749SSergey Zigachev {
189*b843c749SSergey Zigachev 	uint32_t def, data;
190*b843c749SSergey Zigachev 
191*b843c749SSergey Zigachev 	def = data = RREG32_PCIE(smnPCIE_CNTL2);
192*b843c749SSergey Zigachev 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS)) {
193*b843c749SSergey Zigachev 		data |= (PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
194*b843c749SSergey Zigachev 			 PCIE_CNTL2__MST_MEM_LS_EN_MASK |
195*b843c749SSergey Zigachev 			 PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK);
196*b843c749SSergey Zigachev 	} else {
197*b843c749SSergey Zigachev 		data &= ~(PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
198*b843c749SSergey Zigachev 			  PCIE_CNTL2__MST_MEM_LS_EN_MASK |
199*b843c749SSergey Zigachev 			  PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK);
200*b843c749SSergey Zigachev 	}
201*b843c749SSergey Zigachev 
202*b843c749SSergey Zigachev 	if (def != data)
203*b843c749SSergey Zigachev 		WREG32_PCIE(smnPCIE_CNTL2, data);
204*b843c749SSergey Zigachev }
205*b843c749SSergey Zigachev 
nbio_v7_0_get_clockgating_state(struct amdgpu_device * adev,u32 * flags)206*b843c749SSergey Zigachev static void nbio_v7_0_get_clockgating_state(struct amdgpu_device *adev,
207*b843c749SSergey Zigachev 					    u32 *flags)
208*b843c749SSergey Zigachev {
209*b843c749SSergey Zigachev 	int data;
210*b843c749SSergey Zigachev 
211*b843c749SSergey Zigachev 	/* AMD_CG_SUPPORT_BIF_MGCG */
212*b843c749SSergey Zigachev 	data = RREG32_PCIE(smnCPM_CONTROL);
213*b843c749SSergey Zigachev 	if (data & CPM_CONTROL__LCLK_DYN_GATE_ENABLE_MASK)
214*b843c749SSergey Zigachev 		*flags |= AMD_CG_SUPPORT_BIF_MGCG;
215*b843c749SSergey Zigachev 
216*b843c749SSergey Zigachev 	/* AMD_CG_SUPPORT_BIF_LS */
217*b843c749SSergey Zigachev 	data = RREG32_PCIE(smnPCIE_CNTL2);
218*b843c749SSergey Zigachev 	if (data & PCIE_CNTL2__SLV_MEM_LS_EN_MASK)
219*b843c749SSergey Zigachev 		*flags |= AMD_CG_SUPPORT_BIF_LS;
220*b843c749SSergey Zigachev }
221*b843c749SSergey Zigachev 
nbio_v7_0_ih_control(struct amdgpu_device * adev)222*b843c749SSergey Zigachev static void nbio_v7_0_ih_control(struct amdgpu_device *adev)
223*b843c749SSergey Zigachev {
224*b843c749SSergey Zigachev 	u32 interrupt_cntl;
225*b843c749SSergey Zigachev 
226*b843c749SSergey Zigachev 	/* setup interrupt control */
227*b843c749SSergey Zigachev 	WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL2, adev->dummy_page_addr >> 8);
228*b843c749SSergey Zigachev 	interrupt_cntl = RREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL);
229*b843c749SSergey Zigachev 	/* INTERRUPT_CNTL__IH_DUMMY_RD_OVERRIDE_MASK=0 - dummy read disabled with msi, enabled without msi
230*b843c749SSergey Zigachev 	 * INTERRUPT_CNTL__IH_DUMMY_RD_OVERRIDE_MASK=1 - dummy read controlled by IH_DUMMY_RD_EN
231*b843c749SSergey Zigachev 	 */
232*b843c749SSergey Zigachev 	interrupt_cntl = REG_SET_FIELD(interrupt_cntl, INTERRUPT_CNTL, IH_DUMMY_RD_OVERRIDE, 0);
233*b843c749SSergey Zigachev 	/* INTERRUPT_CNTL__IH_REQ_NONSNOOP_EN_MASK=1 if ring is in non-cacheable memory, e.g., vram */
234*b843c749SSergey Zigachev 	interrupt_cntl = REG_SET_FIELD(interrupt_cntl, INTERRUPT_CNTL, IH_REQ_NONSNOOP_EN, 0);
235*b843c749SSergey Zigachev 	WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL, interrupt_cntl);
236*b843c749SSergey Zigachev }
237*b843c749SSergey Zigachev 
nbio_v7_0_get_hdp_flush_req_offset(struct amdgpu_device * adev)238*b843c749SSergey Zigachev static u32 nbio_v7_0_get_hdp_flush_req_offset(struct amdgpu_device *adev)
239*b843c749SSergey Zigachev {
240*b843c749SSergey Zigachev 	return SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_REQ);
241*b843c749SSergey Zigachev }
242*b843c749SSergey Zigachev 
nbio_v7_0_get_hdp_flush_done_offset(struct amdgpu_device * adev)243*b843c749SSergey Zigachev static u32 nbio_v7_0_get_hdp_flush_done_offset(struct amdgpu_device *adev)
244*b843c749SSergey Zigachev {
245*b843c749SSergey Zigachev 	return SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_DONE);
246*b843c749SSergey Zigachev }
247*b843c749SSergey Zigachev 
nbio_v7_0_get_pcie_index_offset(struct amdgpu_device * adev)248*b843c749SSergey Zigachev static u32 nbio_v7_0_get_pcie_index_offset(struct amdgpu_device *adev)
249*b843c749SSergey Zigachev {
250*b843c749SSergey Zigachev 	return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_INDEX2);
251*b843c749SSergey Zigachev }
252*b843c749SSergey Zigachev 
nbio_v7_0_get_pcie_data_offset(struct amdgpu_device * adev)253*b843c749SSergey Zigachev static u32 nbio_v7_0_get_pcie_data_offset(struct amdgpu_device *adev)
254*b843c749SSergey Zigachev {
255*b843c749SSergey Zigachev 	return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_DATA2);
256*b843c749SSergey Zigachev }
257*b843c749SSergey Zigachev 
258*b843c749SSergey Zigachev const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = {
259*b843c749SSergey Zigachev 	.ref_and_mask_cp0 = GPU_HDP_FLUSH_DONE__CP0_MASK,
260*b843c749SSergey Zigachev 	.ref_and_mask_cp1 = GPU_HDP_FLUSH_DONE__CP1_MASK,
261*b843c749SSergey Zigachev 	.ref_and_mask_cp2 = GPU_HDP_FLUSH_DONE__CP2_MASK,
262*b843c749SSergey Zigachev 	.ref_and_mask_cp3 = GPU_HDP_FLUSH_DONE__CP3_MASK,
263*b843c749SSergey Zigachev 	.ref_and_mask_cp4 = GPU_HDP_FLUSH_DONE__CP4_MASK,
264*b843c749SSergey Zigachev 	.ref_and_mask_cp5 = GPU_HDP_FLUSH_DONE__CP5_MASK,
265*b843c749SSergey Zigachev 	.ref_and_mask_cp6 = GPU_HDP_FLUSH_DONE__CP6_MASK,
266*b843c749SSergey Zigachev 	.ref_and_mask_cp7 = GPU_HDP_FLUSH_DONE__CP7_MASK,
267*b843c749SSergey Zigachev 	.ref_and_mask_cp8 = GPU_HDP_FLUSH_DONE__CP8_MASK,
268*b843c749SSergey Zigachev 	.ref_and_mask_cp9 = GPU_HDP_FLUSH_DONE__CP9_MASK,
269*b843c749SSergey Zigachev 	.ref_and_mask_sdma0 = GPU_HDP_FLUSH_DONE__SDMA0_MASK,
270*b843c749SSergey Zigachev 	.ref_and_mask_sdma1 = GPU_HDP_FLUSH_DONE__SDMA1_MASK,
271*b843c749SSergey Zigachev };
272*b843c749SSergey Zigachev 
nbio_v7_0_detect_hw_virt(struct amdgpu_device * adev)273*b843c749SSergey Zigachev static void nbio_v7_0_detect_hw_virt(struct amdgpu_device *adev)
274*b843c749SSergey Zigachev {
275*b843c749SSergey Zigachev 	if (is_virtual_machine())	/* passthrough mode exclus sriov mod */
276*b843c749SSergey Zigachev 		adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
277*b843c749SSergey Zigachev }
278*b843c749SSergey Zigachev 
nbio_v7_0_init_registers(struct amdgpu_device * adev)279*b843c749SSergey Zigachev static void nbio_v7_0_init_registers(struct amdgpu_device *adev)
280*b843c749SSergey Zigachev {
281*b843c749SSergey Zigachev 
282*b843c749SSergey Zigachev }
283*b843c749SSergey Zigachev 
284*b843c749SSergey Zigachev const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {
285*b843c749SSergey Zigachev 	.hdp_flush_reg = &nbio_v7_0_hdp_flush_reg,
286*b843c749SSergey Zigachev 	.get_hdp_flush_req_offset = nbio_v7_0_get_hdp_flush_req_offset,
287*b843c749SSergey Zigachev 	.get_hdp_flush_done_offset = nbio_v7_0_get_hdp_flush_done_offset,
288*b843c749SSergey Zigachev 	.get_pcie_index_offset = nbio_v7_0_get_pcie_index_offset,
289*b843c749SSergey Zigachev 	.get_pcie_data_offset = nbio_v7_0_get_pcie_data_offset,
290*b843c749SSergey Zigachev 	.get_rev_id = nbio_v7_0_get_rev_id,
291*b843c749SSergey Zigachev 	.mc_access_enable = nbio_v7_0_mc_access_enable,
292*b843c749SSergey Zigachev 	.hdp_flush = nbio_v7_0_hdp_flush,
293*b843c749SSergey Zigachev 	.get_memsize = nbio_v7_0_get_memsize,
294*b843c749SSergey Zigachev 	.sdma_doorbell_range = nbio_v7_0_sdma_doorbell_range,
295*b843c749SSergey Zigachev 	.enable_doorbell_aperture = nbio_v7_0_enable_doorbell_aperture,
296*b843c749SSergey Zigachev 	.enable_doorbell_selfring_aperture = nbio_v7_0_enable_doorbell_selfring_aperture,
297*b843c749SSergey Zigachev 	.ih_doorbell_range = nbio_v7_0_ih_doorbell_range,
298*b843c749SSergey Zigachev 	.update_medium_grain_clock_gating = nbio_v7_0_update_medium_grain_clock_gating,
299*b843c749SSergey Zigachev 	.update_medium_grain_light_sleep = nbio_v7_0_update_medium_grain_light_sleep,
300*b843c749SSergey Zigachev 	.get_clockgating_state = nbio_v7_0_get_clockgating_state,
301*b843c749SSergey Zigachev 	.ih_control = nbio_v7_0_ih_control,
302*b843c749SSergey Zigachev 	.init_registers = nbio_v7_0_init_registers,
303*b843c749SSergey Zigachev 	.detect_hw_virt = nbio_v7_0_detect_hw_virt,
304*b843c749SSergey Zigachev };
305