xref: /linux/drivers/gpu/drm/amd/amdgpu/nbio_v7_0.c (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1954d5d43SChunming Zhou /*
2954d5d43SChunming Zhou  * Copyright 2016 Advanced Micro Devices, Inc.
3954d5d43SChunming Zhou  *
4954d5d43SChunming Zhou  * Permission is hereby granted, free of charge, to any person obtaining a
5954d5d43SChunming Zhou  * copy of this software and associated documentation files (the "Software"),
6954d5d43SChunming Zhou  * to deal in the Software without restriction, including without limitation
7954d5d43SChunming Zhou  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8954d5d43SChunming Zhou  * and/or sell copies of the Software, and to permit persons to whom the
9954d5d43SChunming Zhou  * Software is furnished to do so, subject to the following conditions:
10954d5d43SChunming Zhou  *
11954d5d43SChunming Zhou  * The above copyright notice and this permission notice shall be included in
12954d5d43SChunming Zhou  * all copies or substantial portions of the Software.
13954d5d43SChunming Zhou  *
14954d5d43SChunming Zhou  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15954d5d43SChunming Zhou  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16954d5d43SChunming Zhou  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17954d5d43SChunming Zhou  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18954d5d43SChunming Zhou  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19954d5d43SChunming Zhou  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20954d5d43SChunming Zhou  * OTHER DEALINGS IN THE SOFTWARE.
21954d5d43SChunming Zhou  *
22954d5d43SChunming Zhou  */
23954d5d43SChunming Zhou #include "amdgpu.h"
24954d5d43SChunming Zhou #include "amdgpu_atombios.h"
25954d5d43SChunming Zhou #include "nbio_v7_0.h"
26954d5d43SChunming Zhou 
2751199920SFeifei Xu #include "nbio/nbio_7_0_default.h"
2851199920SFeifei Xu #include "nbio/nbio_7_0_offset.h"
2951199920SFeifei Xu #include "nbio/nbio_7_0_sh_mask.h"
30a0bb79e2SKent Russell #include "nbio/nbio_7_0_smn.h"
31fb960bd2SFeifei Xu #include "vega10_enum.h"
3288807dc8SOak Zeng #include <uapi/linux/kfd_ioctl.h>
33954d5d43SChunming Zhou 
34954d5d43SChunming Zhou #define smnNBIF_MGCG_CTRL_LCLK	0x1013a05c
35954d5d43SChunming Zhou 
nbio_v7_0_remap_hdp_registers(struct amdgpu_device * adev)3688807dc8SOak Zeng static void nbio_v7_0_remap_hdp_registers(struct amdgpu_device *adev)
3788807dc8SOak Zeng {
3888807dc8SOak Zeng 	WREG32_SOC15(NBIO, 0, mmREMAP_HDP_MEM_FLUSH_CNTL,
3988807dc8SOak Zeng 		adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL);
4088807dc8SOak Zeng 	WREG32_SOC15(NBIO, 0, mmREMAP_HDP_REG_FLUSH_CNTL,
4188807dc8SOak Zeng 		adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_REG_FLUSH_CNTL);
4288807dc8SOak Zeng }
4388807dc8SOak Zeng 
nbio_v7_0_get_rev_id(struct amdgpu_device * adev)44bf383fb6SAlex Deucher static u32 nbio_v7_0_get_rev_id(struct amdgpu_device *adev)
45954d5d43SChunming Zhou {
46ba7d5a22STom St Denis 	u32 tmp = RREG32_SOC15(NBIO, 0, mmRCC_DEV0_EPF0_STRAP0);
47954d5d43SChunming Zhou 
48954d5d43SChunming Zhou 	tmp &= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0_MASK;
49954d5d43SChunming Zhou 	tmp >>= RCC_DEV0_EPF0_STRAP0__STRAP_ATI_REV_ID_DEV0_F0__SHIFT;
50954d5d43SChunming Zhou 
51954d5d43SChunming Zhou 	return tmp;
52954d5d43SChunming Zhou }
53954d5d43SChunming Zhou 
nbio_v7_0_mc_access_enable(struct amdgpu_device * adev,bool enable)54bf383fb6SAlex Deucher static void nbio_v7_0_mc_access_enable(struct amdgpu_device *adev, bool enable)
55954d5d43SChunming Zhou {
56954d5d43SChunming Zhou 	if (enable)
57ba7d5a22STom St Denis 		WREG32_SOC15(NBIO, 0, mmBIF_FB_EN,
58954d5d43SChunming Zhou 			BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK);
59954d5d43SChunming Zhou 	else
60ba7d5a22STom St Denis 		WREG32_SOC15(NBIO, 0, mmBIF_FB_EN, 0);
61954d5d43SChunming Zhou }
62954d5d43SChunming Zhou 
nbio_v7_0_get_memsize(struct amdgpu_device * adev)63bf383fb6SAlex Deucher static u32 nbio_v7_0_get_memsize(struct amdgpu_device *adev)
64954d5d43SChunming Zhou {
65ba7d5a22STom St Denis 	return RREG32_SOC15(NBIO, 0, mmRCC_CONFIG_MEMSIZE);
66954d5d43SChunming Zhou }
67954d5d43SChunming Zhou 
nbio_v7_0_sdma_doorbell_range(struct amdgpu_device * adev,int instance,bool use_doorbell,int doorbell_index,int doorbell_size)68bf383fb6SAlex Deucher static void nbio_v7_0_sdma_doorbell_range(struct amdgpu_device *adev, int instance,
698987e2e2SOak Zeng 			bool use_doorbell, int doorbell_index, int doorbell_size)
70954d5d43SChunming Zhou {
71946a4d5bSShaoyun Liu 	u32 reg = instance == 0 ? SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA0_DOORBELL_RANGE) :
72946a4d5bSShaoyun Liu 			SOC15_REG_OFFSET(NBIO, 0, mmBIF_SDMA1_DOORBELL_RANGE);
73946a4d5bSShaoyun Liu 
74946a4d5bSShaoyun Liu 	u32 doorbell_range = RREG32(reg);
75954d5d43SChunming Zhou 
76954d5d43SChunming Zhou 	if (use_doorbell) {
77954d5d43SChunming Zhou 		doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, OFFSET, doorbell_index);
788987e2e2SOak Zeng 		doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, doorbell_size);
79954d5d43SChunming Zhou 	} else
80954d5d43SChunming Zhou 		doorbell_range = REG_SET_FIELD(doorbell_range, BIF_SDMA0_DOORBELL_RANGE, SIZE, 0);
81954d5d43SChunming Zhou 
82946a4d5bSShaoyun Liu 	WREG32(reg, doorbell_range);
83954d5d43SChunming Zhou }
84954d5d43SChunming Zhou 
nbio_v7_0_vcn_doorbell_range(struct amdgpu_device * adev,bool use_doorbell,int doorbell_index,int instance)850c6b391dSLeo Liu static void nbio_v7_0_vcn_doorbell_range(struct amdgpu_device *adev, bool use_doorbell,
860c6b391dSLeo Liu 					 int doorbell_index, int instance)
870c6b391dSLeo Liu {
880c6b391dSLeo Liu 	u32 reg = SOC15_REG_OFFSET(NBIO, 0, mmBIF_MMSCH0_DOORBELL_RANGE);
890c6b391dSLeo Liu 
900c6b391dSLeo Liu 	u32 doorbell_range = RREG32(reg);
910c6b391dSLeo Liu 
920c6b391dSLeo Liu 	if (use_doorbell) {
930c6b391dSLeo Liu 		doorbell_range = REG_SET_FIELD(doorbell_range,
940c6b391dSLeo Liu 					       BIF_MMSCH0_DOORBELL_RANGE, OFFSET,
950c6b391dSLeo Liu 					       doorbell_index);
960c6b391dSLeo Liu 		doorbell_range = REG_SET_FIELD(doorbell_range,
970c6b391dSLeo Liu 					       BIF_MMSCH0_DOORBELL_RANGE, SIZE, 8);
980c6b391dSLeo Liu 	} else
990c6b391dSLeo Liu 		doorbell_range = REG_SET_FIELD(doorbell_range,
1000c6b391dSLeo Liu 					       BIF_MMSCH0_DOORBELL_RANGE, SIZE, 0);
1010c6b391dSLeo Liu 
1020c6b391dSLeo Liu 	WREG32(reg, doorbell_range);
1030c6b391dSLeo Liu }
1040c6b391dSLeo Liu 
nbio_v7_0_enable_doorbell_aperture(struct amdgpu_device * adev,bool enable)105bf383fb6SAlex Deucher static void nbio_v7_0_enable_doorbell_aperture(struct amdgpu_device *adev,
106954d5d43SChunming Zhou 					       bool enable)
107954d5d43SChunming Zhou {
108ba7d5a22STom St Denis 	WREG32_FIELD15(NBIO, 0, RCC_DOORBELL_APER_EN, BIF_DOORBELL_APER_EN, enable ? 1 : 0);
109954d5d43SChunming Zhou }
110954d5d43SChunming Zhou 
nbio_v7_0_enable_doorbell_selfring_aperture(struct amdgpu_device * adev,bool enable)111bf383fb6SAlex Deucher static void nbio_v7_0_enable_doorbell_selfring_aperture(struct amdgpu_device *adev,
112bf383fb6SAlex Deucher 							bool enable)
113bf383fb6SAlex Deucher {
114bf383fb6SAlex Deucher 
115bf383fb6SAlex Deucher }
116bf383fb6SAlex Deucher 
nbio_v7_0_ih_doorbell_range(struct amdgpu_device * adev,bool use_doorbell,int doorbell_index)117bf383fb6SAlex Deucher static void nbio_v7_0_ih_doorbell_range(struct amdgpu_device *adev,
118954d5d43SChunming Zhou 					bool use_doorbell, int doorbell_index)
119954d5d43SChunming Zhou {
120ba7d5a22STom St Denis 	u32 ih_doorbell_range = RREG32_SOC15(NBIO, 0, mmBIF_IH_DOORBELL_RANGE);
121954d5d43SChunming Zhou 
122954d5d43SChunming Zhou 	if (use_doorbell) {
123954d5d43SChunming Zhou 		ih_doorbell_range = REG_SET_FIELD(ih_doorbell_range, BIF_IH_DOORBELL_RANGE, OFFSET, doorbell_index);
124954d5d43SChunming Zhou 		ih_doorbell_range = REG_SET_FIELD(ih_doorbell_range, BIF_IH_DOORBELL_RANGE, SIZE, 2);
125954d5d43SChunming Zhou 	} else
126954d5d43SChunming Zhou 		ih_doorbell_range = REG_SET_FIELD(ih_doorbell_range, BIF_IH_DOORBELL_RANGE, SIZE, 0);
127954d5d43SChunming Zhou 
128ba7d5a22STom St Denis 	WREG32_SOC15(NBIO, 0, mmBIF_IH_DOORBELL_RANGE, ih_doorbell_range);
129954d5d43SChunming Zhou }
130954d5d43SChunming Zhou 
nbio_7_0_read_syshub_ind_mmr(struct amdgpu_device * adev,uint32_t offset)131954d5d43SChunming Zhou static uint32_t nbio_7_0_read_syshub_ind_mmr(struct amdgpu_device *adev, uint32_t offset)
132954d5d43SChunming Zhou {
133954d5d43SChunming Zhou 	uint32_t data;
134954d5d43SChunming Zhou 
135ba7d5a22STom St Denis 	WREG32_SOC15(NBIO, 0, mmSYSHUB_INDEX, offset);
136ba7d5a22STom St Denis 	data = RREG32_SOC15(NBIO, 0, mmSYSHUB_DATA);
137954d5d43SChunming Zhou 
138954d5d43SChunming Zhou 	return data;
139954d5d43SChunming Zhou }
140954d5d43SChunming Zhou 
nbio_7_0_write_syshub_ind_mmr(struct amdgpu_device * adev,uint32_t offset,uint32_t data)141954d5d43SChunming Zhou static void nbio_7_0_write_syshub_ind_mmr(struct amdgpu_device *adev, uint32_t offset,
142954d5d43SChunming Zhou 				       uint32_t data)
143954d5d43SChunming Zhou {
144ba7d5a22STom St Denis 	WREG32_SOC15(NBIO, 0, mmSYSHUB_INDEX, offset);
145ba7d5a22STom St Denis 	WREG32_SOC15(NBIO, 0, mmSYSHUB_DATA, data);
146954d5d43SChunming Zhou }
147954d5d43SChunming Zhou 
nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device * adev,bool enable)148bf383fb6SAlex Deucher static void nbio_v7_0_update_medium_grain_clock_gating(struct amdgpu_device *adev,
149954d5d43SChunming Zhou 						       bool enable)
150954d5d43SChunming Zhou {
151954d5d43SChunming Zhou 	uint32_t def, data;
152954d5d43SChunming Zhou 
153954d5d43SChunming Zhou 	/* NBIF_MGCG_CTRL_LCLK */
154954d5d43SChunming Zhou 	def = data = RREG32_PCIE(smnNBIF_MGCG_CTRL_LCLK);
155954d5d43SChunming Zhou 
156954d5d43SChunming Zhou 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG))
157954d5d43SChunming Zhou 		data |= NBIF_MGCG_CTRL_LCLK__NBIF_MGCG_EN_LCLK_MASK;
158954d5d43SChunming Zhou 	else
159954d5d43SChunming Zhou 		data &= ~NBIF_MGCG_CTRL_LCLK__NBIF_MGCG_EN_LCLK_MASK;
160954d5d43SChunming Zhou 
161954d5d43SChunming Zhou 	if (def != data)
162954d5d43SChunming Zhou 		WREG32_PCIE(smnNBIF_MGCG_CTRL_LCLK, data);
163954d5d43SChunming Zhou 
164954d5d43SChunming Zhou 	/* SYSHUB_MGCG_CTRL_SOCCLK */
165954d5d43SChunming Zhou 	def = data = nbio_7_0_read_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SOCCLK);
166954d5d43SChunming Zhou 
167954d5d43SChunming Zhou 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG))
168954d5d43SChunming Zhou 		data |= SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SOCCLK__SYSHUB_MGCG_EN_SOCCLK_MASK;
169954d5d43SChunming Zhou 	else
170954d5d43SChunming Zhou 		data &= ~SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SOCCLK__SYSHUB_MGCG_EN_SOCCLK_MASK;
171954d5d43SChunming Zhou 
172954d5d43SChunming Zhou 	if (def != data)
173954d5d43SChunming Zhou 		nbio_7_0_write_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SOCCLK, data);
174954d5d43SChunming Zhou 
175954d5d43SChunming Zhou 	/* SYSHUB_MGCG_CTRL_SHUBCLK */
176954d5d43SChunming Zhou 	def = data = nbio_7_0_read_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SHUBCLK);
177954d5d43SChunming Zhou 
178954d5d43SChunming Zhou 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_MGCG))
179954d5d43SChunming Zhou 		data |= SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SHUBCLK__SYSHUB_MGCG_EN_SHUBCLK_MASK;
180954d5d43SChunming Zhou 	else
181954d5d43SChunming Zhou 		data &= ~SYSHUB_MMREG_DIRECT_SYSHUB_MGCG_CTRL_SHUBCLK__SYSHUB_MGCG_EN_SHUBCLK_MASK;
182954d5d43SChunming Zhou 
183954d5d43SChunming Zhou 	if (def != data)
184954d5d43SChunming Zhou 		nbio_7_0_write_syshub_ind_mmr(adev, ixSYSHUB_MMREG_IND_SYSHUB_MGCG_CTRL_SHUBCLK, data);
185954d5d43SChunming Zhou }
186954d5d43SChunming Zhou 
nbio_v7_0_update_medium_grain_light_sleep(struct amdgpu_device * adev,bool enable)187bf383fb6SAlex Deucher static void nbio_v7_0_update_medium_grain_light_sleep(struct amdgpu_device *adev,
188bf383fb6SAlex Deucher 						      bool enable)
189bf383fb6SAlex Deucher {
190bf383fb6SAlex Deucher 	uint32_t def, data;
191bf383fb6SAlex Deucher 
192bf383fb6SAlex Deucher 	def = data = RREG32_PCIE(smnPCIE_CNTL2);
193bf383fb6SAlex Deucher 	if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS)) {
194bf383fb6SAlex Deucher 		data |= (PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
195bf383fb6SAlex Deucher 			 PCIE_CNTL2__MST_MEM_LS_EN_MASK |
196bf383fb6SAlex Deucher 			 PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK);
197bf383fb6SAlex Deucher 	} else {
198bf383fb6SAlex Deucher 		data &= ~(PCIE_CNTL2__SLV_MEM_LS_EN_MASK |
199bf383fb6SAlex Deucher 			  PCIE_CNTL2__MST_MEM_LS_EN_MASK |
200bf383fb6SAlex Deucher 			  PCIE_CNTL2__REPLAY_MEM_LS_EN_MASK);
201bf383fb6SAlex Deucher 	}
202bf383fb6SAlex Deucher 
203bf383fb6SAlex Deucher 	if (def != data)
204bf383fb6SAlex Deucher 		WREG32_PCIE(smnPCIE_CNTL2, data);
205bf383fb6SAlex Deucher }
206bf383fb6SAlex Deucher 
nbio_v7_0_get_clockgating_state(struct amdgpu_device * adev,u64 * flags)207bf383fb6SAlex Deucher static void nbio_v7_0_get_clockgating_state(struct amdgpu_device *adev,
20825faeddcSEvan Quan 					    u64 *flags)
209bf383fb6SAlex Deucher {
210bf383fb6SAlex Deucher 	int data;
211bf383fb6SAlex Deucher 
212bf383fb6SAlex Deucher 	/* AMD_CG_SUPPORT_BIF_MGCG */
213bf383fb6SAlex Deucher 	data = RREG32_PCIE(smnCPM_CONTROL);
214bf383fb6SAlex Deucher 	if (data & CPM_CONTROL__LCLK_DYN_GATE_ENABLE_MASK)
215bf383fb6SAlex Deucher 		*flags |= AMD_CG_SUPPORT_BIF_MGCG;
216bf383fb6SAlex Deucher 
217bf383fb6SAlex Deucher 	/* AMD_CG_SUPPORT_BIF_LS */
218bf383fb6SAlex Deucher 	data = RREG32_PCIE(smnPCIE_CNTL2);
219bf383fb6SAlex Deucher 	if (data & PCIE_CNTL2__SLV_MEM_LS_EN_MASK)
220bf383fb6SAlex Deucher 		*flags |= AMD_CG_SUPPORT_BIF_LS;
221bf383fb6SAlex Deucher }
222bf383fb6SAlex Deucher 
nbio_v7_0_ih_control(struct amdgpu_device * adev)223bf383fb6SAlex Deucher static void nbio_v7_0_ih_control(struct amdgpu_device *adev)
224954d5d43SChunming Zhou {
225954d5d43SChunming Zhou 	u32 interrupt_cntl;
226954d5d43SChunming Zhou 
227954d5d43SChunming Zhou 	/* setup interrupt control */
22892e71b06SChristian König 	WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL2, adev->dummy_page_addr >> 8);
229ba7d5a22STom St Denis 	interrupt_cntl = RREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL);
230954d5d43SChunming Zhou 	/* INTERRUPT_CNTL__IH_DUMMY_RD_OVERRIDE_MASK=0 - dummy read disabled with msi, enabled without msi
231954d5d43SChunming Zhou 	 * INTERRUPT_CNTL__IH_DUMMY_RD_OVERRIDE_MASK=1 - dummy read controlled by IH_DUMMY_RD_EN
232954d5d43SChunming Zhou 	 */
233954d5d43SChunming Zhou 	interrupt_cntl = REG_SET_FIELD(interrupt_cntl, INTERRUPT_CNTL, IH_DUMMY_RD_OVERRIDE, 0);
234954d5d43SChunming Zhou 	/* INTERRUPT_CNTL__IH_REQ_NONSNOOP_EN_MASK=1 if ring is in non-cacheable memory, e.g., vram */
235954d5d43SChunming Zhou 	interrupt_cntl = REG_SET_FIELD(interrupt_cntl, INTERRUPT_CNTL, IH_REQ_NONSNOOP_EN, 0);
236ba7d5a22STom St Denis 	WREG32_SOC15(NBIO, 0, mmINTERRUPT_CNTL, interrupt_cntl);
237954d5d43SChunming Zhou }
238954d5d43SChunming Zhou 
nbio_v7_0_get_hdp_flush_req_offset(struct amdgpu_device * adev)23974e1d67cSAlex Deucher static u32 nbio_v7_0_get_hdp_flush_req_offset(struct amdgpu_device *adev)
240946a4d5bSShaoyun Liu {
241946a4d5bSShaoyun Liu 	return SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_REQ);
242946a4d5bSShaoyun Liu }
243946a4d5bSShaoyun Liu 
nbio_v7_0_get_hdp_flush_done_offset(struct amdgpu_device * adev)24474e1d67cSAlex Deucher static u32 nbio_v7_0_get_hdp_flush_done_offset(struct amdgpu_device *adev)
245946a4d5bSShaoyun Liu {
246946a4d5bSShaoyun Liu 	return SOC15_REG_OFFSET(NBIO, 0, mmGPU_HDP_FLUSH_DONE);
247946a4d5bSShaoyun Liu }
248946a4d5bSShaoyun Liu 
nbio_v7_0_get_pcie_index_offset(struct amdgpu_device * adev)24974e1d67cSAlex Deucher static u32 nbio_v7_0_get_pcie_index_offset(struct amdgpu_device *adev)
250946a4d5bSShaoyun Liu {
251946a4d5bSShaoyun Liu 	return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_INDEX2);
252946a4d5bSShaoyun Liu }
253946a4d5bSShaoyun Liu 
nbio_v7_0_get_pcie_data_offset(struct amdgpu_device * adev)25474e1d67cSAlex Deucher static u32 nbio_v7_0_get_pcie_data_offset(struct amdgpu_device *adev)
255946a4d5bSShaoyun Liu {
256946a4d5bSShaoyun Liu 	return SOC15_REG_OFFSET(NBIO, 0, mmPCIE_DATA2);
257946a4d5bSShaoyun Liu }
258946a4d5bSShaoyun Liu 
259c6622f3aSDave Airlie const struct nbio_hdp_flush_reg nbio_v7_0_hdp_flush_reg = {
260c6622f3aSDave Airlie 	.ref_and_mask_cp0 = GPU_HDP_FLUSH_DONE__CP0_MASK,
261c6622f3aSDave Airlie 	.ref_and_mask_cp1 = GPU_HDP_FLUSH_DONE__CP1_MASK,
262c6622f3aSDave Airlie 	.ref_and_mask_cp2 = GPU_HDP_FLUSH_DONE__CP2_MASK,
263c6622f3aSDave Airlie 	.ref_and_mask_cp3 = GPU_HDP_FLUSH_DONE__CP3_MASK,
264c6622f3aSDave Airlie 	.ref_and_mask_cp4 = GPU_HDP_FLUSH_DONE__CP4_MASK,
265c6622f3aSDave Airlie 	.ref_and_mask_cp5 = GPU_HDP_FLUSH_DONE__CP5_MASK,
266c6622f3aSDave Airlie 	.ref_and_mask_cp6 = GPU_HDP_FLUSH_DONE__CP6_MASK,
267c6622f3aSDave Airlie 	.ref_and_mask_cp7 = GPU_HDP_FLUSH_DONE__CP7_MASK,
268c6622f3aSDave Airlie 	.ref_and_mask_cp8 = GPU_HDP_FLUSH_DONE__CP8_MASK,
269c6622f3aSDave Airlie 	.ref_and_mask_cp9 = GPU_HDP_FLUSH_DONE__CP9_MASK,
270c6622f3aSDave Airlie 	.ref_and_mask_sdma0 = GPU_HDP_FLUSH_DONE__SDMA0_MASK,
271c6622f3aSDave Airlie 	.ref_and_mask_sdma1 = GPU_HDP_FLUSH_DONE__SDMA1_MASK,
272c6622f3aSDave Airlie };
273c6622f3aSDave Airlie 
nbio_v7_0_init_registers(struct amdgpu_device * adev)274bf383fb6SAlex Deucher static void nbio_v7_0_init_registers(struct amdgpu_device *adev)
275bf383fb6SAlex Deucher {
276bf383fb6SAlex Deucher }
277bf383fb6SAlex Deucher 
278*b2648640SAlex Deucher #define MMIO_REG_HOLE_OFFSET (0x80000 - PAGE_SIZE)
279*b2648640SAlex Deucher 
nbio_v7_0_set_reg_remap(struct amdgpu_device * adev)280*b2648640SAlex Deucher static void nbio_v7_0_set_reg_remap(struct amdgpu_device *adev)
281*b2648640SAlex Deucher {
282*b2648640SAlex Deucher 	if (!amdgpu_sriov_vf(adev) && (PAGE_SIZE <= 4096)) {
283*b2648640SAlex Deucher 		adev->rmmio_remap.reg_offset = MMIO_REG_HOLE_OFFSET;
284*b2648640SAlex Deucher 		adev->rmmio_remap.bus_addr = adev->rmmio_base + MMIO_REG_HOLE_OFFSET;
285*b2648640SAlex Deucher 	} else {
286*b2648640SAlex Deucher 		adev->rmmio_remap.reg_offset =
287*b2648640SAlex Deucher 			SOC15_REG_OFFSET(NBIO, 0, mmHDP_MEM_COHERENCY_FLUSH_CNTL) << 2;
288*b2648640SAlex Deucher 		adev->rmmio_remap.bus_addr = 0;
289*b2648640SAlex Deucher 	}
290*b2648640SAlex Deucher }
291*b2648640SAlex Deucher 
292946a4d5bSShaoyun Liu const struct amdgpu_nbio_funcs nbio_v7_0_funcs = {
29374e1d67cSAlex Deucher 	.get_hdp_flush_req_offset = nbio_v7_0_get_hdp_flush_req_offset,
29474e1d67cSAlex Deucher 	.get_hdp_flush_done_offset = nbio_v7_0_get_hdp_flush_done_offset,
29574e1d67cSAlex Deucher 	.get_pcie_index_offset = nbio_v7_0_get_pcie_index_offset,
29674e1d67cSAlex Deucher 	.get_pcie_data_offset = nbio_v7_0_get_pcie_data_offset,
297bf383fb6SAlex Deucher 	.get_rev_id = nbio_v7_0_get_rev_id,
298bf383fb6SAlex Deucher 	.mc_access_enable = nbio_v7_0_mc_access_enable,
299bf383fb6SAlex Deucher 	.get_memsize = nbio_v7_0_get_memsize,
300bf383fb6SAlex Deucher 	.sdma_doorbell_range = nbio_v7_0_sdma_doorbell_range,
3010c6b391dSLeo Liu 	.vcn_doorbell_range = nbio_v7_0_vcn_doorbell_range,
302bf383fb6SAlex Deucher 	.enable_doorbell_aperture = nbio_v7_0_enable_doorbell_aperture,
303bf383fb6SAlex Deucher 	.enable_doorbell_selfring_aperture = nbio_v7_0_enable_doorbell_selfring_aperture,
304bf383fb6SAlex Deucher 	.ih_doorbell_range = nbio_v7_0_ih_doorbell_range,
305bf383fb6SAlex Deucher 	.update_medium_grain_clock_gating = nbio_v7_0_update_medium_grain_clock_gating,
306bf383fb6SAlex Deucher 	.update_medium_grain_light_sleep = nbio_v7_0_update_medium_grain_light_sleep,
307bf383fb6SAlex Deucher 	.get_clockgating_state = nbio_v7_0_get_clockgating_state,
308bf383fb6SAlex Deucher 	.ih_control = nbio_v7_0_ih_control,
309bf383fb6SAlex Deucher 	.init_registers = nbio_v7_0_init_registers,
31088807dc8SOak Zeng 	.remap_hdp_registers = nbio_v7_0_remap_hdp_registers,
311*b2648640SAlex Deucher 	.set_reg_remap = nbio_v7_0_set_reg_remap,
31235b31f7cSDave Airlie };
313