xref: /openbmc/linux/drivers/accel/habanalabs/gaudi2/gaudi2P.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1e65e175bSOded Gabbay /* SPDX-License-Identifier: GPL-2.0
2e65e175bSOded Gabbay  *
3e65e175bSOded Gabbay  * Copyright 2020-2022 HabanaLabs, Ltd.
4e65e175bSOded Gabbay  * All Rights Reserved.
5e65e175bSOded Gabbay  *
6e65e175bSOded Gabbay  */
7e65e175bSOded Gabbay 
8e65e175bSOded Gabbay #ifndef GAUDI2P_H_
9e65e175bSOded Gabbay #define GAUDI2P_H_
10e65e175bSOded Gabbay 
11e65e175bSOded Gabbay #include <uapi/drm/habanalabs_accel.h>
12e65e175bSOded Gabbay #include "../common/habanalabs.h"
13e65e175bSOded Gabbay #include "../include/common/hl_boot_if.h"
14e65e175bSOded Gabbay #include "../include/gaudi2/gaudi2.h"
15e65e175bSOded Gabbay #include "../include/gaudi2/gaudi2_packets.h"
16e65e175bSOded Gabbay #include "../include/gaudi2/gaudi2_fw_if.h"
17e65e175bSOded Gabbay #include "../include/gaudi2/gaudi2_async_events.h"
18e65e175bSOded Gabbay 
19e65e175bSOded Gabbay #define GAUDI2_LINUX_FW_FILE	"habanalabs/gaudi2/gaudi2-fit.itb"
20e65e175bSOded Gabbay #define GAUDI2_BOOT_FIT_FILE	"habanalabs/gaudi2/gaudi2-boot-fit.itb"
21e65e175bSOded Gabbay 
22e65e175bSOded Gabbay #define MMU_PAGE_TABLES_INITIAL_SIZE	0x10000000	/* 256MB */
23e65e175bSOded Gabbay 
24e65e175bSOded Gabbay #define GAUDI2_CPU_TIMEOUT_USEC		30000000	/* 30s */
25e65e175bSOded Gabbay 
26e65e175bSOded Gabbay #define NUMBER_OF_PDMA_QUEUES		2
27e65e175bSOded Gabbay #define NUMBER_OF_EDMA_QUEUES		8
28e65e175bSOded Gabbay #define NUMBER_OF_MME_QUEUES		4
29e65e175bSOded Gabbay #define NUMBER_OF_TPC_QUEUES		25
30e65e175bSOded Gabbay #define NUMBER_OF_NIC_QUEUES		24
31e65e175bSOded Gabbay #define NUMBER_OF_ROT_QUEUES		2
32e65e175bSOded Gabbay #define NUMBER_OF_CPU_QUEUES		1
33e65e175bSOded Gabbay 
34e65e175bSOded Gabbay #define NUMBER_OF_HW_QUEUES		((NUMBER_OF_PDMA_QUEUES + \
35e65e175bSOded Gabbay 					NUMBER_OF_EDMA_QUEUES + \
36e65e175bSOded Gabbay 					NUMBER_OF_MME_QUEUES + \
37e65e175bSOded Gabbay 					NUMBER_OF_TPC_QUEUES + \
38e65e175bSOded Gabbay 					NUMBER_OF_NIC_QUEUES + \
39e65e175bSOded Gabbay 					NUMBER_OF_ROT_QUEUES + \
40e65e175bSOded Gabbay 					NUMBER_OF_CPU_QUEUES) * \
41e65e175bSOded Gabbay 					NUM_OF_PQ_PER_QMAN)
42e65e175bSOded Gabbay 
43e65e175bSOded Gabbay #define NUMBER_OF_QUEUES		(NUMBER_OF_CPU_QUEUES + NUMBER_OF_HW_QUEUES)
44e65e175bSOded Gabbay 
45e65e175bSOded Gabbay #define DCORE_NUM_OF_SOB		\
46e65e175bSOded Gabbay 	(((mmDCORE0_SYNC_MNGR_OBJS_SOB_OBJ_8191 - \
47e65e175bSOded Gabbay 	mmDCORE0_SYNC_MNGR_OBJS_SOB_OBJ_0) + 4) >> 2)
48e65e175bSOded Gabbay 
49e65e175bSOded Gabbay #define DCORE_NUM_OF_MONITORS		\
50e65e175bSOded Gabbay 	(((mmDCORE0_SYNC_MNGR_OBJS_MON_STATUS_2047 - \
51e65e175bSOded Gabbay 	mmDCORE0_SYNC_MNGR_OBJS_MON_STATUS_0) + 4) >> 2)
52e65e175bSOded Gabbay 
53e65e175bSOded Gabbay #define NUMBER_OF_DEC		((NUM_OF_DEC_PER_DCORE * NUM_OF_DCORES) + NUMBER_OF_PCIE_DEC)
54e65e175bSOded Gabbay 
55e65e175bSOded Gabbay /* Map all arcs dccm + arc schedulers acp blocks */
56e65e175bSOded Gabbay #define NUM_OF_USER_ACP_BLOCKS		(NUM_OF_SCHEDULER_ARC + 2)
57e65e175bSOded Gabbay #define NUM_OF_USER_NIC_UMR_BLOCKS	15
58e65e175bSOded Gabbay #define NUM_OF_EXPOSED_SM_BLOCKS	((NUM_OF_DCORES - 1) * 2)
59e65e175bSOded Gabbay #define NUM_USER_MAPPED_BLOCKS \
60e65e175bSOded Gabbay 	(NUM_ARC_CPUS + NUM_OF_USER_ACP_BLOCKS + NUMBER_OF_DEC + \
61e65e175bSOded Gabbay 	NUM_OF_EXPOSED_SM_BLOCKS + \
62e65e175bSOded Gabbay 	(NIC_NUMBER_OF_ENGINES * NUM_OF_USER_NIC_UMR_BLOCKS))
63e65e175bSOded Gabbay 
64e65e175bSOded Gabbay /* Within the user mapped array, decoder entries start post all the ARC related
65e65e175bSOded Gabbay  * entries
66e65e175bSOded Gabbay  */
67e65e175bSOded Gabbay #define USR_MAPPED_BLK_DEC_START_IDX \
68e65e175bSOded Gabbay 	(NUM_ARC_CPUS + NUM_OF_USER_ACP_BLOCKS + \
69e65e175bSOded Gabbay 	(NIC_NUMBER_OF_ENGINES * NUM_OF_USER_NIC_UMR_BLOCKS))
70e65e175bSOded Gabbay 
71e65e175bSOded Gabbay #define USR_MAPPED_BLK_SM_START_IDX \
72e65e175bSOded Gabbay 	(NUM_ARC_CPUS + NUM_OF_USER_ACP_BLOCKS + NUMBER_OF_DEC + \
73e65e175bSOded Gabbay 	(NIC_NUMBER_OF_ENGINES * NUM_OF_USER_NIC_UMR_BLOCKS))
74e65e175bSOded Gabbay 
75e65e175bSOded Gabbay #define SM_OBJS_BLOCK_SIZE		(mmDCORE0_SYNC_MNGR_OBJS_SM_SEC_0 - \
76e65e175bSOded Gabbay 					 mmDCORE0_SYNC_MNGR_OBJS_SOB_OBJ_0)
77e65e175bSOded Gabbay 
78e65e175bSOded Gabbay #define GAUDI2_MAX_PENDING_CS		64
79e65e175bSOded Gabbay 
80e65e175bSOded Gabbay #if !IS_MAX_PENDING_CS_VALID(GAUDI2_MAX_PENDING_CS)
81e65e175bSOded Gabbay #error "GAUDI2_MAX_PENDING_CS must be power of 2 and greater than 1"
82e65e175bSOded Gabbay #endif
83e65e175bSOded Gabbay 
84e65e175bSOded Gabbay #define CORESIGHT_TIMEOUT_USEC			100000		/* 100 ms */
85e65e175bSOded Gabbay 
86e65e175bSOded Gabbay #define GAUDI2_PREBOOT_REQ_TIMEOUT_USEC		25000000	/* 25s */
87e65e175bSOded Gabbay 
88e65e175bSOded Gabbay #define GAUDI2_BOOT_FIT_REQ_TIMEOUT_USEC	10000000	/* 10s */
89e65e175bSOded Gabbay 
90e65e175bSOded Gabbay #define GAUDI2_NIC_CLK_FREQ			450000000ull	/* 450 MHz */
91e65e175bSOded Gabbay 
92e65e175bSOded Gabbay #define DC_POWER_DEFAULT			60000		/* 60W */
93e65e175bSOded Gabbay 
94e65e175bSOded Gabbay #define GAUDI2_HBM_NUM				6
95e65e175bSOded Gabbay 
96e65e175bSOded Gabbay #define DMA_MAX_TRANSFER_SIZE			U32_MAX
97e65e175bSOded Gabbay 
98e65e175bSOded Gabbay #define GAUDI2_DEFAULT_CARD_NAME		"HL225"
99e65e175bSOded Gabbay 
100e65e175bSOded Gabbay #define QMAN_STREAMS				4
101e65e175bSOded Gabbay 
102e65e175bSOded Gabbay #define NUM_OF_MME_SBTE_PORTS			5
103e65e175bSOded Gabbay #define NUM_OF_MME_WB_PORTS			2
104e65e175bSOded Gabbay 
105e65e175bSOded Gabbay #define GAUDI2_ENGINE_ID_DCORE_OFFSET \
106e65e175bSOded Gabbay 	(GAUDI2_DCORE1_ENGINE_ID_EDMA_0 - GAUDI2_DCORE0_ENGINE_ID_EDMA_0)
107e65e175bSOded Gabbay 
108e65e175bSOded Gabbay /* DRAM Memory Map */
109e65e175bSOded Gabbay 
110e65e175bSOded Gabbay #define CPU_FW_IMAGE_SIZE			0x10000000	/* 256MB */
111e65e175bSOded Gabbay 
112e65e175bSOded Gabbay /* This define should be used only when working in a debug mode without dram.
113e65e175bSOded Gabbay  * When working with dram, the driver size will be calculated dynamically.
114e65e175bSOded Gabbay  */
115e65e175bSOded Gabbay #define NIC_DEFAULT_DRV_SIZE			0x20000000	/* 512MB */
116e65e175bSOded Gabbay 
117e65e175bSOded Gabbay #define CPU_FW_IMAGE_ADDR			DRAM_PHYS_BASE
118e65e175bSOded Gabbay 
119e65e175bSOded Gabbay #define NIC_NUMBER_OF_PORTS			NIC_NUMBER_OF_ENGINES
120e65e175bSOded Gabbay 
121e65e175bSOded Gabbay #define NUMBER_OF_PCIE_DEC			2
122e65e175bSOded Gabbay #define PCIE_DEC_SHIFT				8
123e65e175bSOded Gabbay 
124e65e175bSOded Gabbay #define SRAM_USER_BASE_OFFSET			0
125e65e175bSOded Gabbay 
126e65e175bSOded Gabbay /* cluster binning */
127e65e175bSOded Gabbay #define MAX_FAULTY_HBMS				1
128e65e175bSOded Gabbay #define GAUDI2_XBAR_EDGE_FULL_MASK		0xF
129e65e175bSOded Gabbay #define GAUDI2_EDMA_FULL_MASK			0xFF
130e65e175bSOded Gabbay #define GAUDI2_DRAM_FULL_MASK			0x3F
131e65e175bSOded Gabbay 
132e65e175bSOded Gabbay /* Host virtual address space. */
133e65e175bSOded Gabbay 
134e65e175bSOded Gabbay #define VA_HOST_SPACE_PAGE_START		0xFFF0000000000000ull
135e65e175bSOded Gabbay #define VA_HOST_SPACE_PAGE_END			0xFFF0800000000000ull /* 140TB */
136e65e175bSOded Gabbay 
137e65e175bSOded Gabbay #define VA_HOST_SPACE_HPAGE_START		0xFFF0800000000000ull
138e65e175bSOded Gabbay #define VA_HOST_SPACE_HPAGE_END			0xFFF1000000000000ull /* 140TB */
139e65e175bSOded Gabbay 
140e65e175bSOded Gabbay /* 140TB */
141e65e175bSOded Gabbay #define VA_HOST_SPACE_PAGE_SIZE		(VA_HOST_SPACE_PAGE_END - VA_HOST_SPACE_PAGE_START)
142e65e175bSOded Gabbay 
143e65e175bSOded Gabbay /* 140TB */
144e65e175bSOded Gabbay #define VA_HOST_SPACE_HPAGE_SIZE	(VA_HOST_SPACE_HPAGE_END - VA_HOST_SPACE_HPAGE_START)
145e65e175bSOded Gabbay 
146e65e175bSOded Gabbay #define VA_HOST_SPACE_SIZE		(VA_HOST_SPACE_PAGE_SIZE + VA_HOST_SPACE_HPAGE_SIZE)
147e65e175bSOded Gabbay 
148e65e175bSOded Gabbay #define HOST_SPACE_INTERNAL_CB_SZ		SZ_2M
149e65e175bSOded Gabbay 
150e65e175bSOded Gabbay /*
151e65e175bSOded Gabbay  * HBM virtual address space
152e65e175bSOded Gabbay  * Gaudi2 has 6 HBM devices, each supporting 16GB total of 96GB at most.
153e65e175bSOded Gabbay  * No core separation is supported so we can have one chunk of virtual address
154e65e175bSOded Gabbay  * space just above the physical ones.
155e65e175bSOded Gabbay  * The virtual address space starts immediately after the end of the physical
156e65e175bSOded Gabbay  * address space which is determined at run-time.
157e65e175bSOded Gabbay  */
158e65e175bSOded Gabbay #define VA_HBM_SPACE_END		0x1002000000000000ull
159e65e175bSOded Gabbay 
160e65e175bSOded Gabbay #define HW_CAP_PLL			BIT_ULL(0)
161e65e175bSOded Gabbay #define HW_CAP_DRAM			BIT_ULL(1)
162e65e175bSOded Gabbay #define HW_CAP_PMMU			BIT_ULL(2)
163e65e175bSOded Gabbay #define HW_CAP_CPU			BIT_ULL(3)
164e65e175bSOded Gabbay #define HW_CAP_MSIX			BIT_ULL(4)
165e65e175bSOded Gabbay 
166e65e175bSOded Gabbay #define HW_CAP_CPU_Q			BIT_ULL(5)
167e65e175bSOded Gabbay #define HW_CAP_CPU_Q_SHIFT		5
168e65e175bSOded Gabbay 
169e65e175bSOded Gabbay #define HW_CAP_CLK_GATE			BIT_ULL(6)
170e65e175bSOded Gabbay #define HW_CAP_KDMA			BIT_ULL(7)
171e65e175bSOded Gabbay #define HW_CAP_SRAM_SCRAMBLER		BIT_ULL(8)
172e65e175bSOded Gabbay 
173e65e175bSOded Gabbay #define HW_CAP_DCORE0_DMMU0		BIT_ULL(9)
174e65e175bSOded Gabbay #define HW_CAP_DCORE0_DMMU1		BIT_ULL(10)
175e65e175bSOded Gabbay #define HW_CAP_DCORE0_DMMU2		BIT_ULL(11)
176e65e175bSOded Gabbay #define HW_CAP_DCORE0_DMMU3		BIT_ULL(12)
177e65e175bSOded Gabbay #define HW_CAP_DCORE1_DMMU0		BIT_ULL(13)
178e65e175bSOded Gabbay #define HW_CAP_DCORE1_DMMU1		BIT_ULL(14)
179e65e175bSOded Gabbay #define HW_CAP_DCORE1_DMMU2		BIT_ULL(15)
180e65e175bSOded Gabbay #define HW_CAP_DCORE1_DMMU3		BIT_ULL(16)
181e65e175bSOded Gabbay #define HW_CAP_DCORE2_DMMU0		BIT_ULL(17)
182e65e175bSOded Gabbay #define HW_CAP_DCORE2_DMMU1		BIT_ULL(18)
183e65e175bSOded Gabbay #define HW_CAP_DCORE2_DMMU2		BIT_ULL(19)
184e65e175bSOded Gabbay #define HW_CAP_DCORE2_DMMU3		BIT_ULL(20)
185e65e175bSOded Gabbay #define HW_CAP_DCORE3_DMMU0		BIT_ULL(21)
186e65e175bSOded Gabbay #define HW_CAP_DCORE3_DMMU1		BIT_ULL(22)
187e65e175bSOded Gabbay #define HW_CAP_DCORE3_DMMU2		BIT_ULL(23)
188e65e175bSOded Gabbay #define HW_CAP_DCORE3_DMMU3		BIT_ULL(24)
189e65e175bSOded Gabbay #define HW_CAP_DMMU_MASK		GENMASK_ULL(24, 9)
190e65e175bSOded Gabbay #define HW_CAP_DMMU_SHIFT		9
191e65e175bSOded Gabbay #define HW_CAP_PDMA_MASK		BIT_ULL(26)
192e65e175bSOded Gabbay #define HW_CAP_EDMA_MASK		GENMASK_ULL(34, 27)
193e65e175bSOded Gabbay #define HW_CAP_EDMA_SHIFT		27
194e65e175bSOded Gabbay #define HW_CAP_MME_MASK			GENMASK_ULL(38, 35)
195e65e175bSOded Gabbay #define HW_CAP_MME_SHIFT		35
196e65e175bSOded Gabbay #define HW_CAP_ROT_MASK			GENMASK_ULL(40, 39)
197e65e175bSOded Gabbay #define HW_CAP_ROT_SHIFT		39
198e65e175bSOded Gabbay #define HW_CAP_HBM_SCRAMBLER_HW_RESET	BIT_ULL(41)
199e65e175bSOded Gabbay #define HW_CAP_HBM_SCRAMBLER_SW_RESET	BIT_ULL(42)
200e65e175bSOded Gabbay #define HW_CAP_HBM_SCRAMBLER_MASK	(HW_CAP_HBM_SCRAMBLER_HW_RESET | \
201e65e175bSOded Gabbay 						HW_CAP_HBM_SCRAMBLER_SW_RESET)
202e65e175bSOded Gabbay #define HW_CAP_HBM_SCRAMBLER_SHIFT	41
203e65e175bSOded Gabbay #define HW_CAP_RESERVED			BIT(43)
204e65e175bSOded Gabbay #define HW_CAP_MMU_MASK			(HW_CAP_PMMU | HW_CAP_DMMU_MASK)
205e65e175bSOded Gabbay 
206e65e175bSOded Gabbay /* Range Registers */
207e65e175bSOded Gabbay #define RR_TYPE_SHORT			0
208e65e175bSOded Gabbay #define RR_TYPE_LONG			1
209e65e175bSOded Gabbay #define RR_TYPE_SHORT_PRIV		2
210e65e175bSOded Gabbay #define RR_TYPE_LONG_PRIV		3
211e65e175bSOded Gabbay #define NUM_SHORT_LBW_RR		14
212e65e175bSOded Gabbay #define NUM_LONG_LBW_RR			4
213e65e175bSOded Gabbay #define NUM_SHORT_HBW_RR		6
214e65e175bSOded Gabbay #define NUM_LONG_HBW_RR			4
215e65e175bSOded Gabbay 
216e65e175bSOded Gabbay /* RAZWI initiator coordinates- X- 5 bits, Y- 4 bits */
217e65e175bSOded Gabbay #define RAZWI_INITIATOR_X_SHIFT		0
218e65e175bSOded Gabbay #define RAZWI_INITIATOR_X_MASK		0x1F
219e65e175bSOded Gabbay #define RAZWI_INITIATOR_Y_SHIFT		5
220e65e175bSOded Gabbay #define RAZWI_INITIATOR_Y_MASK		0xF
221e65e175bSOded Gabbay 
222e65e175bSOded Gabbay #define RTR_ID_X_Y(x, y) \
223e65e175bSOded Gabbay 	((((y) & RAZWI_INITIATOR_Y_MASK) << RAZWI_INITIATOR_Y_SHIFT) | \
224e65e175bSOded Gabbay 		(((x) & RAZWI_INITIATOR_X_MASK) << RAZWI_INITIATOR_X_SHIFT))
225e65e175bSOded Gabbay 
226e65e175bSOded Gabbay /* decoders have separate mask */
227e65e175bSOded Gabbay #define HW_CAP_DEC_SHIFT		0
228e65e175bSOded Gabbay #define HW_CAP_DEC_MASK			GENMASK_ULL(9, 0)
229e65e175bSOded Gabbay 
230e65e175bSOded Gabbay /* TPCs have separate mask */
231e65e175bSOded Gabbay #define HW_CAP_TPC_SHIFT		0
232e65e175bSOded Gabbay #define HW_CAP_TPC_MASK			GENMASK_ULL(24, 0)
233e65e175bSOded Gabbay 
234e65e175bSOded Gabbay /* nics have separate mask */
235e65e175bSOded Gabbay #define HW_CAP_NIC_SHIFT		0
236e65e175bSOded Gabbay #define HW_CAP_NIC_MASK			GENMASK_ULL(NIC_NUMBER_OF_ENGINES - 1, 0)
237e65e175bSOded Gabbay 
238e65e175bSOded Gabbay #define GAUDI2_ARC_PCI_MSB_ADDR(addr)	(((addr) & GENMASK_ULL(49, 28)) >> 28)
239e65e175bSOded Gabbay 
240e65e175bSOded Gabbay #define GAUDI2_SOB_INCREMENT_BY_ONE	(FIELD_PREP(DCORE0_SYNC_MNGR_OBJS_SOB_OBJ_VAL_MASK, 1) | \
241e65e175bSOded Gabbay 					FIELD_PREP(DCORE0_SYNC_MNGR_OBJS_SOB_OBJ_INC_MASK, 1))
242e65e175bSOded Gabbay 
243*31420f93SMoti Haimovski #define GAUDI2_NUM_TESTED_QS (GAUDI2_QUEUE_ID_CPU_PQ - GAUDI2_QUEUE_ID_PDMA_0_0)
244*31420f93SMoti Haimovski 
245f7d67c1cSKoby Elbaz #define GAUDI2_NUM_OF_GLBL_ERR_CAUSE		8
246f7d67c1cSKoby Elbaz 
247e65e175bSOded Gabbay enum gaudi2_reserved_sob_id {
248e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_CS_COMPLETION_FIRST,
249e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_CS_COMPLETION_LAST =
250e65e175bSOded Gabbay 			GAUDI2_RESERVED_SOB_CS_COMPLETION_FIRST + GAUDI2_MAX_PENDING_CS - 1,
251e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_KDMA_COMPLETION,
252e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_DEC_NRM_FIRST,
253e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_DEC_NRM_LAST =
254e65e175bSOded Gabbay 			GAUDI2_RESERVED_SOB_DEC_NRM_FIRST + NUMBER_OF_DEC - 1,
255e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_DEC_ABNRM_FIRST,
256e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_DEC_ABNRM_LAST =
257e65e175bSOded Gabbay 			GAUDI2_RESERVED_SOB_DEC_ABNRM_FIRST + NUMBER_OF_DEC - 1,
258e65e175bSOded Gabbay 	GAUDI2_RESERVED_SOB_NUMBER
259e65e175bSOded Gabbay };
260e65e175bSOded Gabbay 
261e65e175bSOded Gabbay enum gaudi2_reserved_mon_id {
262e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_CS_COMPLETION_FIRST,
263e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_CS_COMPLETION_LAST =
264e65e175bSOded Gabbay 			GAUDI2_RESERVED_MON_CS_COMPLETION_FIRST + GAUDI2_MAX_PENDING_CS - 1,
265e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_KDMA_COMPLETION,
266e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_DEC_NRM_FIRST,
267e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_DEC_NRM_LAST =
268e65e175bSOded Gabbay 			GAUDI2_RESERVED_MON_DEC_NRM_FIRST + 3 * NUMBER_OF_DEC - 1,
269e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_DEC_ABNRM_FIRST,
270e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_DEC_ABNRM_LAST =
271e65e175bSOded Gabbay 			GAUDI2_RESERVED_MON_DEC_ABNRM_FIRST + 3 * NUMBER_OF_DEC - 1,
272e65e175bSOded Gabbay 	GAUDI2_RESERVED_MON_NUMBER
273e65e175bSOded Gabbay };
274e65e175bSOded Gabbay 
275e65e175bSOded Gabbay enum gaudi2_reserved_cq_id {
276e65e175bSOded Gabbay 	GAUDI2_RESERVED_CQ_CS_COMPLETION,
277e65e175bSOded Gabbay 	GAUDI2_RESERVED_CQ_KDMA_COMPLETION,
278e65e175bSOded Gabbay 	GAUDI2_RESERVED_CQ_NUMBER
279e65e175bSOded Gabbay };
280e65e175bSOded Gabbay 
281e65e175bSOded Gabbay /*
282e65e175bSOded Gabbay  * Gaudi2 subtitute TPCs Numbering
283e65e175bSOded Gabbay  * At most- two faulty TPCs are allowed
284e65e175bSOded Gabbay  * First replacement to a faulty TPC will be TPC24, second- TPC23
285e65e175bSOded Gabbay  */
286e65e175bSOded Gabbay enum substitude_tpc {
287e65e175bSOded Gabbay 	FAULTY_TPC_SUBTS_1_TPC_24,
288e65e175bSOded Gabbay 	FAULTY_TPC_SUBTS_2_TPC_23,
289e65e175bSOded Gabbay 	MAX_FAULTY_TPCS
290e65e175bSOded Gabbay };
291e65e175bSOded Gabbay 
292e65e175bSOded Gabbay enum gaudi2_dma_core_id {
293e65e175bSOded Gabbay 	DMA_CORE_ID_PDMA0, /* Dcore 0 */
294e65e175bSOded Gabbay 	DMA_CORE_ID_PDMA1, /* Dcore 0 */
295e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA0, /* Dcore 0 */
296e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA1, /* Dcore 0 */
297e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA2, /* Dcore 1 */
298e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA3, /* Dcore 1 */
299e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA4, /* Dcore 2 */
300e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA5, /* Dcore 2 */
301e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA6, /* Dcore 3 */
302e65e175bSOded Gabbay 	DMA_CORE_ID_EDMA7, /* Dcore 3 */
303e65e175bSOded Gabbay 	DMA_CORE_ID_KDMA, /* Dcore 0 */
304e65e175bSOded Gabbay 	DMA_CORE_ID_SIZE
305e65e175bSOded Gabbay };
306e65e175bSOded Gabbay 
307e65e175bSOded Gabbay enum gaudi2_rotator_id {
308e65e175bSOded Gabbay 	ROTATOR_ID_0,
309e65e175bSOded Gabbay 	ROTATOR_ID_1,
310e65e175bSOded Gabbay 	ROTATOR_ID_SIZE,
311e65e175bSOded Gabbay };
312e65e175bSOded Gabbay 
313e65e175bSOded Gabbay enum gaudi2_mme_id {
314e65e175bSOded Gabbay 	MME_ID_DCORE0,
315e65e175bSOded Gabbay 	MME_ID_DCORE1,
316e65e175bSOded Gabbay 	MME_ID_DCORE2,
317e65e175bSOded Gabbay 	MME_ID_DCORE3,
318e65e175bSOded Gabbay 	MME_ID_SIZE,
319e65e175bSOded Gabbay };
320e65e175bSOded Gabbay 
321e65e175bSOded Gabbay enum gaudi2_tpc_id {
322e65e175bSOded Gabbay 	TPC_ID_DCORE0_TPC0,
323e65e175bSOded Gabbay 	TPC_ID_DCORE0_TPC1,
324e65e175bSOded Gabbay 	TPC_ID_DCORE0_TPC2,
325e65e175bSOded Gabbay 	TPC_ID_DCORE0_TPC3,
326e65e175bSOded Gabbay 	TPC_ID_DCORE0_TPC4,
327e65e175bSOded Gabbay 	TPC_ID_DCORE0_TPC5,
328e65e175bSOded Gabbay 	TPC_ID_DCORE1_TPC0,
329e65e175bSOded Gabbay 	TPC_ID_DCORE1_TPC1,
330e65e175bSOded Gabbay 	TPC_ID_DCORE1_TPC2,
331e65e175bSOded Gabbay 	TPC_ID_DCORE1_TPC3,
332e65e175bSOded Gabbay 	TPC_ID_DCORE1_TPC4,
333e65e175bSOded Gabbay 	TPC_ID_DCORE1_TPC5,
334e65e175bSOded Gabbay 	TPC_ID_DCORE2_TPC0,
335e65e175bSOded Gabbay 	TPC_ID_DCORE2_TPC1,
336e65e175bSOded Gabbay 	TPC_ID_DCORE2_TPC2,
337e65e175bSOded Gabbay 	TPC_ID_DCORE2_TPC3,
338e65e175bSOded Gabbay 	TPC_ID_DCORE2_TPC4,
339e65e175bSOded Gabbay 	TPC_ID_DCORE2_TPC5,
340e65e175bSOded Gabbay 	TPC_ID_DCORE3_TPC0,
341e65e175bSOded Gabbay 	TPC_ID_DCORE3_TPC1,
342e65e175bSOded Gabbay 	TPC_ID_DCORE3_TPC2,
343e65e175bSOded Gabbay 	TPC_ID_DCORE3_TPC3,
344e65e175bSOded Gabbay 	TPC_ID_DCORE3_TPC4,
345e65e175bSOded Gabbay 	TPC_ID_DCORE3_TPC5,
346e65e175bSOded Gabbay 	/* the PCI TPC is placed last (mapped liked HW) */
347e65e175bSOded Gabbay 	TPC_ID_DCORE0_TPC6,
348e65e175bSOded Gabbay 	TPC_ID_SIZE,
349e65e175bSOded Gabbay };
350e65e175bSOded Gabbay 
351e65e175bSOded Gabbay enum gaudi2_dec_id {
352e65e175bSOded Gabbay 	DEC_ID_DCORE0_DEC0,
353e65e175bSOded Gabbay 	DEC_ID_DCORE0_DEC1,
354e65e175bSOded Gabbay 	DEC_ID_DCORE1_DEC0,
355e65e175bSOded Gabbay 	DEC_ID_DCORE1_DEC1,
356e65e175bSOded Gabbay 	DEC_ID_DCORE2_DEC0,
357e65e175bSOded Gabbay 	DEC_ID_DCORE2_DEC1,
358e65e175bSOded Gabbay 	DEC_ID_DCORE3_DEC0,
359e65e175bSOded Gabbay 	DEC_ID_DCORE3_DEC1,
360e65e175bSOded Gabbay 	DEC_ID_PCIE_VDEC0,
361e65e175bSOded Gabbay 	DEC_ID_PCIE_VDEC1,
362e65e175bSOded Gabbay 	DEC_ID_SIZE,
363e65e175bSOded Gabbay };
364e65e175bSOded Gabbay 
365e65e175bSOded Gabbay enum gaudi2_hbm_id {
366e65e175bSOded Gabbay 	HBM_ID0,
367e65e175bSOded Gabbay 	HBM_ID1,
368e65e175bSOded Gabbay 	HBM_ID2,
369e65e175bSOded Gabbay 	HBM_ID3,
370e65e175bSOded Gabbay 	HBM_ID4,
371e65e175bSOded Gabbay 	HBM_ID5,
372e65e175bSOded Gabbay 	HBM_ID_SIZE,
373e65e175bSOded Gabbay };
374e65e175bSOded Gabbay 
375e65e175bSOded Gabbay /* specific EDMA enumeration */
376e65e175bSOded Gabbay enum gaudi2_edma_id {
377e65e175bSOded Gabbay 	EDMA_ID_DCORE0_INSTANCE0,
378e65e175bSOded Gabbay 	EDMA_ID_DCORE0_INSTANCE1,
379e65e175bSOded Gabbay 	EDMA_ID_DCORE1_INSTANCE0,
380e65e175bSOded Gabbay 	EDMA_ID_DCORE1_INSTANCE1,
381e65e175bSOded Gabbay 	EDMA_ID_DCORE2_INSTANCE0,
382e65e175bSOded Gabbay 	EDMA_ID_DCORE2_INSTANCE1,
383e65e175bSOded Gabbay 	EDMA_ID_DCORE3_INSTANCE0,
384e65e175bSOded Gabbay 	EDMA_ID_DCORE3_INSTANCE1,
385e65e175bSOded Gabbay 	EDMA_ID_SIZE,
386e65e175bSOded Gabbay };
387e65e175bSOded Gabbay 
388e65e175bSOded Gabbay /* User interrupt count is aligned with HW CQ count.
389e65e175bSOded Gabbay  * We have 64 CQ's per dcore, CQ0 in dcore 0 is reserved for legacy mode
390e65e175bSOded Gabbay  */
391e65e175bSOded Gabbay #define GAUDI2_NUM_USER_INTERRUPTS 255
392e1ef053eSOfir Bitton #define GAUDI2_NUM_RESERVED_INTERRUPTS 1
393e1ef053eSOfir Bitton #define GAUDI2_TOTAL_USER_INTERRUPTS (GAUDI2_NUM_USER_INTERRUPTS + GAUDI2_NUM_RESERVED_INTERRUPTS)
394e65e175bSOded Gabbay 
395e65e175bSOded Gabbay enum gaudi2_irq_num {
396e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_EVENT_QUEUE = GAUDI2_EVENT_QUEUE_MSIX_IDX,
397e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE0_DEC0_NRM,
398e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE0_DEC0_ABNRM,
399e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE0_DEC1_NRM,
400e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE0_DEC1_ABNRM,
401e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE1_DEC0_NRM,
402e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE1_DEC0_ABNRM,
403e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE1_DEC1_NRM,
404e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE1_DEC1_ABNRM,
405e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE2_DEC0_NRM,
406e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE2_DEC0_ABNRM,
407e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE2_DEC1_NRM,
408e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE2_DEC1_ABNRM,
409e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE3_DEC0_NRM,
410e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE3_DEC0_ABNRM,
411e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE3_DEC1_NRM,
412e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_DCORE3_DEC1_ABNRM,
413e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_SHARED_DEC0_NRM,
414e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_SHARED_DEC0_ABNRM,
415e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_SHARED_DEC1_NRM,
416e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,
4174713ace3SOfir Bitton 	GAUDI2_IRQ_NUM_DEC_LAST = GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM,
418e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_COMPLETION,
419e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_NIC_PORT_FIRST,
420e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_NIC_PORT_LAST = (GAUDI2_IRQ_NUM_NIC_PORT_FIRST + NIC_NUMBER_OF_PORTS - 1),
4214713ace3SOfir Bitton 	GAUDI2_IRQ_NUM_TPC_ASSERT,
422e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_RESERVED_FIRST,
423e1ef053eSOfir Bitton 	GAUDI2_IRQ_NUM_RESERVED_LAST = (GAUDI2_MSIX_ENTRIES - GAUDI2_TOTAL_USER_INTERRUPTS - 1),
424e1ef053eSOfir Bitton 	GAUDI2_IRQ_NUM_UNEXPECTED_ERROR = RESERVED_MSIX_UNEXPECTED_USER_ERROR_INTERRUPT,
425e1ef053eSOfir Bitton 	GAUDI2_IRQ_NUM_USER_FIRST = GAUDI2_IRQ_NUM_UNEXPECTED_ERROR + 1,
426e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_USER_LAST = (GAUDI2_IRQ_NUM_USER_FIRST + GAUDI2_NUM_USER_INTERRUPTS - 1),
427e65e175bSOded Gabbay 	GAUDI2_IRQ_NUM_LAST = (GAUDI2_MSIX_ENTRIES - 1)
428e65e175bSOded Gabbay };
429e65e175bSOded Gabbay 
430e65e175bSOded Gabbay static_assert(GAUDI2_IRQ_NUM_USER_FIRST > GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM);
431e65e175bSOded Gabbay 
432e65e175bSOded Gabbay /**
433e65e175bSOded Gabbay  * struct dup_block_ctx - context to initialize unit instances across multiple
434e65e175bSOded Gabbay  *                        blocks where block can be either a dcore of duplicated
435e65e175bSOded Gabbay  *                        common module. this code relies on constant offsets
436e65e175bSOded Gabbay  *                        of blocks and unit instances in a block.
437e65e175bSOded Gabbay  * @instance_cfg_fn: instance specific configuration function.
438e65e175bSOded Gabbay  * @data: private configuration data.
439e65e175bSOded Gabbay  * @base: base address of the first instance in the first block.
440e65e175bSOded Gabbay  * @block_off: subsequent blocks address spacing.
441e65e175bSOded Gabbay  * @instance_off: subsequent block's instances address spacing.
442e65e175bSOded Gabbay  * @enabled_mask: mask of enabled instances (1- enabled, 0- disabled).
443e65e175bSOded Gabbay  * @blocks: number of blocks.
444e65e175bSOded Gabbay  * @instances: unit instances per block.
445e65e175bSOded Gabbay  */
446e65e175bSOded Gabbay struct dup_block_ctx {
447e65e175bSOded Gabbay 	void (*instance_cfg_fn)(struct hl_device *hdev, u64 base, void *data);
448e65e175bSOded Gabbay 	void *data;
449e65e175bSOded Gabbay 	u64 base;
450e65e175bSOded Gabbay 	u64 block_off;
451e65e175bSOded Gabbay 	u64 instance_off;
452e65e175bSOded Gabbay 	u64 enabled_mask;
453e65e175bSOded Gabbay 	unsigned int blocks;
454e65e175bSOded Gabbay 	unsigned int instances;
455e65e175bSOded Gabbay };
456e65e175bSOded Gabbay 
457e65e175bSOded Gabbay /**
458*31420f93SMoti Haimovski  * struct gaudi2_queues_test_info - Holds the address of a the messages used for testing the
459*31420f93SMoti Haimovski  *                                  device queues.
460*31420f93SMoti Haimovski  * @dma_addr: the address used by the HW for accessing the message.
461*31420f93SMoti Haimovski  * @kern_addr: The address used by the driver for accessing the message.
462*31420f93SMoti Haimovski  */
463*31420f93SMoti Haimovski struct gaudi2_queues_test_info {
464*31420f93SMoti Haimovski 	dma_addr_t dma_addr;
465*31420f93SMoti Haimovski 	void *kern_addr;
466*31420f93SMoti Haimovski };
467*31420f93SMoti Haimovski 
468*31420f93SMoti Haimovski /**
469e65e175bSOded Gabbay  * struct gaudi2_device - ASIC specific manage structure.
470e65e175bSOded Gabbay  * @cpucp_info_get: get information on device from CPU-CP
471e65e175bSOded Gabbay  * @mapped_blocks: array that holds the base address and size of all blocks
472e65e175bSOded Gabbay  *                 the user can map.
473e65e175bSOded Gabbay  * @lfsr_rand_seeds: array of MME ACC random seeds to set.
474e65e175bSOded Gabbay  * @hw_queues_lock: protects the H/W queues from concurrent access.
475e65e175bSOded Gabbay  * @scratchpad_kernel_address: general purpose PAGE_SIZE contiguous memory,
476e65e175bSOded Gabbay  *                             this memory region should be write-only.
477e65e175bSOded Gabbay  *                             currently used for HBW QMAN writes which is
478e65e175bSOded Gabbay  *                             redundant.
479e65e175bSOded Gabbay  * @scratchpad_bus_address: scratchpad bus address
480e65e175bSOded Gabbay  * @virt_msix_db_cpu_addr: host memory page for the virtual MSI-X doorbell.
481e65e175bSOded Gabbay  * @virt_msix_db_dma_addr: bus address of the page for the virtual MSI-X doorbell.
482e65e175bSOded Gabbay  * @dram_bar_cur_addr: current address of DRAM PCI bar.
483e65e175bSOded Gabbay  * @hw_cap_initialized: This field contains a bit per H/W engine. When that
484e65e175bSOded Gabbay  *                      engine is initialized, that bit is set by the driver to
485e65e175bSOded Gabbay  *                      signal we can use this engine in later code paths.
486e65e175bSOded Gabbay  *                      Each bit is cleared upon reset of its corresponding H/W
487e65e175bSOded Gabbay  *                      engine.
488e65e175bSOded Gabbay  * @active_hw_arc: This field contains a bit per ARC of an H/W engine with
489e65e175bSOded Gabbay  *                 exception of TPC and NIC engines. Once an engine arc is
490e65e175bSOded Gabbay  *                 initialized, its respective bit is set. Driver can uniquely
491e65e175bSOded Gabbay  *                 identify each initialized ARC and use this information in
492e65e175bSOded Gabbay  *                 later code paths. Each respective bit is cleared upon reset
493e65e175bSOded Gabbay  *                 of its corresponding ARC of the H/W engine.
494e65e175bSOded Gabbay  * @dec_hw_cap_initialized: This field contains a bit per decoder H/W engine.
495e65e175bSOded Gabbay  *                      When that engine is initialized, that bit is set by
496e65e175bSOded Gabbay  *                      the driver to signal we can use this engine in later
497e65e175bSOded Gabbay  *                      code paths.
498e65e175bSOded Gabbay  *                      Each bit is cleared upon reset of its corresponding H/W
499e65e175bSOded Gabbay  *                      engine.
500e65e175bSOded Gabbay  * @tpc_hw_cap_initialized: This field contains a bit per TPC H/W engine.
501e65e175bSOded Gabbay  *                      When that engine is initialized, that bit is set by
502e65e175bSOded Gabbay  *                      the driver to signal we can use this engine in later
503e65e175bSOded Gabbay  *                      code paths.
504e65e175bSOded Gabbay  *                      Each bit is cleared upon reset of its corresponding H/W
505e65e175bSOded Gabbay  *                      engine.
506e65e175bSOded Gabbay  * @active_tpc_arc: This field contains a bit per ARC of the TPC engines.
507e65e175bSOded Gabbay  *                  Once an engine arc is initialized, its respective bit is
508e65e175bSOded Gabbay  *                  set. Each respective bit is cleared upon reset of its
509e65e175bSOded Gabbay  *                  corresponding ARC of the TPC engine.
510e65e175bSOded Gabbay  * @nic_hw_cap_initialized: This field contains a bit per nic H/W engine.
511e65e175bSOded Gabbay  * @active_nic_arc: This field contains a bit per ARC of the NIC engines.
512e65e175bSOded Gabbay  *                  Once an engine arc is initialized, its respective bit is
513e65e175bSOded Gabbay  *                  set. Each respective bit is cleared upon reset of its
514e65e175bSOded Gabbay  *                  corresponding ARC of the NIC engine.
515e65e175bSOded Gabbay  * @hw_events: array that holds all H/W events that are defined valid.
516e65e175bSOded Gabbay  * @events_stat: array that holds histogram of all received events.
517e65e175bSOded Gabbay  * @events_stat_aggregate: same as events_stat but doesn't get cleared on reset.
518e65e175bSOded Gabbay  * @num_of_valid_hw_events: used to hold the number of valid H/W events.
519e65e175bSOded Gabbay  * @nic_ports: array that holds all NIC ports manage structures.
520e65e175bSOded Gabbay  * @nic_macros: array that holds all NIC macro manage structures.
521e65e175bSOded Gabbay  * @core_info: core info to be used by the Ethernet driver.
522e65e175bSOded Gabbay  * @aux_ops: functions for core <-> aux drivers communication.
523e65e175bSOded Gabbay  * @flush_db_fifo: flag to force flush DB FIFO after a write.
524e65e175bSOded Gabbay  * @hbm_cfg: HBM subsystem settings
525e65e175bSOded Gabbay  * @hw_queues_lock_mutex: used by simulator instead of hw_queues_lock.
526*31420f93SMoti Haimovski  * @queues_test_info: information used by the driver when testing the HW queues.
527e65e175bSOded Gabbay  */
528e65e175bSOded Gabbay struct gaudi2_device {
529e65e175bSOded Gabbay 	int (*cpucp_info_get)(struct hl_device *hdev);
530e65e175bSOded Gabbay 
531e65e175bSOded Gabbay 	struct user_mapped_block	mapped_blocks[NUM_USER_MAPPED_BLOCKS];
532e65e175bSOded Gabbay 	int				lfsr_rand_seeds[MME_NUM_OF_LFSR_SEEDS];
533e65e175bSOded Gabbay 
534e65e175bSOded Gabbay 	spinlock_t			hw_queues_lock;
535e65e175bSOded Gabbay 
536e65e175bSOded Gabbay 	void				*scratchpad_kernel_address;
537e65e175bSOded Gabbay 	dma_addr_t			scratchpad_bus_address;
538e65e175bSOded Gabbay 
539e65e175bSOded Gabbay 	void				*virt_msix_db_cpu_addr;
540e65e175bSOded Gabbay 	dma_addr_t			virt_msix_db_dma_addr;
541e65e175bSOded Gabbay 
542e65e175bSOded Gabbay 	u64				dram_bar_cur_addr;
543e65e175bSOded Gabbay 	u64				hw_cap_initialized;
544e65e175bSOded Gabbay 	u64				active_hw_arc;
545e65e175bSOded Gabbay 	u64				dec_hw_cap_initialized;
546e65e175bSOded Gabbay 	u64				tpc_hw_cap_initialized;
547e65e175bSOded Gabbay 	u64				active_tpc_arc;
548e65e175bSOded Gabbay 	u64				nic_hw_cap_initialized;
549e65e175bSOded Gabbay 	u64				active_nic_arc;
550e65e175bSOded Gabbay 	u32				hw_events[GAUDI2_EVENT_SIZE];
551e65e175bSOded Gabbay 	u32				events_stat[GAUDI2_EVENT_SIZE];
552e65e175bSOded Gabbay 	u32				events_stat_aggregate[GAUDI2_EVENT_SIZE];
553e65e175bSOded Gabbay 	u32				num_of_valid_hw_events;
554*31420f93SMoti Haimovski 
555*31420f93SMoti Haimovski 	/* Queue testing */
556*31420f93SMoti Haimovski 	struct gaudi2_queues_test_info	queues_test_info[GAUDI2_NUM_TESTED_QS];
557e65e175bSOded Gabbay };
558e65e175bSOded Gabbay 
559f7d67c1cSKoby Elbaz /*
560f7d67c1cSKoby Elbaz  * Types of the Gaudi2 IP blocks, used by special blocks iterator.
561f7d67c1cSKoby Elbaz  * Required for scenarios where only particular block types can be
562f7d67c1cSKoby Elbaz  * addressed (e.g., special PLDM images).
563f7d67c1cSKoby Elbaz  */
564f7d67c1cSKoby Elbaz enum gaudi2_block_types {
565f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_PLL,
566f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_RTR,
567f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_CPU,
568f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_HIF,
569f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_HBM,
570f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_NIC,
571f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_PCIE,
572f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_PCIE_PMA,
573f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_PDMA,
574f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_EDMA,
575f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_PMMU,
576f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_PSOC,
577f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_ROT,
578f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_ARC_FARM,
579f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_DEC,
580f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_MME,
581f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_EU_BIST,
582f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_SYNC_MNGR,
583f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_STLB,
584f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_TPC,
585f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_HMMU,
586f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_SRAM,
587f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_XBAR,
588f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_KDMA,
589f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_XDMA,
590f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_XFT,
591f7d67c1cSKoby Elbaz 	GAUDI2_BLOCK_TYPE_MAX
592f7d67c1cSKoby Elbaz };
593f7d67c1cSKoby Elbaz 
594e65e175bSOded Gabbay extern const u32 gaudi2_dma_core_blocks_bases[DMA_CORE_ID_SIZE];
595e65e175bSOded Gabbay extern const u32 gaudi2_qm_blocks_bases[GAUDI2_QUEUE_ID_SIZE];
596e65e175bSOded Gabbay extern const u32 gaudi2_mme_acc_blocks_bases[MME_ID_SIZE];
597e65e175bSOded Gabbay extern const u32 gaudi2_mme_ctrl_lo_blocks_bases[MME_ID_SIZE];
598e65e175bSOded Gabbay extern const u32 edma_stream_base[NUM_OF_EDMA_PER_DCORE * NUM_OF_DCORES];
599e65e175bSOded Gabbay extern const u32 gaudi2_rot_blocks_bases[ROTATOR_ID_SIZE];
600e65e175bSOded Gabbay 
601e65e175bSOded Gabbay void gaudi2_iterate_tpcs(struct hl_device *hdev, struct iterate_module_ctx *ctx);
602e65e175bSOded Gabbay int gaudi2_coresight_init(struct hl_device *hdev);
603e65e175bSOded Gabbay int gaudi2_debug_coresight(struct hl_device *hdev, struct hl_ctx *ctx, void *data);
604e65e175bSOded Gabbay void gaudi2_halt_coresight(struct hl_device *hdev, struct hl_ctx *ctx);
605e65e175bSOded Gabbay void gaudi2_init_blocks(struct hl_device *hdev, struct dup_block_ctx *cfg_ctx);
606e65e175bSOded Gabbay bool gaudi2_is_hmmu_enabled(struct hl_device *hdev, int dcore_id, int hmmu_id);
607e65e175bSOded Gabbay void gaudi2_write_rr_to_all_lbw_rtrs(struct hl_device *hdev, u8 rr_type, u32 rr_index, u64 min_val,
608e65e175bSOded Gabbay 					u64 max_val);
609e65e175bSOded Gabbay void gaudi2_pb_print_security_errors(struct hl_device *hdev, u32 block_addr, u32 cause,
610e65e175bSOded Gabbay 					u32 offended_addr);
611e65e175bSOded Gabbay int gaudi2_init_security(struct hl_device *hdev);
612e65e175bSOded Gabbay void gaudi2_ack_protection_bits_errors(struct hl_device *hdev);
613e65e175bSOded Gabbay int gaudi2_send_device_activity(struct hl_device *hdev, bool open);
614e65e175bSOded Gabbay 
615e65e175bSOded Gabbay #endif /* GAUDI2P_H_ */
616