1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <device/pci_ops.h>
12 /* Send END OF POST message to the ME */
13 static int me8_mkhi_end_of_post(void)
15 struct mkhi_header mkhi
= {
16 .group_id
= MKHI_GROUP_ID_GEN
,
17 .command
= MKHI_END_OF_POST
,
19 struct mei_header mei
= {
21 .host_address
= MEI_HOST_ADDRESS
,
22 .client_address
= MEI_ADDRESS_MKHI
,
23 .length
= sizeof(mkhi
),
28 /* Send request and wait for response */
29 printk(BIOS_NOTICE
, "ME: %s\n", __func__
);
30 if (mei_sendrecv(&mei
, &mkhi
, NULL
, &eop_ack
, sizeof(eop_ack
)) < 0) {
31 printk(BIOS_ERR
, "ME: END OF POST message failed\n");
35 printk(BIOS_INFO
, "ME: END OF POST message successful (%d)\n", eop_ack
);
39 /* Send END OF POST message to the ME */
40 static int me7_mkhi_end_of_post(void)
42 struct mkhi_header mkhi
= {
43 .group_id
= MKHI_GROUP_ID_GEN
,
44 .command
= MKHI_END_OF_POST
,
46 struct mei_header mei
= {
48 .host_address
= MEI_HOST_ADDRESS
,
49 .client_address
= MEI_ADDRESS_MKHI
,
50 .length
= sizeof(mkhi
),
53 /* Send request and wait for response */
54 if (mei_sendrecv(&mei
, &mkhi
, NULL
, NULL
, 0) < 0) {
55 printk(BIOS_ERR
, "ME: END OF POST message failed\n");
59 printk(BIOS_INFO
, "ME: END OF POST message successful\n");
63 void intel_me_finalize_smm(void)
67 update_mei_base_address();
69 /* S3 path will have hidden this device already */
70 if (!is_mei_base_address_valid())
73 /* Make sure ME is in a mode that expects EOP */
74 hfs
.raw
= pci_read_config32(PCH_ME_DEV
, PCI_ME_HFS
);
76 /* Abort and leave device alone if not normal mode */
78 hfs
.working_state
!= ME_HFS_CWS_NORMAL
||
79 hfs
.operation_mode
!= ME_HFS_MODE_NORMAL
)
82 /* Try to send EOP command so ME stops accepting other commands */
83 const u16 did
= pci_read_config16(PCH_ME_DEV
, PCI_DEVICE_ID
);
86 me7_mkhi_end_of_post();
89 me8_mkhi_end_of_post();
92 printk(BIOS_ERR
, "No finalize handler for ME %04x.\n", did
);
95 /* Make sure IO is disabled */
96 pci_and_config16(PCH_ME_DEV
, PCI_COMMAND
,
97 ~(PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
| PCI_COMMAND_IO
));
99 /* Hide the PCI device */
100 RCBA32_OR(FD2
, PCH_DISABLE_MEI1
);