1 /* SPDX-License-Identifier: GPL-2.0-only */
9 #define ME_RETRY 100000 /* 1 second */
10 #define ME_DELAY 10 /* 10 us */
15 * Management Engine PCI registers
18 #define PCI_ME_HFS 0x40
19 #define ME_HFS_CWS_RESET 0
20 #define ME_HFS_CWS_INIT 1
21 #define ME_HFS_CWS_REC 2
22 #define ME_HFS_CWS_TEST 3
23 #define ME_HFS_CWS_DISABLED 4
24 #define ME_HFS_CWS_NORMAL 5
25 #define ME_HFS_CWS_WAIT 6
26 #define ME_HFS_CWS_TRANS 7
27 #define ME_HFS_CWS_INVALID 8
28 #define ME_HFS_STATE_PREBOOT 0
29 #define ME_HFS_STATE_M0_UMA 1
30 #define ME_HFS_STATE_M3 4
31 #define ME_HFS_STATE_M0 5
32 #define ME_HFS_STATE_BRINGUP 6
33 #define ME_HFS_STATE_ERROR 7
34 #define ME_HFS_ERROR_NONE 0
35 #define ME_HFS_ERROR_UNCAT 1
36 #define ME_HFS_ERROR_DISABLED 2
37 #define ME_HFS_ERROR_IMAGE 3
38 #define ME_HFS_ERROR_DEBUG 4
39 #define ME_HFS_MODE_NORMAL 0
40 #define ME_HFS_MODE_DEBUG 2
41 #define ME_HFS_MODE_DIS 3
42 #define ME_HFS_MODE_OVER_JMPR 4
43 #define ME_HFS_MODE_OVER_MEI 5
44 #define ME_HFS_BIOS_DRAM_ACK 1
45 #define ME_HFS_ACK_NO_DID 0
46 #define ME_HFS_ACK_RESET 1
47 #define ME_HFS_ACK_PWR_CYCLE 2
48 #define ME_HFS_ACK_S3 3
49 #define ME_HFS_ACK_S4 4
50 #define ME_HFS_ACK_S5 5
51 #define ME_HFS_ACK_GBL_RESET 6
52 #define ME_HFS_ACK_CONTINUE 7
55 uint32_t working_state
: 4;
58 uint32_t operation_state
: 3;
59 uint32_t fw_init_complete
: 1;
60 uint32_t ft_bup_ld_flr
: 1;
61 uint32_t update_in_progress
: 1;
62 uint32_t error_code
: 4;
63 uint32_t operation_mode
: 4;
65 uint32_t boot_options_present
: 1;
67 uint32_t bios_msg_ack
: 4;
68 } __attribute__((packed
));
70 #define PCI_ME_UMA 0x44
74 uint32_t reserved_1
: 10;
76 uint32_t reserved_0
: 14;
77 uint32_t set_to_one
: 1;
78 } __attribute__((packed
));
80 #define PCI_ME_H_GS 0x4c
81 #define ME_INIT_DONE 1
82 #define ME_INIT_STATUS_SUCCESS 0
83 #define ME_INIT_STATUS_NOMEM 1
84 #define ME_INIT_STATUS_ERROR 2
87 uint32_t uma_base
: 16;
90 uint32_t init_done
: 4;
91 } __attribute__((packed
));
93 #define PCI_ME_GMES 0x48
94 #define ME_GMES_PHASE_ROM 0
95 #define ME_GMES_PHASE_BUP 1
96 #define ME_GMES_PHASE_UKERNEL 2
97 #define ME_GMES_PHASE_POLICY 3
98 #define ME_GMES_PHASE_MODULE 4
99 #define ME_GMES_PHASE_UNKNOWN 5
100 #define ME_GMES_PHASE_HOST 6
103 uint32_t bist_in_prog
: 1;
104 uint32_t icc_prog_sts
: 2;
105 uint32_t invoke_mebx
: 1;
106 uint32_t cpu_replaced_sts
: 1;
107 uint32_t mbp_rdy
: 1;
108 uint32_t mfs_failure
: 1;
109 uint32_t warm_rst_req_for_df
: 1;
110 uint32_t cpu_replaced_valid
: 1;
111 uint32_t reserved_1
: 2;
112 uint32_t fw_upd_ipu
: 1;
113 uint32_t reserved_2
: 4;
114 uint32_t current_state
: 8;
115 uint32_t current_pmevent
: 4;
116 uint32_t progress_code
: 4;
117 } __attribute__((packed
));
119 #define PCI_ME_HERES 0xbc
120 #define PCI_ME_EXT_SHA1 0x00
121 #define PCI_ME_EXT_SHA256 0x02
122 #define PCI_ME_HER(x) (0xc0+(4*(x)))
125 uint32_t extend_reg_algorithm
: 4;
126 uint32_t reserved
: 26;
127 uint32_t extend_feature_present
: 1;
128 uint32_t extend_reg_valid
: 1;
129 } __attribute__((packed
));
131 struct me_thermal_reporting
{
132 uint32_t polling_timeout
: 8;
133 uint32_t smbus_ec_msglen
: 8;
134 uint32_t smbus_ec_msgpec
: 8;
135 uint32_t dimmnumber
: 8;
136 } __attribute__((packed
));
139 * Management Engine MEI registers
142 #define MEI_H_CB_WW 0x00
143 #define MEI_H_CSR 0x04
144 #define MEI_ME_CB_RW 0x08
145 #define MEI_ME_CSR_HA 0x0c
148 uint32_t interrupt_enable
: 1;
149 uint32_t interrupt_status
: 1;
150 uint32_t interrupt_generate
: 1;
153 uint32_t reserved
: 3;
154 uint32_t buffer_read_ptr
: 8;
155 uint32_t buffer_write_ptr
: 8;
156 uint32_t buffer_depth
: 8;
157 } __attribute__((packed
));
159 #define MEI_ADDRESS_HBM 0x00
160 #define MEI_ADDRESS_CORE_WD 0x01
161 #define MEI_ADDRESS_AMT 0x02
162 #define MEI_ADDRESS_RESERVED 0x03
163 #define MEI_ADDRESS_WDT 0x04
164 #define MEI_ADDRESS_POLICY 0x05
165 #define MEI_ADDRESS_PASSWORD 0x06
166 #define MEI_ADDRESS_MKHI 0x07
167 #define MEI_ADDRESS_ICC 0x08
168 #define MEI_ADDRESS_THERMAL 0x09
169 #define MEI_ADDRESS_SPI 0x0a
171 #define MEI_HOST_ADDRESS 0
174 uint32_t client_address
: 8;
175 uint32_t host_address
: 8;
177 uint32_t reserved
: 6;
178 uint32_t is_complete
: 1;
179 } __attribute__((packed
));
181 #define MKHI_GROUP_ID_CBM 0x00
182 #define MKHI_GROUP_ID_PM 0x01
183 #define MKHI_GROUP_ID_PWD 0x02
184 #define MKHI_GROUP_ID_FWCAPS 0x03
185 #define MKHI_GROUP_ID_APP 0x04
186 #define MKHI_GROUP_ID_SPI 0x05
187 #define MKHI_GROUP_ID_MDES 0x08
188 #define MKHI_GROUP_ID_MAX 0x09
189 #define MKHI_GROUP_ID_GEN 0xff
191 #define MKHI_FWCAPS_GET_RULE 0x02
192 #define MKHI_FWCAPS_SET_RULE 0x03
193 #define MKHI_GLOBAL_RESET 0x0b
195 #define GEN_GET_MKHI_VERSION 0x01
196 #define GEN_GET_FW_VERSION 0x02
197 #define GEN_UNCONFIG_NO_PWD 0x0d
198 #define GEN_SET_DEBUG_MEM 0x11
200 #define FWCAPS_ME_FWU_RULE 0x2e
201 #define FWCAPS_OVERRIDE 0x14
203 #define MKHI_THERMAL_REPORTING 0x00
204 #define MKHI_GET_FW_VERSION 0x02
205 #define MKHI_MDES_ENABLE 0x09
206 #define MKHI_END_OF_POST 0x0c
207 #define MKHI_FEATURE_OVERRIDE 0x14
209 #define HBM_HOST_START_REQ_CMD 0x01
210 #define HBM_HOST_STOP_REQ_CMD 0x02
211 #define HBM_ME_STOP_REQ_CMD 0x03
212 #define HBM_HOST_ENUM_REQ_CMD 0x04
213 #define HBM_HOST_CLIENT_PROPERTIES_REQ_CMD 0x05
214 #define HBM_CLIENT_CONNECT_REQ_CMD 0x06
215 #define HBM_CLIENT_DISCONNECT_REQ_CMD 0x07
218 uint32_t group_id
: 8;
220 uint32_t is_response
: 1;
221 uint32_t reserved
: 8;
223 } __attribute__((packed
));
225 struct me_fw_version
{
228 uint16_t code_build_number
;
229 uint16_t code_hot_fix
;
230 uint16_t recovery_minor
;
231 uint16_t recovery_major
;
232 uint16_t recovery_build_number
;
233 uint16_t recovery_hot_fix
;
236 uint16_t fitcbuildno
;
238 } __attribute__((packed
));
241 #define HECI_EOP_STATUS_SUCCESS 0x0
242 #define HECI_EOP_PERFORM_GLOBAL_RESET 0x1
244 #define CBM_RR_GLOBAL_RESET 0x01
246 #define GLOBAL_RESET_BIOS_MRC 0x01
247 #define GLOBAL_RESET_BIOS_POST 0x02
248 #define GLOBAL_RESET_MEBX 0x03
250 struct me_global_reset
{
251 uint8_t request_origin
;
253 } __attribute__((packed
));
259 ME_RECOVERY_BIOS_PATH
,
260 ME_DISABLE_BIOS_PATH
,
261 ME_FIRMWARE_UPDATE_BIOS_PATH
,
265 uint32_t major_version
: 16;
266 uint32_t minor_version
: 16;
267 uint32_t hotfix_version
: 16;
268 uint32_t build_version
: 16;
269 } __attribute__((packed
)) mbp_fw_version_name
;
272 uint8_t num_icc_profiles
;
273 uint8_t icc_profile_soft_strap
;
274 uint8_t icc_profile_index
;
276 uint32_t register_lock_mask
[3];
277 } __attribute__((packed
)) mbp_icc_profile
;
280 uint32_t full_net
: 1;
281 uint32_t std_net
: 1;
282 uint32_t manageability
: 1;
283 uint32_t small_business
: 1;
284 uint32_t l3manageability
: 1;
285 uint32_t intel_at
: 1;
286 uint32_t intel_cls
: 1;
287 uint32_t reserved
: 3;
288 uint32_t intel_mpc
: 1;
289 uint32_t icc_over_clocking
: 1;
291 uint32_t reserved_1
: 4;
297 uint32_t reserved_4
: 1;
299 uint32_t reserved_5
: 8;
300 } __attribute__((packed
)) mefwcaps_sku
;
303 uint16_t lock_state
: 1;
304 uint16_t authenticate_module
: 1;
305 uint16_t s3authentication
: 1;
306 uint16_t flash_wear_out
: 1;
307 uint16_t flash_variable_security
: 1;
308 uint16_t wwan3gpresent
: 1;
309 uint16_t wwan3goob
: 1;
310 uint16_t reserved
: 9;
311 } __attribute__((packed
)) tdt_state_flag
;
315 uint8_t last_theft_trigger
;
316 tdt_state_flag flags
;
317 } __attribute__((packed
)) tdt_state_info
;
320 uint32_t platform_target_usage_type
: 4;
321 uint32_t platform_target_market_type
: 2;
322 uint32_t super_sku
: 1;
323 uint32_t reserved
: 1;
324 uint32_t intel_me_fw_image_type
: 4;
325 uint32_t platform_brand
: 4;
326 uint32_t reserved_1
: 16;
327 } __attribute__((packed
)) platform_type_rule_data
;
330 mefwcaps_sku fw_capabilities
;
336 uint16_t fuse_test_flags
;
338 } __attribute__((packed
)) mbp_rom_bist_data
;
345 platform_type_rule_data rule_data
;
350 mbp_fw_version_name fw_version_name
;
351 mbp_fw_caps fw_caps_sku
;
352 mbp_rom_bist_data rom_bist_data
;
353 mbp_platform_key platform_key
;
354 mbp_plat_type fw_plat_type
;
355 mbp_icc_profile icc_profile
;
356 tdt_state_info at_state
;
357 uint32_t mfsintegrity
;
361 uint32_t mbp_size
: 8;
362 uint32_t num_entries
: 8;
364 } __attribute__((packed
)) mbp_header
;
368 uint32_t item_id
: 8;
371 } __attribute__((packed
)) mbp_item_header
;
376 mefwcaps_sku caps_sku
;
378 } __attribute__((packed
));
380 struct me_debug_mem
{
385 } __attribute__((packed
));
387 void intel_me_status(uint32_t hfs
, uint32_t gmes
);
388 void mkhi_thermal(void);
389 uint32_t intel_mei_setup(struct pci_dev
*dev
);
390 void intel_mei_unmap(void);
391 int mkhi_get_fwcaps(void);
392 int mkhi_get_fw_version(int *major
, int *minor
);
393 int mkhi_debug_me_memory(void *addr
);
394 void mei_reset(void);
395 int intel_me_extend_valid(struct pci_dev
*dev
);