xref: /freebsd/sys/contrib/dev/iwlwifi/pcie/iwl-context-info.h (revision 6b627f88584ce13118e0a24951b503c0b1f2d5a7)
1*6b627f88SBjoern A. Zeeb /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2*6b627f88SBjoern A. Zeeb /*
3*6b627f88SBjoern A. Zeeb  * Copyright (C) 2017 Intel Deutschland GmbH
4*6b627f88SBjoern A. Zeeb  * Copyright (C) 2018-2020, 2022, 2024-2025 Intel Corporation
5*6b627f88SBjoern A. Zeeb  */
6*6b627f88SBjoern A. Zeeb #ifndef __iwl_context_info_file_h__
7*6b627f88SBjoern A. Zeeb #define __iwl_context_info_file_h__
8*6b627f88SBjoern A. Zeeb 
9*6b627f88SBjoern A. Zeeb /* maximum number of DRAM map entries supported by FW */
10*6b627f88SBjoern A. Zeeb #define IWL_MAX_DRAM_ENTRY	64
11*6b627f88SBjoern A. Zeeb #define CSR_CTXT_INFO_BA	0x40
12*6b627f88SBjoern A. Zeeb 
13*6b627f88SBjoern A. Zeeb /**
14*6b627f88SBjoern A. Zeeb  * enum iwl_context_info_flags - Context information control flags
15*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_AUTO_FUNC_INIT: If set, FW will not wait before interrupting
16*6b627f88SBjoern A. Zeeb  *	the init done for driver command that configures several system modes
17*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_EARLY_DEBUG: enable early debug
18*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_ENABLE_CDMP: enable core dump
19*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_CB_SIZE: mask of the RBD Cyclic Buffer Size
20*6b627f88SBjoern A. Zeeb  *	exponent, the actual size is 2**value, valid sizes are 8-2048.
21*6b627f88SBjoern A. Zeeb  *	The value is four bits long. Maximum valid exponent is 12
22*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_TFD_FORMAT_LONG: use long TFD Format (the
23*6b627f88SBjoern A. Zeeb  *	default is short format - not supported by the driver)
24*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE: RB size mask
25*6b627f88SBjoern A. Zeeb  *	(values are IWL_CTXT_INFO_RB_SIZE_*K)
26*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_1K: Value for 1K RB size
27*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_2K: Value for 2K RB size
28*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_4K: Value for 4K RB size
29*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_8K: Value for 8K RB size
30*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_12K: Value for 12K RB size
31*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_16K: Value for 16K RB size
32*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_20K: Value for 20K RB size
33*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_24K: Value for 24K RB size
34*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_28K: Value for 28K RB size
35*6b627f88SBjoern A. Zeeb  * @IWL_CTXT_INFO_RB_SIZE_32K: Value for 32K RB size
36*6b627f88SBjoern A. Zeeb  */
37*6b627f88SBjoern A. Zeeb enum iwl_context_info_flags {
38*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_AUTO_FUNC_INIT	= 0x0001,
39*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_EARLY_DEBUG	= 0x0002,
40*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_ENABLE_CDMP	= 0x0004,
41*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_CB_SIZE	= 0x00f0,
42*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_TFD_FORMAT_LONG	= 0x0100,
43*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE		= 0x1e00,
44*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_1K	= 0x1,
45*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_2K	= 0x2,
46*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_4K	= 0x4,
47*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_8K	= 0x8,
48*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_12K	= 0x9,
49*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_16K	= 0xa,
50*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_20K	= 0xb,
51*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_24K	= 0xc,
52*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_28K	= 0xd,
53*6b627f88SBjoern A. Zeeb 	IWL_CTXT_INFO_RB_SIZE_32K	= 0xe,
54*6b627f88SBjoern A. Zeeb };
55*6b627f88SBjoern A. Zeeb 
56*6b627f88SBjoern A. Zeeb /**
57*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_version - version structure
58*6b627f88SBjoern A. Zeeb  * @mac_id: SKU and revision id
59*6b627f88SBjoern A. Zeeb  * @version: context information version id
60*6b627f88SBjoern A. Zeeb  * @size: the size of the context information in DWs
61*6b627f88SBjoern A. Zeeb  * @reserved: (reserved)
62*6b627f88SBjoern A. Zeeb  */
63*6b627f88SBjoern A. Zeeb struct iwl_context_info_version {
64*6b627f88SBjoern A. Zeeb 	__le16 mac_id;
65*6b627f88SBjoern A. Zeeb 	__le16 version;
66*6b627f88SBjoern A. Zeeb 	__le16 size;
67*6b627f88SBjoern A. Zeeb 	__le16 reserved;
68*6b627f88SBjoern A. Zeeb } __packed;
69*6b627f88SBjoern A. Zeeb 
70*6b627f88SBjoern A. Zeeb /**
71*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_control - version structure
72*6b627f88SBjoern A. Zeeb  * @control_flags: context information flags see &enum iwl_context_info_flags
73*6b627f88SBjoern A. Zeeb  * @reserved: (reserved)
74*6b627f88SBjoern A. Zeeb  */
75*6b627f88SBjoern A. Zeeb struct iwl_context_info_control {
76*6b627f88SBjoern A. Zeeb 	__le32 control_flags;
77*6b627f88SBjoern A. Zeeb 	__le32 reserved;
78*6b627f88SBjoern A. Zeeb } __packed;
79*6b627f88SBjoern A. Zeeb 
80*6b627f88SBjoern A. Zeeb /**
81*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_dram_nonfseq - images DRAM map
82*6b627f88SBjoern A. Zeeb  * each entry in the map represents a DRAM chunk of up to 32 KB
83*6b627f88SBjoern A. Zeeb  * @umac_img: UMAC image DRAM map
84*6b627f88SBjoern A. Zeeb  * @lmac_img: LMAC image DRAM map
85*6b627f88SBjoern A. Zeeb  * @virtual_img: paged image DRAM map
86*6b627f88SBjoern A. Zeeb  */
87*6b627f88SBjoern A. Zeeb struct iwl_context_info_dram_nonfseq {
88*6b627f88SBjoern A. Zeeb 	__le64 umac_img[IWL_MAX_DRAM_ENTRY];
89*6b627f88SBjoern A. Zeeb 	__le64 lmac_img[IWL_MAX_DRAM_ENTRY];
90*6b627f88SBjoern A. Zeeb 	__le64 virtual_img[IWL_MAX_DRAM_ENTRY];
91*6b627f88SBjoern A. Zeeb } __packed;
92*6b627f88SBjoern A. Zeeb 
93*6b627f88SBjoern A. Zeeb /**
94*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_rbd_cfg - RBDs configuration
95*6b627f88SBjoern A. Zeeb  * @free_rbd_addr: default queue free RB CB base address
96*6b627f88SBjoern A. Zeeb  * @used_rbd_addr: default queue used RB CB base address
97*6b627f88SBjoern A. Zeeb  * @status_wr_ptr: default queue used RB status write pointer
98*6b627f88SBjoern A. Zeeb  */
99*6b627f88SBjoern A. Zeeb struct iwl_context_info_rbd_cfg {
100*6b627f88SBjoern A. Zeeb 	__le64 free_rbd_addr;
101*6b627f88SBjoern A. Zeeb 	__le64 used_rbd_addr;
102*6b627f88SBjoern A. Zeeb 	__le64 status_wr_ptr;
103*6b627f88SBjoern A. Zeeb } __packed;
104*6b627f88SBjoern A. Zeeb 
105*6b627f88SBjoern A. Zeeb /**
106*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_hcmd_cfg  - command queue configuration
107*6b627f88SBjoern A. Zeeb  * @cmd_queue_addr: address of command queue
108*6b627f88SBjoern A. Zeeb  * @cmd_queue_size: number of entries
109*6b627f88SBjoern A. Zeeb  * @reserved: (reserved)
110*6b627f88SBjoern A. Zeeb  */
111*6b627f88SBjoern A. Zeeb struct iwl_context_info_hcmd_cfg {
112*6b627f88SBjoern A. Zeeb 	__le64 cmd_queue_addr;
113*6b627f88SBjoern A. Zeeb 	u8 cmd_queue_size;
114*6b627f88SBjoern A. Zeeb 	u8 reserved[7];
115*6b627f88SBjoern A. Zeeb } __packed;
116*6b627f88SBjoern A. Zeeb 
117*6b627f88SBjoern A. Zeeb /**
118*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_dump_cfg - Core Dump configuration
119*6b627f88SBjoern A. Zeeb  * @core_dump_addr: core dump (debug DRAM address) start address
120*6b627f88SBjoern A. Zeeb  * @core_dump_size: size, in DWs
121*6b627f88SBjoern A. Zeeb  * @reserved: (reserved)
122*6b627f88SBjoern A. Zeeb  */
123*6b627f88SBjoern A. Zeeb struct iwl_context_info_dump_cfg {
124*6b627f88SBjoern A. Zeeb 	__le64 core_dump_addr;
125*6b627f88SBjoern A. Zeeb 	__le32 core_dump_size;
126*6b627f88SBjoern A. Zeeb 	__le32 reserved;
127*6b627f88SBjoern A. Zeeb } __packed;
128*6b627f88SBjoern A. Zeeb 
129*6b627f88SBjoern A. Zeeb /**
130*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_pnvm_cfg - platform NVM data configuration
131*6b627f88SBjoern A. Zeeb  * @platform_nvm_addr: Platform NVM data start address
132*6b627f88SBjoern A. Zeeb  * @platform_nvm_size: size in DWs
133*6b627f88SBjoern A. Zeeb  * @reserved: (reserved)
134*6b627f88SBjoern A. Zeeb  */
135*6b627f88SBjoern A. Zeeb struct iwl_context_info_pnvm_cfg {
136*6b627f88SBjoern A. Zeeb 	__le64 platform_nvm_addr;
137*6b627f88SBjoern A. Zeeb 	__le32 platform_nvm_size;
138*6b627f88SBjoern A. Zeeb 	__le32 reserved;
139*6b627f88SBjoern A. Zeeb } __packed;
140*6b627f88SBjoern A. Zeeb 
141*6b627f88SBjoern A. Zeeb /**
142*6b627f88SBjoern A. Zeeb  * struct iwl_context_info_early_dbg_cfg - early debug configuration for
143*6b627f88SBjoern A. Zeeb  *	dumping DRAM addresses
144*6b627f88SBjoern A. Zeeb  * @early_debug_addr: early debug start address
145*6b627f88SBjoern A. Zeeb  * @early_debug_size: size in DWs
146*6b627f88SBjoern A. Zeeb  * @reserved: (reserved)
147*6b627f88SBjoern A. Zeeb  */
148*6b627f88SBjoern A. Zeeb struct iwl_context_info_early_dbg_cfg {
149*6b627f88SBjoern A. Zeeb 	__le64 early_debug_addr;
150*6b627f88SBjoern A. Zeeb 	__le32 early_debug_size;
151*6b627f88SBjoern A. Zeeb 	__le32 reserved;
152*6b627f88SBjoern A. Zeeb } __packed;
153*6b627f88SBjoern A. Zeeb 
154*6b627f88SBjoern A. Zeeb /**
155*6b627f88SBjoern A. Zeeb  * struct iwl_context_info - device INIT configuration
156*6b627f88SBjoern A. Zeeb  * @version: version information of context info and HW
157*6b627f88SBjoern A. Zeeb  * @control: control flags of FH configurations
158*6b627f88SBjoern A. Zeeb  * @reserved0: (reserved)
159*6b627f88SBjoern A. Zeeb  * @rbd_cfg: default RX queue configuration
160*6b627f88SBjoern A. Zeeb  * @hcmd_cfg: command queue configuration
161*6b627f88SBjoern A. Zeeb  * @reserved1: (reserved)
162*6b627f88SBjoern A. Zeeb  * @dump_cfg: core dump data
163*6b627f88SBjoern A. Zeeb  * @edbg_cfg: early debug configuration
164*6b627f88SBjoern A. Zeeb  * @pnvm_cfg: platform nvm configuration
165*6b627f88SBjoern A. Zeeb  * @reserved2: (reserved)
166*6b627f88SBjoern A. Zeeb  * @dram: firmware image addresses in DRAM
167*6b627f88SBjoern A. Zeeb  * @reserved3: (reserved)
168*6b627f88SBjoern A. Zeeb  */
169*6b627f88SBjoern A. Zeeb struct iwl_context_info {
170*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_version version;
171*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_control control;
172*6b627f88SBjoern A. Zeeb 	__le64 reserved0;
173*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_rbd_cfg rbd_cfg;
174*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_hcmd_cfg hcmd_cfg;
175*6b627f88SBjoern A. Zeeb 	__le32 reserved1[4];
176*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_dump_cfg dump_cfg;
177*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_early_dbg_cfg edbg_cfg;
178*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_pnvm_cfg pnvm_cfg;
179*6b627f88SBjoern A. Zeeb 	__le32 reserved2[16];
180*6b627f88SBjoern A. Zeeb 	struct iwl_context_info_dram_nonfseq dram;
181*6b627f88SBjoern A. Zeeb 	__le32 reserved3[16];
182*6b627f88SBjoern A. Zeeb } __packed; /* BOOT_LOADER_CONTEXT_INFO_S */
183*6b627f88SBjoern A. Zeeb 
184*6b627f88SBjoern A. Zeeb int iwl_pcie_ctxt_info_init(struct iwl_trans *trans, const struct fw_img *img);
185*6b627f88SBjoern A. Zeeb void iwl_pcie_ctxt_info_free(struct iwl_trans *trans);
186*6b627f88SBjoern A. Zeeb void iwl_pcie_ctxt_info_free_paging(struct iwl_trans *trans);
187*6b627f88SBjoern A. Zeeb int iwl_pcie_init_fw_sec(struct iwl_trans *trans,
188*6b627f88SBjoern A. Zeeb 			 const struct fw_img *fw,
189*6b627f88SBjoern A. Zeeb 			 struct iwl_context_info_dram_nonfseq *ctxt_dram);
190*6b627f88SBjoern A. Zeeb void *iwl_pcie_ctxt_info_dma_alloc_coherent(struct iwl_trans *trans,
191*6b627f88SBjoern A. Zeeb 					    size_t size,
192*6b627f88SBjoern A. Zeeb 					    dma_addr_t *phys);
193*6b627f88SBjoern A. Zeeb int iwl_pcie_ctxt_info_alloc_dma(struct iwl_trans *trans,
194*6b627f88SBjoern A. Zeeb 				 const void *data, u32 len,
195*6b627f88SBjoern A. Zeeb 				 struct iwl_dram_data *dram);
196*6b627f88SBjoern A. Zeeb 
197*6b627f88SBjoern A. Zeeb #endif /* __iwl_context_info_file_h__ */
198