xref: /openbmc/linux/drivers/gpu/drm/amd/amdgpu/umc_v6_7.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
11696bf35SHawking Zhang /*
21696bf35SHawking Zhang  * Copyright 2021 Advanced Micro Devices, Inc.
31696bf35SHawking Zhang  *
41696bf35SHawking Zhang  * Permission is hereby granted, free of charge, to any person obtaining a
51696bf35SHawking Zhang  * copy of this software and associated documentation files (the "Software"),
61696bf35SHawking Zhang  * to deal in the Software without restriction, including without limitation
71696bf35SHawking Zhang  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
81696bf35SHawking Zhang  * and/or sell copies of the Software, and to permit persons to whom the
91696bf35SHawking Zhang  * Software is furnished to do so, subject to the following conditions:
101696bf35SHawking Zhang  *
111696bf35SHawking Zhang  * The above copyright notice and this permission notice shall be included in
121696bf35SHawking Zhang  * all copies or substantial portions of the Software.
131696bf35SHawking Zhang  *
141696bf35SHawking Zhang  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151696bf35SHawking Zhang  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
161696bf35SHawking Zhang  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
171696bf35SHawking Zhang  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
181696bf35SHawking Zhang  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
191696bf35SHawking Zhang  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
201696bf35SHawking Zhang  * OTHER DEALINGS IN THE SOFTWARE.
211696bf35SHawking Zhang  *
221696bf35SHawking Zhang  */
231696bf35SHawking Zhang #ifndef __UMC_V6_7_H__
241696bf35SHawking Zhang #define __UMC_V6_7_H__
251696bf35SHawking Zhang 
26186c8a85SJohn Clements #include "soc15_common.h"
27186c8a85SJohn Clements #include "amdgpu.h"
28186c8a85SJohn Clements 
293f903560SHawking Zhang /* EccErrCnt max value */
303f903560SHawking Zhang #define UMC_V6_7_CE_CNT_MAX		0xffff
313f903560SHawking Zhang /* umc ce interrupt threshold */
323f903560SHawking Zhang #define UMC_V6_7_CE_INT_THRESHOLD	0xffff
333f903560SHawking Zhang /* umc ce count initial value */
343f903560SHawking Zhang #define UMC_V6_7_CE_CNT_INIT	(UMC_V6_7_CE_CNT_MAX - UMC_V6_7_CE_INT_THRESHOLD)
353f903560SHawking Zhang 
36878b9e94SHawking Zhang #define UMC_V6_7_INST_DIST	0x40000
37878b9e94SHawking Zhang 
38186c8a85SJohn Clements /* number of umc channel instance with memory map register access */
39719e433eSMukul Joshi #define UMC_V6_7_UMC_INSTANCE_NUM		4
40186c8a85SJohn Clements /* number of umc instance with memory map register access */
41719e433eSMukul Joshi #define UMC_V6_7_CHANNEL_INSTANCE_NUM		8
42186c8a85SJohn Clements /* total channel instances in one umc block */
43186c8a85SJohn Clements #define UMC_V6_7_TOTAL_CHANNEL_NUM	(UMC_V6_7_CHANNEL_INSTANCE_NUM * UMC_V6_7_UMC_INSTANCE_NUM)
44498d46feSTao Zhou /* one piece of normalizing address is mapped to 8 pieces of physical address */
45498d46feSTao Zhou #define UMC_V6_7_NA_MAP_PA_NUM	8
46498d46feSTao Zhou /* R14 bit shift should be considered, double the number */
47498d46feSTao Zhou #define UMC_V6_7_BAD_PAGE_NUM_PER_CHANNEL	(UMC_V6_7_NA_MAP_PA_NUM * 2)
48bee7f8d0STao Zhou /* The CH4 bit in SOC physical address */
49bee7f8d0STao Zhou #define UMC_V6_7_PA_CH4_BIT	12
50e63fa4dcSTao Zhou /* The C2 bit in SOC physical address */
51e63fa4dcSTao Zhou #define UMC_V6_7_PA_C2_BIT	17
52e63fa4dcSTao Zhou /* The R14 bit in SOC physical address */
53e63fa4dcSTao Zhou #define UMC_V6_7_PA_R14_BIT	34
54186c8a85SJohn Clements /* UMC regiser per channel offset */
55186c8a85SJohn Clements #define UMC_V6_7_PER_CHANNEL_OFFSET		0x400
56bee7f8d0STao Zhou 
57bee7f8d0STao Zhou /* XOR bit 20, 25, 34 of PA into CH4 bit (bit 12 of PA),
58bee7f8d0STao Zhou  * hash bit is only effective when related setting is enabled
59bee7f8d0STao Zhou  */
60bee7f8d0STao Zhou #define CHANNEL_HASH(channel_idx, pa) (((channel_idx) >> 4) ^ \
61bee7f8d0STao Zhou 			(((pa)  >> 20) & 0x1ULL & adev->df.hash_status.hash_64k) ^ \
62bee7f8d0STao Zhou 			(((pa)  >> 25) & 0x1ULL & adev->df.hash_status.hash_2m) ^ \
63bee7f8d0STao Zhou 			(((pa)  >> 34) & 0x1ULL & adev->df.hash_status.hash_1g))
64bee7f8d0STao Zhou #define SET_CHANNEL_HASH(channel_idx, pa) do { \
65bee7f8d0STao Zhou 		(pa) &= ~(0x1ULL << UMC_V6_7_PA_CH4_BIT); \
66bee7f8d0STao Zhou 		(pa) |= (CHANNEL_HASH(channel_idx, pa) << UMC_V6_7_PA_CH4_BIT); \
67bee7f8d0STao Zhou 	} while (0)
68bee7f8d0STao Zhou 
69efe17d5aSyipechai extern struct amdgpu_umc_ras umc_v6_7_ras;
70186c8a85SJohn Clements extern const uint32_t
71186c8a85SJohn Clements 	umc_v6_7_channel_idx_tbl_second[UMC_V6_7_UMC_INSTANCE_NUM][UMC_V6_7_CHANNEL_INSTANCE_NUM];
72186c8a85SJohn Clements extern const uint32_t
73186c8a85SJohn Clements 	umc_v6_7_channel_idx_tbl_first[UMC_V6_7_UMC_INSTANCE_NUM][UMC_V6_7_CHANNEL_INSTANCE_NUM];
74*6c0ca748SHawking Zhang void umc_v6_7_convert_error_address(struct amdgpu_device *adev,
75*6c0ca748SHawking Zhang                                     struct ras_err_data *err_data, uint64_t err_addr,
76*6c0ca748SHawking Zhang                                     uint32_t ch_inst, uint32_t umc_inst);
771696bf35SHawking Zhang #endif
78