Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 2 | |
| 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 Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 11 | #include <acpi/acpi.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 12 | #include <device/mmio.h> |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 13 | #include <device/device.h> |
| 14 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 15 | #include <device/pci_ops.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 16 | #include <console/console.h> |
| 17 | #include <device/pci_ids.h> |
| 18 | #include <device/pci_def.h> |
| 19 | #include <string.h> |
| 20 | #include <delay.h> |
Duncan Laurie | c1c9435 | 2012-07-13 10:11:54 -0700 | [diff] [blame] | 21 | #include <elog.h> |
Patrick Georgi | 546953c | 2014-11-29 10:38:17 +0100 | [diff] [blame] | 22 | #include <halt.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 23 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 24 | #include "me.h" |
| 25 | #include "pch.h" |
| 26 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 27 | #if CONFIG(CHROMEOS) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 28 | #include <vendorcode/google/chromeos/chromeos.h> |
Stefan Reinauer | 49058c0 | 2012-06-11 14:13:09 -0700 | [diff] [blame] | 29 | #include <vendorcode/google/chromeos/gnvs.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 30 | #endif |
| 31 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 32 | /* Path that the BIOS should take based on ME state */ |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 33 | static const char *me_bios_path_values[] __unused = { |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 34 | [ME_NORMAL_BIOS_PATH] = "Normal", |
| 35 | [ME_S3WAKE_BIOS_PATH] = "S3 Wake", |
| 36 | [ME_ERROR_BIOS_PATH] = "Error", |
| 37 | [ME_RECOVERY_BIOS_PATH] = "Recovery", |
| 38 | [ME_DISABLE_BIOS_PATH] = "Disable", |
| 39 | [ME_FIRMWARE_UPDATE_BIOS_PATH] = "Firmware Update", |
| 40 | }; |
| 41 | static int intel_me_read_mbp(me_bios_payload *mbp_data); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 42 | |
| 43 | /* MMIO base address for MEI interface */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 44 | static u32 *mei_base_address; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 45 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 46 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 47 | static void mei_dump(void *ptr, int dword, int offset, const char *type) |
| 48 | { |
| 49 | struct mei_csr *csr; |
| 50 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 51 | if (!CONFIG(DEBUG_INTEL_ME)) |
| 52 | return; |
| 53 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 54 | printk(BIOS_SPEW, "%-9s[%02x] : ", type, offset); |
| 55 | |
| 56 | switch (offset) { |
| 57 | case MEI_H_CSR: |
| 58 | case MEI_ME_CSR_HA: |
| 59 | csr = ptr; |
| 60 | if (!csr) { |
| 61 | printk(BIOS_SPEW, "ERROR: 0x%08x\n", dword); |
| 62 | break; |
| 63 | } |
| 64 | printk(BIOS_SPEW, "cbd=%u cbrp=%02u cbwp=%02u ready=%u " |
| 65 | "reset=%u ig=%u is=%u ie=%u\n", csr->buffer_depth, |
| 66 | csr->buffer_read_ptr, csr->buffer_write_ptr, |
| 67 | csr->ready, csr->reset, csr->interrupt_generate, |
| 68 | csr->interrupt_status, csr->interrupt_enable); |
| 69 | break; |
| 70 | case MEI_ME_CB_RW: |
| 71 | case MEI_H_CB_WW: |
| 72 | printk(BIOS_SPEW, "CB: 0x%08x\n", dword); |
| 73 | break; |
| 74 | default: |
| 75 | printk(BIOS_SPEW, "0x%08x\n", offset); |
| 76 | break; |
| 77 | } |
| 78 | } |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 79 | |
| 80 | /* |
| 81 | * ME/MEI access helpers using memcpy to avoid aliasing. |
| 82 | */ |
| 83 | |
| 84 | static inline void mei_read_dword_ptr(void *ptr, int offset) |
| 85 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 86 | u32 dword = read32(mei_base_address + (offset/sizeof(u32))); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 87 | memcpy(ptr, &dword, sizeof(dword)); |
| 88 | mei_dump(ptr, dword, offset, "READ"); |
| 89 | } |
| 90 | |
| 91 | static inline void mei_write_dword_ptr(void *ptr, int offset) |
| 92 | { |
| 93 | u32 dword = 0; |
| 94 | memcpy(&dword, ptr, sizeof(dword)); |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 95 | write32(mei_base_address + (offset/sizeof(u32)), dword); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 96 | mei_dump(ptr, dword, offset, "WRITE"); |
| 97 | } |
| 98 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 99 | #ifndef __SIMPLE_DEVICE__ |
Elyes HAOUAS | dc03528 | 2018-09-18 13:28:49 +0200 | [diff] [blame] | 100 | static inline void pci_read_dword_ptr(struct device *dev, void *ptr, int offset) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 101 | { |
| 102 | u32 dword = pci_read_config32(dev, offset); |
| 103 | memcpy(ptr, &dword, sizeof(dword)); |
| 104 | mei_dump(ptr, dword, offset, "PCI READ"); |
| 105 | } |
| 106 | #endif |
| 107 | |
| 108 | static inline void read_host_csr(struct mei_csr *csr) |
| 109 | { |
| 110 | mei_read_dword_ptr(csr, MEI_H_CSR); |
| 111 | } |
| 112 | |
| 113 | static inline void write_host_csr(struct mei_csr *csr) |
| 114 | { |
| 115 | mei_write_dword_ptr(csr, MEI_H_CSR); |
| 116 | } |
| 117 | |
| 118 | static inline void read_me_csr(struct mei_csr *csr) |
| 119 | { |
| 120 | mei_read_dword_ptr(csr, MEI_ME_CSR_HA); |
| 121 | } |
| 122 | |
| 123 | static inline void write_cb(u32 dword) |
| 124 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 125 | write32(mei_base_address + (MEI_H_CB_WW/sizeof(u32)), dword); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 126 | mei_dump(NULL, dword, MEI_H_CB_WW, "WRITE"); |
| 127 | } |
| 128 | |
| 129 | static inline u32 read_cb(void) |
| 130 | { |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 131 | u32 dword = read32(mei_base_address + (MEI_ME_CB_RW/sizeof(u32))); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 132 | mei_dump(NULL, dword, MEI_ME_CB_RW, "READ"); |
| 133 | return dword; |
| 134 | } |
| 135 | |
| 136 | /* Wait for ME ready bit to be asserted */ |
| 137 | static int mei_wait_for_me_ready(void) |
| 138 | { |
| 139 | struct mei_csr me; |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 140 | unsigned int try = ME_RETRY; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 141 | |
| 142 | while (try--) { |
| 143 | read_me_csr(&me); |
| 144 | if (me.ready) |
| 145 | return 0; |
| 146 | udelay(ME_DELAY); |
| 147 | } |
| 148 | |
| 149 | printk(BIOS_ERR, "ME: failed to become ready\n"); |
| 150 | return -1; |
| 151 | } |
| 152 | |
| 153 | static void mei_reset(void) |
| 154 | { |
| 155 | struct mei_csr host; |
| 156 | |
| 157 | if (mei_wait_for_me_ready() < 0) |
| 158 | return; |
| 159 | |
| 160 | /* Reset host and ME circular buffers for next message */ |
| 161 | read_host_csr(&host); |
| 162 | host.reset = 1; |
| 163 | host.interrupt_generate = 1; |
| 164 | write_host_csr(&host); |
| 165 | |
| 166 | if (mei_wait_for_me_ready() < 0) |
| 167 | return; |
| 168 | |
| 169 | /* Re-init and indicate host is ready */ |
| 170 | read_host_csr(&host); |
| 171 | host.interrupt_generate = 1; |
| 172 | host.ready = 1; |
| 173 | host.reset = 0; |
| 174 | write_host_csr(&host); |
| 175 | } |
| 176 | |
| 177 | static int mei_send_msg(struct mei_header *mei, struct mkhi_header *mkhi, |
| 178 | void *req_data) |
| 179 | { |
| 180 | struct mei_csr host; |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 181 | unsigned int ndata, n; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 182 | u32 *data; |
| 183 | |
| 184 | /* Number of dwords to write, ignoring MKHI */ |
| 185 | ndata = mei->length >> 2; |
| 186 | |
| 187 | /* Pad non-dword aligned request message length */ |
| 188 | if (mei->length & 3) |
| 189 | ndata++; |
| 190 | if (!ndata) { |
| 191 | printk(BIOS_DEBUG, "ME: request does not include MKHI\n"); |
| 192 | return -1; |
| 193 | } |
| 194 | ndata++; /* Add MEI header */ |
| 195 | |
| 196 | /* |
| 197 | * Make sure there is still room left in the circular buffer. |
| 198 | * Reset the buffer pointers if the requested message will not fit. |
| 199 | */ |
| 200 | read_host_csr(&host); |
| 201 | if ((host.buffer_depth - host.buffer_write_ptr) < ndata) { |
| 202 | printk(BIOS_ERR, "ME: circular buffer full, resetting...\n"); |
| 203 | mei_reset(); |
| 204 | read_host_csr(&host); |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | * This implementation does not handle splitting large messages |
| 209 | * across multiple transactions. Ensure the requested length |
| 210 | * will fit in the available circular buffer depth. |
| 211 | */ |
| 212 | if ((host.buffer_depth - host.buffer_write_ptr) < ndata) { |
| 213 | printk(BIOS_ERR, "ME: message (%u) too large for buffer (%u)\n", |
| 214 | ndata + 2, host.buffer_depth); |
| 215 | return -1; |
| 216 | } |
| 217 | |
| 218 | /* Write MEI header */ |
| 219 | mei_write_dword_ptr(mei, MEI_H_CB_WW); |
| 220 | ndata--; |
| 221 | |
| 222 | /* Write MKHI header */ |
| 223 | mei_write_dword_ptr(mkhi, MEI_H_CB_WW); |
| 224 | ndata--; |
| 225 | |
| 226 | /* Write message data */ |
| 227 | data = req_data; |
| 228 | for (n = 0; n < ndata; ++n) |
| 229 | write_cb(*data++); |
| 230 | |
| 231 | /* Generate interrupt to the ME */ |
| 232 | read_host_csr(&host); |
| 233 | host.interrupt_generate = 1; |
| 234 | write_host_csr(&host); |
| 235 | |
| 236 | /* Make sure ME is ready after sending request data */ |
| 237 | return mei_wait_for_me_ready(); |
| 238 | } |
| 239 | |
| 240 | static int mei_recv_msg(struct mkhi_header *mkhi, |
| 241 | void *rsp_data, int rsp_bytes) |
| 242 | { |
| 243 | struct mei_header mei_rsp; |
| 244 | struct mkhi_header mkhi_rsp; |
| 245 | struct mei_csr me, host; |
Martin Roth | ff744bf | 2019-10-23 21:46:03 -0600 | [diff] [blame] | 246 | unsigned int ndata, n/*, me_data_len*/; |
| 247 | unsigned int expected; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 248 | u32 *data; |
| 249 | |
| 250 | /* Total number of dwords to read from circular buffer */ |
| 251 | expected = (rsp_bytes + sizeof(mei_rsp) + sizeof(mkhi_rsp)) >> 2; |
| 252 | if (rsp_bytes & 3) |
| 253 | expected++; |
| 254 | |
| 255 | /* |
| 256 | * The interrupt status bit does not appear to indicate that the |
| 257 | * message has actually been received. Instead we wait until the |
| 258 | * expected number of dwords are present in the circular buffer. |
| 259 | */ |
| 260 | for (n = ME_RETRY; n; --n) { |
| 261 | read_me_csr(&me); |
| 262 | if ((me.buffer_write_ptr - me.buffer_read_ptr) >= expected) |
| 263 | break; |
| 264 | udelay(ME_DELAY); |
| 265 | } |
| 266 | if (!n) { |
| 267 | printk(BIOS_ERR, "ME: timeout waiting for data: expected " |
| 268 | "%u, available %u\n", expected, |
| 269 | me.buffer_write_ptr - me.buffer_read_ptr); |
| 270 | return -1; |
| 271 | } |
| 272 | |
| 273 | /* Read and verify MEI response header from the ME */ |
| 274 | mei_read_dword_ptr(&mei_rsp, MEI_ME_CB_RW); |
| 275 | if (!mei_rsp.is_complete) { |
| 276 | printk(BIOS_ERR, "ME: response is not complete\n"); |
| 277 | return -1; |
| 278 | } |
| 279 | |
| 280 | /* Handle non-dword responses and expect at least MKHI header */ |
| 281 | ndata = mei_rsp.length >> 2; |
| 282 | if (mei_rsp.length & 3) |
| 283 | ndata++; |
| 284 | if (ndata != (expected - 1)) { |
| 285 | printk(BIOS_ERR, "ME: response is missing data %d != %d\n", |
| 286 | ndata, (expected - 1)); |
| 287 | return -1; |
| 288 | } |
| 289 | |
| 290 | /* Read and verify MKHI response header from the ME */ |
| 291 | mei_read_dword_ptr(&mkhi_rsp, MEI_ME_CB_RW); |
| 292 | if (!mkhi_rsp.is_response || |
| 293 | mkhi->group_id != mkhi_rsp.group_id || |
| 294 | mkhi->command != mkhi_rsp.command) { |
| 295 | printk(BIOS_ERR, "ME: invalid response, group %u ?= %u," |
| 296 | "command %u ?= %u, is_response %u\n", mkhi->group_id, |
| 297 | mkhi_rsp.group_id, mkhi->command, mkhi_rsp.command, |
| 298 | mkhi_rsp.is_response); |
| 299 | return -1; |
| 300 | } |
| 301 | ndata--; /* MKHI header has been read */ |
| 302 | |
| 303 | /* Make sure caller passed a buffer with enough space */ |
| 304 | if (ndata != (rsp_bytes >> 2)) { |
| 305 | printk(BIOS_ERR, "ME: not enough room in response buffer: " |
| 306 | "%u != %u\n", ndata, rsp_bytes >> 2); |
| 307 | return -1; |
| 308 | } |
| 309 | |
| 310 | /* Read response data from the circular buffer */ |
| 311 | data = rsp_data; |
| 312 | for (n = 0; n < ndata; ++n) |
| 313 | *data++ = read_cb(); |
| 314 | |
| 315 | /* Tell the ME that we have consumed the response */ |
| 316 | read_host_csr(&host); |
| 317 | host.interrupt_status = 1; |
| 318 | host.interrupt_generate = 1; |
| 319 | write_host_csr(&host); |
| 320 | |
| 321 | return mei_wait_for_me_ready(); |
| 322 | } |
| 323 | |
| 324 | static inline int mei_sendrecv(struct mei_header *mei, struct mkhi_header *mkhi, |
| 325 | void *req_data, void *rsp_data, int rsp_bytes) |
| 326 | { |
| 327 | if (mei_send_msg(mei, mkhi, req_data) < 0) |
| 328 | return -1; |
| 329 | if (mei_recv_msg(mkhi, rsp_data, rsp_bytes) < 0) |
| 330 | return -1; |
| 331 | return 0; |
| 332 | } |
| 333 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 334 | static inline void print_cap(const char *name, int state) |
| 335 | { |
| 336 | printk(BIOS_DEBUG, "ME Capability: %-41s : %sabled\n", |
| 337 | name, state ? " en" : "dis"); |
| 338 | } |
| 339 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 340 | static void __unused me_print_fw_version(mbp_fw_version_name *vers_name) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 341 | { |
| 342 | if (!vers_name->major_version) { |
| 343 | printk(BIOS_ERR, "ME: mbp missing version report\n"); |
| 344 | return; |
| 345 | } |
| 346 | |
| 347 | printk(BIOS_DEBUG, "ME: found version %d.%d.%d.%d\n", |
| 348 | vers_name->major_version, vers_name->minor_version, |
| 349 | vers_name->hotfix_version, vers_name->build_version); |
| 350 | } |
| 351 | |
| 352 | /* Get ME Firmware Capabilities */ |
| 353 | static int mkhi_get_fwcaps(mefwcaps_sku *cap) |
| 354 | { |
| 355 | u32 rule_id = 0; |
| 356 | struct me_fwcaps cap_msg; |
| 357 | struct mkhi_header mkhi = { |
| 358 | .group_id = MKHI_GROUP_ID_FWCAPS, |
| 359 | .command = MKHI_FWCAPS_GET_RULE, |
| 360 | }; |
| 361 | struct mei_header mei = { |
| 362 | .is_complete = 1, |
| 363 | .host_address = MEI_HOST_ADDRESS, |
| 364 | .client_address = MEI_ADDRESS_MKHI, |
| 365 | .length = sizeof(mkhi) + sizeof(rule_id), |
| 366 | }; |
| 367 | |
| 368 | /* Send request and wait for response */ |
Edward O'Callaghan | 152e517 | 2014-07-13 00:28:05 +1000 | [diff] [blame] | 369 | if (mei_sendrecv(&mei, &mkhi, &rule_id, &cap_msg, sizeof(cap_msg)) < 0) { |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 370 | printk(BIOS_ERR, "ME: GET FWCAPS message failed\n"); |
| 371 | return -1; |
Edward O'Callaghan | 152e517 | 2014-07-13 00:28:05 +1000 | [diff] [blame] | 372 | } |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 373 | *cap = cap_msg.caps_sku; |
| 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | /* Get ME Firmware Capabilities */ |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 378 | static void __unused me_print_fwcaps(mbp_fw_caps *caps_section) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 379 | { |
| 380 | mefwcaps_sku *cap = &caps_section->fw_capabilities; |
| 381 | if (!caps_section->available) { |
| 382 | printk(BIOS_ERR, "ME: mbp missing fwcaps report\n"); |
| 383 | if (mkhi_get_fwcaps(cap)) |
| 384 | return; |
| 385 | } |
| 386 | |
| 387 | print_cap("Full Network manageability", cap->full_net); |
| 388 | print_cap("Regular Network manageability", cap->std_net); |
| 389 | print_cap("Manageability", cap->manageability); |
| 390 | print_cap("Small business technology", cap->small_business); |
| 391 | print_cap("Level III manageability", cap->l3manageability); |
| 392 | print_cap("IntelR Anti-Theft (AT)", cap->intel_at); |
| 393 | print_cap("IntelR Capability Licensing Service (CLS)", cap->intel_cls); |
| 394 | print_cap("IntelR Power Sharing Technology (MPC)", cap->intel_mpc); |
| 395 | print_cap("ICC Over Clocking", cap->icc_over_clocking); |
Edward O'Callaghan | 152e517 | 2014-07-13 00:28:05 +1000 | [diff] [blame] | 396 | print_cap("Protected Audio Video Path (PAVP)", cap->pavp); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 397 | print_cap("IPV6", cap->ipv6); |
| 398 | print_cap("KVM Remote Control (KVM)", cap->kvm); |
| 399 | print_cap("Outbreak Containment Heuristic (OCH)", cap->och); |
| 400 | print_cap("Virtual LAN (VLAN)", cap->vlan); |
| 401 | print_cap("TLS", cap->tls); |
| 402 | print_cap("Wireless LAN (WLAN)", cap->wlan); |
| 403 | } |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 404 | |
Duncan Laurie | 708f731 | 2012-07-10 15:15:41 -0700 | [diff] [blame] | 405 | /* Send END OF POST message to the ME */ |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 406 | static int __unused mkhi_end_of_post(void) |
Duncan Laurie | 708f731 | 2012-07-10 15:15:41 -0700 | [diff] [blame] | 407 | { |
| 408 | struct mkhi_header mkhi = { |
| 409 | .group_id = MKHI_GROUP_ID_GEN, |
| 410 | .command = MKHI_END_OF_POST, |
| 411 | }; |
| 412 | struct mei_header mei = { |
| 413 | .is_complete = 1, |
| 414 | .host_address = MEI_HOST_ADDRESS, |
| 415 | .client_address = MEI_ADDRESS_MKHI, |
| 416 | .length = sizeof(mkhi), |
| 417 | }; |
| 418 | |
| 419 | u32 eop_ack; |
| 420 | |
| 421 | /* Send request and wait for response */ |
| 422 | printk(BIOS_NOTICE, "ME: %s\n", __FUNCTION__); |
| 423 | if (mei_sendrecv(&mei, &mkhi, NULL, &eop_ack, sizeof(eop_ack)) < 0) { |
| 424 | printk(BIOS_ERR, "ME: END OF POST message failed\n"); |
| 425 | return -1; |
| 426 | } |
| 427 | |
| 428 | printk(BIOS_INFO, "ME: END OF POST message successful (%d)\n", eop_ack); |
| 429 | return 0; |
| 430 | } |
| 431 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 432 | #ifdef __SIMPLE_DEVICE__ |
| 433 | |
Stefan Reinauer | 998f3a2 | 2012-06-11 15:15:46 -0700 | [diff] [blame] | 434 | void intel_me8_finalize_smm(void) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 435 | { |
| 436 | struct me_hfs hfs; |
| 437 | u32 reg32; |
Elyes HAOUAS | 729c069 | 2020-04-28 19:50:44 +0200 | [diff] [blame] | 438 | u16 reg16; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 439 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 440 | mei_base_address = (void *) |
| 441 | (pci_read_config32(PCH_ME_DEV, PCI_BASE_ADDRESS_0) & ~0xf); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 442 | |
| 443 | /* S3 path will have hidden this device already */ |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 444 | if (!mei_base_address || mei_base_address == (u32 *)0xfffffff0) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 445 | return; |
| 446 | |
| 447 | /* Make sure ME is in a mode that expects EOP */ |
Kyösti Mälkki | fd98c65 | 2013-07-26 08:50:53 +0300 | [diff] [blame] | 448 | reg32 = pci_read_config32(PCH_ME_DEV, PCI_ME_HFS); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 449 | memcpy(&hfs, ®32, sizeof(u32)); |
| 450 | |
| 451 | /* Abort and leave device alone if not normal mode */ |
| 452 | if (hfs.fpt_bad || |
| 453 | hfs.working_state != ME_HFS_CWS_NORMAL || |
| 454 | hfs.operation_mode != ME_HFS_MODE_NORMAL) |
| 455 | return; |
| 456 | |
| 457 | /* Try to send EOP command so ME stops accepting other commands */ |
| 458 | mkhi_end_of_post(); |
| 459 | |
| 460 | /* Make sure IO is disabled */ |
Elyes HAOUAS | 729c069 | 2020-04-28 19:50:44 +0200 | [diff] [blame] | 461 | reg16 = pci_read_config16(PCH_ME_DEV, PCI_COMMAND); |
| 462 | reg16 &= ~(PCI_COMMAND_MASTER | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 463 | PCI_COMMAND_MEMORY | PCI_COMMAND_IO); |
Elyes HAOUAS | 729c069 | 2020-04-28 19:50:44 +0200 | [diff] [blame] | 464 | pci_write_config16(PCH_ME_DEV, PCI_COMMAND, reg16); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 465 | |
| 466 | /* Hide the PCI device */ |
| 467 | RCBA32_OR(FD2, PCH_DISABLE_MEI1); |
| 468 | } |
| 469 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 470 | #else /* !__SIMPLE_DEVICE__ */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 471 | |
| 472 | /* Determine the path that we should take based on ME status */ |
Elyes HAOUAS | dc03528 | 2018-09-18 13:28:49 +0200 | [diff] [blame] | 473 | static me_bios_path intel_me_path(struct device *dev) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 474 | { |
| 475 | me_bios_path path = ME_DISABLE_BIOS_PATH; |
| 476 | struct me_hfs hfs; |
| 477 | struct me_gmes gmes; |
| 478 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 479 | /* S3 wake skips all MKHI messages */ |
Kyösti Mälkki | c3ed886 | 2014-06-19 19:50:51 +0300 | [diff] [blame] | 480 | if (acpi_is_wakeup_s3()) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 481 | return ME_S3WAKE_BIOS_PATH; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 482 | |
| 483 | pci_read_dword_ptr(dev, &hfs, PCI_ME_HFS); |
| 484 | pci_read_dword_ptr(dev, &gmes, PCI_ME_GMES); |
| 485 | |
| 486 | /* Check and dump status */ |
| 487 | intel_me_status(&hfs, &gmes); |
| 488 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 489 | /* Check Current Working State */ |
| 490 | switch (hfs.working_state) { |
| 491 | case ME_HFS_CWS_NORMAL: |
| 492 | path = ME_NORMAL_BIOS_PATH; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 493 | break; |
| 494 | case ME_HFS_CWS_REC: |
| 495 | path = ME_RECOVERY_BIOS_PATH; |
| 496 | break; |
| 497 | default: |
| 498 | path = ME_DISABLE_BIOS_PATH; |
| 499 | break; |
| 500 | } |
| 501 | |
| 502 | /* Check Current Operation Mode */ |
| 503 | switch (hfs.operation_mode) { |
| 504 | case ME_HFS_MODE_NORMAL: |
| 505 | break; |
| 506 | case ME_HFS_MODE_DEBUG: |
| 507 | case ME_HFS_MODE_DIS: |
| 508 | case ME_HFS_MODE_OVER_JMPR: |
| 509 | case ME_HFS_MODE_OVER_MEI: |
| 510 | default: |
| 511 | path = ME_DISABLE_BIOS_PATH; |
| 512 | break; |
| 513 | } |
| 514 | |
Duncan Laurie | 5c88c6f | 2012-09-01 14:00:23 -0700 | [diff] [blame] | 515 | /* Check for any error code and valid firmware and MBP */ |
| 516 | if (hfs.error_code || hfs.fpt_bad) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 517 | path = ME_ERROR_BIOS_PATH; |
| 518 | |
Duncan Laurie | 5c88c6f | 2012-09-01 14:00:23 -0700 | [diff] [blame] | 519 | /* Check if the MBP is ready */ |
| 520 | if (!gmes.mbp_rdy) { |
| 521 | printk(BIOS_CRIT, "%s: mbp is not ready!\n", |
| 522 | __FUNCTION__); |
| 523 | path = ME_ERROR_BIOS_PATH; |
| 524 | } |
| 525 | |
Kyösti Mälkki | be5317f | 2019-11-06 12:07:21 +0200 | [diff] [blame] | 526 | if (CONFIG(ELOG) && path != ME_NORMAL_BIOS_PATH) { |
Duncan Laurie | 5c88c6f | 2012-09-01 14:00:23 -0700 | [diff] [blame] | 527 | struct elog_event_data_me_extended data = { |
| 528 | .current_working_state = hfs.working_state, |
| 529 | .operation_state = hfs.operation_state, |
| 530 | .operation_mode = hfs.operation_mode, |
| 531 | .error_code = hfs.error_code, |
| 532 | .progress_code = gmes.progress_code, |
| 533 | .current_pmevent = gmes.current_pmevent, |
| 534 | .current_state = gmes.current_state, |
| 535 | }; |
| 536 | elog_add_event_byte(ELOG_TYPE_MANAGEMENT_ENGINE, path); |
| 537 | elog_add_event_raw(ELOG_TYPE_MANAGEMENT_ENGINE_EXT, |
| 538 | &data, sizeof(data)); |
| 539 | } |
Duncan Laurie | 5c88c6f | 2012-09-01 14:00:23 -0700 | [diff] [blame] | 540 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 541 | return path; |
| 542 | } |
| 543 | |
| 544 | /* Prepare ME for MEI messages */ |
Elyes HAOUAS | dc03528 | 2018-09-18 13:28:49 +0200 | [diff] [blame] | 545 | static int intel_mei_setup(struct device *dev) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 546 | { |
| 547 | struct resource *res; |
| 548 | struct mei_csr host; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 549 | |
| 550 | /* Find the MMIO base for the ME interface */ |
| 551 | res = find_resource(dev, PCI_BASE_ADDRESS_0); |
| 552 | if (!res || res->base == 0 || res->size == 0) { |
| 553 | printk(BIOS_DEBUG, "ME: MEI resource not present!\n"); |
| 554 | return -1; |
| 555 | } |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 556 | mei_base_address = (u32 *)(uintptr_t)res->base; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 557 | |
| 558 | /* Ensure Memory and Bus Master bits are set */ |
Elyes HAOUAS | 729c069 | 2020-04-28 19:50:44 +0200 | [diff] [blame] | 559 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 560 | |
| 561 | /* Clean up status for next message */ |
| 562 | read_host_csr(&host); |
| 563 | host.interrupt_generate = 1; |
| 564 | host.ready = 1; |
| 565 | host.reset = 0; |
| 566 | write_host_csr(&host); |
| 567 | |
| 568 | return 0; |
| 569 | } |
| 570 | |
| 571 | /* Read the Extend register hash of ME firmware */ |
Elyes HAOUAS | dc03528 | 2018-09-18 13:28:49 +0200 | [diff] [blame] | 572 | static int intel_me_extend_valid(struct device *dev) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 573 | { |
| 574 | struct me_heres status; |
Stefan Reinauer | 49058c0 | 2012-06-11 14:13:09 -0700 | [diff] [blame] | 575 | u32 extend[8] = {0}; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 576 | int i, count = 0; |
| 577 | |
| 578 | pci_read_dword_ptr(dev, &status, PCI_ME_HERES); |
| 579 | if (!status.extend_feature_present) { |
| 580 | printk(BIOS_ERR, "ME: Extend Feature not present\n"); |
| 581 | return -1; |
| 582 | } |
| 583 | |
| 584 | if (!status.extend_reg_valid) { |
| 585 | printk(BIOS_ERR, "ME: Extend Register not valid\n"); |
| 586 | return -1; |
| 587 | } |
| 588 | |
| 589 | switch (status.extend_reg_algorithm) { |
| 590 | case PCI_ME_EXT_SHA1: |
| 591 | count = 5; |
| 592 | printk(BIOS_DEBUG, "ME: Extend SHA-1: "); |
| 593 | break; |
| 594 | case PCI_ME_EXT_SHA256: |
| 595 | count = 8; |
| 596 | printk(BIOS_DEBUG, "ME: Extend SHA-256: "); |
| 597 | break; |
| 598 | default: |
| 599 | printk(BIOS_ERR, "ME: Extend Algorithm %d unknown\n", |
| 600 | status.extend_reg_algorithm); |
| 601 | return -1; |
| 602 | } |
| 603 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 604 | for (i = 0; i < count; ++i) { |
Stefan Reinauer | 49058c0 | 2012-06-11 14:13:09 -0700 | [diff] [blame] | 605 | extend[i] = pci_read_config32(dev, PCI_ME_HER(i)); |
| 606 | printk(BIOS_DEBUG, "%08x", extend[i]); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 607 | } |
| 608 | printk(BIOS_DEBUG, "\n"); |
| 609 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 610 | #if CONFIG(CHROMEOS) |
Stefan Reinauer | 49058c0 | 2012-06-11 14:13:09 -0700 | [diff] [blame] | 611 | /* Save hash in NVS for the OS to verify */ |
| 612 | chromeos_set_me_hash(extend, count); |
| 613 | #endif |
| 614 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 615 | return 0; |
| 616 | } |
| 617 | |
| 618 | /* Hide the ME virtual PCI devices */ |
Elyes HAOUAS | dc03528 | 2018-09-18 13:28:49 +0200 | [diff] [blame] | 619 | static void intel_me_hide(struct device *dev) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 620 | { |
| 621 | dev->enabled = 0; |
| 622 | pch_enable(dev); |
| 623 | } |
| 624 | |
| 625 | /* Check whether ME is present and do basic init */ |
Elyes HAOUAS | dc03528 | 2018-09-18 13:28:49 +0200 | [diff] [blame] | 626 | static void intel_me_init(struct device *dev) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 627 | { |
| 628 | me_bios_path path = intel_me_path(dev); |
| 629 | me_bios_payload mbp_data; |
| 630 | |
| 631 | /* Do initial setup and determine the BIOS path */ |
| 632 | printk(BIOS_NOTICE, "ME: BIOS path: %s\n", me_bios_path_values[path]); |
| 633 | |
| 634 | switch (path) { |
| 635 | case ME_S3WAKE_BIOS_PATH: |
| 636 | intel_me_hide(dev); |
| 637 | break; |
| 638 | |
| 639 | case ME_NORMAL_BIOS_PATH: |
| 640 | /* Validate the extend register */ |
| 641 | if (intel_me_extend_valid(dev) < 0) |
| 642 | break; /* TODO: force recovery mode */ |
| 643 | |
| 644 | /* Prepare MEI MMIO interface */ |
| 645 | if (intel_mei_setup(dev) < 0) |
| 646 | break; |
| 647 | |
Elyes HAOUAS | ba28e8d | 2016-08-31 19:22:16 +0200 | [diff] [blame] | 648 | if (intel_me_read_mbp(&mbp_data)) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 649 | break; |
| 650 | |
Kyösti Mälkki | c86fc8e | 2019-11-06 06:32:27 +0200 | [diff] [blame] | 651 | if (CONFIG_DEFAULT_CONSOLE_LOGLEVEL >= BIOS_DEBUG) { |
| 652 | me_print_fw_version(&mbp_data.fw_version_name); |
| 653 | me_print_fwcaps(&mbp_data.fw_caps_sku); |
| 654 | } |
Duncan Laurie | 708f731 | 2012-07-10 15:15:41 -0700 | [diff] [blame] | 655 | |
| 656 | /* |
| 657 | * Leave the ME unlocked in this path. |
| 658 | * It will be locked via SMI command later. |
| 659 | */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 660 | break; |
| 661 | |
| 662 | case ME_ERROR_BIOS_PATH: |
| 663 | case ME_RECOVERY_BIOS_PATH: |
| 664 | case ME_DISABLE_BIOS_PATH: |
| 665 | case ME_FIRMWARE_UPDATE_BIOS_PATH: |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 666 | break; |
| 667 | } |
| 668 | } |
| 669 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 670 | static struct device_operations device_ops = { |
| 671 | .read_resources = pci_dev_read_resources, |
| 672 | .set_resources = pci_dev_set_resources, |
| 673 | .enable_resources = pci_dev_enable_resources, |
| 674 | .init = intel_me_init, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 675 | .ops_pci = &pci_dev_ops_pci, |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 676 | }; |
| 677 | |
| 678 | static const struct pci_driver intel_me __pci_driver = { |
| 679 | .ops = &device_ops, |
| 680 | .vendor = PCI_VENDOR_ID_INTEL, |
| 681 | .device = 0x1e3a, |
| 682 | }; |
| 683 | |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 684 | #endif /* !__SIMPLE_DEVICE__ */ |
| 685 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 686 | /****************************************************************************** |
| 687 | * */ |
| 688 | static u32 me_to_host_words_pending(void) |
| 689 | { |
| 690 | struct mei_csr me; |
| 691 | read_me_csr(&me); |
| 692 | if (!me.ready) |
| 693 | return 0; |
| 694 | return (me.buffer_write_ptr - me.buffer_read_ptr) & |
| 695 | (me.buffer_depth - 1); |
| 696 | } |
| 697 | |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 698 | /* |
| 699 | * mbp seems to be following its own flow, let's retrieve it in a dedicated |
| 700 | * function. |
| 701 | */ |
Kyösti Mälkki | 21d6a27 | 2019-11-05 18:50:38 +0200 | [diff] [blame] | 702 | static int __unused intel_me_read_mbp(me_bios_payload *mbp_data) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 703 | { |
| 704 | mbp_header mbp_hdr; |
| 705 | mbp_item_header mbp_item_hdr; |
| 706 | u32 me2host_pending; |
| 707 | u32 mbp_item_id; |
| 708 | struct mei_csr host; |
| 709 | |
| 710 | me2host_pending = me_to_host_words_pending(); |
| 711 | if (!me2host_pending) { |
| 712 | printk(BIOS_ERR, "ME: no mbp data!\n"); |
| 713 | return -1; |
| 714 | } |
| 715 | |
| 716 | /* we know for sure that at least the header is there */ |
| 717 | mei_read_dword_ptr(&mbp_hdr, MEI_ME_CB_RW); |
| 718 | |
| 719 | if ((mbp_hdr.num_entries > (mbp_hdr.mbp_size / 2)) || |
| 720 | (me2host_pending < mbp_hdr.mbp_size)) { |
| 721 | printk(BIOS_ERR, "ME: mbp of %d entries, total size %d words" |
| 722 | " buffer contains %d words\n", |
| 723 | mbp_hdr.num_entries, mbp_hdr.mbp_size, |
| 724 | me2host_pending); |
| 725 | return -1; |
| 726 | } |
| 727 | |
| 728 | me2host_pending--; |
| 729 | memset(mbp_data, 0, sizeof(*mbp_data)); |
| 730 | |
| 731 | while (mbp_hdr.num_entries--) { |
Elyes HAOUAS | 448d9fb | 2018-05-22 12:51:27 +0200 | [diff] [blame] | 732 | u32 *copy_addr; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 733 | u32 copy_size, buffer_room; |
| 734 | void *p; |
| 735 | |
| 736 | if (!me2host_pending) { |
| 737 | printk(BIOS_ERR, "ME: no mbp data %d entries to go!\n", |
| 738 | mbp_hdr.num_entries + 1); |
| 739 | return -1; |
| 740 | } |
| 741 | |
| 742 | mei_read_dword_ptr(&mbp_item_hdr, MEI_ME_CB_RW); |
| 743 | |
| 744 | if (mbp_item_hdr.length > me2host_pending) { |
| 745 | printk(BIOS_ERR, "ME: insufficient mbp data %d " |
| 746 | "entries to go!\n", |
| 747 | mbp_hdr.num_entries + 1); |
| 748 | return -1; |
| 749 | } |
| 750 | |
| 751 | me2host_pending -= mbp_item_hdr.length; |
| 752 | |
| 753 | mbp_item_id = (((u32)mbp_item_hdr.item_id) << 8) + |
| 754 | mbp_item_hdr.app_id; |
| 755 | |
| 756 | copy_size = mbp_item_hdr.length - 1; |
| 757 | |
| 758 | #define SET_UP_COPY(field) { copy_addr = (u32 *)&mbp_data->field; \ |
| 759 | buffer_room = sizeof(mbp_data->field) / sizeof(u32); \ |
| 760 | break; \ |
| 761 | } |
| 762 | |
| 763 | p = &mbp_item_hdr; |
| 764 | printk(BIOS_INFO, "ME: MBP item header %8.8x\n", *((u32*)p)); |
| 765 | |
Elyes HAOUAS | f9de5a4 | 2018-05-03 17:21:02 +0200 | [diff] [blame] | 766 | switch (mbp_item_id) { |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 767 | case 0x101: |
| 768 | SET_UP_COPY(fw_version_name); |
| 769 | |
| 770 | case 0x102: |
| 771 | SET_UP_COPY(icc_profile); |
| 772 | |
| 773 | case 0x103: |
| 774 | SET_UP_COPY(at_state); |
| 775 | |
| 776 | case 0x201: |
| 777 | mbp_data->fw_caps_sku.available = 1; |
| 778 | SET_UP_COPY(fw_caps_sku.fw_capabilities); |
| 779 | |
| 780 | case 0x301: |
| 781 | SET_UP_COPY(rom_bist_data); |
| 782 | |
| 783 | case 0x401: |
| 784 | SET_UP_COPY(platform_key); |
| 785 | |
| 786 | case 0x501: |
| 787 | mbp_data->fw_plat_type.available = 1; |
| 788 | SET_UP_COPY(fw_plat_type.rule_data); |
| 789 | |
| 790 | case 0x601: |
| 791 | SET_UP_COPY(mfsintegrity); |
| 792 | |
| 793 | default: |
Vladimir Serbinenko | afc8d98 | 2014-06-11 18:52:55 +0000 | [diff] [blame] | 794 | printk(BIOS_ERR, "ME: unknown mbp item id 0x%x! Skipping\n", |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 795 | mbp_item_id); |
Elyes HAOUAS | ba28e8d | 2016-08-31 19:22:16 +0200 | [diff] [blame] | 796 | while (copy_size--) |
Vladimir Serbinenko | afc8d98 | 2014-06-11 18:52:55 +0000 | [diff] [blame] | 797 | read_cb(); |
| 798 | continue; |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | if (buffer_room != copy_size) { |
| 802 | printk(BIOS_ERR, "ME: buffer room %d != %d copy size" |
| 803 | " for item 0x%x!!!\n", |
| 804 | buffer_room, copy_size, mbp_item_id); |
| 805 | return -1; |
| 806 | } |
Elyes HAOUAS | ba28e8d | 2016-08-31 19:22:16 +0200 | [diff] [blame] | 807 | while (copy_size--) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 808 | *copy_addr++ = read_cb(); |
| 809 | } |
| 810 | |
| 811 | read_host_csr(&host); |
| 812 | host.interrupt_generate = 1; |
| 813 | write_host_csr(&host); |
| 814 | |
| 815 | { |
| 816 | int cntr = 0; |
Elyes HAOUAS | ba28e8d | 2016-08-31 19:22:16 +0200 | [diff] [blame] | 817 | while (host.interrupt_generate) { |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 818 | read_host_csr(&host); |
| 819 | cntr++; |
| 820 | } |
| 821 | printk(BIOS_SPEW, "ME: mbp read OK after %d cycles\n", cntr); |
| 822 | } |
| 823 | |
| 824 | return 0; |
| 825 | } |