Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 The Chromium OS Authors. All rights reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * This is a ramstage driver for the Intel Management Engine found in the |
| 19 | * 6-series chipset. It handles the required boot-time messages over the |
| 20 | * MMIO-based Management Engine Interface to tell the ME that the BIOS is |
| 21 | * finished with POST. Additional messages are defined for debug but are |
| 22 | * not used unless the console loglevel is high enough. |
| 23 | */ |
| 24 | |
| 25 | #include <arch/acpi.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 26 | #include <device/mmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 27 | #include <device/pci_ops.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 28 | #include <console/console.h> |
Stefan Reinauer | 24d1d4b | 2013-03-21 11:51:41 -0700 | [diff] [blame] | 29 | #include <device/device.h> |
| 30 | #include <device/pci.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 31 | #include <device/pci_ids.h> |
| 32 | #include <device/pci_def.h> |
| 33 | #include <string.h> |
| 34 | #include <delay.h> |
| 35 | #include <elog.h> |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 36 | #include <halt.h> |
Elyes HAOUAS | 400f9ca | 2019-06-23 07:01:22 +0200 | [diff] [blame] | 37 | #include <stdlib.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 38 | |
Kyösti Mälkki | 12b121c | 2019-08-18 16:33:39 +0300 | [diff] [blame] | 39 | #include "chip.h" |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 40 | #include "me.h" |
| 41 | #include "pch.h" |
| 42 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 43 | #if CONFIG(CHROMEOS) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 44 | #include <vendorcode/google/chromeos/chromeos.h> |
| 45 | #include <vendorcode/google/chromeos/gnvs.h> |
| 46 | #endif |
| 47 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 48 | /* Path that the BIOS should take based on ME state */ |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 49 | static const char *me_bios_path_values[] __unused = { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 50 | [ME_NORMAL_BIOS_PATH] = "Normal", |
| 51 | [ME_S3WAKE_BIOS_PATH] = "S3 Wake", |
| 52 | [ME_ERROR_BIOS_PATH] = "Error", |
| 53 | [ME_RECOVERY_BIOS_PATH] = "Recovery", |
| 54 | [ME_DISABLE_BIOS_PATH] = "Disable", |
| 55 | [ME_FIRMWARE_UPDATE_BIOS_PATH] = "Firmware Update", |
| 56 | }; |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 57 | static int intel_me_read_mbp(me_bios_payload *mbp_data, struct device *dev); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 58 | |
| 59 | /* MMIO base address for MEI interface */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 60 | static u32 *mei_base_address; |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 61 | #ifdef __SIMPLE_DEVICE__ |
| 62 | void intel_me_mbp_clear(pci_devfn_t dev); |
| 63 | #else |
| 64 | void intel_me_mbp_clear(struct device *dev); |
| 65 | #endif |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 66 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 67 | static void mei_dump(void *ptr, int dword, int offset, const char *type) |
| 68 | { |
| 69 | struct mei_csr *csr; |
| 70 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 71 | if (!CONFIG(DEBUG_INTEL_ME)) |
| 72 | return; |
| 73 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 74 | printk(BIOS_SPEW, "%-9s[%02x] : ", type, offset); |
| 75 | |
| 76 | switch (offset) { |
| 77 | case MEI_H_CSR: |
| 78 | case MEI_ME_CSR_HA: |
| 79 | csr = ptr; |
| 80 | if (!csr) { |
| 81 | printk(BIOS_SPEW, "ERROR: 0x%08x\n", dword); |
| 82 | break; |
| 83 | } |
| 84 | printk(BIOS_SPEW, "cbd=%u cbrp=%02u cbwp=%02u ready=%u " |
| 85 | "reset=%u ig=%u is=%u ie=%u\n", csr->buffer_depth, |
| 86 | csr->buffer_read_ptr, csr->buffer_write_ptr, |
| 87 | csr->ready, csr->reset, csr->interrupt_generate, |
| 88 | csr->interrupt_status, csr->interrupt_enable); |
| 89 | break; |
| 90 | case MEI_ME_CB_RW: |
| 91 | case MEI_H_CB_WW: |
| 92 | printk(BIOS_SPEW, "CB: 0x%08x\n", dword); |
| 93 | break; |
| 94 | default: |
| 95 | printk(BIOS_SPEW, "0x%08x\n", offset); |
| 96 | break; |
| 97 | } |
| 98 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * ME/MEI access helpers using memcpy to avoid aliasing. |
| 102 | */ |
| 103 | |
| 104 | static inline void mei_read_dword_ptr(void *ptr, int offset) |
| 105 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 106 | u32 dword = read32(mei_base_address + (offset/sizeof(u32))); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 107 | memcpy(ptr, &dword, sizeof(dword)); |
| 108 | mei_dump(ptr, dword, offset, "READ"); |
| 109 | } |
| 110 | |
| 111 | static inline void mei_write_dword_ptr(void *ptr, int offset) |
| 112 | { |
| 113 | u32 dword = 0; |
| 114 | memcpy(&dword, ptr, sizeof(dword)); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 115 | write32(mei_base_address + (offset/sizeof(u32)), dword); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 116 | mei_dump(ptr, dword, offset, "WRITE"); |
| 117 | } |
| 118 | |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 119 | #ifdef __SIMPLE_DEVICE__ |
| 120 | static inline void pci_read_dword_ptr(pci_devfn_t dev, void *ptr, int offset) |
| 121 | #else |
| 122 | static inline void pci_read_dword_ptr(struct device *dev, void *ptr, int offset) |
| 123 | #endif |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 124 | { |
| 125 | u32 dword = pci_read_config32(dev, offset); |
| 126 | memcpy(ptr, &dword, sizeof(dword)); |
| 127 | mei_dump(ptr, dword, offset, "PCI READ"); |
| 128 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 129 | |
| 130 | static inline void read_host_csr(struct mei_csr *csr) |
| 131 | { |
| 132 | mei_read_dword_ptr(csr, MEI_H_CSR); |
| 133 | } |
| 134 | |
| 135 | static inline void write_host_csr(struct mei_csr *csr) |
| 136 | { |
| 137 | mei_write_dword_ptr(csr, MEI_H_CSR); |
| 138 | } |
| 139 | |
| 140 | static inline void read_me_csr(struct mei_csr *csr) |
| 141 | { |
| 142 | mei_read_dword_ptr(csr, MEI_ME_CSR_HA); |
| 143 | } |
| 144 | |
| 145 | static inline void write_cb(u32 dword) |
| 146 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 147 | write32(mei_base_address + (MEI_H_CB_WW/sizeof(u32)), dword); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 148 | mei_dump(NULL, dword, MEI_H_CB_WW, "WRITE"); |
| 149 | } |
| 150 | |
| 151 | static inline u32 read_cb(void) |
| 152 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 153 | u32 dword = read32(mei_base_address + (MEI_ME_CB_RW/sizeof(u32))); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 154 | mei_dump(NULL, dword, MEI_ME_CB_RW, "READ"); |
| 155 | return dword; |
| 156 | } |
| 157 | |
| 158 | /* Wait for ME ready bit to be asserted */ |
| 159 | static int mei_wait_for_me_ready(void) |
| 160 | { |
| 161 | struct mei_csr me; |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 162 | unsigned int try = ME_RETRY; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 163 | |
| 164 | while (try--) { |
| 165 | read_me_csr(&me); |
| 166 | if (me.ready) |
| 167 | return 0; |
| 168 | udelay(ME_DELAY); |
| 169 | } |
| 170 | |
| 171 | printk(BIOS_ERR, "ME: failed to become ready\n"); |
| 172 | return -1; |
| 173 | } |
| 174 | |
| 175 | static void mei_reset(void) |
| 176 | { |
| 177 | struct mei_csr host; |
| 178 | |
| 179 | if (mei_wait_for_me_ready() < 0) |
| 180 | return; |
| 181 | |
| 182 | /* Reset host and ME circular buffers for next message */ |
| 183 | read_host_csr(&host); |
| 184 | host.reset = 1; |
| 185 | host.interrupt_generate = 1; |
| 186 | write_host_csr(&host); |
| 187 | |
| 188 | if (mei_wait_for_me_ready() < 0) |
| 189 | return; |
| 190 | |
| 191 | /* Re-init and indicate host is ready */ |
| 192 | read_host_csr(&host); |
| 193 | host.interrupt_generate = 1; |
| 194 | host.ready = 1; |
| 195 | host.reset = 0; |
| 196 | write_host_csr(&host); |
| 197 | } |
| 198 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 199 | static int mei_send_packet(struct mei_header *mei, void *req_data) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 200 | { |
| 201 | struct mei_csr host; |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 202 | unsigned int ndata, n; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 203 | u32 *data; |
| 204 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 205 | /* Number of dwords to write */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 206 | ndata = mei->length >> 2; |
| 207 | |
| 208 | /* Pad non-dword aligned request message length */ |
| 209 | if (mei->length & 3) |
| 210 | ndata++; |
| 211 | if (!ndata) { |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 212 | printk(BIOS_DEBUG, "ME: request has no data\n"); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 213 | return -1; |
| 214 | } |
| 215 | ndata++; /* Add MEI header */ |
| 216 | |
| 217 | /* |
| 218 | * Make sure there is still room left in the circular buffer. |
| 219 | * Reset the buffer pointers if the requested message will not fit. |
| 220 | */ |
| 221 | read_host_csr(&host); |
| 222 | if ((host.buffer_depth - host.buffer_write_ptr) < ndata) { |
| 223 | printk(BIOS_ERR, "ME: circular buffer full, resetting...\n"); |
| 224 | mei_reset(); |
| 225 | read_host_csr(&host); |
| 226 | } |
| 227 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 228 | /* Ensure the requested length will fit in the circular buffer. */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 229 | if ((host.buffer_depth - host.buffer_write_ptr) < ndata) { |
| 230 | printk(BIOS_ERR, "ME: message (%u) too large for buffer (%u)\n", |
| 231 | ndata + 2, host.buffer_depth); |
| 232 | return -1; |
| 233 | } |
| 234 | |
| 235 | /* Write MEI header */ |
| 236 | mei_write_dword_ptr(mei, MEI_H_CB_WW); |
| 237 | ndata--; |
| 238 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 239 | /* Write message data */ |
| 240 | data = req_data; |
| 241 | for (n = 0; n < ndata; ++n) |
| 242 | write_cb(*data++); |
| 243 | |
| 244 | /* Generate interrupt to the ME */ |
| 245 | read_host_csr(&host); |
| 246 | host.interrupt_generate = 1; |
| 247 | write_host_csr(&host); |
| 248 | |
| 249 | /* Make sure ME is ready after sending request data */ |
| 250 | return mei_wait_for_me_ready(); |
| 251 | } |
| 252 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 253 | static int mei_send_data(u8 me_address, u8 host_address, |
| 254 | void *req_data, int req_bytes) |
| 255 | { |
| 256 | struct mei_header header = { |
| 257 | .client_address = me_address, |
| 258 | .host_address = host_address, |
| 259 | }; |
| 260 | struct mei_csr host; |
| 261 | int current = 0; |
| 262 | u8 *req_ptr = req_data; |
| 263 | |
| 264 | while (!header.is_complete) { |
| 265 | int remain = req_bytes - current; |
| 266 | int buf_len; |
| 267 | |
| 268 | read_host_csr(&host); |
| 269 | buf_len = host.buffer_depth - host.buffer_write_ptr; |
| 270 | |
| 271 | if (buf_len > remain) { |
| 272 | /* Send all remaining data as final message */ |
| 273 | header.length = req_bytes - current; |
| 274 | header.is_complete = 1; |
| 275 | } else { |
| 276 | /* Send as much data as the buffer can hold */ |
| 277 | header.length = buf_len; |
| 278 | } |
| 279 | |
| 280 | mei_send_packet(&header, req_ptr); |
| 281 | |
| 282 | req_ptr += header.length; |
| 283 | current += header.length; |
| 284 | } |
| 285 | |
| 286 | return 0; |
| 287 | } |
| 288 | |
| 289 | static int mei_send_header(u8 me_address, u8 host_address, |
| 290 | void *header, int header_len, int complete) |
| 291 | { |
| 292 | struct mei_header mei = { |
| 293 | .client_address = me_address, |
| 294 | .host_address = host_address, |
| 295 | .length = header_len, |
| 296 | .is_complete = complete, |
| 297 | }; |
| 298 | return mei_send_packet(&mei, header); |
| 299 | } |
| 300 | |
| 301 | static int mei_recv_msg(void *header, int header_bytes, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 302 | void *rsp_data, int rsp_bytes) |
| 303 | { |
| 304 | struct mei_header mei_rsp; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 305 | struct mei_csr me, host; |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 306 | unsigned int ndata, n; |
| 307 | unsigned int expected; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 308 | u32 *data; |
| 309 | |
| 310 | /* Total number of dwords to read from circular buffer */ |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 311 | expected = (rsp_bytes + sizeof(mei_rsp) + header_bytes) >> 2; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 312 | if (rsp_bytes & 3) |
| 313 | expected++; |
| 314 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 315 | if (mei_wait_for_me_ready() < 0) |
| 316 | return -1; |
| 317 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 318 | /* |
| 319 | * The interrupt status bit does not appear to indicate that the |
| 320 | * message has actually been received. Instead we wait until the |
| 321 | * expected number of dwords are present in the circular buffer. |
| 322 | */ |
| 323 | for (n = ME_RETRY; n; --n) { |
| 324 | read_me_csr(&me); |
| 325 | if ((me.buffer_write_ptr - me.buffer_read_ptr) >= expected) |
| 326 | break; |
| 327 | udelay(ME_DELAY); |
| 328 | } |
| 329 | if (!n) { |
| 330 | printk(BIOS_ERR, "ME: timeout waiting for data: expected " |
| 331 | "%u, available %u\n", expected, |
| 332 | me.buffer_write_ptr - me.buffer_read_ptr); |
| 333 | return -1; |
| 334 | } |
| 335 | |
| 336 | /* Read and verify MEI response header from the ME */ |
| 337 | mei_read_dword_ptr(&mei_rsp, MEI_ME_CB_RW); |
| 338 | if (!mei_rsp.is_complete) { |
| 339 | printk(BIOS_ERR, "ME: response is not complete\n"); |
| 340 | return -1; |
| 341 | } |
| 342 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 343 | /* Handle non-dword responses and expect at least the header */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 344 | ndata = mei_rsp.length >> 2; |
| 345 | if (mei_rsp.length & 3) |
| 346 | ndata++; |
| 347 | if (ndata != (expected - 1)) { |
| 348 | printk(BIOS_ERR, "ME: response is missing data %d != %d\n", |
| 349 | ndata, (expected - 1)); |
| 350 | return -1; |
| 351 | } |
| 352 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 353 | /* Read response header from the ME */ |
| 354 | data = header; |
| 355 | for (n = 0; n < (header_bytes >> 2); ++n) |
| 356 | *data++ = read_cb(); |
| 357 | ndata -= header_bytes >> 2; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 358 | |
| 359 | /* Make sure caller passed a buffer with enough space */ |
| 360 | if (ndata != (rsp_bytes >> 2)) { |
| 361 | printk(BIOS_ERR, "ME: not enough room in response buffer: " |
| 362 | "%u != %u\n", ndata, rsp_bytes >> 2); |
| 363 | return -1; |
| 364 | } |
| 365 | |
| 366 | /* Read response data from the circular buffer */ |
| 367 | data = rsp_data; |
| 368 | for (n = 0; n < ndata; ++n) |
| 369 | *data++ = read_cb(); |
| 370 | |
| 371 | /* Tell the ME that we have consumed the response */ |
| 372 | read_host_csr(&host); |
| 373 | host.interrupt_status = 1; |
| 374 | host.interrupt_generate = 1; |
| 375 | write_host_csr(&host); |
| 376 | |
| 377 | return mei_wait_for_me_ready(); |
| 378 | } |
| 379 | |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 380 | static inline int mei_sendrecv_mkhi(struct mkhi_header *mkhi, |
| 381 | void *req_data, int req_bytes, |
| 382 | void *rsp_data, int rsp_bytes) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 383 | { |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 384 | struct mkhi_header mkhi_rsp; |
| 385 | |
| 386 | /* Send header */ |
| 387 | if (mei_send_header(MEI_ADDRESS_MKHI, MEI_HOST_ADDRESS, |
| 388 | mkhi, sizeof(*mkhi), req_bytes ? 0 : 1) < 0) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 389 | return -1; |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 390 | |
| 391 | /* Send data if available */ |
| 392 | if (req_bytes && mei_send_data(MEI_ADDRESS_MKHI, MEI_HOST_ADDRESS, |
| 393 | req_data, req_bytes) < 0) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 394 | return -1; |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 395 | |
| 396 | /* Return now if no response expected */ |
| 397 | if (!rsp_bytes) |
| 398 | return 0; |
| 399 | |
| 400 | /* Read header and data */ |
| 401 | if (mei_recv_msg(&mkhi_rsp, sizeof(mkhi_rsp), |
| 402 | rsp_data, rsp_bytes) < 0) |
| 403 | return -1; |
| 404 | |
| 405 | if (!mkhi_rsp.is_response || |
| 406 | mkhi->group_id != mkhi_rsp.group_id || |
| 407 | mkhi->command != mkhi_rsp.command) { |
| 408 | printk(BIOS_ERR, "ME: invalid response, group %u ?= %u," |
| 409 | "command %u ?= %u, is_response %u\n", mkhi->group_id, |
| 410 | mkhi_rsp.group_id, mkhi->command, mkhi_rsp.command, |
| 411 | mkhi_rsp.is_response); |
| 412 | return -1; |
| 413 | } |
| 414 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 415 | return 0; |
| 416 | } |
Duncan Laurie | 0dc0d13 | 2013-08-08 15:31:51 -0700 | [diff] [blame] | 417 | |
Duncan Laurie | 3d299c4 | 2013-07-19 08:48:05 -0700 | [diff] [blame] | 418 | /* |
| 419 | * mbp give up routine. This path is taken if hfs.mpb_rdy is 0 or the read |
| 420 | * state machine on the BIOS end doesn't match the ME's state machine. |
| 421 | */ |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 422 | #ifdef __SIMPLE_DEVICE__ |
| 423 | static void intel_me_mbp_give_up(pci_devfn_t dev) |
| 424 | #else |
| 425 | static void intel_me_mbp_give_up(struct device *dev) |
| 426 | #endif |
Duncan Laurie | 3d299c4 | 2013-07-19 08:48:05 -0700 | [diff] [blame] | 427 | { |
| 428 | struct mei_csr csr; |
| 429 | |
| 430 | pci_write_config32(dev, PCI_ME_H_GS2, PCI_ME_MBP_GIVE_UP); |
| 431 | |
| 432 | read_host_csr(&csr); |
| 433 | csr.reset = 1; |
| 434 | csr.interrupt_generate = 1; |
| 435 | write_host_csr(&csr); |
| 436 | } |
| 437 | |
| 438 | /* |
| 439 | * mbp clear routine. This will wait for the ME to indicate that |
| 440 | * the MBP has been read and cleared. |
| 441 | */ |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 442 | #ifdef __SIMPLE_DEVICE__ |
| 443 | void intel_me_mbp_clear(pci_devfn_t dev) |
| 444 | #else |
| 445 | void intel_me_mbp_clear(struct device *dev) |
| 446 | #endif |
Duncan Laurie | 3d299c4 | 2013-07-19 08:48:05 -0700 | [diff] [blame] | 447 | { |
| 448 | int count; |
| 449 | struct me_hfs2 hfs2; |
| 450 | |
| 451 | /* Wait for the mbp_cleared indicator */ |
| 452 | for (count = ME_RETRY; count > 0; --count) { |
| 453 | pci_read_dword_ptr(dev, &hfs2, PCI_ME_HFS2); |
| 454 | if (hfs2.mbp_cleared) |
| 455 | break; |
| 456 | udelay(ME_DELAY); |
| 457 | } |
| 458 | |
| 459 | if (count == 0) { |
| 460 | printk(BIOS_WARNING, "ME: Timeout waiting for mbp_cleared\n"); |
| 461 | intel_me_mbp_give_up(dev); |
| 462 | } else { |
| 463 | printk(BIOS_INFO, "ME: MBP cleared\n"); |
| 464 | } |
| 465 | } |
| 466 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 467 | static void __unused me_print_fw_version(mbp_fw_version_name *vers_name) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 468 | { |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 469 | if (!vers_name) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 470 | printk(BIOS_ERR, "ME: mbp missing version report\n"); |
| 471 | return; |
| 472 | } |
| 473 | |
| 474 | printk(BIOS_DEBUG, "ME: found version %d.%d.%d.%d\n", |
| 475 | vers_name->major_version, vers_name->minor_version, |
| 476 | vers_name->hotfix_version, vers_name->build_version); |
| 477 | } |
| 478 | |
Edward O'Callaghan | 7bf4f48 | 2014-06-17 15:12:09 +1000 | [diff] [blame] | 479 | static inline void print_cap(const char *name, int state) |
| 480 | { |
| 481 | printk(BIOS_DEBUG, "ME Capability: %-41s : %sabled\n", |
| 482 | name, state ? " en" : "dis"); |
| 483 | } |
| 484 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 485 | /* Get ME Firmware Capabilities */ |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 486 | static int mkhi_get_fwcaps(mbp_mefwcaps *cap) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 487 | { |
| 488 | u32 rule_id = 0; |
| 489 | struct me_fwcaps cap_msg; |
| 490 | struct mkhi_header mkhi = { |
| 491 | .group_id = MKHI_GROUP_ID_FWCAPS, |
| 492 | .command = MKHI_FWCAPS_GET_RULE, |
| 493 | }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 494 | |
| 495 | /* Send request and wait for response */ |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 496 | if (mei_sendrecv_mkhi(&mkhi, &rule_id, sizeof(u32), |
| 497 | &cap_msg, sizeof(cap_msg)) < 0) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 498 | printk(BIOS_ERR, "ME: GET FWCAPS message failed\n"); |
| 499 | return -1; |
Elyes HAOUAS | ba28e8d | 2016-08-31 19:22:16 +0200 | [diff] [blame] | 500 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 501 | *cap = cap_msg.caps_sku; |
| 502 | return 0; |
| 503 | } |
| 504 | |
| 505 | /* Get ME Firmware Capabilities */ |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 506 | static void __unused me_print_fwcaps(mbp_mefwcaps *cap) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 507 | { |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 508 | mbp_mefwcaps local_caps; |
| 509 | if (!cap) { |
| 510 | cap = &local_caps; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 511 | printk(BIOS_ERR, "ME: mbp missing fwcaps report\n"); |
| 512 | if (mkhi_get_fwcaps(cap)) |
| 513 | return; |
| 514 | } |
| 515 | |
| 516 | print_cap("Full Network manageability", cap->full_net); |
| 517 | print_cap("Regular Network manageability", cap->std_net); |
| 518 | print_cap("Manageability", cap->manageability); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 519 | print_cap("IntelR Anti-Theft (AT)", cap->intel_at); |
| 520 | print_cap("IntelR Capability Licensing Service (CLS)", cap->intel_cls); |
| 521 | print_cap("IntelR Power Sharing Technology (MPC)", cap->intel_mpc); |
| 522 | print_cap("ICC Over Clocking", cap->icc_over_clocking); |
Edward O'Callaghan | 7bf4f48 | 2014-06-17 15:12:09 +1000 | [diff] [blame] | 523 | print_cap("Protected Audio Video Path (PAVP)", cap->pavp); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 524 | print_cap("IPV6", cap->ipv6); |
| 525 | print_cap("KVM Remote Control (KVM)", cap->kvm); |
| 526 | print_cap("Outbreak Containment Heuristic (OCH)", cap->och); |
| 527 | print_cap("Virtual LAN (VLAN)", cap->vlan); |
| 528 | print_cap("TLS", cap->tls); |
| 529 | print_cap("Wireless LAN (WLAN)", cap->wlan); |
| 530 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 531 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 532 | #if CONFIG(CHROMEOS) && 0 /* DISABLED */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 533 | /* Tell ME to issue a global reset */ |
| 534 | static int mkhi_global_reset(void) |
| 535 | { |
| 536 | struct me_global_reset reset = { |
| 537 | .request_origin = GLOBAL_RESET_BIOS_POST, |
| 538 | .reset_type = CBM_RR_GLOBAL_RESET, |
| 539 | }; |
| 540 | struct mkhi_header mkhi = { |
| 541 | .group_id = MKHI_GROUP_ID_CBM, |
| 542 | .command = MKHI_GLOBAL_RESET, |
| 543 | }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 544 | |
| 545 | /* Send request and wait for response */ |
| 546 | printk(BIOS_NOTICE, "ME: %s\n", __FUNCTION__); |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 547 | if (mei_sendrecv_mkhi(&mkhi, &reset, sizeof(reset), NULL, 0) < 0) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 548 | /* No response means reset will happen shortly... */ |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 549 | halt(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | /* If the ME responded it rejected the reset request */ |
| 553 | printk(BIOS_ERR, "ME: Global Reset failed\n"); |
| 554 | return -1; |
| 555 | } |
| 556 | #endif |
| 557 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 558 | /* Send END OF POST message to the ME */ |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 559 | static int __unused mkhi_end_of_post(void) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 560 | { |
| 561 | struct mkhi_header mkhi = { |
| 562 | .group_id = MKHI_GROUP_ID_GEN, |
| 563 | .command = MKHI_END_OF_POST, |
| 564 | }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 565 | u32 eop_ack; |
| 566 | |
| 567 | /* Send request and wait for response */ |
| 568 | printk(BIOS_NOTICE, "ME: %s\n", __FUNCTION__); |
Duncan Laurie | 2017b4a | 2013-08-08 15:07:12 -0700 | [diff] [blame] | 569 | if (mei_sendrecv_mkhi(&mkhi, NULL, 0, &eop_ack, sizeof(eop_ack)) < 0) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 570 | printk(BIOS_ERR, "ME: END OF POST message failed\n"); |
| 571 | return -1; |
| 572 | } |
| 573 | |
| 574 | printk(BIOS_INFO, "ME: END OF POST message successful (%d)\n", eop_ack); |
| 575 | return 0; |
| 576 | } |
| 577 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 578 | #ifdef __SIMPLE_DEVICE__ |
| 579 | |
Duncan Laurie | af98062 | 2013-07-18 23:02:18 -0700 | [diff] [blame] | 580 | void intel_me_finalize_smm(void) |
| 581 | { |
| 582 | struct me_hfs hfs; |
| 583 | u32 reg32; |
| 584 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 585 | mei_base_address = (u32 *) |
| 586 | (pci_read_config32(PCH_ME_DEV, PCI_BASE_ADDRESS_0) & ~0xf); |
Duncan Laurie | af98062 | 2013-07-18 23:02:18 -0700 | [diff] [blame] | 587 | |
| 588 | /* S3 path will have hidden this device already */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 589 | if (!mei_base_address || mei_base_address == (u32 *)0xfffffff0) |
Duncan Laurie | af98062 | 2013-07-18 23:02:18 -0700 | [diff] [blame] | 590 | return; |
| 591 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 592 | #if CONFIG(ME_MBP_CLEAR_LATE) |
Duncan Laurie | 3d299c4 | 2013-07-19 08:48:05 -0700 | [diff] [blame] | 593 | /* Wait for ME MBP Cleared indicator */ |
| 594 | intel_me_mbp_clear(PCH_ME_DEV); |
| 595 | #endif |
| 596 | |
Duncan Laurie | af98062 | 2013-07-18 23:02:18 -0700 | [diff] [blame] | 597 | /* Make sure ME is in a mode that expects EOP */ |
| 598 | reg32 = pci_read_config32(PCH_ME_DEV, PCI_ME_HFS); |
| 599 | memcpy(&hfs, ®32, sizeof(u32)); |
| 600 | |
| 601 | /* Abort and leave device alone if not normal mode */ |
| 602 | if (hfs.fpt_bad || |
| 603 | hfs.working_state != ME_HFS_CWS_NORMAL || |
| 604 | hfs.operation_mode != ME_HFS_MODE_NORMAL) |
| 605 | return; |
| 606 | |
| 607 | /* Try to send EOP command so ME stops accepting other commands */ |
| 608 | mkhi_end_of_post(); |
| 609 | |
| 610 | /* Make sure IO is disabled */ |
| 611 | reg32 = pci_read_config32(PCH_ME_DEV, PCI_COMMAND); |
| 612 | reg32 &= ~(PCI_COMMAND_MASTER | |
| 613 | PCI_COMMAND_MEMORY | PCI_COMMAND_IO); |
| 614 | pci_write_config32(PCH_ME_DEV, PCI_COMMAND, reg32); |
| 615 | |
| 616 | /* Hide the PCI device */ |
| 617 | RCBA32_OR(FD2, PCH_DISABLE_MEI1); |
| 618 | } |
| 619 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 620 | #else /* !__SIMPLE_DEVICE__ */ |
Duncan Laurie | af98062 | 2013-07-18 23:02:18 -0700 | [diff] [blame] | 621 | |
Edward O'Callaghan | 97ccefd | 2015-01-07 15:53:00 +1100 | [diff] [blame] | 622 | static inline int mei_sendrecv_icc(struct icc_header *icc, |
| 623 | void *req_data, int req_bytes, |
| 624 | void *rsp_data, int rsp_bytes) |
| 625 | { |
| 626 | struct icc_header icc_rsp; |
| 627 | |
| 628 | /* Send header */ |
| 629 | if (mei_send_header(MEI_ADDRESS_ICC, MEI_HOST_ADDRESS, |
| 630 | icc, sizeof(*icc), req_bytes ? 0 : 1) < 0) |
| 631 | return -1; |
| 632 | |
| 633 | /* Send data if available */ |
| 634 | if (req_bytes && mei_send_data(MEI_ADDRESS_ICC, MEI_HOST_ADDRESS, |
| 635 | req_data, req_bytes) < 0) |
| 636 | return -1; |
| 637 | |
| 638 | /* Read header and data, if needed */ |
| 639 | if (rsp_bytes && mei_recv_msg(&icc_rsp, sizeof(icc_rsp), |
| 640 | rsp_data, rsp_bytes) < 0) |
| 641 | return -1; |
| 642 | |
| 643 | return 0; |
| 644 | } |
| 645 | |
Duncan Laurie | 0dc0d13 | 2013-08-08 15:31:51 -0700 | [diff] [blame] | 646 | static int me_icc_set_clock_enables(u32 mask) |
| 647 | { |
| 648 | struct icc_clock_enables_msg clk = { |
| 649 | .clock_enables = 0, /* Turn off specified clocks */ |
| 650 | .clock_mask = mask, |
| 651 | .no_response = 1, /* Do not expect response */ |
| 652 | }; |
| 653 | struct icc_header icc = { |
| 654 | .api_version = ICC_API_VERSION_LYNXPOINT, |
| 655 | .icc_command = ICC_SET_CLOCK_ENABLES, |
| 656 | .length = sizeof(clk), |
| 657 | }; |
| 658 | |
| 659 | /* Send request and wait for response */ |
| 660 | if (mei_sendrecv_icc(&icc, &clk, sizeof(clk), NULL, 0) < 0) { |
| 661 | printk(BIOS_ERR, "ME: ICC SET CLOCK ENABLES message failed\n"); |
| 662 | return -1; |
Duncan Laurie | 0dc0d13 | 2013-08-08 15:31:51 -0700 | [diff] [blame] | 663 | } |
| 664 | |
Elyes HAOUAS | 54f9424 | 2018-10-25 10:57:39 +0200 | [diff] [blame] | 665 | printk(BIOS_INFO, "ME: ICC SET CLOCK ENABLES 0x%08x\n", mask); |
Duncan Laurie | 0dc0d13 | 2013-08-08 15:31:51 -0700 | [diff] [blame] | 666 | return 0; |
| 667 | } |
| 668 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 669 | /* Determine the path that we should take based on ME status */ |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 670 | static me_bios_path intel_me_path(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 671 | { |
| 672 | me_bios_path path = ME_DISABLE_BIOS_PATH; |
| 673 | struct me_hfs hfs; |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 674 | struct me_hfs2 hfs2; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 675 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 676 | pci_read_dword_ptr(dev, &hfs, PCI_ME_HFS); |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 677 | pci_read_dword_ptr(dev, &hfs2, PCI_ME_HFS2); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 678 | |
| 679 | /* Check and dump status */ |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 680 | intel_me_status(&hfs, &hfs2); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 681 | |
| 682 | /* Check Current Working State */ |
| 683 | switch (hfs.working_state) { |
| 684 | case ME_HFS_CWS_NORMAL: |
| 685 | path = ME_NORMAL_BIOS_PATH; |
| 686 | break; |
| 687 | case ME_HFS_CWS_REC: |
| 688 | path = ME_RECOVERY_BIOS_PATH; |
| 689 | break; |
| 690 | default: |
| 691 | path = ME_DISABLE_BIOS_PATH; |
| 692 | break; |
| 693 | } |
| 694 | |
| 695 | /* Check Current Operation Mode */ |
| 696 | switch (hfs.operation_mode) { |
| 697 | case ME_HFS_MODE_NORMAL: |
| 698 | break; |
| 699 | case ME_HFS_MODE_DEBUG: |
| 700 | case ME_HFS_MODE_DIS: |
| 701 | case ME_HFS_MODE_OVER_JMPR: |
| 702 | case ME_HFS_MODE_OVER_MEI: |
| 703 | default: |
| 704 | path = ME_DISABLE_BIOS_PATH; |
| 705 | break; |
| 706 | } |
| 707 | |
| 708 | /* Check for any error code and valid firmware and MBP */ |
| 709 | if (hfs.error_code || hfs.fpt_bad) |
| 710 | path = ME_ERROR_BIOS_PATH; |
| 711 | |
| 712 | /* Check if the MBP is ready */ |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 713 | if (!hfs2.mbp_rdy) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 714 | printk(BIOS_CRIT, "%s: mbp is not ready!\n", |
| 715 | __FUNCTION__); |
| 716 | path = ME_ERROR_BIOS_PATH; |
| 717 | } |
| 718 | |
Kyösti Mälkki | be5317f | 2019-11-06 12:07:21 +0200 | [diff] [blame] | 719 | if (CONFIG(ELOG) && path != ME_NORMAL_BIOS_PATH) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 720 | struct elog_event_data_me_extended data = { |
| 721 | .current_working_state = hfs.working_state, |
| 722 | .operation_state = hfs.operation_state, |
| 723 | .operation_mode = hfs.operation_mode, |
| 724 | .error_code = hfs.error_code, |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 725 | .progress_code = hfs2.progress_code, |
| 726 | .current_pmevent = hfs2.current_pmevent, |
| 727 | .current_state = hfs2.current_state, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 728 | }; |
| 729 | elog_add_event_byte(ELOG_TYPE_MANAGEMENT_ENGINE, path); |
| 730 | elog_add_event_raw(ELOG_TYPE_MANAGEMENT_ENGINE_EXT, |
| 731 | &data, sizeof(data)); |
| 732 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 733 | |
| 734 | return path; |
| 735 | } |
| 736 | |
| 737 | /* Prepare ME for MEI messages */ |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 738 | static int intel_mei_setup(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 739 | { |
| 740 | struct resource *res; |
| 741 | struct mei_csr host; |
| 742 | u32 reg32; |
| 743 | |
| 744 | /* Find the MMIO base for the ME interface */ |
| 745 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 746 | if (!res || res->base == 0 || res->size == 0) { |
| 747 | printk(BIOS_DEBUG, "ME: MEI resource not present!\n"); |
| 748 | return -1; |
| 749 | } |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 750 | mei_base_address = (u32 *)(uintptr_t)res->base; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 751 | |
| 752 | /* Ensure Memory and Bus Master bits are set */ |
| 753 | reg32 = pci_read_config32(dev, PCI_COMMAND); |
| 754 | reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; |
| 755 | pci_write_config32(dev, PCI_COMMAND, reg32); |
| 756 | |
| 757 | /* Clean up status for next message */ |
| 758 | read_host_csr(&host); |
| 759 | host.interrupt_generate = 1; |
| 760 | host.ready = 1; |
| 761 | host.reset = 0; |
| 762 | write_host_csr(&host); |
| 763 | |
| 764 | return 0; |
| 765 | } |
| 766 | |
| 767 | /* Read the Extend register hash of ME firmware */ |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 768 | static int intel_me_extend_valid(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 769 | { |
| 770 | struct me_heres status; |
| 771 | u32 extend[8] = {0}; |
| 772 | int i, count = 0; |
| 773 | |
| 774 | pci_read_dword_ptr(dev, &status, PCI_ME_HERES); |
| 775 | if (!status.extend_feature_present) { |
| 776 | printk(BIOS_ERR, "ME: Extend Feature not present\n"); |
| 777 | return -1; |
| 778 | } |
| 779 | |
| 780 | if (!status.extend_reg_valid) { |
| 781 | printk(BIOS_ERR, "ME: Extend Register not valid\n"); |
| 782 | return -1; |
| 783 | } |
| 784 | |
| 785 | switch (status.extend_reg_algorithm) { |
| 786 | case PCI_ME_EXT_SHA1: |
| 787 | count = 5; |
| 788 | printk(BIOS_DEBUG, "ME: Extend SHA-1: "); |
| 789 | break; |
| 790 | case PCI_ME_EXT_SHA256: |
| 791 | count = 8; |
| 792 | printk(BIOS_DEBUG, "ME: Extend SHA-256: "); |
| 793 | break; |
| 794 | default: |
| 795 | printk(BIOS_ERR, "ME: Extend Algorithm %d unknown\n", |
| 796 | status.extend_reg_algorithm); |
| 797 | return -1; |
| 798 | } |
| 799 | |
| 800 | for (i = 0; i < count; ++i) { |
| 801 | extend[i] = pci_read_config32(dev, PCI_ME_HER(i)); |
| 802 | printk(BIOS_DEBUG, "%08x", extend[i]); |
| 803 | } |
| 804 | printk(BIOS_DEBUG, "\n"); |
| 805 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 806 | #if CONFIG(CHROMEOS) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 807 | /* Save hash in NVS for the OS to verify */ |
| 808 | chromeos_set_me_hash(extend, count); |
| 809 | #endif |
| 810 | |
| 811 | return 0; |
| 812 | } |
| 813 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 814 | /* Check whether ME is present and do basic init */ |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 815 | static void intel_me_init(struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 816 | { |
Duncan Laurie | 0dc0d13 | 2013-08-08 15:31:51 -0700 | [diff] [blame] | 817 | struct southbridge_intel_lynxpoint_config *config = dev->chip_info; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 818 | me_bios_path path = intel_me_path(dev); |
| 819 | me_bios_payload mbp_data; |
| 820 | |
| 821 | /* Do initial setup and determine the BIOS path */ |
| 822 | printk(BIOS_NOTICE, "ME: BIOS path: %s\n", me_bios_path_values[path]); |
| 823 | |
Duncan Laurie | 8056dc6 | 2013-07-22 08:47:43 -0700 | [diff] [blame] | 824 | if (path == ME_NORMAL_BIOS_PATH) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 825 | /* Validate the extend register */ |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 826 | intel_me_extend_valid(dev); |
| 827 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 828 | |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 829 | memset(&mbp_data, 0, sizeof(mbp_data)); |
| 830 | |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 831 | /* |
| 832 | * According to the ME9 BWG, BIOS is required to fetch MBP data in |
| 833 | * all boot flows except S3 Resume. |
| 834 | */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 835 | |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 836 | /* Prepare MEI MMIO interface */ |
| 837 | if (intel_mei_setup(dev) < 0) |
| 838 | return; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 839 | |
Duncan Laurie | 144f7b2 | 2013-05-01 11:27:58 -0700 | [diff] [blame] | 840 | if (intel_me_read_mbp(&mbp_data, dev)) |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 841 | return; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 842 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 843 | if (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= BIOS_DEBUG) { |
| 844 | me_print_fw_version(mbp_data.fw_version_name); |
Duncan Laurie | 144f7b2 | 2013-05-01 11:27:58 -0700 | [diff] [blame] | 845 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 846 | if (CONFIG(DEBUG_INTEL_ME)) |
| 847 | me_print_fwcaps(mbp_data.fw_capabilities); |
| 848 | |
| 849 | if (mbp_data.plat_time) { |
| 850 | printk(BIOS_DEBUG, "ME: Wake Event to ME Reset: %u ms\n", |
| 851 | mbp_data.plat_time->wake_event_mrst_time_ms); |
| 852 | printk(BIOS_DEBUG, "ME: ME Reset to Platform Reset: %u ms\n", |
| 853 | mbp_data.plat_time->mrst_pltrst_time_ms); |
| 854 | printk(BIOS_DEBUG, "ME: Platform Reset to CPU Reset: %u ms\n", |
| 855 | mbp_data.plat_time->pltrst_cpurst_time_ms); |
| 856 | } |
Duncan Laurie | 144f7b2 | 2013-05-01 11:27:58 -0700 | [diff] [blame] | 857 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 858 | |
Duncan Laurie | 0dc0d13 | 2013-08-08 15:31:51 -0700 | [diff] [blame] | 859 | /* Set clock enables according to devicetree */ |
| 860 | if (config && config->icc_clock_disable) |
| 861 | me_icc_set_clock_enables(config->icc_clock_disable); |
| 862 | |
Duncan Laurie | af98062 | 2013-07-18 23:02:18 -0700 | [diff] [blame] | 863 | /* |
| 864 | * Leave the ME unlocked. It will be locked via SMI command later. |
| 865 | */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 866 | } |
| 867 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 868 | static struct pci_operations pci_ops = { |
Subrata Banik | 4a0f071 | 2019-03-20 14:29:47 +0530 | [diff] [blame] | 869 | .set_subsystem = pci_dev_set_subsystem, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 870 | }; |
| 871 | |
Elyes HAOUAS | 1dcd8db | 2018-12-05 10:59:42 +0100 | [diff] [blame] | 872 | static void intel_me_enable(struct device *dev) |
Duncan Laurie | 8056dc6 | 2013-07-22 08:47:43 -0700 | [diff] [blame] | 873 | { |
Duncan Laurie | 8056dc6 | 2013-07-22 08:47:43 -0700 | [diff] [blame] | 874 | /* Avoid talking to the device in S3 path */ |
Kyösti Mälkki | c3ed886 | 2014-06-19 19:50:51 +0300 | [diff] [blame] | 875 | if (acpi_is_wakeup_s3()) { |
Duncan Laurie | 8056dc6 | 2013-07-22 08:47:43 -0700 | [diff] [blame] | 876 | dev->enabled = 0; |
| 877 | pch_disable_devfn(dev); |
| 878 | } |
Duncan Laurie | 8056dc6 | 2013-07-22 08:47:43 -0700 | [diff] [blame] | 879 | } |
| 880 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 881 | static struct device_operations device_ops = { |
| 882 | .read_resources = pci_dev_read_resources, |
| 883 | .set_resources = pci_dev_set_resources, |
| 884 | .enable_resources = pci_dev_enable_resources, |
Duncan Laurie | 8056dc6 | 2013-07-22 08:47:43 -0700 | [diff] [blame] | 885 | .enable = intel_me_enable, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 886 | .init = intel_me_init, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 887 | .ops_pci = &pci_ops, |
| 888 | }; |
| 889 | |
Duncan Laurie | 26e7dd7 | 2012-12-19 09:12:31 -0800 | [diff] [blame] | 890 | static const unsigned short pci_device_ids[] = { |
| 891 | 0x8c3a, /* Mobile */ |
| 892 | 0x9c3a, /* Low Power */ |
| 893 | 0 |
| 894 | }; |
| 895 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 896 | static const struct pci_driver intel_me __pci_driver = { |
| 897 | .ops = &device_ops, |
| 898 | .vendor = PCI_VENDOR_ID_INTEL, |
Duncan Laurie | 26e7dd7 | 2012-12-19 09:12:31 -0800 | [diff] [blame] | 899 | .devices= pci_device_ids, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 900 | }; |
| 901 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 902 | #endif /* !__SIMPLE_DEVICE__ */ |
| 903 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 904 | /****************************************************************************** |
| 905 | * */ |
| 906 | static u32 me_to_host_words_pending(void) |
| 907 | { |
| 908 | struct mei_csr me; |
| 909 | read_me_csr(&me); |
| 910 | if (!me.ready) |
| 911 | return 0; |
| 912 | return (me.buffer_write_ptr - me.buffer_read_ptr) & |
| 913 | (me.buffer_depth - 1); |
| 914 | } |
| 915 | |
| 916 | #if 0 |
| 917 | /* This function is not yet being used, keep it in for the future. */ |
| 918 | static u32 host_to_me_words_room(void) |
| 919 | { |
| 920 | struct mei_csr csr; |
| 921 | |
| 922 | read_me_csr(&csr); |
| 923 | if (!csr.ready) |
| 924 | return 0; |
| 925 | |
| 926 | read_host_csr(&csr); |
| 927 | return (csr.buffer_read_ptr - csr.buffer_write_ptr - 1) & |
| 928 | (csr.buffer_depth - 1); |
| 929 | } |
| 930 | #endif |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 931 | |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 932 | struct mbp_payload { |
| 933 | mbp_header header; |
| 934 | u32 data[0]; |
| 935 | }; |
| 936 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 937 | /* |
| 938 | * mbp seems to be following its own flow, let's retrieve it in a dedicated |
| 939 | * function. |
| 940 | */ |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 941 | static int __unused intel_me_read_mbp(me_bios_payload *mbp_data, struct device *dev) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 942 | { |
| 943 | mbp_header mbp_hdr; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 944 | u32 me2host_pending; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 945 | struct mei_csr host; |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 946 | struct me_hfs2 hfs2; |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 947 | struct mbp_payload *mbp; |
| 948 | int i; |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 949 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 950 | #ifdef __SIMPLE_DEVICE__ |
| 951 | pci_read_dword_ptr(PCI_BDF(dev), &hfs2, PCI_ME_HFS2); |
| 952 | #else |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 953 | pci_read_dword_ptr(dev, &hfs2, PCI_ME_HFS2); |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 954 | #endif |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 955 | |
| 956 | if (!hfs2.mbp_rdy) { |
| 957 | printk(BIOS_ERR, "ME: MBP not ready\n"); |
| 958 | goto mbp_failure; |
| 959 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 960 | |
| 961 | me2host_pending = me_to_host_words_pending(); |
| 962 | if (!me2host_pending) { |
| 963 | printk(BIOS_ERR, "ME: no mbp data!\n"); |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 964 | goto mbp_failure; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 965 | } |
| 966 | |
| 967 | /* we know for sure that at least the header is there */ |
| 968 | mei_read_dword_ptr(&mbp_hdr, MEI_ME_CB_RW); |
| 969 | |
| 970 | if ((mbp_hdr.num_entries > (mbp_hdr.mbp_size / 2)) || |
| 971 | (me2host_pending < mbp_hdr.mbp_size)) { |
| 972 | printk(BIOS_ERR, "ME: mbp of %d entries, total size %d words" |
| 973 | " buffer contains %d words\n", |
| 974 | mbp_hdr.num_entries, mbp_hdr.mbp_size, |
| 975 | me2host_pending); |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 976 | goto mbp_failure; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 977 | } |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 978 | mbp = malloc(mbp_hdr.mbp_size * sizeof(u32)); |
| 979 | if (!mbp) |
| 980 | goto mbp_failure; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 981 | |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 982 | mbp->header = mbp_hdr; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 983 | me2host_pending--; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 984 | |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 985 | i = 0; |
| 986 | while (i != me2host_pending) { |
| 987 | mei_read_dword_ptr(&mbp->data[i], MEI_ME_CB_RW); |
| 988 | i++; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 989 | } |
| 990 | |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 991 | /* Signal to the ME that the host has finished reading the MBP. */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 992 | read_host_csr(&host); |
| 993 | host.interrupt_generate = 1; |
| 994 | write_host_csr(&host); |
| 995 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 996 | #if !CONFIG(ME_MBP_CLEAR_LATE) |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 997 | /* Wait for the mbp_cleared indicator. */ |
Duncan Laurie | 3d299c4 | 2013-07-19 08:48:05 -0700 | [diff] [blame] | 998 | intel_me_mbp_clear(dev); |
| 999 | #endif |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1000 | |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 1001 | /* Dump out the MBP contents. */ |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 1002 | if (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= BIOS_DEBUG) { |
| 1003 | printk(BIOS_INFO, "ME MBP: Header: items: %d, size dw: %d\n", |
| 1004 | mbp->header.num_entries, mbp->header.mbp_size); |
| 1005 | if (CONFIG(DEBUG_INTEL_ME)) { |
| 1006 | for (i = 0; i < mbp->header.mbp_size - 1; i++) { |
| 1007 | printk(BIOS_INFO, "ME MBP: %04x: 0x%08x\n", i, mbp->data[i]); |
| 1008 | } |
| 1009 | } |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 1010 | } |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 1011 | |
| 1012 | #define ASSIGN_FIELD_PTR(field_,val_) \ |
| 1013 | { \ |
| 1014 | mbp_data->field_ = (typeof(mbp_data->field_))(void *)val_; \ |
| 1015 | break; \ |
| 1016 | } |
| 1017 | /* Setup the pointers in the me_bios_payload structure. */ |
| 1018 | for (i = 0; i < mbp->header.mbp_size - 1;) { |
| 1019 | mbp_item_header *item = (void *)&mbp->data[i]; |
| 1020 | |
Elyes HAOUAS | f9de5a4 | 2018-05-03 17:21:02 +0200 | [diff] [blame] | 1021 | switch (MBP_MAKE_IDENT(item->app_id, item->item_id)) { |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 1022 | case MBP_IDENT(KERNEL, FW_VER): |
| 1023 | ASSIGN_FIELD_PTR(fw_version_name, &mbp->data[i+1]); |
| 1024 | |
| 1025 | case MBP_IDENT(ICC, PROFILE): |
| 1026 | ASSIGN_FIELD_PTR(icc_profile, &mbp->data[i+1]); |
| 1027 | |
| 1028 | case MBP_IDENT(INTEL_AT, STATE): |
| 1029 | ASSIGN_FIELD_PTR(at_state, &mbp->data[i+1]); |
| 1030 | |
| 1031 | case MBP_IDENT(KERNEL, FW_CAP): |
| 1032 | ASSIGN_FIELD_PTR(fw_capabilities, &mbp->data[i+1]); |
| 1033 | |
| 1034 | case MBP_IDENT(KERNEL, ROM_BIST): |
| 1035 | ASSIGN_FIELD_PTR(rom_bist_data, &mbp->data[i+1]); |
| 1036 | |
| 1037 | case MBP_IDENT(KERNEL, PLAT_KEY): |
| 1038 | ASSIGN_FIELD_PTR(platform_key, &mbp->data[i+1]); |
| 1039 | |
| 1040 | case MBP_IDENT(KERNEL, FW_TYPE): |
| 1041 | ASSIGN_FIELD_PTR(fw_plat_type, &mbp->data[i+1]); |
| 1042 | |
| 1043 | case MBP_IDENT(KERNEL, MFS_FAILURE): |
| 1044 | ASSIGN_FIELD_PTR(mfsintegrity, &mbp->data[i+1]); |
| 1045 | |
Duncan Laurie | 144f7b2 | 2013-05-01 11:27:58 -0700 | [diff] [blame] | 1046 | case MBP_IDENT(KERNEL, PLAT_TIME): |
| 1047 | ASSIGN_FIELD_PTR(plat_time, &mbp->data[i+1]); |
| 1048 | |
| 1049 | case MBP_IDENT(NFC, SUPPORT_DATA): |
| 1050 | ASSIGN_FIELD_PTR(nfc_data, &mbp->data[i+1]); |
| 1051 | |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 1052 | default: |
Duncan Laurie | 0b3cd36 | 2013-08-08 15:40:01 -0700 | [diff] [blame] | 1053 | printk(BIOS_ERR, "ME MBP: unknown item 0x%x @ " |
| 1054 | "dw offset 0x%x\n", mbp->data[i], i); |
Aaron Durbin | be98524 | 2012-12-12 12:40:33 -0600 | [diff] [blame] | 1055 | break; |
| 1056 | } |
| 1057 | i += item->length; |
| 1058 | } |
| 1059 | #undef ASSIGN_FIELD_PTR |
| 1060 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1061 | return 0; |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 1062 | |
| 1063 | mbp_failure: |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 1064 | #ifdef __SIMPLE_DEVICE__ |
| 1065 | intel_me_mbp_give_up(PCI_BDF(dev)); |
| 1066 | #else |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 1067 | intel_me_mbp_give_up(dev); |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame^] | 1068 | #endif |
Aaron Durbin | 9aa031e | 2012-11-02 09:16:46 -0500 | [diff] [blame] | 1069 | return -1; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1070 | } |