blob: 73fbf02ec333d46406e2b9fcaa2b7fd6023c7816 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin76c37002012-10-30 09:03:43 -05002
3/*
4 * This is a ramstage driver for the Intel Management Engine found in the
5 * 6-series chipset. It handles the required boot-time messages over the
6 * MMIO-based Management Engine Interface to tell the ME that the BIOS is
7 * finished with POST. Additional messages are defined for debug but are
8 * not used unless the console loglevel is high enough.
9 */
10
Furquan Shaikh76cedd22020-05-02 10:24:23 -070011#include <acpi/acpi.h>
Kyösti Mälkki13f66502019-03-03 08:01:05 +020012#include <device/mmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020013#include <device/pci_ops.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050014#include <console/console.h>
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070015#include <device/device.h>
16#include <device/pci.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050017#include <device/pci_ids.h>
18#include <device/pci_def.h>
19#include <string.h>
20#include <delay.h>
21#include <elog.h>
Patrick Georgi546953c2014-11-29 10:38:17 +010022#include <halt.h>
Elyes HAOUAS400f9ca2019-06-23 07:01:22 +020023#include <stdlib.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050024
Kyösti Mälkki12b121c2019-08-18 16:33:39 +030025#include "chip.h"
Aaron Durbin76c37002012-10-30 09:03:43 -050026#include "me.h"
27#include "pch.h"
28
Julius Wernercd49cce2019-03-05 16:53:33 -080029#if CONFIG(CHROMEOS)
Aaron Durbin76c37002012-10-30 09:03:43 -050030#include <vendorcode/google/chromeos/chromeos.h>
31#include <vendorcode/google/chromeos/gnvs.h>
32#endif
33
Aaron Durbin76c37002012-10-30 09:03:43 -050034/* Path that the BIOS should take based on ME state */
Angel Ponsf01884e2020-06-21 12:48:48 +020035static const char *const me_bios_path_values[] __unused = {
Aaron Durbin76c37002012-10-30 09:03:43 -050036 [ME_NORMAL_BIOS_PATH] = "Normal",
37 [ME_S3WAKE_BIOS_PATH] = "S3 Wake",
38 [ME_ERROR_BIOS_PATH] = "Error",
39 [ME_RECOVERY_BIOS_PATH] = "Recovery",
40 [ME_DISABLE_BIOS_PATH] = "Disable",
41 [ME_FIRMWARE_UPDATE_BIOS_PATH] = "Firmware Update",
42};
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +010043static int intel_me_read_mbp(me_bios_payload *mbp_data, struct device *dev);
Aaron Durbin76c37002012-10-30 09:03:43 -050044
45/* MMIO base address for MEI interface */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080046static u32 *mei_base_address;
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +010047#ifdef __SIMPLE_DEVICE__
48void intel_me_mbp_clear(pci_devfn_t dev);
49#else
50void intel_me_mbp_clear(struct device *dev);
51#endif
Aaron Durbin76c37002012-10-30 09:03:43 -050052
Aaron Durbin76c37002012-10-30 09:03:43 -050053static void mei_dump(void *ptr, int dword, int offset, const char *type)
54{
55 struct mei_csr *csr;
56
Kyösti Mälkkic86fc8e2019-11-06 06:32:27 +020057 if (!CONFIG(DEBUG_INTEL_ME))
58 return;
59
Aaron Durbin76c37002012-10-30 09:03:43 -050060 printk(BIOS_SPEW, "%-9s[%02x] : ", type, offset);
61
62 switch (offset) {
63 case MEI_H_CSR:
64 case MEI_ME_CSR_HA:
65 csr = ptr;
66 if (!csr) {
67 printk(BIOS_SPEW, "ERROR: 0x%08x\n", dword);
68 break;
69 }
70 printk(BIOS_SPEW, "cbd=%u cbrp=%02u cbwp=%02u ready=%u "
71 "reset=%u ig=%u is=%u ie=%u\n", csr->buffer_depth,
72 csr->buffer_read_ptr, csr->buffer_write_ptr,
73 csr->ready, csr->reset, csr->interrupt_generate,
74 csr->interrupt_status, csr->interrupt_enable);
75 break;
76 case MEI_ME_CB_RW:
77 case MEI_H_CB_WW:
78 printk(BIOS_SPEW, "CB: 0x%08x\n", dword);
79 break;
80 default:
81 printk(BIOS_SPEW, "0x%08x\n", offset);
82 break;
83 }
84}
Aaron Durbin76c37002012-10-30 09:03:43 -050085
86/*
87 * ME/MEI access helpers using memcpy to avoid aliasing.
88 */
89
90static inline void mei_read_dword_ptr(void *ptr, int offset)
91{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080092 u32 dword = read32(mei_base_address + (offset/sizeof(u32)));
Aaron Durbin76c37002012-10-30 09:03:43 -050093 memcpy(ptr, &dword, sizeof(dword));
94 mei_dump(ptr, dword, offset, "READ");
95}
96
97static inline void mei_write_dword_ptr(void *ptr, int offset)
98{
99 u32 dword = 0;
100 memcpy(&dword, ptr, sizeof(dword));
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800101 write32(mei_base_address + (offset/sizeof(u32)), dword);
Aaron Durbin76c37002012-10-30 09:03:43 -0500102 mei_dump(ptr, dword, offset, "WRITE");
103}
104
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100105#ifdef __SIMPLE_DEVICE__
106static inline void pci_read_dword_ptr(pci_devfn_t dev, void *ptr, int offset)
107#else
108static inline void pci_read_dword_ptr(struct device *dev, void *ptr, int offset)
109#endif
Aaron Durbin76c37002012-10-30 09:03:43 -0500110{
111 u32 dword = pci_read_config32(dev, offset);
112 memcpy(ptr, &dword, sizeof(dword));
113 mei_dump(ptr, dword, offset, "PCI READ");
114}
Aaron Durbin76c37002012-10-30 09:03:43 -0500115
116static inline void read_host_csr(struct mei_csr *csr)
117{
118 mei_read_dword_ptr(csr, MEI_H_CSR);
119}
120
121static inline void write_host_csr(struct mei_csr *csr)
122{
123 mei_write_dword_ptr(csr, MEI_H_CSR);
124}
125
126static inline void read_me_csr(struct mei_csr *csr)
127{
128 mei_read_dword_ptr(csr, MEI_ME_CSR_HA);
129}
130
131static inline void write_cb(u32 dword)
132{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800133 write32(mei_base_address + (MEI_H_CB_WW/sizeof(u32)), dword);
Aaron Durbin76c37002012-10-30 09:03:43 -0500134 mei_dump(NULL, dword, MEI_H_CB_WW, "WRITE");
135}
136
137static inline u32 read_cb(void)
138{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800139 u32 dword = read32(mei_base_address + (MEI_ME_CB_RW/sizeof(u32)));
Aaron Durbin76c37002012-10-30 09:03:43 -0500140 mei_dump(NULL, dword, MEI_ME_CB_RW, "READ");
141 return dword;
142}
143
144/* Wait for ME ready bit to be asserted */
145static int mei_wait_for_me_ready(void)
146{
147 struct mei_csr me;
Martin Rothff744bf2019-10-23 21:46:03 -0600148 unsigned int try = ME_RETRY;
Aaron Durbin76c37002012-10-30 09:03:43 -0500149
150 while (try--) {
151 read_me_csr(&me);
152 if (me.ready)
153 return 0;
154 udelay(ME_DELAY);
155 }
156
157 printk(BIOS_ERR, "ME: failed to become ready\n");
158 return -1;
159}
160
161static void mei_reset(void)
162{
163 struct mei_csr host;
164
165 if (mei_wait_for_me_ready() < 0)
166 return;
167
168 /* Reset host and ME circular buffers for next message */
169 read_host_csr(&host);
170 host.reset = 1;
171 host.interrupt_generate = 1;
172 write_host_csr(&host);
173
174 if (mei_wait_for_me_ready() < 0)
175 return;
176
177 /* Re-init and indicate host is ready */
178 read_host_csr(&host);
179 host.interrupt_generate = 1;
180 host.ready = 1;
181 host.reset = 0;
182 write_host_csr(&host);
183}
184
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700185static int mei_send_packet(struct mei_header *mei, void *req_data)
Aaron Durbin76c37002012-10-30 09:03:43 -0500186{
187 struct mei_csr host;
Martin Rothff744bf2019-10-23 21:46:03 -0600188 unsigned int ndata, n;
Aaron Durbin76c37002012-10-30 09:03:43 -0500189 u32 *data;
190
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700191 /* Number of dwords to write */
Aaron Durbin76c37002012-10-30 09:03:43 -0500192 ndata = mei->length >> 2;
193
194 /* Pad non-dword aligned request message length */
195 if (mei->length & 3)
196 ndata++;
197 if (!ndata) {
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700198 printk(BIOS_DEBUG, "ME: request has no data\n");
Aaron Durbin76c37002012-10-30 09:03:43 -0500199 return -1;
200 }
201 ndata++; /* Add MEI header */
202
203 /*
204 * Make sure there is still room left in the circular buffer.
205 * Reset the buffer pointers if the requested message will not fit.
206 */
207 read_host_csr(&host);
208 if ((host.buffer_depth - host.buffer_write_ptr) < ndata) {
209 printk(BIOS_ERR, "ME: circular buffer full, resetting...\n");
210 mei_reset();
211 read_host_csr(&host);
212 }
213
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700214 /* Ensure the requested length will fit in the circular buffer. */
Aaron Durbin76c37002012-10-30 09:03:43 -0500215 if ((host.buffer_depth - host.buffer_write_ptr) < ndata) {
216 printk(BIOS_ERR, "ME: message (%u) too large for buffer (%u)\n",
217 ndata + 2, host.buffer_depth);
218 return -1;
219 }
220
221 /* Write MEI header */
222 mei_write_dword_ptr(mei, MEI_H_CB_WW);
223 ndata--;
224
Aaron Durbin76c37002012-10-30 09:03:43 -0500225 /* Write message data */
226 data = req_data;
227 for (n = 0; n < ndata; ++n)
228 write_cb(*data++);
229
230 /* Generate interrupt to the ME */
231 read_host_csr(&host);
232 host.interrupt_generate = 1;
233 write_host_csr(&host);
234
235 /* Make sure ME is ready after sending request data */
236 return mei_wait_for_me_ready();
237}
238
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700239static int mei_send_data(u8 me_address, u8 host_address,
240 void *req_data, int req_bytes)
241{
242 struct mei_header header = {
243 .client_address = me_address,
244 .host_address = host_address,
245 };
246 struct mei_csr host;
247 int current = 0;
248 u8 *req_ptr = req_data;
249
250 while (!header.is_complete) {
251 int remain = req_bytes - current;
252 int buf_len;
253
254 read_host_csr(&host);
255 buf_len = host.buffer_depth - host.buffer_write_ptr;
256
257 if (buf_len > remain) {
258 /* Send all remaining data as final message */
259 header.length = req_bytes - current;
260 header.is_complete = 1;
261 } else {
262 /* Send as much data as the buffer can hold */
263 header.length = buf_len;
264 }
265
266 mei_send_packet(&header, req_ptr);
267
268 req_ptr += header.length;
269 current += header.length;
270 }
271
272 return 0;
273}
274
275static int mei_send_header(u8 me_address, u8 host_address,
276 void *header, int header_len, int complete)
277{
278 struct mei_header mei = {
279 .client_address = me_address,
280 .host_address = host_address,
281 .length = header_len,
282 .is_complete = complete,
283 };
284 return mei_send_packet(&mei, header);
285}
286
287static int mei_recv_msg(void *header, int header_bytes,
Aaron Durbin76c37002012-10-30 09:03:43 -0500288 void *rsp_data, int rsp_bytes)
289{
290 struct mei_header mei_rsp;
Aaron Durbin76c37002012-10-30 09:03:43 -0500291 struct mei_csr me, host;
Martin Rothff744bf2019-10-23 21:46:03 -0600292 unsigned int ndata, n;
293 unsigned int expected;
Aaron Durbin76c37002012-10-30 09:03:43 -0500294 u32 *data;
295
296 /* Total number of dwords to read from circular buffer */
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700297 expected = (rsp_bytes + sizeof(mei_rsp) + header_bytes) >> 2;
Aaron Durbin76c37002012-10-30 09:03:43 -0500298 if (rsp_bytes & 3)
299 expected++;
300
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700301 if (mei_wait_for_me_ready() < 0)
302 return -1;
303
Aaron Durbin76c37002012-10-30 09:03:43 -0500304 /*
305 * The interrupt status bit does not appear to indicate that the
306 * message has actually been received. Instead we wait until the
307 * expected number of dwords are present in the circular buffer.
308 */
309 for (n = ME_RETRY; n; --n) {
310 read_me_csr(&me);
311 if ((me.buffer_write_ptr - me.buffer_read_ptr) >= expected)
312 break;
313 udelay(ME_DELAY);
314 }
315 if (!n) {
316 printk(BIOS_ERR, "ME: timeout waiting for data: expected "
317 "%u, available %u\n", expected,
318 me.buffer_write_ptr - me.buffer_read_ptr);
319 return -1;
320 }
321
322 /* Read and verify MEI response header from the ME */
323 mei_read_dword_ptr(&mei_rsp, MEI_ME_CB_RW);
324 if (!mei_rsp.is_complete) {
325 printk(BIOS_ERR, "ME: response is not complete\n");
326 return -1;
327 }
328
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700329 /* Handle non-dword responses and expect at least the header */
Aaron Durbin76c37002012-10-30 09:03:43 -0500330 ndata = mei_rsp.length >> 2;
331 if (mei_rsp.length & 3)
332 ndata++;
333 if (ndata != (expected - 1)) {
334 printk(BIOS_ERR, "ME: response is missing data %d != %d\n",
335 ndata, (expected - 1));
336 return -1;
337 }
338
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700339 /* Read response header from the ME */
340 data = header;
341 for (n = 0; n < (header_bytes >> 2); ++n)
342 *data++ = read_cb();
343 ndata -= header_bytes >> 2;
Aaron Durbin76c37002012-10-30 09:03:43 -0500344
345 /* Make sure caller passed a buffer with enough space */
346 if (ndata != (rsp_bytes >> 2)) {
347 printk(BIOS_ERR, "ME: not enough room in response buffer: "
348 "%u != %u\n", ndata, rsp_bytes >> 2);
349 return -1;
350 }
351
352 /* Read response data from the circular buffer */
353 data = rsp_data;
354 for (n = 0; n < ndata; ++n)
355 *data++ = read_cb();
356
357 /* Tell the ME that we have consumed the response */
358 read_host_csr(&host);
359 host.interrupt_status = 1;
360 host.interrupt_generate = 1;
361 write_host_csr(&host);
362
363 return mei_wait_for_me_ready();
364}
365
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700366static inline int mei_sendrecv_mkhi(struct mkhi_header *mkhi,
367 void *req_data, int req_bytes,
368 void *rsp_data, int rsp_bytes)
Aaron Durbin76c37002012-10-30 09:03:43 -0500369{
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700370 struct mkhi_header mkhi_rsp;
371
372 /* Send header */
373 if (mei_send_header(MEI_ADDRESS_MKHI, MEI_HOST_ADDRESS,
374 mkhi, sizeof(*mkhi), req_bytes ? 0 : 1) < 0)
Aaron Durbin76c37002012-10-30 09:03:43 -0500375 return -1;
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700376
377 /* Send data if available */
378 if (req_bytes && mei_send_data(MEI_ADDRESS_MKHI, MEI_HOST_ADDRESS,
379 req_data, req_bytes) < 0)
Aaron Durbin76c37002012-10-30 09:03:43 -0500380 return -1;
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700381
382 /* Return now if no response expected */
383 if (!rsp_bytes)
384 return 0;
385
386 /* Read header and data */
387 if (mei_recv_msg(&mkhi_rsp, sizeof(mkhi_rsp),
388 rsp_data, rsp_bytes) < 0)
389 return -1;
390
391 if (!mkhi_rsp.is_response ||
392 mkhi->group_id != mkhi_rsp.group_id ||
393 mkhi->command != mkhi_rsp.command) {
394 printk(BIOS_ERR, "ME: invalid response, group %u ?= %u,"
395 "command %u ?= %u, is_response %u\n", mkhi->group_id,
396 mkhi_rsp.group_id, mkhi->command, mkhi_rsp.command,
397 mkhi_rsp.is_response);
398 return -1;
399 }
400
Aaron Durbin76c37002012-10-30 09:03:43 -0500401 return 0;
402}
Duncan Laurie0dc0d132013-08-08 15:31:51 -0700403
Duncan Laurie3d299c42013-07-19 08:48:05 -0700404/*
405 * mbp give up routine. This path is taken if hfs.mpb_rdy is 0 or the read
406 * state machine on the BIOS end doesn't match the ME's state machine.
407 */
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100408#ifdef __SIMPLE_DEVICE__
409static void intel_me_mbp_give_up(pci_devfn_t dev)
410#else
411static void intel_me_mbp_give_up(struct device *dev)
412#endif
Duncan Laurie3d299c42013-07-19 08:48:05 -0700413{
414 struct mei_csr csr;
415
416 pci_write_config32(dev, PCI_ME_H_GS2, PCI_ME_MBP_GIVE_UP);
417
418 read_host_csr(&csr);
419 csr.reset = 1;
420 csr.interrupt_generate = 1;
421 write_host_csr(&csr);
422}
423
424/*
425 * mbp clear routine. This will wait for the ME to indicate that
426 * the MBP has been read and cleared.
427 */
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100428#ifdef __SIMPLE_DEVICE__
429void intel_me_mbp_clear(pci_devfn_t dev)
430#else
431void intel_me_mbp_clear(struct device *dev)
432#endif
Duncan Laurie3d299c42013-07-19 08:48:05 -0700433{
434 int count;
435 struct me_hfs2 hfs2;
436
437 /* Wait for the mbp_cleared indicator */
438 for (count = ME_RETRY; count > 0; --count) {
439 pci_read_dword_ptr(dev, &hfs2, PCI_ME_HFS2);
440 if (hfs2.mbp_cleared)
441 break;
442 udelay(ME_DELAY);
443 }
444
445 if (count == 0) {
446 printk(BIOS_WARNING, "ME: Timeout waiting for mbp_cleared\n");
447 intel_me_mbp_give_up(dev);
448 } else {
449 printk(BIOS_INFO, "ME: MBP cleared\n");
450 }
451}
452
Kyösti Mälkkic86fc8e2019-11-06 06:32:27 +0200453static void __unused me_print_fw_version(mbp_fw_version_name *vers_name)
Aaron Durbin76c37002012-10-30 09:03:43 -0500454{
Aaron Durbinbe985242012-12-12 12:40:33 -0600455 if (!vers_name) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500456 printk(BIOS_ERR, "ME: mbp missing version report\n");
457 return;
458 }
459
460 printk(BIOS_DEBUG, "ME: found version %d.%d.%d.%d\n",
461 vers_name->major_version, vers_name->minor_version,
462 vers_name->hotfix_version, vers_name->build_version);
463}
464
Edward O'Callaghan7bf4f482014-06-17 15:12:09 +1000465static inline void print_cap(const char *name, int state)
466{
467 printk(BIOS_DEBUG, "ME Capability: %-41s : %sabled\n",
468 name, state ? " en" : "dis");
469}
470
Aaron Durbin76c37002012-10-30 09:03:43 -0500471/* Get ME Firmware Capabilities */
Aaron Durbinbe985242012-12-12 12:40:33 -0600472static int mkhi_get_fwcaps(mbp_mefwcaps *cap)
Aaron Durbin76c37002012-10-30 09:03:43 -0500473{
474 u32 rule_id = 0;
475 struct me_fwcaps cap_msg;
476 struct mkhi_header mkhi = {
477 .group_id = MKHI_GROUP_ID_FWCAPS,
478 .command = MKHI_FWCAPS_GET_RULE,
479 };
Aaron Durbin76c37002012-10-30 09:03:43 -0500480
481 /* Send request and wait for response */
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700482 if (mei_sendrecv_mkhi(&mkhi, &rule_id, sizeof(u32),
483 &cap_msg, sizeof(cap_msg)) < 0) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500484 printk(BIOS_ERR, "ME: GET FWCAPS message failed\n");
485 return -1;
Elyes HAOUASba28e8d2016-08-31 19:22:16 +0200486 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500487 *cap = cap_msg.caps_sku;
488 return 0;
489}
490
491/* Get ME Firmware Capabilities */
Kyösti Mälkkic86fc8e2019-11-06 06:32:27 +0200492static void __unused me_print_fwcaps(mbp_mefwcaps *cap)
Aaron Durbin76c37002012-10-30 09:03:43 -0500493{
Aaron Durbinbe985242012-12-12 12:40:33 -0600494 mbp_mefwcaps local_caps;
495 if (!cap) {
496 cap = &local_caps;
Aaron Durbin76c37002012-10-30 09:03:43 -0500497 printk(BIOS_ERR, "ME: mbp missing fwcaps report\n");
498 if (mkhi_get_fwcaps(cap))
499 return;
500 }
501
502 print_cap("Full Network manageability", cap->full_net);
503 print_cap("Regular Network manageability", cap->std_net);
504 print_cap("Manageability", cap->manageability);
Aaron Durbin76c37002012-10-30 09:03:43 -0500505 print_cap("IntelR Anti-Theft (AT)", cap->intel_at);
506 print_cap("IntelR Capability Licensing Service (CLS)", cap->intel_cls);
507 print_cap("IntelR Power Sharing Technology (MPC)", cap->intel_mpc);
508 print_cap("ICC Over Clocking", cap->icc_over_clocking);
Edward O'Callaghan7bf4f482014-06-17 15:12:09 +1000509 print_cap("Protected Audio Video Path (PAVP)", cap->pavp);
Aaron Durbin76c37002012-10-30 09:03:43 -0500510 print_cap("IPV6", cap->ipv6);
511 print_cap("KVM Remote Control (KVM)", cap->kvm);
512 print_cap("Outbreak Containment Heuristic (OCH)", cap->och);
513 print_cap("Virtual LAN (VLAN)", cap->vlan);
514 print_cap("TLS", cap->tls);
515 print_cap("Wireless LAN (WLAN)", cap->wlan);
516}
Aaron Durbin76c37002012-10-30 09:03:43 -0500517
Aaron Durbin76c37002012-10-30 09:03:43 -0500518/* Send END OF POST message to the ME */
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200519static int __unused mkhi_end_of_post(void)
Aaron Durbin76c37002012-10-30 09:03:43 -0500520{
521 struct mkhi_header mkhi = {
522 .group_id = MKHI_GROUP_ID_GEN,
523 .command = MKHI_END_OF_POST,
524 };
Aaron Durbin76c37002012-10-30 09:03:43 -0500525 u32 eop_ack;
526
527 /* Send request and wait for response */
Angel Pons08e8cab2020-06-18 15:20:37 +0200528 printk(BIOS_NOTICE, "ME: %s\n", __func__);
Duncan Laurie2017b4a2013-08-08 15:07:12 -0700529 if (mei_sendrecv_mkhi(&mkhi, NULL, 0, &eop_ack, sizeof(eop_ack)) < 0) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500530 printk(BIOS_ERR, "ME: END OF POST message failed\n");
531 return -1;
532 }
533
534 printk(BIOS_INFO, "ME: END OF POST message successful (%d)\n", eop_ack);
535 return 0;
536}
537
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200538#ifdef __SIMPLE_DEVICE__
539
Duncan Laurieaf980622013-07-18 23:02:18 -0700540void intel_me_finalize_smm(void)
541{
542 struct me_hfs hfs;
543 u32 reg32;
544
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800545 mei_base_address = (u32 *)
546 (pci_read_config32(PCH_ME_DEV, PCI_BASE_ADDRESS_0) & ~0xf);
Duncan Laurieaf980622013-07-18 23:02:18 -0700547
548 /* S3 path will have hidden this device already */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800549 if (!mei_base_address || mei_base_address == (u32 *)0xfffffff0)
Duncan Laurieaf980622013-07-18 23:02:18 -0700550 return;
551
Julius Wernercd49cce2019-03-05 16:53:33 -0800552#if CONFIG(ME_MBP_CLEAR_LATE)
Duncan Laurie3d299c42013-07-19 08:48:05 -0700553 /* Wait for ME MBP Cleared indicator */
554 intel_me_mbp_clear(PCH_ME_DEV);
555#endif
556
Duncan Laurieaf980622013-07-18 23:02:18 -0700557 /* Make sure ME is in a mode that expects EOP */
558 reg32 = pci_read_config32(PCH_ME_DEV, PCI_ME_HFS);
559 memcpy(&hfs, &reg32, sizeof(u32));
560
561 /* Abort and leave device alone if not normal mode */
562 if (hfs.fpt_bad ||
563 hfs.working_state != ME_HFS_CWS_NORMAL ||
564 hfs.operation_mode != ME_HFS_MODE_NORMAL)
565 return;
566
567 /* Try to send EOP command so ME stops accepting other commands */
568 mkhi_end_of_post();
569
570 /* Make sure IO is disabled */
Angel Ponsbf9bc502020-06-08 00:12:43 +0200571 pci_and_config16(PCH_ME_DEV, PCI_COMMAND,
572 ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
Duncan Laurieaf980622013-07-18 23:02:18 -0700573
574 /* Hide the PCI device */
575 RCBA32_OR(FD2, PCH_DISABLE_MEI1);
576}
577
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200578#else /* !__SIMPLE_DEVICE__ */
Duncan Laurieaf980622013-07-18 23:02:18 -0700579
Edward O'Callaghan97ccefd2015-01-07 15:53:00 +1100580static inline int mei_sendrecv_icc(struct icc_header *icc,
581 void *req_data, int req_bytes,
582 void *rsp_data, int rsp_bytes)
583{
584 struct icc_header icc_rsp;
585
586 /* Send header */
587 if (mei_send_header(MEI_ADDRESS_ICC, MEI_HOST_ADDRESS,
588 icc, sizeof(*icc), req_bytes ? 0 : 1) < 0)
589 return -1;
590
591 /* Send data if available */
592 if (req_bytes && mei_send_data(MEI_ADDRESS_ICC, MEI_HOST_ADDRESS,
593 req_data, req_bytes) < 0)
594 return -1;
595
596 /* Read header and data, if needed */
597 if (rsp_bytes && mei_recv_msg(&icc_rsp, sizeof(icc_rsp),
598 rsp_data, rsp_bytes) < 0)
599 return -1;
600
601 return 0;
602}
603
Duncan Laurie0dc0d132013-08-08 15:31:51 -0700604static int me_icc_set_clock_enables(u32 mask)
605{
606 struct icc_clock_enables_msg clk = {
607 .clock_enables = 0, /* Turn off specified clocks */
608 .clock_mask = mask,
609 .no_response = 1, /* Do not expect response */
610 };
611 struct icc_header icc = {
612 .api_version = ICC_API_VERSION_LYNXPOINT,
613 .icc_command = ICC_SET_CLOCK_ENABLES,
614 .length = sizeof(clk),
615 };
616
617 /* Send request and wait for response */
618 if (mei_sendrecv_icc(&icc, &clk, sizeof(clk), NULL, 0) < 0) {
619 printk(BIOS_ERR, "ME: ICC SET CLOCK ENABLES message failed\n");
620 return -1;
Duncan Laurie0dc0d132013-08-08 15:31:51 -0700621 }
622
Elyes HAOUAS54f94242018-10-25 10:57:39 +0200623 printk(BIOS_INFO, "ME: ICC SET CLOCK ENABLES 0x%08x\n", mask);
Duncan Laurie0dc0d132013-08-08 15:31:51 -0700624 return 0;
625}
626
Aaron Durbin76c37002012-10-30 09:03:43 -0500627/* Determine the path that we should take based on ME status */
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100628static me_bios_path intel_me_path(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500629{
630 me_bios_path path = ME_DISABLE_BIOS_PATH;
631 struct me_hfs hfs;
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500632 struct me_hfs2 hfs2;
Aaron Durbin76c37002012-10-30 09:03:43 -0500633
Aaron Durbin76c37002012-10-30 09:03:43 -0500634 pci_read_dword_ptr(dev, &hfs, PCI_ME_HFS);
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500635 pci_read_dword_ptr(dev, &hfs2, PCI_ME_HFS2);
Aaron Durbin76c37002012-10-30 09:03:43 -0500636
637 /* Check and dump status */
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500638 intel_me_status(&hfs, &hfs2);
Aaron Durbin76c37002012-10-30 09:03:43 -0500639
640 /* Check Current Working State */
641 switch (hfs.working_state) {
642 case ME_HFS_CWS_NORMAL:
643 path = ME_NORMAL_BIOS_PATH;
644 break;
645 case ME_HFS_CWS_REC:
646 path = ME_RECOVERY_BIOS_PATH;
647 break;
648 default:
649 path = ME_DISABLE_BIOS_PATH;
650 break;
651 }
652
653 /* Check Current Operation Mode */
654 switch (hfs.operation_mode) {
655 case ME_HFS_MODE_NORMAL:
656 break;
657 case ME_HFS_MODE_DEBUG:
658 case ME_HFS_MODE_DIS:
659 case ME_HFS_MODE_OVER_JMPR:
660 case ME_HFS_MODE_OVER_MEI:
661 default:
662 path = ME_DISABLE_BIOS_PATH;
663 break;
664 }
665
666 /* Check for any error code and valid firmware and MBP */
667 if (hfs.error_code || hfs.fpt_bad)
668 path = ME_ERROR_BIOS_PATH;
669
670 /* Check if the MBP is ready */
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500671 if (!hfs2.mbp_rdy) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500672 printk(BIOS_CRIT, "%s: mbp is not ready!\n",
Angel Pons08e8cab2020-06-18 15:20:37 +0200673 __func__);
Aaron Durbin76c37002012-10-30 09:03:43 -0500674 path = ME_ERROR_BIOS_PATH;
675 }
676
Kyösti Mälkkibe5317f2019-11-06 12:07:21 +0200677 if (CONFIG(ELOG) && path != ME_NORMAL_BIOS_PATH) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500678 struct elog_event_data_me_extended data = {
679 .current_working_state = hfs.working_state,
680 .operation_state = hfs.operation_state,
681 .operation_mode = hfs.operation_mode,
682 .error_code = hfs.error_code,
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500683 .progress_code = hfs2.progress_code,
684 .current_pmevent = hfs2.current_pmevent,
685 .current_state = hfs2.current_state,
Aaron Durbin76c37002012-10-30 09:03:43 -0500686 };
687 elog_add_event_byte(ELOG_TYPE_MANAGEMENT_ENGINE, path);
688 elog_add_event_raw(ELOG_TYPE_MANAGEMENT_ENGINE_EXT,
689 &data, sizeof(data));
690 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500691
692 return path;
693}
694
695/* Prepare ME for MEI messages */
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100696static int intel_mei_setup(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500697{
698 struct resource *res;
699 struct mei_csr host;
Aaron Durbin76c37002012-10-30 09:03:43 -0500700
701 /* Find the MMIO base for the ME interface */
702 res = find_resource(dev, PCI_BASE_ADDRESS_0);
703 if (!res || res->base == 0 || res->size == 0) {
704 printk(BIOS_DEBUG, "ME: MEI resource not present!\n");
705 return -1;
706 }
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800707 mei_base_address = (u32 *)(uintptr_t)res->base;
Aaron Durbin76c37002012-10-30 09:03:43 -0500708
709 /* Ensure Memory and Bus Master bits are set */
Angel Ponsd5d4fbc2020-05-31 01:03:59 +0200710 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
Aaron Durbin76c37002012-10-30 09:03:43 -0500711
712 /* Clean up status for next message */
713 read_host_csr(&host);
714 host.interrupt_generate = 1;
715 host.ready = 1;
716 host.reset = 0;
717 write_host_csr(&host);
718
719 return 0;
720}
721
722/* Read the Extend register hash of ME firmware */
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100723static int intel_me_extend_valid(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500724{
725 struct me_heres status;
726 u32 extend[8] = {0};
727 int i, count = 0;
728
729 pci_read_dword_ptr(dev, &status, PCI_ME_HERES);
730 if (!status.extend_feature_present) {
731 printk(BIOS_ERR, "ME: Extend Feature not present\n");
732 return -1;
733 }
734
735 if (!status.extend_reg_valid) {
736 printk(BIOS_ERR, "ME: Extend Register not valid\n");
737 return -1;
738 }
739
740 switch (status.extend_reg_algorithm) {
741 case PCI_ME_EXT_SHA1:
742 count = 5;
743 printk(BIOS_DEBUG, "ME: Extend SHA-1: ");
744 break;
745 case PCI_ME_EXT_SHA256:
746 count = 8;
747 printk(BIOS_DEBUG, "ME: Extend SHA-256: ");
748 break;
749 default:
750 printk(BIOS_ERR, "ME: Extend Algorithm %d unknown\n",
751 status.extend_reg_algorithm);
752 return -1;
753 }
754
755 for (i = 0; i < count; ++i) {
756 extend[i] = pci_read_config32(dev, PCI_ME_HER(i));
757 printk(BIOS_DEBUG, "%08x", extend[i]);
758 }
759 printk(BIOS_DEBUG, "\n");
760
Julius Wernercd49cce2019-03-05 16:53:33 -0800761#if CONFIG(CHROMEOS)
Aaron Durbin76c37002012-10-30 09:03:43 -0500762 /* Save hash in NVS for the OS to verify */
763 chromeos_set_me_hash(extend, count);
764#endif
765
766 return 0;
767}
768
Aaron Durbin76c37002012-10-30 09:03:43 -0500769/* Check whether ME is present and do basic init */
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100770static void intel_me_init(struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500771{
Duncan Laurie0dc0d132013-08-08 15:31:51 -0700772 struct southbridge_intel_lynxpoint_config *config = dev->chip_info;
Aaron Durbin76c37002012-10-30 09:03:43 -0500773 me_bios_path path = intel_me_path(dev);
774 me_bios_payload mbp_data;
775
776 /* Do initial setup and determine the BIOS path */
777 printk(BIOS_NOTICE, "ME: BIOS path: %s\n", me_bios_path_values[path]);
778
Duncan Laurie8056dc62013-07-22 08:47:43 -0700779 if (path == ME_NORMAL_BIOS_PATH) {
Aaron Durbin76c37002012-10-30 09:03:43 -0500780 /* Validate the extend register */
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500781 intel_me_extend_valid(dev);
782 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500783
Aaron Durbinbe985242012-12-12 12:40:33 -0600784 memset(&mbp_data, 0, sizeof(mbp_data));
785
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500786 /*
787 * According to the ME9 BWG, BIOS is required to fetch MBP data in
788 * all boot flows except S3 Resume.
789 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500790
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500791 /* Prepare MEI MMIO interface */
792 if (intel_mei_setup(dev) < 0)
793 return;
Aaron Durbin76c37002012-10-30 09:03:43 -0500794
Duncan Laurie144f7b22013-05-01 11:27:58 -0700795 if (intel_me_read_mbp(&mbp_data, dev))
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500796 return;
Aaron Durbin76c37002012-10-30 09:03:43 -0500797
Kyösti Mälkkic86fc8e2019-11-06 06:32:27 +0200798 if (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= BIOS_DEBUG) {
799 me_print_fw_version(mbp_data.fw_version_name);
Duncan Laurie144f7b22013-05-01 11:27:58 -0700800
Kyösti Mälkkic86fc8e2019-11-06 06:32:27 +0200801 if (CONFIG(DEBUG_INTEL_ME))
802 me_print_fwcaps(mbp_data.fw_capabilities);
803
804 if (mbp_data.plat_time) {
805 printk(BIOS_DEBUG, "ME: Wake Event to ME Reset: %u ms\n",
806 mbp_data.plat_time->wake_event_mrst_time_ms);
807 printk(BIOS_DEBUG, "ME: ME Reset to Platform Reset: %u ms\n",
808 mbp_data.plat_time->mrst_pltrst_time_ms);
809 printk(BIOS_DEBUG, "ME: Platform Reset to CPU Reset: %u ms\n",
810 mbp_data.plat_time->pltrst_cpurst_time_ms);
811 }
Duncan Laurie144f7b22013-05-01 11:27:58 -0700812 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500813
Duncan Laurie0dc0d132013-08-08 15:31:51 -0700814 /* Set clock enables according to devicetree */
815 if (config && config->icc_clock_disable)
816 me_icc_set_clock_enables(config->icc_clock_disable);
817
Duncan Laurieaf980622013-07-18 23:02:18 -0700818 /*
819 * Leave the ME unlocked. It will be locked via SMI command later.
820 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500821}
822
Elyes HAOUAS1dcd8db2018-12-05 10:59:42 +0100823static void intel_me_enable(struct device *dev)
Duncan Laurie8056dc62013-07-22 08:47:43 -0700824{
Duncan Laurie8056dc62013-07-22 08:47:43 -0700825 /* Avoid talking to the device in S3 path */
Kyösti Mälkkic3ed8862014-06-19 19:50:51 +0300826 if (acpi_is_wakeup_s3()) {
Duncan Laurie8056dc62013-07-22 08:47:43 -0700827 dev->enabled = 0;
828 pch_disable_devfn(dev);
829 }
Duncan Laurie8056dc62013-07-22 08:47:43 -0700830}
831
Aaron Durbin76c37002012-10-30 09:03:43 -0500832static struct device_operations device_ops = {
833 .read_resources = pci_dev_read_resources,
834 .set_resources = pci_dev_set_resources,
835 .enable_resources = pci_dev_enable_resources,
Duncan Laurie8056dc62013-07-22 08:47:43 -0700836 .enable = intel_me_enable,
Aaron Durbin76c37002012-10-30 09:03:43 -0500837 .init = intel_me_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +0200838 .ops_pci = &pci_dev_ops_pci,
Aaron Durbin76c37002012-10-30 09:03:43 -0500839};
840
Duncan Laurie26e7dd72012-12-19 09:12:31 -0800841static const unsigned short pci_device_ids[] = {
842 0x8c3a, /* Mobile */
843 0x9c3a, /* Low Power */
844 0
845};
846
Aaron Durbin76c37002012-10-30 09:03:43 -0500847static const struct pci_driver intel_me __pci_driver = {
Angel Ponsb4b4e322020-06-21 12:47:13 +0200848 .ops = &device_ops,
849 .vendor = PCI_VENDOR_ID_INTEL,
850 .devices = pci_device_ids,
Aaron Durbin76c37002012-10-30 09:03:43 -0500851};
852
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200853#endif /* !__SIMPLE_DEVICE__ */
854
Aaron Durbin76c37002012-10-30 09:03:43 -0500855/******************************************************************************
856 * */
857static u32 me_to_host_words_pending(void)
858{
859 struct mei_csr me;
860 read_me_csr(&me);
861 if (!me.ready)
862 return 0;
863 return (me.buffer_write_ptr - me.buffer_read_ptr) &
864 (me.buffer_depth - 1);
865}
866
Aaron Durbinbe985242012-12-12 12:40:33 -0600867struct mbp_payload {
868 mbp_header header;
869 u32 data[0];
870};
871
Aaron Durbin76c37002012-10-30 09:03:43 -0500872/*
873 * mbp seems to be following its own flow, let's retrieve it in a dedicated
874 * function.
875 */
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200876static int __unused intel_me_read_mbp(me_bios_payload *mbp_data, struct device *dev)
Aaron Durbin76c37002012-10-30 09:03:43 -0500877{
878 mbp_header mbp_hdr;
Aaron Durbin76c37002012-10-30 09:03:43 -0500879 u32 me2host_pending;
Aaron Durbin76c37002012-10-30 09:03:43 -0500880 struct mei_csr host;
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500881 struct me_hfs2 hfs2;
Aaron Durbinbe985242012-12-12 12:40:33 -0600882 struct mbp_payload *mbp;
883 int i;
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500884
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200885#ifdef __SIMPLE_DEVICE__
886 pci_read_dword_ptr(PCI_BDF(dev), &hfs2, PCI_ME_HFS2);
887#else
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500888 pci_read_dword_ptr(dev, &hfs2, PCI_ME_HFS2);
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200889#endif
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500890
891 if (!hfs2.mbp_rdy) {
892 printk(BIOS_ERR, "ME: MBP not ready\n");
893 goto mbp_failure;
894 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500895
896 me2host_pending = me_to_host_words_pending();
897 if (!me2host_pending) {
898 printk(BIOS_ERR, "ME: no mbp data!\n");
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500899 goto mbp_failure;
Aaron Durbin76c37002012-10-30 09:03:43 -0500900 }
901
902 /* we know for sure that at least the header is there */
903 mei_read_dword_ptr(&mbp_hdr, MEI_ME_CB_RW);
904
905 if ((mbp_hdr.num_entries > (mbp_hdr.mbp_size / 2)) ||
906 (me2host_pending < mbp_hdr.mbp_size)) {
907 printk(BIOS_ERR, "ME: mbp of %d entries, total size %d words"
908 " buffer contains %d words\n",
909 mbp_hdr.num_entries, mbp_hdr.mbp_size,
910 me2host_pending);
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500911 goto mbp_failure;
Aaron Durbin76c37002012-10-30 09:03:43 -0500912 }
Aaron Durbinbe985242012-12-12 12:40:33 -0600913 mbp = malloc(mbp_hdr.mbp_size * sizeof(u32));
914 if (!mbp)
915 goto mbp_failure;
Aaron Durbin76c37002012-10-30 09:03:43 -0500916
Aaron Durbinbe985242012-12-12 12:40:33 -0600917 mbp->header = mbp_hdr;
Aaron Durbin76c37002012-10-30 09:03:43 -0500918 me2host_pending--;
Aaron Durbin76c37002012-10-30 09:03:43 -0500919
Aaron Durbinbe985242012-12-12 12:40:33 -0600920 i = 0;
921 while (i != me2host_pending) {
922 mei_read_dword_ptr(&mbp->data[i], MEI_ME_CB_RW);
923 i++;
Aaron Durbin76c37002012-10-30 09:03:43 -0500924 }
925
Aaron Durbinbe985242012-12-12 12:40:33 -0600926 /* Signal to the ME that the host has finished reading the MBP. */
Aaron Durbin76c37002012-10-30 09:03:43 -0500927 read_host_csr(&host);
928 host.interrupt_generate = 1;
929 write_host_csr(&host);
930
Julius Wernercd49cce2019-03-05 16:53:33 -0800931#if !CONFIG(ME_MBP_CLEAR_LATE)
Aaron Durbinbe985242012-12-12 12:40:33 -0600932 /* Wait for the mbp_cleared indicator. */
Duncan Laurie3d299c42013-07-19 08:48:05 -0700933 intel_me_mbp_clear(dev);
934#endif
Aaron Durbin76c37002012-10-30 09:03:43 -0500935
Aaron Durbinbe985242012-12-12 12:40:33 -0600936 /* Dump out the MBP contents. */
Kyösti Mälkkic86fc8e2019-11-06 06:32:27 +0200937 if (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= BIOS_DEBUG) {
938 printk(BIOS_INFO, "ME MBP: Header: items: %d, size dw: %d\n",
939 mbp->header.num_entries, mbp->header.mbp_size);
940 if (CONFIG(DEBUG_INTEL_ME)) {
941 for (i = 0; i < mbp->header.mbp_size - 1; i++) {
942 printk(BIOS_INFO, "ME MBP: %04x: 0x%08x\n", i, mbp->data[i]);
943 }
944 }
Aaron Durbinbe985242012-12-12 12:40:33 -0600945 }
Aaron Durbinbe985242012-12-12 12:40:33 -0600946
947 #define ASSIGN_FIELD_PTR(field_,val_) \
948 { \
949 mbp_data->field_ = (typeof(mbp_data->field_))(void *)val_; \
950 break; \
951 }
952 /* Setup the pointers in the me_bios_payload structure. */
953 for (i = 0; i < mbp->header.mbp_size - 1;) {
954 mbp_item_header *item = (void *)&mbp->data[i];
955
Elyes HAOUASf9de5a42018-05-03 17:21:02 +0200956 switch (MBP_MAKE_IDENT(item->app_id, item->item_id)) {
Aaron Durbinbe985242012-12-12 12:40:33 -0600957 case MBP_IDENT(KERNEL, FW_VER):
958 ASSIGN_FIELD_PTR(fw_version_name, &mbp->data[i+1]);
959
960 case MBP_IDENT(ICC, PROFILE):
961 ASSIGN_FIELD_PTR(icc_profile, &mbp->data[i+1]);
962
963 case MBP_IDENT(INTEL_AT, STATE):
964 ASSIGN_FIELD_PTR(at_state, &mbp->data[i+1]);
965
966 case MBP_IDENT(KERNEL, FW_CAP):
967 ASSIGN_FIELD_PTR(fw_capabilities, &mbp->data[i+1]);
968
969 case MBP_IDENT(KERNEL, ROM_BIST):
970 ASSIGN_FIELD_PTR(rom_bist_data, &mbp->data[i+1]);
971
972 case MBP_IDENT(KERNEL, PLAT_KEY):
973 ASSIGN_FIELD_PTR(platform_key, &mbp->data[i+1]);
974
975 case MBP_IDENT(KERNEL, FW_TYPE):
976 ASSIGN_FIELD_PTR(fw_plat_type, &mbp->data[i+1]);
977
978 case MBP_IDENT(KERNEL, MFS_FAILURE):
979 ASSIGN_FIELD_PTR(mfsintegrity, &mbp->data[i+1]);
980
Duncan Laurie144f7b22013-05-01 11:27:58 -0700981 case MBP_IDENT(KERNEL, PLAT_TIME):
982 ASSIGN_FIELD_PTR(plat_time, &mbp->data[i+1]);
983
984 case MBP_IDENT(NFC, SUPPORT_DATA):
985 ASSIGN_FIELD_PTR(nfc_data, &mbp->data[i+1]);
986
Aaron Durbinbe985242012-12-12 12:40:33 -0600987 default:
Duncan Laurie0b3cd362013-08-08 15:40:01 -0700988 printk(BIOS_ERR, "ME MBP: unknown item 0x%x @ "
989 "dw offset 0x%x\n", mbp->data[i], i);
Aaron Durbinbe985242012-12-12 12:40:33 -0600990 break;
991 }
992 i += item->length;
993 }
994 #undef ASSIGN_FIELD_PTR
995
Aaron Durbin76c37002012-10-30 09:03:43 -0500996 return 0;
Aaron Durbin9aa031e2012-11-02 09:16:46 -0500997
998mbp_failure:
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200999#ifdef __SIMPLE_DEVICE__
1000 intel_me_mbp_give_up(PCI_BDF(dev));
1001#else
Aaron Durbin9aa031e2012-11-02 09:16:46 -05001002 intel_me_mbp_give_up(dev);
Kyösti Mälkki21d6a272019-11-05 18:50:38 +02001003#endif
Aaron Durbin9aa031e2012-11-02 09:16:46 -05001004 return -1;
Aaron Durbin76c37002012-10-30 09:03:43 -05001005}