xref: /linux/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1f37945d5SLe Ma /*
2f37945d5SLe Ma  * Copyright 2019 Advanced Micro Devices, Inc.
3f37945d5SLe Ma  *
4f37945d5SLe Ma  * Permission is hereby granted, free of charge, to any person obtaining a
5f37945d5SLe Ma  * copy of this software and associated documentation files (the "Software"),
6f37945d5SLe Ma  * to deal in the Software without restriction, including without limitation
7f37945d5SLe Ma  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8f37945d5SLe Ma  * and/or sell copies of the Software, and to permit persons to whom the
9f37945d5SLe Ma  * Software is furnished to do so, subject to the following conditions:
10f37945d5SLe Ma  *
11f37945d5SLe Ma  * The above copyright notice and this permission notice shall be included in
12f37945d5SLe Ma  * all copies or substantial portions of the Software.
13f37945d5SLe Ma  *
14f37945d5SLe Ma  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15f37945d5SLe Ma  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16f37945d5SLe Ma  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17f37945d5SLe Ma  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18f37945d5SLe Ma  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19f37945d5SLe Ma  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20f37945d5SLe Ma  * OTHER DEALINGS IN THE SOFTWARE.
21f37945d5SLe Ma  *
22f37945d5SLe Ma  */
23f37945d5SLe Ma #include "amdgpu.h"
24f37945d5SLe Ma #include "amdgpu_ras.h"
25f37945d5SLe Ma #include "mmhub_v1_7.h"
26f37945d5SLe Ma 
27f37945d5SLe Ma #include "mmhub/mmhub_1_7_offset.h"
28f37945d5SLe Ma #include "mmhub/mmhub_1_7_sh_mask.h"
29f37945d5SLe Ma #include "vega10_enum.h"
30f37945d5SLe Ma 
31f37945d5SLe Ma #include "soc15_common.h"
32cbb84e7aSHawking Zhang #include "soc15.h"
33f37945d5SLe Ma 
34f37945d5SLe Ma #define regVM_L2_CNTL3_DEFAULT	0x80100007
35f37945d5SLe Ma #define regVM_L2_CNTL4_DEFAULT	0x000000c1
36f37945d5SLe Ma 
mmhub_v1_7_get_fb_location(struct amdgpu_device * adev)374da999cdSOak Zeng static u64 mmhub_v1_7_get_fb_location(struct amdgpu_device *adev)
38f37945d5SLe Ma {
39f37945d5SLe Ma 	u64 base = RREG32_SOC15(MMHUB, 0, regMC_VM_FB_LOCATION_BASE);
40f37945d5SLe Ma 	u64 top = RREG32_SOC15(MMHUB, 0, regMC_VM_FB_LOCATION_TOP);
41f37945d5SLe Ma 
42f37945d5SLe Ma 	base &= MC_VM_FB_LOCATION_BASE__FB_BASE_MASK;
43f37945d5SLe Ma 	base <<= 24;
44f37945d5SLe Ma 
45f37945d5SLe Ma 	top &= MC_VM_FB_LOCATION_TOP__FB_TOP_MASK;
46f37945d5SLe Ma 	top <<= 24;
47f37945d5SLe Ma 
48f37945d5SLe Ma 	adev->gmc.fb_start = base;
49f37945d5SLe Ma 	adev->gmc.fb_end = top;
50f37945d5SLe Ma 
51f37945d5SLe Ma 	return base;
52f37945d5SLe Ma }
53f37945d5SLe Ma 
mmhub_v1_7_setup_vm_pt_regs(struct amdgpu_device * adev,uint32_t vmid,uint64_t page_table_base)5464f17158SOak Zeng static void mmhub_v1_7_setup_vm_pt_regs(struct amdgpu_device *adev, uint32_t vmid,
55f37945d5SLe Ma 				uint64_t page_table_base)
56f37945d5SLe Ma {
57f4caf584SHawking Zhang 	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_MMHUB0(0)];
58f37945d5SLe Ma 
59f37945d5SLe Ma 	WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32,
605be50a8fSKevin Wang 			hub->ctx_addr_distance * vmid, lower_32_bits(page_table_base));
61f37945d5SLe Ma 
62f37945d5SLe Ma 	WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32,
635be50a8fSKevin Wang 			hub->ctx_addr_distance * vmid, upper_32_bits(page_table_base));
64f37945d5SLe Ma }
65f37945d5SLe Ma 
mmhub_v1_7_init_gart_aperture_regs(struct amdgpu_device * adev)66f37945d5SLe Ma static void mmhub_v1_7_init_gart_aperture_regs(struct amdgpu_device *adev)
67f37945d5SLe Ma {
680c19cab5SOak Zeng 	uint64_t pt_base;
690c19cab5SOak Zeng 
700c19cab5SOak Zeng 	if (adev->gmc.pdb0_bo)
710c19cab5SOak Zeng 		pt_base = amdgpu_gmc_pd_addr(adev->gmc.pdb0_bo);
720c19cab5SOak Zeng 	else
730c19cab5SOak Zeng 		pt_base = amdgpu_gmc_pd_addr(adev->gart.bo);
74f37945d5SLe Ma 
75f37945d5SLe Ma 	mmhub_v1_7_setup_vm_pt_regs(adev, 0, pt_base);
76f37945d5SLe Ma 
770c19cab5SOak Zeng 	/* If use GART for FB translation, vmid0 page table covers both
780c19cab5SOak Zeng 	 * vram and system memory (gart)
790c19cab5SOak Zeng 	 */
800c19cab5SOak Zeng 	if (adev->gmc.pdb0_bo) {
810c19cab5SOak Zeng 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32,
820c19cab5SOak Zeng 				(u32)(adev->gmc.fb_start >> 12));
830c19cab5SOak Zeng 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32,
840c19cab5SOak Zeng 				(u32)(adev->gmc.fb_start >> 44));
850c19cab5SOak Zeng 
860c19cab5SOak Zeng 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32,
870c19cab5SOak Zeng 				(u32)(adev->gmc.gart_end >> 12));
880c19cab5SOak Zeng 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32,
890c19cab5SOak Zeng 				(u32)(adev->gmc.gart_end >> 44));
900c19cab5SOak Zeng 
910c19cab5SOak Zeng 	} else {
92f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32,
93f37945d5SLe Ma 				(u32)(adev->gmc.gart_start >> 12));
94f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32,
95f37945d5SLe Ma 				(u32)(adev->gmc.gart_start >> 44));
96f37945d5SLe Ma 
97f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32,
98f37945d5SLe Ma 				(u32)(adev->gmc.gart_end >> 12));
99f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32,
100f37945d5SLe Ma 				(u32)(adev->gmc.gart_end >> 44));
101f37945d5SLe Ma 	}
1020c19cab5SOak Zeng }
103f37945d5SLe Ma 
mmhub_v1_7_init_system_aperture_regs(struct amdgpu_device * adev)104f37945d5SLe Ma static void mmhub_v1_7_init_system_aperture_regs(struct amdgpu_device *adev)
105f37945d5SLe Ma {
106f37945d5SLe Ma 	uint64_t value;
107f37945d5SLe Ma 	uint32_t tmp;
108f37945d5SLe Ma 
109f37945d5SLe Ma 	/* Program the AGP BAR */
110f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_AGP_BASE, 0);
111f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_AGP_BOT, adev->gmc.agp_start >> 24);
112f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_AGP_TOP, adev->gmc.agp_end >> 24);
113f37945d5SLe Ma 
114488b83f4SZhigang Luo 	if (amdgpu_sriov_vf(adev))
115488b83f4SZhigang Luo 		return;
116488b83f4SZhigang Luo 
117f37945d5SLe Ma 	/* Program the system aperture low logical page number. */
118f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_SYSTEM_APERTURE_LOW_ADDR,
119f37945d5SLe Ma 		     min(adev->gmc.fb_start, adev->gmc.agp_start) >> 18);
120f37945d5SLe Ma 
121f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
122f37945d5SLe Ma 		     max(adev->gmc.fb_end, adev->gmc.agp_end) >> 18);
123f37945d5SLe Ma 
1240c19cab5SOak Zeng 	/* In the case squeezing vram into GART aperture, we don't use
1250c19cab5SOak Zeng 	 * FB aperture and AGP aperture. Disable them.
1260c19cab5SOak Zeng 	 */
1270c19cab5SOak Zeng 	if (adev->gmc.pdb0_bo) {
1280c19cab5SOak Zeng 		WREG32_SOC15(MMHUB, 0, regMC_VM_AGP_BOT, 0xFFFFFF);
1290c19cab5SOak Zeng 		WREG32_SOC15(MMHUB, 0, regMC_VM_AGP_TOP, 0);
1305f41741aSOak Zeng 		WREG32_SOC15(MMHUB, 0, regMC_VM_FB_LOCATION_TOP, 0);
1315f41741aSOak Zeng 		WREG32_SOC15(MMHUB, 0, regMC_VM_FB_LOCATION_BASE, 0x00FFFFFF);
1325f41741aSOak Zeng 		WREG32_SOC15(MMHUB, 0, regMC_VM_SYSTEM_APERTURE_LOW_ADDR, 0x3FFFFFFF);
1335f41741aSOak Zeng 		WREG32_SOC15(MMHUB, 0, regMC_VM_SYSTEM_APERTURE_HIGH_ADDR, 0);
1340c19cab5SOak Zeng 	}
135f37945d5SLe Ma 
136f37945d5SLe Ma 	/* Set default page address. */
1377ccfd79fSChristian König 	value = amdgpu_gmc_vram_mc2pa(adev, adev->mem_scratch.gpu_addr);
138f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB,
139f37945d5SLe Ma 		     (u32)(value >> 12));
140f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB,
141f37945d5SLe Ma 		     (u32)(value >> 44));
142f37945d5SLe Ma 
143f37945d5SLe Ma 	/* Program "protection fault". */
144f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_PROTECTION_FAULT_DEFAULT_ADDR_LO32,
145f37945d5SLe Ma 		     (u32)(adev->dummy_page_addr >> 12));
146f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_PROTECTION_FAULT_DEFAULT_ADDR_HI32,
147f37945d5SLe Ma 		     (u32)((u64)adev->dummy_page_addr >> 44));
148f37945d5SLe Ma 
149f37945d5SLe Ma 	tmp = RREG32_SOC15(MMHUB, 0, regVM_L2_PROTECTION_FAULT_CNTL2);
150f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL2,
151f37945d5SLe Ma 			    ACTIVE_PAGE_MIGRATION_PTE_READ_RETRY, 1);
152f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_PROTECTION_FAULT_CNTL2, tmp);
153f37945d5SLe Ma }
154f37945d5SLe Ma 
mmhub_v1_7_init_tlb_regs(struct amdgpu_device * adev)155f37945d5SLe Ma static void mmhub_v1_7_init_tlb_regs(struct amdgpu_device *adev)
156f37945d5SLe Ma {
157f37945d5SLe Ma 	uint32_t tmp;
158f37945d5SLe Ma 
159f37945d5SLe Ma 	/* Setup TLB control */
160f37945d5SLe Ma 	tmp = RREG32_SOC15(MMHUB, 0, regMC_VM_MX_L1_TLB_CNTL);
161f37945d5SLe Ma 
162f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 1);
163f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, SYSTEM_ACCESS_MODE, 3);
164f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL,
165f37945d5SLe Ma 			    ENABLE_ADVANCED_DRIVER_MODEL, 1);
166f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL,
167f37945d5SLe Ma 			    SYSTEM_APERTURE_UNMAPPED_ACCESS, 0);
168f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL,
169f37945d5SLe Ma 			    MTYPE, MTYPE_UC);/* XXX for emulation. */
170f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ATC_EN, 1);
171f37945d5SLe Ma 
172f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_MX_L1_TLB_CNTL, tmp);
173f37945d5SLe Ma }
174f37945d5SLe Ma 
mmhub_v1_7_init_cache_regs(struct amdgpu_device * adev)175f37945d5SLe Ma static void mmhub_v1_7_init_cache_regs(struct amdgpu_device *adev)
176f37945d5SLe Ma {
177f37945d5SLe Ma 	uint32_t tmp;
178f37945d5SLe Ma 
179f37945d5SLe Ma 	if (amdgpu_sriov_vf(adev))
180f37945d5SLe Ma 		return;
181f37945d5SLe Ma 
182f37945d5SLe Ma 	/* Setup L2 cache */
183f37945d5SLe Ma 	tmp = RREG32_SOC15(MMHUB, 0, regVM_L2_CNTL);
184f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 1);
185f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING, 1);
186f37945d5SLe Ma 	/* XXX for emulation, Refer to closed source code.*/
187f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, L2_PDE0_CACHE_TAG_GENERATION_MODE,
188f37945d5SLe Ma 			    0);
189f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, PDE_FAULT_CLASSIFICATION, 0);
190f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, CONTEXT1_IDENTITY_ACCESS_MODE, 1);
191f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, IDENTITY_MODE_FRAGMENT_SIZE, 0);
192f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CNTL, tmp);
193f37945d5SLe Ma 
194f37945d5SLe Ma 	tmp = RREG32_SOC15(MMHUB, 0, regVM_L2_CNTL2);
195f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS, 1);
196f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_L2_CACHE, 1);
197f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CNTL2, tmp);
198f37945d5SLe Ma 
199f37945d5SLe Ma 	tmp = regVM_L2_CNTL3_DEFAULT;
200f37945d5SLe Ma 	if (adev->gmc.translate_further) {
201f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 12);
202f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3,
203f37945d5SLe Ma 				    L2_CACHE_BIGK_FRAGMENT_SIZE, 9);
204f37945d5SLe Ma 	} else {
205f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, 9);
206f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3,
207f37945d5SLe Ma 				    L2_CACHE_BIGK_FRAGMENT_SIZE, 6);
208f37945d5SLe Ma 	}
209f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CNTL3, tmp);
210f37945d5SLe Ma 
211f37945d5SLe Ma 	tmp = regVM_L2_CNTL4_DEFAULT;
2121f928f51SOak Zeng 	if (adev->gmc.xgmi.connected_to_cpu) {
2131f928f51SOak Zeng 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4,
2141f928f51SOak Zeng 				    VMC_TAP_PDE_REQUEST_PHYSICAL, 1);
2151f928f51SOak Zeng 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4,
2161f928f51SOak Zeng 				    VMC_TAP_PTE_REQUEST_PHYSICAL, 1);
2171f928f51SOak Zeng 	} else {
2181f928f51SOak Zeng 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4,
2191f928f51SOak Zeng 				    VMC_TAP_PDE_REQUEST_PHYSICAL, 0);
2201f928f51SOak Zeng 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4,
2211f928f51SOak Zeng 				    VMC_TAP_PTE_REQUEST_PHYSICAL, 0);
2221f928f51SOak Zeng 	}
223f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CNTL4, tmp);
224f37945d5SLe Ma }
225f37945d5SLe Ma 
mmhub_v1_7_enable_system_domain(struct amdgpu_device * adev)226f37945d5SLe Ma static void mmhub_v1_7_enable_system_domain(struct amdgpu_device *adev)
227f37945d5SLe Ma {
228f37945d5SLe Ma 	uint32_t tmp;
229f37945d5SLe Ma 
230f37945d5SLe Ma 	tmp = RREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_CNTL);
231f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, ENABLE_CONTEXT, 1);
2327b454b3aSOak Zeng 	tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, PAGE_TABLE_DEPTH,
2337b454b3aSOak Zeng 			adev->gmc.vmid0_page_table_depth);
2347b454b3aSOak Zeng 	tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, PAGE_TABLE_BLOCK_SIZE,
2357b454b3aSOak Zeng 			adev->gmc.vmid0_page_table_block_size);
236f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL,
237f37945d5SLe Ma 			    RETRY_PERMISSION_OR_INVALID_PAGE_FAULT, 0);
238f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_CONTEXT0_CNTL, tmp);
239f37945d5SLe Ma }
240f37945d5SLe Ma 
mmhub_v1_7_disable_identity_aperture(struct amdgpu_device * adev)241f37945d5SLe Ma static void mmhub_v1_7_disable_identity_aperture(struct amdgpu_device *adev)
242f37945d5SLe Ma {
243f37945d5SLe Ma 	if (amdgpu_sriov_vf(adev))
244f37945d5SLe Ma 		return;
245f37945d5SLe Ma 
246f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_LO32,
247f37945d5SLe Ma 		     0XFFFFFFFF);
248f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_HI32,
249f37945d5SLe Ma 		     0x0000000F);
250f37945d5SLe Ma 
251f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0,
252f37945d5SLe Ma 		     regVM_L2_CONTEXT1_IDENTITY_APERTURE_HIGH_ADDR_LO32, 0);
253f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0,
254f37945d5SLe Ma 		     regVM_L2_CONTEXT1_IDENTITY_APERTURE_HIGH_ADDR_HI32, 0);
255f37945d5SLe Ma 
256f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET_LO32,
257f37945d5SLe Ma 		     0);
258f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET_HI32,
259f37945d5SLe Ma 		     0);
260f37945d5SLe Ma }
261f37945d5SLe Ma 
mmhub_v1_7_setup_vmid_config(struct amdgpu_device * adev)262f37945d5SLe Ma static void mmhub_v1_7_setup_vmid_config(struct amdgpu_device *adev)
263f37945d5SLe Ma {
264f4caf584SHawking Zhang 	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_MMHUB0(0)];
265f37945d5SLe Ma 	unsigned num_level, block_size;
266f37945d5SLe Ma 	uint32_t tmp;
267f37945d5SLe Ma 	int i;
268f37945d5SLe Ma 
269f37945d5SLe Ma 	num_level = adev->vm_manager.num_level;
270f37945d5SLe Ma 	block_size = adev->vm_manager.block_size;
271f37945d5SLe Ma 	if (adev->gmc.translate_further)
272f37945d5SLe Ma 		num_level -= 1;
273f37945d5SLe Ma 	else
274f37945d5SLe Ma 		block_size -= 9;
275f37945d5SLe Ma 
276f37945d5SLe Ma 	for (i = 0; i <= 14; i++) {
277061863e5SYifan Zhang 		tmp = RREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT1_CNTL, i * hub->ctx_distance);
278f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
279f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH,
280f37945d5SLe Ma 				    num_level);
281f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
282f37945d5SLe Ma 				    RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
283f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
284f37945d5SLe Ma 				    DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT,
285f37945d5SLe Ma 				    1);
286f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
287f37945d5SLe Ma 				    PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
288f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
289f37945d5SLe Ma 				    VALID_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
290f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
291f37945d5SLe Ma 				    READ_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
292f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
293f37945d5SLe Ma 				    WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
294f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
295f37945d5SLe Ma 				    EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
296f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
297f37945d5SLe Ma 				    PAGE_TABLE_BLOCK_SIZE,
298f37945d5SLe Ma 				    block_size);
2999705c85fSFelix Kuehling 		/* On Aldebaran, XNACK can be enabled in the SQ per-process.
3009705c85fSFelix Kuehling 		 * Retry faults need to be enabled for that to work.
3019705c85fSFelix Kuehling 		 */
302f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
303f37945d5SLe Ma 				    RETRY_PERMISSION_OR_INVALID_PAGE_FAULT,
3049705c85fSFelix Kuehling 				    1);
3055be50a8fSKevin Wang 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT1_CNTL,
3065be50a8fSKevin Wang 				    i * hub->ctx_distance, tmp);
3075be50a8fSKevin Wang 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT1_PAGE_TABLE_START_ADDR_LO32,
3085be50a8fSKevin Wang 				    i * hub->ctx_addr_distance, 0);
3095be50a8fSKevin Wang 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT1_PAGE_TABLE_START_ADDR_HI32,
3105be50a8fSKevin Wang 				    i * hub->ctx_addr_distance, 0);
3115be50a8fSKevin Wang 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT1_PAGE_TABLE_END_ADDR_LO32,
3125be50a8fSKevin Wang 				    i * hub->ctx_addr_distance,
313f37945d5SLe Ma 				    lower_32_bits(adev->vm_manager.max_pfn - 1));
3145be50a8fSKevin Wang 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32,
3155be50a8fSKevin Wang 				    i * hub->ctx_addr_distance,
316f37945d5SLe Ma 				    upper_32_bits(adev->vm_manager.max_pfn - 1));
317f37945d5SLe Ma 	}
318f37945d5SLe Ma }
319f37945d5SLe Ma 
mmhub_v1_7_program_invalidation(struct amdgpu_device * adev)320f37945d5SLe Ma static void mmhub_v1_7_program_invalidation(struct amdgpu_device *adev)
321f37945d5SLe Ma {
322f4caf584SHawking Zhang 	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_MMHUB0(0)];
323f37945d5SLe Ma 	unsigned i;
324f37945d5SLe Ma 
325f37945d5SLe Ma 	for (i = 0; i < 18; ++i) {
326f37945d5SLe Ma 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_INVALIDATE_ENG0_ADDR_RANGE_LO32,
3275be50a8fSKevin Wang 				    i * hub->eng_addr_distance, 0xffffffff);
328f37945d5SLe Ma 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_INVALIDATE_ENG0_ADDR_RANGE_HI32,
3295be50a8fSKevin Wang 				    i * hub->eng_addr_distance, 0x1f);
330f37945d5SLe Ma 	}
331f37945d5SLe Ma }
332f37945d5SLe Ma 
mmhub_v1_7_gart_enable(struct amdgpu_device * adev)3334da999cdSOak Zeng static int mmhub_v1_7_gart_enable(struct amdgpu_device *adev)
334f37945d5SLe Ma {
335f37945d5SLe Ma 	/* GART Enable. */
336f37945d5SLe Ma 	mmhub_v1_7_init_gart_aperture_regs(adev);
337f37945d5SLe Ma 	mmhub_v1_7_init_system_aperture_regs(adev);
338f37945d5SLe Ma 	mmhub_v1_7_init_tlb_regs(adev);
339f37945d5SLe Ma 	mmhub_v1_7_init_cache_regs(adev);
340f37945d5SLe Ma 
341f37945d5SLe Ma 	mmhub_v1_7_enable_system_domain(adev);
342f37945d5SLe Ma 	mmhub_v1_7_disable_identity_aperture(adev);
343f37945d5SLe Ma 	mmhub_v1_7_setup_vmid_config(adev);
344f37945d5SLe Ma 	mmhub_v1_7_program_invalidation(adev);
345f37945d5SLe Ma 
346f37945d5SLe Ma 	return 0;
347f37945d5SLe Ma }
348f37945d5SLe Ma 
mmhub_v1_7_gart_disable(struct amdgpu_device * adev)3494da999cdSOak Zeng static void mmhub_v1_7_gart_disable(struct amdgpu_device *adev)
350f37945d5SLe Ma {
351f4caf584SHawking Zhang 	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_MMHUB0(0)];
352f37945d5SLe Ma 	u32 tmp;
353f37945d5SLe Ma 	u32 i;
354f37945d5SLe Ma 
355f37945d5SLe Ma 	/* Disable all tables */
356f37945d5SLe Ma 	for (i = 0; i < 16; i++)
3575be50a8fSKevin Wang 		WREG32_SOC15_OFFSET(MMHUB, 0, regVM_CONTEXT0_CNTL,
3585be50a8fSKevin Wang 				    i * hub->ctx_distance, 0);
359f37945d5SLe Ma 
360f37945d5SLe Ma 	/* Setup TLB control */
361f37945d5SLe Ma 	tmp = RREG32_SOC15(MMHUB, 0, regMC_VM_MX_L1_TLB_CNTL);
362f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
363f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp,
364f37945d5SLe Ma 				MC_VM_MX_L1_TLB_CNTL,
365f37945d5SLe Ma 				ENABLE_ADVANCED_DRIVER_MODEL,
366f37945d5SLe Ma 				0);
367f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regMC_VM_MX_L1_TLB_CNTL, tmp);
368f37945d5SLe Ma 
369f37945d5SLe Ma 	if (!amdgpu_sriov_vf(adev)) {
370f37945d5SLe Ma 		/* Setup L2 cache */
371f37945d5SLe Ma 		tmp = RREG32_SOC15(MMHUB, 0, regVM_L2_CNTL);
372f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
373f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regVM_L2_CNTL, tmp);
374f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regVM_L2_CNTL3, 0);
375f37945d5SLe Ma 	}
376f37945d5SLe Ma }
377f37945d5SLe Ma 
378f37945d5SLe Ma /**
379f37945d5SLe Ma  * mmhub_v1_7_set_fault_enable_default - update GART/VM fault handling
380f37945d5SLe Ma  *
381f37945d5SLe Ma  * @adev: amdgpu_device pointer
382f37945d5SLe Ma  * @value: true redirects VM faults to the default page
383f37945d5SLe Ma  */
mmhub_v1_7_set_fault_enable_default(struct amdgpu_device * adev,bool value)3844da999cdSOak Zeng static void mmhub_v1_7_set_fault_enable_default(struct amdgpu_device *adev, bool value)
385f37945d5SLe Ma {
386f37945d5SLe Ma 	u32 tmp;
387f37945d5SLe Ma 
388f37945d5SLe Ma 	if (amdgpu_sriov_vf(adev))
389f37945d5SLe Ma 		return;
390f37945d5SLe Ma 
391f37945d5SLe Ma 	tmp = RREG32_SOC15(MMHUB, 0, regVM_L2_PROTECTION_FAULT_CNTL);
392f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
393f37945d5SLe Ma 			RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
394f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
395f37945d5SLe Ma 			PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, value);
396f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
397f37945d5SLe Ma 			PDE1_PROTECTION_FAULT_ENABLE_DEFAULT, value);
398f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
399f37945d5SLe Ma 			PDE2_PROTECTION_FAULT_ENABLE_DEFAULT, value);
400f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp,
401f37945d5SLe Ma 			VM_L2_PROTECTION_FAULT_CNTL,
402f37945d5SLe Ma 			TRANSLATE_FURTHER_PROTECTION_FAULT_ENABLE_DEFAULT,
403f37945d5SLe Ma 			value);
404f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
405f37945d5SLe Ma 			NACK_PROTECTION_FAULT_ENABLE_DEFAULT, value);
406f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
407f37945d5SLe Ma 			DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
408f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
409f37945d5SLe Ma 			VALID_PROTECTION_FAULT_ENABLE_DEFAULT, value);
410f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
411f37945d5SLe Ma 			READ_PROTECTION_FAULT_ENABLE_DEFAULT, value);
412f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
413f37945d5SLe Ma 			WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
414f37945d5SLe Ma 	tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
415f37945d5SLe Ma 			EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
416f37945d5SLe Ma 	if (!value) {
417f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
418f37945d5SLe Ma 				CRASH_ON_NO_RETRY_FAULT, 1);
419f37945d5SLe Ma 		tmp = REG_SET_FIELD(tmp, VM_L2_PROTECTION_FAULT_CNTL,
420f37945d5SLe Ma 				CRASH_ON_RETRY_FAULT, 1);
421f37945d5SLe Ma     }
422f37945d5SLe Ma 
423f37945d5SLe Ma 	WREG32_SOC15(MMHUB, 0, regVM_L2_PROTECTION_FAULT_CNTL, tmp);
424f37945d5SLe Ma }
425f37945d5SLe Ma 
mmhub_v1_7_init(struct amdgpu_device * adev)4264da999cdSOak Zeng static void mmhub_v1_7_init(struct amdgpu_device *adev)
427f37945d5SLe Ma {
428f4caf584SHawking Zhang 	struct amdgpu_vmhub *hub = &adev->vmhub[AMDGPU_MMHUB0(0)];
429f37945d5SLe Ma 
430f37945d5SLe Ma 	hub->ctx0_ptb_addr_lo32 =
431f37945d5SLe Ma 		SOC15_REG_OFFSET(MMHUB, 0,
432f37945d5SLe Ma 				 regVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32);
433f37945d5SLe Ma 	hub->ctx0_ptb_addr_hi32 =
434f37945d5SLe Ma 		SOC15_REG_OFFSET(MMHUB, 0,
435f37945d5SLe Ma 				 regVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32);
436f37945d5SLe Ma 	hub->vm_inv_eng0_req =
437f37945d5SLe Ma 		SOC15_REG_OFFSET(MMHUB, 0, regVM_INVALIDATE_ENG0_REQ);
438f37945d5SLe Ma 	hub->vm_inv_eng0_ack =
439f37945d5SLe Ma 		SOC15_REG_OFFSET(MMHUB, 0, regVM_INVALIDATE_ENG0_ACK);
440f37945d5SLe Ma 	hub->vm_context0_cntl =
441f37945d5SLe Ma 		SOC15_REG_OFFSET(MMHUB, 0, regVM_CONTEXT0_CNTL);
442f37945d5SLe Ma 	hub->vm_l2_pro_fault_status =
443f37945d5SLe Ma 		SOC15_REG_OFFSET(MMHUB, 0, regVM_L2_PROTECTION_FAULT_STATUS);
444f37945d5SLe Ma 	hub->vm_l2_pro_fault_cntl =
445f37945d5SLe Ma 		SOC15_REG_OFFSET(MMHUB, 0, regVM_L2_PROTECTION_FAULT_CNTL);
446f37945d5SLe Ma 
4475be50a8fSKevin Wang 	hub->ctx_distance = regVM_CONTEXT1_CNTL - regVM_CONTEXT0_CNTL;
4485be50a8fSKevin Wang 	hub->ctx_addr_distance = regVM_CONTEXT1_PAGE_TABLE_BASE_ADDR_LO32 -
4495be50a8fSKevin Wang 		regVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32;
4505be50a8fSKevin Wang 	hub->eng_distance = regVM_INVALIDATE_ENG1_REQ - regVM_INVALIDATE_ENG0_REQ;
4515be50a8fSKevin Wang 	hub->eng_addr_distance = regVM_INVALIDATE_ENG1_ADDR_RANGE_LO32 -
4525be50a8fSKevin Wang 		regVM_INVALIDATE_ENG0_ADDR_RANGE_LO32;
4535be50a8fSKevin Wang 
454f37945d5SLe Ma }
455f37945d5SLe Ma 
mmhub_v1_7_update_medium_grain_clock_gating(struct amdgpu_device * adev,bool enable)456f37945d5SLe Ma static void mmhub_v1_7_update_medium_grain_clock_gating(struct amdgpu_device *adev,
457f37945d5SLe Ma 							bool enable)
458f37945d5SLe Ma {
459f37945d5SLe Ma 	uint32_t def, data, def1, data1, def2 = 0, data2 = 0;
460f37945d5SLe Ma 
461f37945d5SLe Ma 	def  = data  = RREG32_SOC15(MMHUB, 0, regATC_L2_MISC_CG);
462f37945d5SLe Ma 
463f37945d5SLe Ma 	def1 = data1 = RREG32_SOC15(MMHUB, 0, regDAGB0_CNTL_MISC2);
464f37945d5SLe Ma 	def2 = data2 = RREG32_SOC15(MMHUB, 0, regDAGB1_CNTL_MISC2);
465f37945d5SLe Ma 
4666d905921SLijo Lazar 	if (enable) {
467f37945d5SLe Ma 		data |= ATC_L2_MISC_CG__ENABLE_MASK;
468f37945d5SLe Ma 
469f37945d5SLe Ma 		data1 &= ~(DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
470f37945d5SLe Ma 		           DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
471f37945d5SLe Ma 		           DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
472f37945d5SLe Ma 		           DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
473f37945d5SLe Ma 		           DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
474f37945d5SLe Ma 		           DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
475f37945d5SLe Ma 
476f37945d5SLe Ma 		data2 &= ~(DAGB1_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
477f37945d5SLe Ma 		           DAGB1_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
478f37945d5SLe Ma 		           DAGB1_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
479f37945d5SLe Ma 		           DAGB1_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
480f37945d5SLe Ma 		           DAGB1_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
481f37945d5SLe Ma 		           DAGB1_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
482f37945d5SLe Ma 	} else {
483f37945d5SLe Ma 		data &= ~ATC_L2_MISC_CG__ENABLE_MASK;
484f37945d5SLe Ma 
485f37945d5SLe Ma 		data1 |= (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
486f37945d5SLe Ma 			  DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
487f37945d5SLe Ma 			  DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
488f37945d5SLe Ma 			  DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
489f37945d5SLe Ma 			  DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
490f37945d5SLe Ma 			  DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
491f37945d5SLe Ma 
492f37945d5SLe Ma 		data2 |= (DAGB1_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
493f37945d5SLe Ma 		          DAGB1_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
494f37945d5SLe Ma 		          DAGB1_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
495f37945d5SLe Ma 		          DAGB1_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
496f37945d5SLe Ma 		          DAGB1_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
497f37945d5SLe Ma 		          DAGB1_CNTL_MISC2__DISABLE_TLBRD_CG_MASK);
498f37945d5SLe Ma 	}
499f37945d5SLe Ma 
500f37945d5SLe Ma 	if (def != data)
501f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regATC_L2_MISC_CG, data);
502f37945d5SLe Ma 
503f37945d5SLe Ma 	if (def1 != data1)
504f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regDAGB0_CNTL_MISC2, data1);
505f37945d5SLe Ma 
506f37945d5SLe Ma 	if (def2 != data2)
507f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regDAGB1_CNTL_MISC2, data2);
508f37945d5SLe Ma }
509f37945d5SLe Ma 
mmhub_v1_7_update_medium_grain_light_sleep(struct amdgpu_device * adev,bool enable)510f37945d5SLe Ma static void mmhub_v1_7_update_medium_grain_light_sleep(struct amdgpu_device *adev,
511f37945d5SLe Ma 						       bool enable)
512f37945d5SLe Ma {
513f37945d5SLe Ma 	uint32_t def, data;
514f37945d5SLe Ma 
515f37945d5SLe Ma 	def = data = RREG32_SOC15(MMHUB, 0, regATC_L2_MISC_CG);
516f37945d5SLe Ma 
5176d905921SLijo Lazar 	if (enable)
518f37945d5SLe Ma 		data |= ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK;
519f37945d5SLe Ma 	else
520f37945d5SLe Ma 		data &= ~ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK;
521f37945d5SLe Ma 
522f37945d5SLe Ma 	if (def != data)
523f37945d5SLe Ma 		WREG32_SOC15(MMHUB, 0, regATC_L2_MISC_CG, data);
524f37945d5SLe Ma }
525f37945d5SLe Ma 
mmhub_v1_7_set_clockgating(struct amdgpu_device * adev,enum amd_clockgating_state state)5264da999cdSOak Zeng static int mmhub_v1_7_set_clockgating(struct amdgpu_device *adev,
527f37945d5SLe Ma 			       enum amd_clockgating_state state)
528f37945d5SLe Ma {
529f37945d5SLe Ma 	if (amdgpu_sriov_vf(adev))
530f37945d5SLe Ma 		return 0;
531f37945d5SLe Ma 
5326d905921SLijo Lazar 	/* Change state only if MCCG support is enabled through driver */
5336d905921SLijo Lazar 	if (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG)
534f37945d5SLe Ma 		mmhub_v1_7_update_medium_grain_clock_gating(adev,
5356d905921SLijo Lazar 				state == AMD_CG_STATE_GATE);
5366d905921SLijo Lazar 
5376d905921SLijo Lazar 	/* Change state only if LS support is enabled through driver */
5386d905921SLijo Lazar 	if (adev->cg_flags & AMD_CG_SUPPORT_MC_LS)
539f37945d5SLe Ma 		mmhub_v1_7_update_medium_grain_light_sleep(adev,
5406d905921SLijo Lazar 				state == AMD_CG_STATE_GATE);
541f37945d5SLe Ma 
542f37945d5SLe Ma 	return 0;
543f37945d5SLe Ma }
544f37945d5SLe Ma 
mmhub_v1_7_get_clockgating(struct amdgpu_device * adev,u64 * flags)54525faeddcSEvan Quan static void mmhub_v1_7_get_clockgating(struct amdgpu_device *adev, u64 *flags)
546f37945d5SLe Ma {
547*be6a69b2SBob Zhou 	u32 data, data1;
548f37945d5SLe Ma 
549f37945d5SLe Ma 	if (amdgpu_sriov_vf(adev))
550f37945d5SLe Ma 		*flags = 0;
551f37945d5SLe Ma 
552f37945d5SLe Ma 	data = RREG32_SOC15(MMHUB, 0, regATC_L2_MISC_CG);
553f37945d5SLe Ma 
554f37945d5SLe Ma 	data1 = RREG32_SOC15(MMHUB, 0, regDAGB0_CNTL_MISC2);
555f37945d5SLe Ma 
556f37945d5SLe Ma 	/* AMD_CG_SUPPORT_MC_MGCG */
557f37945d5SLe Ma 	if ((data & ATC_L2_MISC_CG__ENABLE_MASK) &&
558f37945d5SLe Ma 	    !(data1 & (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK |
559f37945d5SLe Ma 		       DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK |
560f37945d5SLe Ma 		       DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK |
561f37945d5SLe Ma 		       DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK |
562f37945d5SLe Ma 		       DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK |
563f37945d5SLe Ma 		       DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK)))
564f37945d5SLe Ma 		*flags |= AMD_CG_SUPPORT_MC_MGCG;
565f37945d5SLe Ma 
566f37945d5SLe Ma 	/* AMD_CG_SUPPORT_MC_LS */
567f37945d5SLe Ma 	if (data & ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK)
568f37945d5SLe Ma 		*flags |= AMD_CG_SUPPORT_MC_LS;
569f37945d5SLe Ma }
570f37945d5SLe Ma 
571cbb84e7aSHawking Zhang static const struct soc15_ras_field_entry mmhub_v1_7_ras_fields[] = {
572cbb84e7aSHawking Zhang 	/* MMHUB Range 0 */
573cbb84e7aSHawking Zhang 	{ "MMEA0_DRAMRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
574cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMRD_CMDMEM_SEC_COUNT),
575cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMRD_CMDMEM_DED_COUNT),
576cbb84e7aSHawking Zhang 	},
577cbb84e7aSHawking Zhang 	{ "MMEA0_DRAMWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
578cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMWR_CMDMEM_SEC_COUNT),
579cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMWR_CMDMEM_DED_COUNT),
580cbb84e7aSHawking Zhang 	},
581cbb84e7aSHawking Zhang 	{ "MMEA0_DRAMWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
582cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMWR_DATAMEM_SEC_COUNT),
583cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMWR_DATAMEM_DED_COUNT),
584cbb84e7aSHawking Zhang 	},
585cbb84e7aSHawking Zhang 	{ "MMEA0_RRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
586cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, RRET_TAGMEM_SEC_COUNT),
587cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, RRET_TAGMEM_DED_COUNT),
588cbb84e7aSHawking Zhang 	},
589cbb84e7aSHawking Zhang 	{ "MMEA0_WRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
590cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, WRET_TAGMEM_SEC_COUNT),
591cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, WRET_TAGMEM_DED_COUNT),
592cbb84e7aSHawking Zhang 	},
593cbb84e7aSHawking Zhang 	{ "MMEA0_IOWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
594cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, IOWR_DATAMEM_SEC_COUNT),
595cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, IOWR_DATAMEM_DED_COUNT),
596cbb84e7aSHawking Zhang 	},
597cbb84e7aSHawking Zhang 	{ "MMEA0_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
598cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMRD_PAGEMEM_SED_COUNT),
599cbb84e7aSHawking Zhang 	0, 0,
600cbb84e7aSHawking Zhang 	},
601cbb84e7aSHawking Zhang 	{ "MMEA0_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
602cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, DRAMWR_PAGEMEM_SED_COUNT),
603cbb84e7aSHawking Zhang 	0, 0,
604cbb84e7aSHawking Zhang 	},
605cbb84e7aSHawking Zhang 	{ "MMEA0_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
606cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, IORD_CMDMEM_SED_COUNT),
607cbb84e7aSHawking Zhang 	0, 0,
608cbb84e7aSHawking Zhang 	},
609cbb84e7aSHawking Zhang 	{ "MMEA0_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT),
610cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT, IOWR_CMDMEM_SED_COUNT),
611cbb84e7aSHawking Zhang 	0, 0,
612cbb84e7aSHawking Zhang 	},
613cbb84e7aSHawking Zhang 	{ "MMEA0_GMIRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
614cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIRD_CMDMEM_SEC_COUNT),
615cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIRD_CMDMEM_DED_COUNT),
616cbb84e7aSHawking Zhang 	},
617cbb84e7aSHawking Zhang 	{ "MMEA0_GMIWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
618cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIWR_CMDMEM_SEC_COUNT),
619cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIWR_CMDMEM_DED_COUNT),
620cbb84e7aSHawking Zhang 	},
621cbb84e7aSHawking Zhang 	{ "MMEA0_GMIWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
622cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIWR_DATAMEM_SEC_COUNT),
623cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIWR_DATAMEM_DED_COUNT),
624cbb84e7aSHawking Zhang 	},
625cbb84e7aSHawking Zhang 	{ "MMEA0_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
626cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIRD_PAGEMEM_SED_COUNT),
627cbb84e7aSHawking Zhang 	0, 0,
628cbb84e7aSHawking Zhang 	},
629cbb84e7aSHawking Zhang 	{ "MMEA0_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
630cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, GMIWR_PAGEMEM_SED_COUNT),
631cbb84e7aSHawking Zhang 	0, 0,
632cbb84e7aSHawking Zhang 	},
633cbb84e7aSHawking Zhang 	{ "MMEA0_MAM_D0MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
634cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D0MEM_SED_COUNT),
635cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D0MEM_DED_COUNT),
636cbb84e7aSHawking Zhang 	},
637cbb84e7aSHawking Zhang 	{ "MMEA0_MAM_D1MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
638cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D1MEM_SED_COUNT),
639cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D1MEM_DED_COUNT),
640cbb84e7aSHawking Zhang 	},
641cbb84e7aSHawking Zhang 	{ "MMEA0_MAM_D2MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
642cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D2MEM_SED_COUNT),
643cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D2MEM_DED_COUNT),
644cbb84e7aSHawking Zhang 	},
645cbb84e7aSHawking Zhang 	{ "MMEA0_MAM_D3MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2),
646cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D3MEM_SED_COUNT),
647cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D3MEM_DED_COUNT),
648cbb84e7aSHawking Zhang 	},
649cbb84e7aSHawking Zhang 	{ "MMEA0_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT3),
650cbb84e7aSHawking Zhang 	0, 0,
651cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT3, DRAMRD_PAGEMEM_DED_COUNT),
652cbb84e7aSHawking Zhang 	},
653cbb84e7aSHawking Zhang 	{ "MMEA0_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT3),
654cbb84e7aSHawking Zhang 	0, 0,
655cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT3, DRAMWR_PAGEMEM_DED_COUNT),
656cbb84e7aSHawking Zhang 	},
657cbb84e7aSHawking Zhang 	{ "MMEA0_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT3),
658cbb84e7aSHawking Zhang 	0, 0,
659cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT3, IORD_CMDMEM_DED_COUNT),
660cbb84e7aSHawking Zhang 	},
661cbb84e7aSHawking Zhang 	{ "MMEA0_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT3),
662cbb84e7aSHawking Zhang 	0, 0,
663cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT3, IOWR_CMDMEM_DED_COUNT),
664cbb84e7aSHawking Zhang 	},
665cbb84e7aSHawking Zhang 	{ "MMEA0_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT3),
666cbb84e7aSHawking Zhang 	0, 0,
667cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT3, GMIRD_PAGEMEM_DED_COUNT),
668cbb84e7aSHawking Zhang 	},
669cbb84e7aSHawking Zhang 	{ "MMEA0_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT3),
670cbb84e7aSHawking Zhang 	0, 0,
671cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT3, GMIWR_PAGEMEM_DED_COUNT),
672cbb84e7aSHawking Zhang 	},
673cbb84e7aSHawking Zhang 
674cbb84e7aSHawking Zhang 	/* MMHUB Range 1 */
675cbb84e7aSHawking Zhang 	{ "MMEA1_DRAMRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
676cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMRD_CMDMEM_SEC_COUNT),
677cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMRD_CMDMEM_DED_COUNT),
678cbb84e7aSHawking Zhang 	},
679cbb84e7aSHawking Zhang 	{ "MMEA1_DRAMWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
680cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMWR_CMDMEM_SEC_COUNT),
681cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMWR_CMDMEM_DED_COUNT),
682cbb84e7aSHawking Zhang 	},
683cbb84e7aSHawking Zhang 	{ "MMEA1_DRAMWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
684cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMWR_DATAMEM_SEC_COUNT),
685cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMWR_DATAMEM_DED_COUNT),
686cbb84e7aSHawking Zhang 	},
687cbb84e7aSHawking Zhang 	{ "MMEA1_RRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
688cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, RRET_TAGMEM_SEC_COUNT),
689cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, RRET_TAGMEM_DED_COUNT),
690cbb84e7aSHawking Zhang 	},
691cbb84e7aSHawking Zhang 	{ "MMEA1_WRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
692cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, WRET_TAGMEM_SEC_COUNT),
693cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, WRET_TAGMEM_DED_COUNT),
694cbb84e7aSHawking Zhang 	},
695cbb84e7aSHawking Zhang 	{ "MMEA1_IOWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
696cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, IOWR_DATAMEM_SEC_COUNT),
697cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, IOWR_DATAMEM_DED_COUNT),
698cbb84e7aSHawking Zhang 	},
699cbb84e7aSHawking Zhang 	{ "MMEA1_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
700cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMRD_PAGEMEM_SED_COUNT),
701cbb84e7aSHawking Zhang 	0, 0,
702cbb84e7aSHawking Zhang 	},
703cbb84e7aSHawking Zhang 	{ "MMEA1_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
704cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, DRAMWR_PAGEMEM_SED_COUNT),
705cbb84e7aSHawking Zhang 	0, 0,
706cbb84e7aSHawking Zhang 	},
707cbb84e7aSHawking Zhang 	{ "MMEA1_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
708cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, IORD_CMDMEM_SED_COUNT),
709cbb84e7aSHawking Zhang 	0, 0,
710cbb84e7aSHawking Zhang 	},
711cbb84e7aSHawking Zhang 	{ "MMEA1_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT),
712cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT, IOWR_CMDMEM_SED_COUNT),
713cbb84e7aSHawking Zhang 	0, 0,
714cbb84e7aSHawking Zhang 	},
715cbb84e7aSHawking Zhang 	{ "MMEA1_GMIRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
716cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIRD_CMDMEM_SEC_COUNT),
717cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIRD_CMDMEM_DED_COUNT),
718cbb84e7aSHawking Zhang 	},
719cbb84e7aSHawking Zhang 	{ "MMEA1_GMIWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
720cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIWR_CMDMEM_SEC_COUNT),
721cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIWR_CMDMEM_DED_COUNT),
722cbb84e7aSHawking Zhang 	},
723cbb84e7aSHawking Zhang 	{ "MMEA1_GMIWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
724cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIWR_DATAMEM_SEC_COUNT),
725cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIWR_DATAMEM_DED_COUNT),
726cbb84e7aSHawking Zhang 	},
727cbb84e7aSHawking Zhang 	{ "MMEA1_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
728cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIRD_PAGEMEM_SED_COUNT),
729cbb84e7aSHawking Zhang 	0, 0,
730cbb84e7aSHawking Zhang 	},
731cbb84e7aSHawking Zhang 	{ "MMEA1_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
732cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, GMIWR_PAGEMEM_SED_COUNT),
733cbb84e7aSHawking Zhang 	0, 0,
734cbb84e7aSHawking Zhang 	},
735cbb84e7aSHawking Zhang 	{ "MMEA1_MAM_D0MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
736cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D0MEM_SED_COUNT),
737cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D0MEM_DED_COUNT),
738cbb84e7aSHawking Zhang 	},
739cbb84e7aSHawking Zhang 	{ "MMEA1_MAM_D1MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
740cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D1MEM_SED_COUNT),
741cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D1MEM_DED_COUNT),
742cbb84e7aSHawking Zhang 	},
743cbb84e7aSHawking Zhang 	{ "MMEA1_MAM_D2MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
744cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D2MEM_SED_COUNT),
745cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D2MEM_DED_COUNT),
746cbb84e7aSHawking Zhang 	},
747cbb84e7aSHawking Zhang 	{ "MMEA1_MAM_D3MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2),
748cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D3MEM_SED_COUNT),
749cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT2, MAM_D3MEM_DED_COUNT),
750cbb84e7aSHawking Zhang 	},
751cbb84e7aSHawking Zhang 	{ "MMEA1_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT3),
752cbb84e7aSHawking Zhang 	0, 0,
753cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT3, DRAMRD_PAGEMEM_DED_COUNT),
754cbb84e7aSHawking Zhang 	},
755cbb84e7aSHawking Zhang 	{ "MMEA1_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT3),
756cbb84e7aSHawking Zhang 	0, 0,
757cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT3, DRAMWR_PAGEMEM_DED_COUNT),
758cbb84e7aSHawking Zhang 	},
759cbb84e7aSHawking Zhang 	{ "MMEA1_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT3),
760cbb84e7aSHawking Zhang 	0, 0,
761cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT3, IORD_CMDMEM_DED_COUNT),
762cbb84e7aSHawking Zhang 	},
763cbb84e7aSHawking Zhang 	{ "MMEA1_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT3),
764cbb84e7aSHawking Zhang 	0, 0,
765cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT3, IOWR_CMDMEM_DED_COUNT),
766cbb84e7aSHawking Zhang 	},
767cbb84e7aSHawking Zhang 	{ "MMEA1_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT3),
768cbb84e7aSHawking Zhang 	0, 0,
769cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT3, GMIRD_PAGEMEM_DED_COUNT),
770cbb84e7aSHawking Zhang 	},
771cbb84e7aSHawking Zhang 	{ "MMEA1_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT3),
772cbb84e7aSHawking Zhang 	0, 0,
773cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA1_EDC_CNT3, GMIWR_PAGEMEM_DED_COUNT),
774cbb84e7aSHawking Zhang 	},
775cbb84e7aSHawking Zhang 
776cbb84e7aSHawking Zhang 	/* MMHAB Range 2*/
777cbb84e7aSHawking Zhang 	{ "MMEA2_DRAMRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
778cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMRD_CMDMEM_SEC_COUNT),
779cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMRD_CMDMEM_DED_COUNT),
780cbb84e7aSHawking Zhang 	},
781cbb84e7aSHawking Zhang 	{ "MMEA2_DRAMWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
782cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMWR_CMDMEM_SEC_COUNT),
783cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMWR_CMDMEM_DED_COUNT),
784cbb84e7aSHawking Zhang 	},
785cbb84e7aSHawking Zhang 	{ "MMEA2_DRAMWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
786cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMWR_DATAMEM_SEC_COUNT),
787cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMWR_DATAMEM_DED_COUNT),
788cbb84e7aSHawking Zhang 	},
789cbb84e7aSHawking Zhang 	{ "MMEA2_RRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
790cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, RRET_TAGMEM_SEC_COUNT),
791cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, RRET_TAGMEM_DED_COUNT),
792cbb84e7aSHawking Zhang 	},
793cbb84e7aSHawking Zhang 	{ "MMEA2_WRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
794cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, WRET_TAGMEM_SEC_COUNT),
795cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, WRET_TAGMEM_DED_COUNT),
796cbb84e7aSHawking Zhang 	},
797cbb84e7aSHawking Zhang 	{ "MMEA2_IOWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
798cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, IOWR_DATAMEM_SEC_COUNT),
799cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, IOWR_DATAMEM_DED_COUNT),
800cbb84e7aSHawking Zhang 	},
801cbb84e7aSHawking Zhang 	{ "MMEA2_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
802cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMRD_PAGEMEM_SED_COUNT),
803cbb84e7aSHawking Zhang 	0, 0,
804cbb84e7aSHawking Zhang 	},
805cbb84e7aSHawking Zhang 	{ "MMEA2_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
806cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, DRAMWR_PAGEMEM_SED_COUNT),
807cbb84e7aSHawking Zhang 	0, 0,
808cbb84e7aSHawking Zhang 	},
809cbb84e7aSHawking Zhang 	{ "MMEA2_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
810cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, IORD_CMDMEM_SED_COUNT),
811cbb84e7aSHawking Zhang 	0, 0,
812cbb84e7aSHawking Zhang 	},
813cbb84e7aSHawking Zhang 	{ "MMEA2_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT),
814cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT, IOWR_CMDMEM_SED_COUNT),
815cbb84e7aSHawking Zhang 	0, 0,
816cbb84e7aSHawking Zhang 	},
817cbb84e7aSHawking Zhang 	{ "MMEA2_GMIRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
818cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIRD_CMDMEM_SEC_COUNT),
819cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIRD_CMDMEM_DED_COUNT),
820cbb84e7aSHawking Zhang 	},
821cbb84e7aSHawking Zhang 	{ "MMEA2_GMIWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
822cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIWR_CMDMEM_SEC_COUNT),
823cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIWR_CMDMEM_DED_COUNT),
824cbb84e7aSHawking Zhang 	},
825cbb84e7aSHawking Zhang 	{ "MMEA2_GMIWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
826cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIWR_DATAMEM_SEC_COUNT),
827cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIWR_DATAMEM_DED_COUNT),
828cbb84e7aSHawking Zhang 	},
829cbb84e7aSHawking Zhang 	{ "MMEA2_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
830cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIRD_PAGEMEM_SED_COUNT),
831cbb84e7aSHawking Zhang 	0, 0,
832cbb84e7aSHawking Zhang 	},
833cbb84e7aSHawking Zhang 	{ "MMEA2_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
834cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, GMIWR_PAGEMEM_SED_COUNT),
835cbb84e7aSHawking Zhang 	0, 0,
836cbb84e7aSHawking Zhang 	},
837cbb84e7aSHawking Zhang 	{ "MMEA2_MAM_D0MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
838cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D0MEM_SED_COUNT),
839cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA0_EDC_CNT2, MAM_D0MEM_DED_COUNT),
840cbb84e7aSHawking Zhang 	},
841cbb84e7aSHawking Zhang 	{ "MMEA2_MAM_D1MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
842cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, MAM_D1MEM_SED_COUNT),
843cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, MAM_D1MEM_DED_COUNT),
844cbb84e7aSHawking Zhang 	},
845cbb84e7aSHawking Zhang 	{ "MMEA2_MAM_D2MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
846cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, MAM_D2MEM_SED_COUNT),
847cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, MAM_D2MEM_DED_COUNT),
848cbb84e7aSHawking Zhang 	},
849cbb84e7aSHawking Zhang 	{ "MMEA2_MAM_D3MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2),
850cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, MAM_D3MEM_SED_COUNT),
851cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT2, MAM_D3MEM_DED_COUNT),
852cbb84e7aSHawking Zhang 	},
853cbb84e7aSHawking Zhang 	{ "MMEA2_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT3),
854cbb84e7aSHawking Zhang 	0, 0,
855cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT3, DRAMRD_PAGEMEM_DED_COUNT),
856cbb84e7aSHawking Zhang 	},
857cbb84e7aSHawking Zhang 	{ "MMEA2_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT3),
858cbb84e7aSHawking Zhang 	0, 0,
859cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT3, DRAMWR_PAGEMEM_DED_COUNT),
860cbb84e7aSHawking Zhang 	},
861cbb84e7aSHawking Zhang 	{ "MMEA2_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT3),
862cbb84e7aSHawking Zhang 	0, 0,
863cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT3, IORD_CMDMEM_DED_COUNT),
864cbb84e7aSHawking Zhang 	},
865cbb84e7aSHawking Zhang 	{ "MMEA2_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT3),
866cbb84e7aSHawking Zhang 	0, 0,
867cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT3, IOWR_CMDMEM_DED_COUNT),
868cbb84e7aSHawking Zhang 	},
869cbb84e7aSHawking Zhang 	{ "MMEA2_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT3),
870cbb84e7aSHawking Zhang 	0, 0,
871cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT3, GMIRD_PAGEMEM_DED_COUNT),
872cbb84e7aSHawking Zhang 	},
873cbb84e7aSHawking Zhang 	{ "MMEA2_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT3),
874cbb84e7aSHawking Zhang 	0, 0,
875cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA2_EDC_CNT3, GMIWR_PAGEMEM_DED_COUNT),
876cbb84e7aSHawking Zhang 	},
877cbb84e7aSHawking Zhang 
878cbb84e7aSHawking Zhang 	/* MMHUB Rang 3 */
879cbb84e7aSHawking Zhang 	{ "MMEA3_DRAMRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
880cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMRD_CMDMEM_SEC_COUNT),
881cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMRD_CMDMEM_DED_COUNT),
882cbb84e7aSHawking Zhang 	},
883cbb84e7aSHawking Zhang 	{ "MMEA3_DRAMWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
884cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMWR_CMDMEM_SEC_COUNT),
885cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMWR_CMDMEM_DED_COUNT),
886cbb84e7aSHawking Zhang 	},
887cbb84e7aSHawking Zhang 	{ "MMEA3_DRAMWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
888cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMWR_DATAMEM_SEC_COUNT),
889cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMWR_DATAMEM_DED_COUNT),
890cbb84e7aSHawking Zhang 	},
891cbb84e7aSHawking Zhang 	{ "MMEA3_RRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
892cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, RRET_TAGMEM_SEC_COUNT),
893cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, RRET_TAGMEM_DED_COUNT),
894cbb84e7aSHawking Zhang 	},
895cbb84e7aSHawking Zhang 	{ "MMEA3_WRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
896cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, WRET_TAGMEM_SEC_COUNT),
897cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, WRET_TAGMEM_DED_COUNT),
898cbb84e7aSHawking Zhang 	},
899cbb84e7aSHawking Zhang 	{ "MMEA3_IOWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
900cbb84e7aSHawking Zhang         SOC15_REG_FIELD(MMEA3_EDC_CNT, IOWR_DATAMEM_SEC_COUNT),
901cbb84e7aSHawking Zhang         SOC15_REG_FIELD(MMEA3_EDC_CNT, IOWR_DATAMEM_DED_COUNT),
902cbb84e7aSHawking Zhang         },
903cbb84e7aSHawking Zhang 	{ "MMEA3_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
904cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMRD_PAGEMEM_SED_COUNT),
905cbb84e7aSHawking Zhang 	0, 0,
906cbb84e7aSHawking Zhang 	},
907cbb84e7aSHawking Zhang 	{ "MMEA3_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
908cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, DRAMWR_PAGEMEM_SED_COUNT),
909cbb84e7aSHawking Zhang 	0, 0,
910cbb84e7aSHawking Zhang 	},
911cbb84e7aSHawking Zhang 	{ "MMEA3_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
912cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, IORD_CMDMEM_SED_COUNT),
913cbb84e7aSHawking Zhang 	0, 0,
914cbb84e7aSHawking Zhang 	},
915cbb84e7aSHawking Zhang 	{ "MMEA3_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT),
916cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT, IOWR_CMDMEM_SED_COUNT),
917cbb84e7aSHawking Zhang 	0, 0,
918cbb84e7aSHawking Zhang 	},
919cbb84e7aSHawking Zhang 	{ "MMEA3_GMIRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
920cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIRD_CMDMEM_SEC_COUNT),
921cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIRD_CMDMEM_DED_COUNT),
922cbb84e7aSHawking Zhang 	},
923cbb84e7aSHawking Zhang 	{ "MMEA3_GMIWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
924cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIWR_CMDMEM_SEC_COUNT),
925cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIWR_CMDMEM_DED_COUNT),
926cbb84e7aSHawking Zhang 	},
927cbb84e7aSHawking Zhang 	{ "MMEA3_GMIWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
928cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIWR_DATAMEM_SEC_COUNT),
929cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIWR_DATAMEM_DED_COUNT),
930cbb84e7aSHawking Zhang 	},
931cbb84e7aSHawking Zhang 	{ "MMEA3_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
932cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIRD_PAGEMEM_SED_COUNT),
933cbb84e7aSHawking Zhang 	0, 0,
934cbb84e7aSHawking Zhang 	},
935cbb84e7aSHawking Zhang 	{ "MMEA3_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
936cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, GMIWR_PAGEMEM_SED_COUNT),
937cbb84e7aSHawking Zhang 	0, 0,
938cbb84e7aSHawking Zhang 	},
939cbb84e7aSHawking Zhang 	{ "MMEA3_MAM_D0MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
940cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D0MEM_SED_COUNT),
941cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D0MEM_DED_COUNT),
942cbb84e7aSHawking Zhang 	},
943cbb84e7aSHawking Zhang 	{ "MMEA3_MAM_D1MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
944cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D1MEM_SED_COUNT),
945cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D1MEM_DED_COUNT),
946cbb84e7aSHawking Zhang 	},
947cbb84e7aSHawking Zhang 	{ "MMEA3_MAM_D2MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
948cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D2MEM_SED_COUNT),
949cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D2MEM_DED_COUNT),
950cbb84e7aSHawking Zhang 	},
951cbb84e7aSHawking Zhang 	{ "MMEA3_MAM_D3MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2),
952cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D3MEM_SED_COUNT),
953cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT2, MAM_D3MEM_DED_COUNT),
954cbb84e7aSHawking Zhang 	},
955cbb84e7aSHawking Zhang 	{ "MMEA3_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT3),
956cbb84e7aSHawking Zhang 	0, 0,
957cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT3, DRAMRD_PAGEMEM_DED_COUNT),
958cbb84e7aSHawking Zhang 	},
959cbb84e7aSHawking Zhang 	{ "MMEA3_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT3),
960cbb84e7aSHawking Zhang 	0, 0,
961cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT3, DRAMWR_PAGEMEM_DED_COUNT),
962cbb84e7aSHawking Zhang 	},
963cbb84e7aSHawking Zhang 	{ "MMEA3_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT3),
964cbb84e7aSHawking Zhang 	0, 0,
965cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT3, IORD_CMDMEM_DED_COUNT),
966cbb84e7aSHawking Zhang 	},
967cbb84e7aSHawking Zhang 	{ "MMEA3_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT3),
968cbb84e7aSHawking Zhang 	0, 0,
969cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT3, IOWR_CMDMEM_DED_COUNT),
970cbb84e7aSHawking Zhang 	},
971cbb84e7aSHawking Zhang 	{ "MMEA3_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT3),
972cbb84e7aSHawking Zhang 	0, 0,
973cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT3, GMIRD_PAGEMEM_DED_COUNT),
974cbb84e7aSHawking Zhang 	},
975cbb84e7aSHawking Zhang 	{ "MMEA3_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT3),
976cbb84e7aSHawking Zhang 	0, 0,
977cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA3_EDC_CNT3, GMIWR_PAGEMEM_DED_COUNT),
978cbb84e7aSHawking Zhang 	},
979cbb84e7aSHawking Zhang 
980cbb84e7aSHawking Zhang 	/* MMHUB Range 4 */
981cbb84e7aSHawking Zhang 	{ "MMEA4_DRAMRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
982cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMRD_CMDMEM_SEC_COUNT),
983cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMRD_CMDMEM_DED_COUNT),
984cbb84e7aSHawking Zhang 	},
985cbb84e7aSHawking Zhang 	{ "MMEA4_DRAMWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
986cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMWR_CMDMEM_SEC_COUNT),
987cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMWR_CMDMEM_DED_COUNT),
988cbb84e7aSHawking Zhang 	},
989cbb84e7aSHawking Zhang 	{ "MMEA4_DRAMWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
990cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMWR_DATAMEM_SEC_COUNT),
991cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMWR_DATAMEM_DED_COUNT),
992cbb84e7aSHawking Zhang 	},
993cbb84e7aSHawking Zhang 	{ "MMEA4_RRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
994cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, RRET_TAGMEM_SEC_COUNT),
995cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, RRET_TAGMEM_DED_COUNT),
996cbb84e7aSHawking Zhang 	},
997cbb84e7aSHawking Zhang 	{ "MMEA4_WRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
998cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, WRET_TAGMEM_SEC_COUNT),
999cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, WRET_TAGMEM_DED_COUNT),
1000cbb84e7aSHawking Zhang 	},
1001cbb84e7aSHawking Zhang 	{ "MMEA4_IOWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
1002cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, IOWR_DATAMEM_SEC_COUNT),
1003cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, IOWR_DATAMEM_DED_COUNT),
1004cbb84e7aSHawking Zhang 	},
1005cbb84e7aSHawking Zhang 	{ "MMEA4_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
1006cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMRD_PAGEMEM_SED_COUNT),
1007cbb84e7aSHawking Zhang 	0, 0,
1008cbb84e7aSHawking Zhang 	},
1009cbb84e7aSHawking Zhang 	{ "MMEA4_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
1010cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, DRAMWR_PAGEMEM_SED_COUNT),
1011cbb84e7aSHawking Zhang 	0, 0,
1012cbb84e7aSHawking Zhang 	},
1013cbb84e7aSHawking Zhang 	{ "MMEA4_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
1014cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, IORD_CMDMEM_SED_COUNT),
1015cbb84e7aSHawking Zhang 	0, 0,
1016cbb84e7aSHawking Zhang 	},
1017cbb84e7aSHawking Zhang 	{ "MMEA4_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT),
1018cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT, IOWR_CMDMEM_SED_COUNT),
1019cbb84e7aSHawking Zhang 	0, 0,
1020cbb84e7aSHawking Zhang 	},
1021cbb84e7aSHawking Zhang 	{ "MMEA4_GMIRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1022cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIRD_CMDMEM_SEC_COUNT),
1023cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIRD_CMDMEM_DED_COUNT),
1024cbb84e7aSHawking Zhang 	},
1025cbb84e7aSHawking Zhang 	{ "MMEA4_GMIWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1026cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIWR_CMDMEM_SEC_COUNT),
1027cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIWR_CMDMEM_DED_COUNT),
1028cbb84e7aSHawking Zhang 	},
1029cbb84e7aSHawking Zhang 	{ "MMEA4_GMIWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1030cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIWR_DATAMEM_SEC_COUNT),
1031cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIWR_DATAMEM_DED_COUNT),
1032cbb84e7aSHawking Zhang 	},
1033cbb84e7aSHawking Zhang 	{ "MMEA4_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1034cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIRD_PAGEMEM_SED_COUNT),
1035cbb84e7aSHawking Zhang 	0, 0,
1036cbb84e7aSHawking Zhang 	},
1037cbb84e7aSHawking Zhang 	{ "MMEA4_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1038cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, GMIWR_PAGEMEM_SED_COUNT),
1039cbb84e7aSHawking Zhang 	0, 0,
1040cbb84e7aSHawking Zhang 	},
1041cbb84e7aSHawking Zhang 	{ "MMEA4_MAM_D0MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1042cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D0MEM_SED_COUNT),
1043cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D0MEM_DED_COUNT),
1044cbb84e7aSHawking Zhang 	},
1045cbb84e7aSHawking Zhang 	{ "MMEA4_MAM_D1MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1046cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D1MEM_SED_COUNT),
1047cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D1MEM_DED_COUNT),
1048cbb84e7aSHawking Zhang 	},
1049cbb84e7aSHawking Zhang 	{ "MMEA4_MAM_D2MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1050cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D2MEM_SED_COUNT),
1051cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D2MEM_DED_COUNT),
1052cbb84e7aSHawking Zhang 	},
1053cbb84e7aSHawking Zhang 	{ "MMEA4_MAM_D3MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2),
1054cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D3MEM_SED_COUNT),
1055cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT2, MAM_D3MEM_DED_COUNT),
1056cbb84e7aSHawking Zhang 	},
1057cbb84e7aSHawking Zhang 	{ "MMEA4_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT3),
1058cbb84e7aSHawking Zhang 	0, 0,
1059cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT3, DRAMRD_PAGEMEM_DED_COUNT),
1060cbb84e7aSHawking Zhang 	},
1061cbb84e7aSHawking Zhang 	{ "MMEA4_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT3),
1062cbb84e7aSHawking Zhang 	0, 0,
1063cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT3, DRAMWR_PAGEMEM_DED_COUNT),
1064cbb84e7aSHawking Zhang 	},
1065cbb84e7aSHawking Zhang 	{ "MMEA4_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT3),
1066cbb84e7aSHawking Zhang 	0, 0,
1067cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT3, IORD_CMDMEM_DED_COUNT),
1068cbb84e7aSHawking Zhang 	},
1069cbb84e7aSHawking Zhang 	{ "MMEA4_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT3),
1070cbb84e7aSHawking Zhang 	0, 0,
1071cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT3, IOWR_CMDMEM_DED_COUNT),
1072cbb84e7aSHawking Zhang 	},
1073cbb84e7aSHawking Zhang 	{ "MMEA4_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT3),
1074cbb84e7aSHawking Zhang 	0, 0,
1075cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT3, GMIRD_PAGEMEM_DED_COUNT),
1076cbb84e7aSHawking Zhang 	},
1077cbb84e7aSHawking Zhang 	{ "MMEA4_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT3),
1078cbb84e7aSHawking Zhang 	0, 0,
1079cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA4_EDC_CNT3, GMIWR_PAGEMEM_DED_COUNT),
1080cbb84e7aSHawking Zhang 	},
1081cbb84e7aSHawking Zhang 
1082cbb84e7aSHawking Zhang 	/* MMHUAB Range 5 */
1083cbb84e7aSHawking Zhang 	{ "MMEA5_DRAMRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1084cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMRD_CMDMEM_SEC_COUNT),
1085cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMRD_CMDMEM_DED_COUNT),
1086cbb84e7aSHawking Zhang 	},
1087cbb84e7aSHawking Zhang 	{ "MMEA5_DRAMWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1088cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMWR_CMDMEM_SEC_COUNT),
1089cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMWR_CMDMEM_DED_COUNT),
1090cbb84e7aSHawking Zhang 	},
1091cbb84e7aSHawking Zhang 	{ "MMEA5_DRAMWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1092cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMWR_DATAMEM_SEC_COUNT),
1093cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMWR_DATAMEM_DED_COUNT),
1094cbb84e7aSHawking Zhang 	},
1095cbb84e7aSHawking Zhang 	{ "MMEA5_RRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1096cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, RRET_TAGMEM_SEC_COUNT),
1097cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, RRET_TAGMEM_DED_COUNT),
1098cbb84e7aSHawking Zhang 	},
1099cbb84e7aSHawking Zhang 	{ "MMEA5_WRET_TAGMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1100cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, WRET_TAGMEM_SEC_COUNT),
1101cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, WRET_TAGMEM_DED_COUNT),
1102cbb84e7aSHawking Zhang 	},
1103cbb84e7aSHawking Zhang 	{ "MMEA5_IOWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1104cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, IOWR_DATAMEM_SEC_COUNT),
1105cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, IOWR_DATAMEM_DED_COUNT),
1106cbb84e7aSHawking Zhang 	},
1107cbb84e7aSHawking Zhang 	{ "MMEA5_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1108cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMRD_PAGEMEM_SED_COUNT),
1109cbb84e7aSHawking Zhang 	0, 0,
1110cbb84e7aSHawking Zhang 	},
1111cbb84e7aSHawking Zhang 	{ "MMEA5_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1112cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, DRAMWR_PAGEMEM_SED_COUNT),
1113cbb84e7aSHawking Zhang 	0, 0,
1114cbb84e7aSHawking Zhang 	},
1115cbb84e7aSHawking Zhang 	{ "MMEA5_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1116cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, IORD_CMDMEM_SED_COUNT),
1117cbb84e7aSHawking Zhang 	0, 0,
1118cbb84e7aSHawking Zhang 	},
1119cbb84e7aSHawking Zhang 	{ "MMEA5_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT),
1120cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT, IOWR_CMDMEM_SED_COUNT),
1121cbb84e7aSHawking Zhang 	0, 0,
1122cbb84e7aSHawking Zhang 	},
1123cbb84e7aSHawking Zhang 	{ "MMEA5_GMIRD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1124cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIRD_CMDMEM_SEC_COUNT),
1125cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIRD_CMDMEM_DED_COUNT),
1126cbb84e7aSHawking Zhang 	},
1127cbb84e7aSHawking Zhang 	{ "MMEA5_GMIWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1128cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIWR_CMDMEM_SEC_COUNT),
1129cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIWR_CMDMEM_DED_COUNT),
1130cbb84e7aSHawking Zhang 	},
1131cbb84e7aSHawking Zhang 	{ "MMEA5_GMIWR_DATAMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1132cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIWR_DATAMEM_SEC_COUNT),
1133cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIWR_DATAMEM_DED_COUNT),
1134cbb84e7aSHawking Zhang 	},
1135cbb84e7aSHawking Zhang 	{ "MMEA5_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1136cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIRD_PAGEMEM_SED_COUNT),
1137cbb84e7aSHawking Zhang 	0, 0,
1138cbb84e7aSHawking Zhang 	},
1139cbb84e7aSHawking Zhang 	{ "MMEA5_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1140cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, GMIWR_PAGEMEM_SED_COUNT),
1141cbb84e7aSHawking Zhang 	0, 0,
1142cbb84e7aSHawking Zhang 	},
1143cbb84e7aSHawking Zhang 	{ "MMEA5_MAM_D0MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1144cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D0MEM_SED_COUNT),
1145cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D0MEM_DED_COUNT),
1146cbb84e7aSHawking Zhang 	},
1147cbb84e7aSHawking Zhang 	{ "MMEA5_MAM_D1MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1148cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D1MEM_SED_COUNT),
1149cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D1MEM_DED_COUNT),
1150cbb84e7aSHawking Zhang 	},
1151cbb84e7aSHawking Zhang 	{ "MMEA5_MAM_D2MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1152cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D2MEM_SED_COUNT),
1153cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D2MEM_DED_COUNT),
1154cbb84e7aSHawking Zhang 	},
1155cbb84e7aSHawking Zhang 	{ "MMEA5_MAM_D3MEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2),
1156cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D3MEM_SED_COUNT),
1157cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT2, MAM_D3MEM_DED_COUNT),
1158cbb84e7aSHawking Zhang 	},
1159cbb84e7aSHawking Zhang 	{ "MMEA5_DRAMRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT3),
1160cbb84e7aSHawking Zhang 	0, 0,
1161cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT3, DRAMRD_PAGEMEM_DED_COUNT),
1162cbb84e7aSHawking Zhang 	},
1163cbb84e7aSHawking Zhang 	{ "MMEA5_DRAMWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT3),
1164cbb84e7aSHawking Zhang 	0, 0,
1165cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT3, DRAMWR_PAGEMEM_DED_COUNT),
1166cbb84e7aSHawking Zhang 	},
1167cbb84e7aSHawking Zhang 	{ "MMEA5_IORD_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT3),
1168cbb84e7aSHawking Zhang 	0, 0,
1169cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT3, IORD_CMDMEM_DED_COUNT),
1170cbb84e7aSHawking Zhang 	},
1171cbb84e7aSHawking Zhang 	{ "MMEA5_IOWR_CMDMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT3),
1172cbb84e7aSHawking Zhang 	0, 0,
1173cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT3, IOWR_CMDMEM_DED_COUNT),
1174cbb84e7aSHawking Zhang 	},
1175cbb84e7aSHawking Zhang 	{ "MMEA5_GMIRD_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT3),
1176cbb84e7aSHawking Zhang 	0, 0,
1177cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT3, GMIRD_PAGEMEM_DED_COUNT),
1178cbb84e7aSHawking Zhang 	},
1179cbb84e7aSHawking Zhang 	{ "MMEA5_GMIWR_PAGEMEM", SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT3),
1180cbb84e7aSHawking Zhang 	0, 0,
1181cbb84e7aSHawking Zhang 	SOC15_REG_FIELD(MMEA5_EDC_CNT3, GMIWR_PAGEMEM_DED_COUNT),
1182cbb84e7aSHawking Zhang 	},
1183cbb84e7aSHawking Zhang };
1184cbb84e7aSHawking Zhang 
1185cbb84e7aSHawking Zhang static const struct soc15_reg_entry mmhub_v1_7_edc_cnt_regs[] = {
1186cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT), 0, 0, 0 },
1187cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT2), 0, 0, 0 },
1188cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_EDC_CNT3), 0, 0, 0 },
1189cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT), 0, 0, 0 },
1190cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT2), 0, 0, 0 },
1191cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_EDC_CNT3), 0, 0, 0 },
1192cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT), 0, 0, 0 },
1193cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT2), 0, 0, 0 },
1194cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_EDC_CNT3), 0, 0, 0 },
1195cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT), 0, 0, 0 },
1196cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT2), 0, 0, 0 },
1197cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_EDC_CNT3), 0, 0, 0 },
1198cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT), 0, 0, 0 },
1199cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT2), 0, 0, 0 },
1200cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_EDC_CNT3), 0, 0, 0 },
1201cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT), 0, 0, 0 },
1202cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT2), 0, 0, 0 },
1203cbb84e7aSHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_EDC_CNT3), 0, 0, 0 },
1204cbb84e7aSHawking Zhang };
1205cbb84e7aSHawking Zhang 
mmhub_v1_7_get_ras_error_count(struct amdgpu_device * adev,const struct soc15_reg_entry * reg,uint32_t value,uint32_t * sec_count,uint32_t * ded_count)1206cbb84e7aSHawking Zhang static int mmhub_v1_7_get_ras_error_count(struct amdgpu_device *adev,
1207cbb84e7aSHawking Zhang 					  const struct soc15_reg_entry *reg,
1208cbb84e7aSHawking Zhang 					  uint32_t value,
1209cbb84e7aSHawking Zhang 					  uint32_t *sec_count,
1210cbb84e7aSHawking Zhang 					  uint32_t *ded_count)
1211cbb84e7aSHawking Zhang {
1212cbb84e7aSHawking Zhang 	uint32_t i;
1213cbb84e7aSHawking Zhang 	uint32_t sec_cnt, ded_cnt;
1214cbb84e7aSHawking Zhang 
1215cbb84e7aSHawking Zhang 	for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_ras_fields); i++) {
1216cbb84e7aSHawking Zhang 		if(mmhub_v1_7_ras_fields[i].reg_offset != reg->reg_offset)
1217cbb84e7aSHawking Zhang 			continue;
1218cbb84e7aSHawking Zhang 
1219cbb84e7aSHawking Zhang 		sec_cnt = (value &
1220cbb84e7aSHawking Zhang 				mmhub_v1_7_ras_fields[i].sec_count_mask) >>
1221cbb84e7aSHawking Zhang 				mmhub_v1_7_ras_fields[i].sec_count_shift;
1222cbb84e7aSHawking Zhang 		if (sec_cnt) {
1223cbb84e7aSHawking Zhang 			dev_info(adev->dev, "MMHUB SubBlock %s, SEC %d\n",
1224cbb84e7aSHawking Zhang 				 mmhub_v1_7_ras_fields[i].name,
1225cbb84e7aSHawking Zhang 				 sec_cnt);
1226cbb84e7aSHawking Zhang 			*sec_count += sec_cnt;
1227cbb84e7aSHawking Zhang 		}
1228cbb84e7aSHawking Zhang 
1229cbb84e7aSHawking Zhang 		ded_cnt = (value &
1230cbb84e7aSHawking Zhang 				mmhub_v1_7_ras_fields[i].ded_count_mask) >>
1231cbb84e7aSHawking Zhang 				mmhub_v1_7_ras_fields[i].ded_count_shift;
1232cbb84e7aSHawking Zhang 		if (ded_cnt) {
1233cbb84e7aSHawking Zhang 			dev_info(adev->dev, "MMHUB SubBlock %s, DED %d\n",
1234cbb84e7aSHawking Zhang 				 mmhub_v1_7_ras_fields[i].name,
1235cbb84e7aSHawking Zhang 				 ded_cnt);
1236cbb84e7aSHawking Zhang 			*ded_count += ded_cnt;
1237cbb84e7aSHawking Zhang 		}
1238cbb84e7aSHawking Zhang 	}
1239cbb84e7aSHawking Zhang 
1240cbb84e7aSHawking Zhang 	return 0;
1241cbb84e7aSHawking Zhang }
1242cbb84e7aSHawking Zhang 
mmhub_v1_7_query_ras_error_count(struct amdgpu_device * adev,void * ras_error_status)1243f37945d5SLe Ma static void mmhub_v1_7_query_ras_error_count(struct amdgpu_device *adev,
1244f37945d5SLe Ma 					     void *ras_error_status)
1245f37945d5SLe Ma {
1246f37945d5SLe Ma 	struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status;
1247cbb84e7aSHawking Zhang 	uint32_t sec_count = 0, ded_count = 0;
1248cbb84e7aSHawking Zhang 	uint32_t i;
1249cbb84e7aSHawking Zhang 	uint32_t reg_value;
1250f37945d5SLe Ma 
1251cbb84e7aSHawking Zhang 	err_data->ue_count = 0;
1252cbb84e7aSHawking Zhang 	err_data->ce_count = 0;
1253f37945d5SLe Ma 
1254cbb84e7aSHawking Zhang 	for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_edc_cnt_regs); i++) {
1255cbb84e7aSHawking Zhang 		reg_value =
1256cbb84e7aSHawking Zhang 			RREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v1_7_edc_cnt_regs[i]));
1257cbb84e7aSHawking Zhang 		if (reg_value)
1258cbb84e7aSHawking Zhang 			mmhub_v1_7_get_ras_error_count(adev, &mmhub_v1_7_edc_cnt_regs[i],
1259cbb84e7aSHawking Zhang 				reg_value, &sec_count, &ded_count);
1260f37945d5SLe Ma 	}
1261f37945d5SLe Ma 
1262cbb84e7aSHawking Zhang 	err_data->ce_count += sec_count;
1263cbb84e7aSHawking Zhang 	err_data->ue_count += ded_count;
1264f37945d5SLe Ma }
1265f37945d5SLe Ma 
mmhub_v1_7_reset_ras_error_count(struct amdgpu_device * adev)126627ad2ca6SHawking Zhang static void mmhub_v1_7_reset_ras_error_count(struct amdgpu_device *adev)
126727ad2ca6SHawking Zhang {
126827ad2ca6SHawking Zhang 	uint32_t i;
126927ad2ca6SHawking Zhang 
127027ad2ca6SHawking Zhang 	/* write 0 to reset the edc counters */
127127ad2ca6SHawking Zhang 	if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__MMHUB)) {
127227ad2ca6SHawking Zhang 		for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_edc_cnt_regs); i++)
127327ad2ca6SHawking Zhang 			WREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v1_7_edc_cnt_regs[i]), 0);
127427ad2ca6SHawking Zhang 	}
127527ad2ca6SHawking Zhang }
127627ad2ca6SHawking Zhang 
12771f8d3ad2SHawking Zhang static const struct soc15_reg_entry mmhub_v1_7_ea_err_status_regs[] = {
1278b45589b8SHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA0_ERR_STATUS), 0, 0, 0 },
1279b45589b8SHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA1_ERR_STATUS), 0, 0, 0 },
1280b45589b8SHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA2_ERR_STATUS), 0, 0, 0 },
1281b45589b8SHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA3_ERR_STATUS), 0, 0, 0 },
1282b45589b8SHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA4_ERR_STATUS), 0, 0, 0 },
1283b45589b8SHawking Zhang 	{ SOC15_REG_ENTRY(MMHUB, 0, regMMEA5_ERR_STATUS), 0, 0, 0 },
1284b45589b8SHawking Zhang };
1285b45589b8SHawking Zhang 
mmhub_v1_7_query_ras_error_status(struct amdgpu_device * adev)1286b45589b8SHawking Zhang static void mmhub_v1_7_query_ras_error_status(struct amdgpu_device *adev)
1287b45589b8SHawking Zhang {
1288b45589b8SHawking Zhang 	int i;
1289b45589b8SHawking Zhang 	uint32_t reg_value;
1290b45589b8SHawking Zhang 
1291b45589b8SHawking Zhang 	if (!amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__MMHUB))
1292b45589b8SHawking Zhang 		return;
1293b45589b8SHawking Zhang 
12941f8d3ad2SHawking Zhang 	for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_ea_err_status_regs); i++) {
1295b45589b8SHawking Zhang 		reg_value =
12961f8d3ad2SHawking Zhang 			RREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v1_7_ea_err_status_regs[i]));
12971f8d3ad2SHawking Zhang 		if (REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, SDP_RDRSP_STATUS) ||
12981f8d3ad2SHawking Zhang 		    REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, SDP_WRRSP_STATUS) ||
12991f8d3ad2SHawking Zhang 		    REG_GET_FIELD(reg_value, MMEA0_ERR_STATUS, SDP_RDRSP_DATAPARITY_ERROR)) {
1300b45589b8SHawking Zhang 			dev_warn(adev->dev, "MMHUB EA err detected at instance: %d, status: 0x%x!\n",
1301b45589b8SHawking Zhang 					i, reg_value);
1302b45589b8SHawking Zhang 		}
1303b45589b8SHawking Zhang 	}
13041f8d3ad2SHawking Zhang }
1305b45589b8SHawking Zhang 
mmhub_v1_7_reset_ras_error_status(struct amdgpu_device * adev)13067780f503SDennis Li static void mmhub_v1_7_reset_ras_error_status(struct amdgpu_device *adev)
13077780f503SDennis Li {
13087780f503SDennis Li 	int i;
13097780f503SDennis Li 	uint32_t reg_value;
13107780f503SDennis Li 
13117780f503SDennis Li 	if (!amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__MMHUB))
13127780f503SDennis Li 		return;
13137780f503SDennis Li 
13147780f503SDennis Li 	for (i = 0; i < ARRAY_SIZE(mmhub_v1_7_ea_err_status_regs); i++) {
13157780f503SDennis Li 		reg_value = RREG32(SOC15_REG_ENTRY_OFFSET(
13167780f503SDennis Li 			mmhub_v1_7_ea_err_status_regs[i]));
13177780f503SDennis Li 		reg_value = REG_SET_FIELD(reg_value, MMEA0_ERR_STATUS,
13187780f503SDennis Li 					  CLEAR_ERROR_STATUS, 0x01);
13197780f503SDennis Li 		WREG32(SOC15_REG_ENTRY_OFFSET(mmhub_v1_7_ea_err_status_regs[i]),
13207780f503SDennis Li 		       reg_value);
13217780f503SDennis Li 	}
13227780f503SDennis Li }
13237780f503SDennis Li 
13245e67bba3Syipechai struct amdgpu_ras_block_hw_ops mmhub_v1_7_ras_hw_ops = {
1325f37945d5SLe Ma 	.query_ras_error_count = mmhub_v1_7_query_ras_error_count,
132627ad2ca6SHawking Zhang 	.reset_ras_error_count = mmhub_v1_7_reset_ras_error_count,
13278bc7b360SHawking Zhang 	.query_ras_error_status = mmhub_v1_7_query_ras_error_status,
13287780f503SDennis Li 	.reset_ras_error_status = mmhub_v1_7_reset_ras_error_status,
13298bc7b360SHawking Zhang };
13308bc7b360SHawking Zhang 
13315e67bba3Syipechai struct amdgpu_mmhub_ras mmhub_v1_7_ras = {
13325e67bba3Syipechai 	.ras_block = {
13335e67bba3Syipechai 		.hw_ops = &mmhub_v1_7_ras_hw_ops,
13345e67bba3Syipechai 	},
13355e67bba3Syipechai };
13365e67bba3Syipechai 
13378bc7b360SHawking Zhang const struct amdgpu_mmhub_funcs mmhub_v1_7_funcs = {
13384da999cdSOak Zeng 	.get_fb_location = mmhub_v1_7_get_fb_location,
13394da999cdSOak Zeng 	.init = mmhub_v1_7_init,
13404da999cdSOak Zeng 	.gart_enable = mmhub_v1_7_gart_enable,
13414da999cdSOak Zeng 	.set_fault_enable_default = mmhub_v1_7_set_fault_enable_default,
13424da999cdSOak Zeng 	.gart_disable = mmhub_v1_7_gart_disable,
13434da999cdSOak Zeng 	.set_clockgating = mmhub_v1_7_set_clockgating,
13444da999cdSOak Zeng 	.get_clockgating = mmhub_v1_7_get_clockgating,
13454da999cdSOak Zeng 	.setup_vm_pt_regs = mmhub_v1_7_setup_vm_pt_regs,
1346f37945d5SLe Ma };
1347