[coreboot-gerrit] Change in coreboot[master]: soc/intel/skylake: Add support to print ME version

Furquan Shaikh (Code Review) gerrit at coreboot.org
Fri Feb 23 23:12:02 CET 2018


Furquan Shaikh has uploaded this change for review. ( https://review.coreboot.org/23857


Change subject: soc/intel/skylake: Add support to print ME version
......................................................................

soc/intel/skylake: Add support to print ME version

This change adds a boot state callback to print ME version after
DEV_ENABLE is complete. Information is printed only if UART_DEBUG is
enabled because talking to ME to get the firmware version adds ~1
second to boot time.

Change-Id: I360d5d7420950d5aa255df08be6d7123621b87a8
Signed-off-by: Furquan Shaikh <furquan at google.com>
---
M src/soc/intel/skylake/include/soc/me.h
M src/soc/intel/skylake/me.c
2 files changed, 78 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/57/23857/1

diff --git a/src/soc/intel/skylake/include/soc/me.h b/src/soc/intel/skylake/include/soc/me.h
index e4b6abf..590bfb7 100644
--- a/src/soc/intel/skylake/include/soc/me.h
+++ b/src/soc/intel/skylake/include/soc/me.h
@@ -202,9 +202,13 @@
 	} __packed fields;
 };
 
+#define MKHI_GEN_GROUP_ID	0xff
+
 /* Reset Request  */
 #define MKHI_GLOBAL_RESET	0x0b
 
+#define MKHI_GET_FW_VERSION	0x02
+
 #define GR_ORIGIN_BIOS_MEM_INIT	0x01
 #define GR_ORIGIN_BIOS_POST	0x02
 #define GR_ORIGIN_MEBX	0x03
diff --git a/src/soc/intel/skylake/me.c b/src/soc/intel/skylake/me.c
index 2569bcf..c9a0dfa 100644
--- a/src/soc/intel/skylake/me.c
+++ b/src/soc/intel/skylake/me.c
@@ -14,6 +14,7 @@
  */
 
 #include <arch/io.h>
+#include <bootstate.h>
 #include <commonlib/helpers.h>
 #include <compiler.h>
 #include <console/console.h>
@@ -203,6 +204,79 @@
 	"M0 kernel load",
 };
 
+static void print_me_version(void *unused)
+{
+	struct mkhi_hdr {
+		uint8_t group_id;
+		uint8_t command:7;
+		uint8_t is_resp:1;
+		uint8_t rsvd;
+		uint8_t result;
+	} __packed;
+
+	struct version {
+		uint16_t minor;
+		uint16_t major;
+		uint16_t build;
+		uint16_t hotfix;
+	} __packed;
+
+	struct fw_ver_resp {
+		struct mkhi_hdr hdr;
+		struct version code;
+		struct version rec;
+		struct version fitc;
+	} __packed;
+
+	struct mkhi_hdr fw_ver_msg = {
+		.group_id = MKHI_GEN_GROUP_ID,
+		.command = MKHI_GET_FW_VERSION,
+	};
+
+	struct fw_ver_resp resp;
+	size_t resp_size = sizeof(resp);
+	union me_hfs hfs;
+
+	/*
+	 * Print ME version only if UART debugging is enabled. Else, it takes ~1
+	 * second to talk to ME and get this information.
+	 */
+	if (!IS_ENABLED(CONFIG_UART_DEBUG))
+		return;
+
+	hfs.data = me_read_config32(PCI_ME_HFSTS1);
+	/*
+	 * This command can be run only if:
+	 * Working state is normal and
+	 * Operation mode is normal.
+	 */
+	if ((hfs.fields.working_state != ME_HFS_CWS_NORMAL) ||
+	    (hfs.fields.operation_mode != ME_HFS_MODE_NORMAL))
+		goto failed;
+
+	if (!heci_send(&fw_ver_msg, sizeof(fw_ver_msg), BIOS_HOST_ADD,
+		       HECI_MKHI_ADD))
+		goto failed;
+
+	if (!heci_receive(&resp, &resp_size))
+		goto failed;
+
+	if (resp.hdr.result)
+		goto failed;
+
+	printk(BIOS_DEBUG, "ME: Version : %d.%d.%d.%d\n", resp.code.major,
+	       resp.code.minor, resp.code.hotfix, resp.code.build);
+	return;
+
+failed:
+	printk(BIOS_DEBUG, "ME: Version : Unavailable\n");
+}
+/*
+ * This can't be put in intel_me_status because by the time control
+ * reaches there, ME doesn't respond to GET_FW_VERSION command.
+ */
+BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_EXIT, print_me_version, NULL);
+
 void intel_me_status(void)
 {
 	union me_hfs hfs;

-- 
To view, visit https://review.coreboot.org/23857
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I360d5d7420950d5aa255df08be6d7123621b87a8
Gerrit-Change-Number: 23857
Gerrit-PatchSet: 1
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180223/311948f4/attachment-0001.html>


More information about the coreboot-gerrit mailing list