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