blob: 5f6be1d163f3036b9aa91e69b480d0192fce92f3 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Vladimir Serbinenko888d5592013-11-13 17:53:38 +01003
4/*
5 * This is a ramstage driver for the Intel Management Engine found in the
6 * 6-series chipset. It handles the required boot-time messages over the
7 * MMIO-based Management Engine Interface to tell the ME that the BIOS is
8 * finished with POST. Additional messages are defined for debug but are
9 * not used unless the console loglevel is high enough.
10 */
11
12#include <arch/acpi.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010013#include <console/console.h>
Kyösti Mälkki21d6a272019-11-05 18:50:38 +020014#include <device/device.h>
15#include <device/mmio.h>
16#include <device/pci.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010017#include <device/pci_def.h>
Kyösti Mälkki21d6a272019-11-05 18:50:38 +020018#include <device/pci_ids.h>
19#include <device/pci_ops.h>
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010020#include <string.h>
21#include <delay.h>
22#include <elog.h>
23
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010024#include "me.h"
25#include "pch.h"
26
Julius Wernercd49cce2019-03-05 16:53:33 -080027#if CONFIG(CHROMEOS)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010028#include <vendorcode/google/chromeos/gnvs.h>
29#endif
30
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010031/* Path that the BIOS should take based on ME state */
Kyösti Mälkki21d6a272019-11-05 18:50:38 +020032static const char *me_bios_path_values[] __unused = {
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010033 [ME_NORMAL_BIOS_PATH] = "Normal",
34 [ME_S3WAKE_BIOS_PATH] = "S3 Wake",
35 [ME_ERROR_BIOS_PATH] = "Error",
36 [ME_RECOVERY_BIOS_PATH] = "Recovery",
37 [ME_DISABLE_BIOS_PATH] = "Disable",
38 [ME_FIRMWARE_UPDATE_BIOS_PATH] = "Firmware Update",
39};
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010040
41/* MMIO base address for MEI interface */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080042static u32 *mei_base_address;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010043
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010044static void mei_dump(void *ptr, int dword, int offset, const char *type)
45{
46 struct mei_csr *csr;
47
Kyösti Mälkkic86fc8e2019-11-06 06:32:27 +020048 if (!CONFIG(DEBUG_INTEL_ME))
49 return;
50
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010051 printk(BIOS_SPEW, "%-9s[%02x] : ", type, offset);
52
53 switch (offset) {
54 case MEI_H_CSR:
55 case MEI_ME_CSR_HA:
56 csr = ptr;
57 if (!csr) {
58 printk(BIOS_SPEW, "ERROR: 0x%08x\n", dword);
59 break;
60 }
61 printk(BIOS_SPEW, "cbd=%u cbrp=%02u cbwp=%02u ready=%u "
62 "reset=%u ig=%u is=%u ie=%u\n", csr->buffer_depth,
63 csr->buffer_read_ptr, csr->buffer_write_ptr,
64 csr->ready, csr->reset, csr->interrupt_generate,
65 csr->interrupt_status, csr->interrupt_enable);
66 break;
67 case MEI_ME_CB_RW:
68 case MEI_H_CB_WW:
69 printk(BIOS_SPEW, "CB: 0x%08x\n", dword);
70 break;
71 default:
72 printk(BIOS_SPEW, "0x%08x\n", offset);
73 break;
74 }
75}
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010076
77/*
78 * ME/MEI access helpers using memcpy to avoid aliasing.
79 */
80
81static inline void mei_read_dword_ptr(void *ptr, int offset)
82{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080083 u32 dword = read32(mei_base_address + (offset/sizeof(u32)));
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010084 memcpy(ptr, &dword, sizeof(dword));
85 mei_dump(ptr, dword, offset, "READ");
86}
87
88static inline void mei_write_dword_ptr(void *ptr, int offset)
89{
90 u32 dword = 0;
91 memcpy(&dword, ptr, sizeof(dword));
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080092 write32(mei_base_address + (offset/sizeof(u32)), dword);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010093 mei_dump(ptr, dword, offset, "WRITE");
94}
95
Kyösti Mälkki21d6a272019-11-05 18:50:38 +020096#ifndef __SIMPLE_DEVICE__
Elyes HAOUASbe841402018-05-13 13:40:39 +020097static inline void pci_read_dword_ptr(struct device *dev,void *ptr,
98 int offset)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +010099{
100 u32 dword = pci_read_config32(dev, offset);
101 memcpy(ptr, &dword, sizeof(dword));
102 mei_dump(ptr, dword, offset, "PCI READ");
103}
104#endif
105
106static inline void read_host_csr(struct mei_csr *csr)
107{
108 mei_read_dword_ptr(csr, MEI_H_CSR);
109}
110
111static inline void write_host_csr(struct mei_csr *csr)
112{
113 mei_write_dword_ptr(csr, MEI_H_CSR);
114}
115
116static inline void read_me_csr(struct mei_csr *csr)
117{
118 mei_read_dword_ptr(csr, MEI_ME_CSR_HA);
119}
120
121static inline void write_cb(u32 dword)
122{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800123 write32(mei_base_address + (MEI_H_CB_WW/sizeof(u32)), dword);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100124 mei_dump(NULL, dword, MEI_H_CB_WW, "WRITE");
125}
126
127static inline u32 read_cb(void)
128{
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800129 u32 dword = read32(mei_base_address + (MEI_ME_CB_RW/sizeof(u32)));
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100130 mei_dump(NULL, dword, MEI_ME_CB_RW, "READ");
131 return dword;
132}
133
134/* Wait for ME ready bit to be asserted */
135static int mei_wait_for_me_ready(void)
136{
137 struct mei_csr me;
Martin Rothff744bf2019-10-23 21:46:03 -0600138 unsigned int try = ME_RETRY;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100139
140 while (try--) {
141 read_me_csr(&me);
142 if (me.ready)
143 return 0;
144 udelay(ME_DELAY);
145 }
146
147 printk(BIOS_ERR, "ME: failed to become ready\n");
148 return -1;
149}
150
151static void mei_reset(void)
152{
153 struct mei_csr host;
154
155 if (mei_wait_for_me_ready() < 0)
156 return;
157
158 /* Reset host and ME circular buffers for next message */
159 read_host_csr(&host);
160 host.reset = 1;
161 host.interrupt_generate = 1;
162 write_host_csr(&host);
163
164 if (mei_wait_for_me_ready() < 0)
165 return;
166
167 /* Re-init and indicate host is ready */
168 read_host_csr(&host);
169 host.interrupt_generate = 1;
170 host.ready = 1;
171 host.reset = 0;
172 write_host_csr(&host);
173}
174
175static int mei_send_msg(struct mei_header *mei, struct mkhi_header *mkhi,
176 void *req_data)
177{
178 struct mei_csr host;
Martin Rothff744bf2019-10-23 21:46:03 -0600179 unsigned int ndata, n;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100180 u32 *data;
181
182 /* Number of dwords to write, ignoring MKHI */
183 ndata = mei->length >> 2;
184
185 /* Pad non-dword aligned request message length */
186 if (mei->length & 3)
187 ndata++;
188 if (!ndata) {
189 printk(BIOS_DEBUG, "ME: request does not include MKHI\n");
190 return -1;
191 }
192 ndata++; /* Add MEI header */
193
194 /*
195 * Make sure there is still room left in the circular buffer.
196 * Reset the buffer pointers if the requested message will not fit.
197 */
198 read_host_csr(&host);
199 if ((host.buffer_depth - host.buffer_write_ptr) < ndata) {
200 printk(BIOS_ERR, "ME: circular buffer full, resetting...\n");
201 mei_reset();
202 read_host_csr(&host);
203 }
204
205 /*
206 * This implementation does not handle splitting large messages
207 * across multiple transactions. Ensure the requested length
208 * will fit in the available circular buffer depth.
209 */
210 if ((host.buffer_depth - host.buffer_write_ptr) < ndata) {
211 printk(BIOS_ERR, "ME: message (%u) too large for buffer (%u)\n",
212 ndata + 2, host.buffer_depth);
213 return -1;
214 }
215
216 /* Write MEI header */
217 mei_write_dword_ptr(mei, MEI_H_CB_WW);
218 ndata--;
219
220 /* Write MKHI header */
221 mei_write_dword_ptr(mkhi, MEI_H_CB_WW);
222 ndata--;
223
224 /* Write message data */
225 data = req_data;
226 for (n = 0; n < ndata; ++n)
227 write_cb(*data++);
228
229 /* Generate interrupt to the ME */
230 read_host_csr(&host);
231 host.interrupt_generate = 1;
232 write_host_csr(&host);
233
234 /* Make sure ME is ready after sending request data */
235 return mei_wait_for_me_ready();
236}
237
238static int mei_recv_msg(struct mei_header *mei, struct mkhi_header *mkhi,
239 void *rsp_data, int rsp_bytes)
240{
241 struct mei_header mei_rsp;
242 struct mkhi_header mkhi_rsp;
243 struct mei_csr me, host;
Martin Rothff744bf2019-10-23 21:46:03 -0600244 unsigned int ndata, n;
245 unsigned int expected;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100246 u32 *data;
247
248 /* Total number of dwords to read from circular buffer */
249 expected = (rsp_bytes + sizeof(mei_rsp) + sizeof(mkhi_rsp)) >> 2;
250 if (rsp_bytes & 3)
251 expected++;
252
253 /*
254 * The interrupt status bit does not appear to indicate that the
255 * message has actually been received. Instead we wait until the
256 * expected number of dwords are present in the circular buffer.
257 */
258 for (n = ME_RETRY; n; --n) {
259 read_me_csr(&me);
260 if ((me.buffer_write_ptr - me.buffer_read_ptr) >= expected)
261 break;
262 udelay(ME_DELAY);
263 }
264 if (!n) {
265 printk(BIOS_ERR, "ME: timeout waiting for data: expected "
266 "%u, available %u\n", expected,
267 me.buffer_write_ptr - me.buffer_read_ptr);
268 return -1;
269 }
270
271 /* Read and verify MEI response header from the ME */
272 mei_read_dword_ptr(&mei_rsp, MEI_ME_CB_RW);
273 if (!mei_rsp.is_complete) {
274 printk(BIOS_ERR, "ME: response is not complete\n");
275 return -1;
276 }
277
278 /* Handle non-dword responses and expect at least MKHI header */
279 ndata = mei_rsp.length >> 2;
280 if (mei_rsp.length & 3)
281 ndata++;
282 if (ndata != (expected - 1)) {
283 printk(BIOS_ERR, "ME: response is missing data\n");
284 return -1;
285 }
286
287 /* Read and verify MKHI response header from the ME */
288 mei_read_dword_ptr(&mkhi_rsp, MEI_ME_CB_RW);
289 if (!mkhi_rsp.is_response ||
290 mkhi->group_id != mkhi_rsp.group_id ||
291 mkhi->command != mkhi_rsp.command) {
292 printk(BIOS_ERR, "ME: invalid response, group %u ?= %u, "
293 "command %u ?= %u, is_response %u\n", mkhi->group_id,
294 mkhi_rsp.group_id, mkhi->command, mkhi_rsp.command,
295 mkhi_rsp.is_response);
296 return -1;
297 }
298 ndata--; /* MKHI header has been read */
299
300 /* Make sure caller passed a buffer with enough space */
301 if (ndata != (rsp_bytes >> 2)) {
302 printk(BIOS_ERR, "ME: not enough room in response buffer: "
303 "%u != %u\n", ndata, rsp_bytes >> 2);
304 return -1;
305 }
306
307 /* Read response data from the circular buffer */
308 data = rsp_data;
309 for (n = 0; n < ndata; ++n)
310 *data++ = read_cb();
311
312 /* Tell the ME that we have consumed the response */
313 read_host_csr(&host);
314 host.interrupt_status = 1;
315 host.interrupt_generate = 1;
316 write_host_csr(&host);
317
318 return mei_wait_for_me_ready();
319}
320
321static inline int mei_sendrecv(struct mei_header *mei, struct mkhi_header *mkhi,
322 void *req_data, void *rsp_data, int rsp_bytes)
323{
324 if (mei_send_msg(mei, mkhi, req_data) < 0)
325 return -1;
326 if (mei_recv_msg(mei, mkhi, rsp_data, rsp_bytes) < 0)
327 return -1;
328 return 0;
329}
330
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100331/* Send END OF POST message to the ME */
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200332static int __unused mkhi_end_of_post(void)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100333{
334 struct mkhi_header mkhi = {
335 .group_id = MKHI_GROUP_ID_GEN,
336 .command = MKHI_END_OF_POST,
337 };
338 struct mei_header mei = {
339 .is_complete = 1,
340 .host_address = MEI_HOST_ADDRESS,
341 .client_address = MEI_ADDRESS_MKHI,
342 .length = sizeof(mkhi),
343 };
344
345 /* Send request and wait for response */
346 if (mei_sendrecv(&mei, &mkhi, NULL, NULL, 0) < 0) {
347 printk(BIOS_ERR, "ME: END OF POST message failed\n");
348 return -1;
349 }
350
351 printk(BIOS_INFO, "ME: END OF POST message successful\n");
352 return 0;
353}
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100354
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200355#ifdef __SIMPLE_DEVICE__
356
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100357static void intel_me7_finalize_smm(void)
358{
359 struct me_hfs hfs;
360 u32 reg32;
361
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800362 mei_base_address = (u32 *)
363 (pci_read_config32(PCH_ME_DEV, PCI_BASE_ADDRESS_0) & ~0xf);
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100364
365 /* S3 path will have hidden this device already */
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800366 if (!mei_base_address || mei_base_address == (u32 *)0xfffffff0)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100367 return;
368
369 /* Make sure ME is in a mode that expects EOP */
370 reg32 = pci_read_config32(PCH_ME_DEV, PCI_ME_HFS);
371 memcpy(&hfs, &reg32, sizeof(u32));
372
373 /* Abort and leave device alone if not normal mode */
374 if (hfs.fpt_bad ||
375 hfs.working_state != ME_HFS_CWS_NORMAL ||
376 hfs.operation_mode != ME_HFS_MODE_NORMAL)
377 return;
378
379 /* Try to send EOP command so ME stops accepting other commands */
380 mkhi_end_of_post();
381
382 /* Make sure IO is disabled */
383 reg32 = pci_read_config32(PCH_ME_DEV, PCI_COMMAND);
384 reg32 &= ~(PCI_COMMAND_MASTER |
385 PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
386 pci_write_config32(PCH_ME_DEV, PCI_COMMAND, reg32);
387
388 /* Hide the PCI device */
389 RCBA32_OR(FD2, PCH_DISABLE_MEI1);
390}
391
392void intel_me_finalize_smm(void)
393{
394 u32 did = pci_read_config32(PCH_ME_DEV, PCI_VENDOR_ID);
395 switch (did) {
396 case 0x1c3a8086:
397 intel_me7_finalize_smm();
398 break;
399 case 0x1e3a8086:
400 intel_me8_finalize_smm();
401 break;
402 default:
403 printk(BIOS_ERR, "No finalize handler for ME %08x.\n", did);
404 }
405}
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200406#else /* !__SIMPLE_DEVICE__ */
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100407
408/* Determine the path that we should take based on ME status */
Elyes HAOUASbe841402018-05-13 13:40:39 +0200409static me_bios_path intel_me_path(struct device *dev)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100410{
411 me_bios_path path = ME_DISABLE_BIOS_PATH;
412 struct me_hfs hfs;
413 struct me_gmes gmes;
414
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100415 /* S3 wake skips all MKHI messages */
Kyösti Mälkkic3ed8862014-06-19 19:50:51 +0300416 if (acpi_is_wakeup_s3())
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100417 return ME_S3WAKE_BIOS_PATH;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100418
419 pci_read_dword_ptr(dev, &hfs, PCI_ME_HFS);
420 pci_read_dword_ptr(dev, &gmes, PCI_ME_GMES);
421
422 /* Check and dump status */
423 intel_me_status(&hfs, &gmes);
424
425 /* Check Current Working State */
426 switch (hfs.working_state) {
427 case ME_HFS_CWS_NORMAL:
428 path = ME_NORMAL_BIOS_PATH;
429 break;
430 case ME_HFS_CWS_REC:
431 path = ME_RECOVERY_BIOS_PATH;
432 break;
433 default:
434 path = ME_DISABLE_BIOS_PATH;
435 break;
436 }
437
438 /* Check Current Operation Mode */
439 switch (hfs.operation_mode) {
440 case ME_HFS_MODE_NORMAL:
441 break;
442 case ME_HFS_MODE_DEBUG:
443 case ME_HFS_MODE_DIS:
444 case ME_HFS_MODE_OVER_JMPR:
445 case ME_HFS_MODE_OVER_MEI:
446 default:
447 path = ME_DISABLE_BIOS_PATH;
448 break;
449 }
450
451 /* Check for any error code and valid firmware */
452 if (hfs.error_code || hfs.fpt_bad)
453 path = ME_ERROR_BIOS_PATH;
454
Kyösti Mälkkibe5317f2019-11-06 12:07:21 +0200455 if (CONFIG(ELOG) && path != ME_NORMAL_BIOS_PATH) {
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100456 struct elog_event_data_me_extended data = {
457 .current_working_state = hfs.working_state,
458 .operation_state = hfs.operation_state,
459 .operation_mode = hfs.operation_mode,
460 .error_code = hfs.error_code,
461 .progress_code = gmes.progress_code,
462 .current_pmevent = gmes.current_pmevent,
463 .current_state = gmes.current_state,
464 };
465 elog_add_event_byte(ELOG_TYPE_MANAGEMENT_ENGINE, path);
466 elog_add_event_raw(ELOG_TYPE_MANAGEMENT_ENGINE_EXT,
467 &data, sizeof(data));
468 }
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100469
470 return path;
471}
472
473/* Prepare ME for MEI messages */
Elyes HAOUASbe841402018-05-13 13:40:39 +0200474static int intel_mei_setup(struct device *dev)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100475{
476 struct resource *res;
477 struct mei_csr host;
478 u32 reg32;
479
480 /* Find the MMIO base for the ME interface */
481 res = find_resource(dev, PCI_BASE_ADDRESS_0);
482 if (!res || res->base == 0 || res->size == 0) {
483 printk(BIOS_DEBUG, "ME: MEI resource not present!\n");
484 return -1;
485 }
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800486 mei_base_address = (u32 *)(uintptr_t)res->base;
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100487
488 /* Ensure Memory and Bus Master bits are set */
489 reg32 = pci_read_config32(dev, PCI_COMMAND);
490 reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
491 pci_write_config32(dev, PCI_COMMAND, reg32);
492
493 /* Clean up status for next message */
494 read_host_csr(&host);
495 host.interrupt_generate = 1;
496 host.ready = 1;
497 host.reset = 0;
498 write_host_csr(&host);
499
500 return 0;
501}
502
503/* Read the Extend register hash of ME firmware */
Elyes HAOUASbe841402018-05-13 13:40:39 +0200504static int intel_me_extend_valid(struct device *dev)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100505{
506 struct me_heres status;
507 u32 extend[8] = {0};
508 int i, count = 0;
509
510 pci_read_dword_ptr(dev, &status, PCI_ME_HERES);
511 if (!status.extend_feature_present) {
512 printk(BIOS_ERR, "ME: Extend Feature not present\n");
513 return -1;
514 }
515
516 if (!status.extend_reg_valid) {
517 printk(BIOS_ERR, "ME: Extend Register not valid\n");
518 return -1;
519 }
520
521 switch (status.extend_reg_algorithm) {
522 case PCI_ME_EXT_SHA1:
523 count = 5;
524 printk(BIOS_DEBUG, "ME: Extend SHA-1: ");
525 break;
526 case PCI_ME_EXT_SHA256:
527 count = 8;
528 printk(BIOS_DEBUG, "ME: Extend SHA-256: ");
529 break;
530 default:
531 printk(BIOS_ERR, "ME: Extend Algorithm %d unknown\n",
532 status.extend_reg_algorithm);
533 return -1;
534 }
535
536 for (i = 0; i < count; ++i) {
537 extend[i] = pci_read_config32(dev, PCI_ME_HER(i));
538 printk(BIOS_DEBUG, "%08x", extend[i]);
539 }
540 printk(BIOS_DEBUG, "\n");
541
Julius Wernercd49cce2019-03-05 16:53:33 -0800542#if CONFIG(CHROMEOS)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100543 /* Save hash in NVS for the OS to verify */
544 chromeos_set_me_hash(extend, count);
545#endif
546
547 return 0;
548}
549
550/* Hide the ME virtual PCI devices */
Elyes HAOUASbe841402018-05-13 13:40:39 +0200551static void intel_me_hide(struct device *dev)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100552{
553 dev->enabled = 0;
554 pch_enable(dev);
555}
556
557/* Check whether ME is present and do basic init */
Elyes HAOUASbe841402018-05-13 13:40:39 +0200558static void intel_me_init(struct device *dev)
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100559{
560 me_bios_path path = intel_me_path(dev);
561
562 /* Do initial setup and determine the BIOS path */
563 printk(BIOS_NOTICE, "ME: BIOS path: %s\n", me_bios_path_values[path]);
564
565 switch (path) {
566 case ME_S3WAKE_BIOS_PATH:
567 intel_me_hide(dev);
568 break;
569
570 case ME_NORMAL_BIOS_PATH:
571 /* Validate the extend register */
572 if (intel_me_extend_valid(dev) < 0)
573 break; /* TODO: force recovery mode */
574
575 /* Prepare MEI MMIO interface */
576 if (intel_mei_setup(dev) < 0)
577 break;
578
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100579 /*
580 * Leave the ME unlocked in this path.
581 * It will be locked via SMI command later.
582 */
583 break;
584
585 case ME_ERROR_BIOS_PATH:
586 case ME_RECOVERY_BIOS_PATH:
587 case ME_DISABLE_BIOS_PATH:
588 case ME_FIRMWARE_UPDATE_BIOS_PATH:
589 break;
590 }
591}
592
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100593static struct pci_operations pci_ops = {
Subrata Banik4a0f0712019-03-20 14:29:47 +0530594 .set_subsystem = pci_dev_set_subsystem,
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100595};
596
597static struct device_operations device_ops = {
598 .read_resources = pci_dev_read_resources,
599 .set_resources = pci_dev_set_resources,
600 .enable_resources = pci_dev_enable_resources,
601 .init = intel_me_init,
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100602 .ops_pci = &pci_ops,
603};
604
Felix Singer838fbc72019-11-21 21:23:32 +0100605static const unsigned short pci_device_ids[] = {
606 0x1c3a,
607 PCI_DID_INTEL_IBEXPEAK_HECI1,
608 0
609};
Vladimir Serbinenko888d5592013-11-13 17:53:38 +0100610
611
612static const struct pci_driver intel_me __pci_driver = {
613 .ops = &device_ops,
614 .vendor = PCI_VENDOR_ID_INTEL,
615 .devices = pci_device_ids
616};
617
Kyösti Mälkki21d6a272019-11-05 18:50:38 +0200618#endif /* !__SIMPLE_DEVICE__ */