xref: /openbmc/u-boot/arch/x86/cpu/intel_common/me_status.c (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0
28b900a41SSimon Glass /*
38b900a41SSimon Glass  * From Coreboot src/southbridge/intel/bd82x6x/me_status.c
48b900a41SSimon Glass  *
58b900a41SSimon Glass  * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
68b900a41SSimon Glass  */
78b900a41SSimon Glass 
88b900a41SSimon Glass #include <common.h>
98b900a41SSimon Glass #include <asm/arch/me.h>
108b900a41SSimon Glass 
118b900a41SSimon Glass /* HFS1[3:0] Current Working State Values */
128b900a41SSimon Glass static const char *const me_cws_values[] = {
138b900a41SSimon Glass 	[ME_HFS_CWS_RESET]	= "Reset",
148b900a41SSimon Glass 	[ME_HFS_CWS_INIT]	= "Initializing",
158b900a41SSimon Glass 	[ME_HFS_CWS_REC]	= "Recovery",
168b900a41SSimon Glass 	[ME_HFS_CWS_NORMAL]	= "Normal",
178b900a41SSimon Glass 	[ME_HFS_CWS_WAIT]	= "Platform Disable Wait",
188b900a41SSimon Glass 	[ME_HFS_CWS_TRANS]	= "OP State Transition",
198b900a41SSimon Glass 	[ME_HFS_CWS_INVALID]	= "Invalid CPU Plugged In"
208b900a41SSimon Glass };
218b900a41SSimon Glass 
228b900a41SSimon Glass /* HFS1[8:6] Current Operation State Values */
238b900a41SSimon Glass static const char *const me_opstate_values[] = {
248b900a41SSimon Glass 	[ME_HFS_STATE_PREBOOT]	= "Preboot",
258b900a41SSimon Glass 	[ME_HFS_STATE_M0_UMA]	= "M0 with UMA",
268b900a41SSimon Glass 	[ME_HFS_STATE_M3]	= "M3 without UMA",
278b900a41SSimon Glass 	[ME_HFS_STATE_M0]	= "M0 without UMA",
288b900a41SSimon Glass 	[ME_HFS_STATE_BRINGUP]	= "Bring up",
298b900a41SSimon Glass 	[ME_HFS_STATE_ERROR]	= "M0 without UMA but with error"
308b900a41SSimon Glass };
318b900a41SSimon Glass 
328b900a41SSimon Glass /* HFS[19:16] Current Operation Mode Values */
338b900a41SSimon Glass static const char *const me_opmode_values[] = {
348b900a41SSimon Glass 	[ME_HFS_MODE_NORMAL]	= "Normal",
358b900a41SSimon Glass 	[ME_HFS_MODE_DEBUG]	= "Debug",
368b900a41SSimon Glass 	[ME_HFS_MODE_DIS]	= "Soft Temporary Disable",
378b900a41SSimon Glass 	[ME_HFS_MODE_OVER_JMPR]	= "Security Override via Jumper",
388b900a41SSimon Glass 	[ME_HFS_MODE_OVER_MEI]	= "Security Override via MEI Message"
398b900a41SSimon Glass };
408b900a41SSimon Glass 
418b900a41SSimon Glass /* HFS[15:12] Error Code Values */
428b900a41SSimon Glass static const char *const me_error_values[] = {
438b900a41SSimon Glass 	[ME_HFS_ERROR_NONE]	= "No Error",
448b900a41SSimon Glass 	[ME_HFS_ERROR_UNCAT]	= "Uncategorized Failure",
458b900a41SSimon Glass 	[ME_HFS_ERROR_IMAGE]	= "Image Failure",
468b900a41SSimon Glass 	[ME_HFS_ERROR_DEBUG]	= "Debug Failure"
478b900a41SSimon Glass };
488b900a41SSimon Glass 
498b900a41SSimon Glass /* GMES[31:28] ME Progress Code */
508b900a41SSimon Glass static const char *const me_progress_values[] = {
518b900a41SSimon Glass 	[ME_GMES_PHASE_ROM]	= "ROM Phase",
528b900a41SSimon Glass 	[ME_GMES_PHASE_BUP]	= "BUP Phase",
538b900a41SSimon Glass 	[ME_GMES_PHASE_UKERNEL]	= "uKernel Phase",
548b900a41SSimon Glass 	[ME_GMES_PHASE_POLICY]	= "Policy Module",
558b900a41SSimon Glass 	[ME_GMES_PHASE_MODULE]	= "Module Loading",
568b900a41SSimon Glass 	[ME_GMES_PHASE_UNKNOWN]	= "Unknown",
578b900a41SSimon Glass 	[ME_GMES_PHASE_HOST]	= "Host Communication"
588b900a41SSimon Glass };
598b900a41SSimon Glass 
608b900a41SSimon Glass /* GMES[27:24] Power Management Event */
618b900a41SSimon Glass static const char *const me_pmevent_values[] = {
628b900a41SSimon Glass 	[0x00] = "Clean Moff->Mx wake",
638b900a41SSimon Glass 	[0x01] = "Moff->Mx wake after an error",
648b900a41SSimon Glass 	[0x02] = "Clean global reset",
658b900a41SSimon Glass 	[0x03] = "Global reset after an error",
668b900a41SSimon Glass 	[0x04] = "Clean Intel ME reset",
678b900a41SSimon Glass 	[0x05] = "Intel ME reset due to exception",
688b900a41SSimon Glass 	[0x06] = "Pseudo-global reset",
698b900a41SSimon Glass 	[0x07] = "S0/M0->Sx/M3",
708b900a41SSimon Glass 	[0x08] = "Sx/M3->S0/M0",
718b900a41SSimon Glass 	[0x09] = "Non-power cycle reset",
728b900a41SSimon Glass 	[0x0a] = "Power cycle reset through M3",
738b900a41SSimon Glass 	[0x0b] = "Power cycle reset through Moff",
748b900a41SSimon Glass 	[0x0c] = "Sx/Mx->Sx/Moff"
758b900a41SSimon Glass };
768b900a41SSimon Glass 
778b900a41SSimon Glass /* Progress Code 0 states */
788b900a41SSimon Glass static const char *const me_progress_rom_values[] = {
798b900a41SSimon Glass 	[0x00] = "BEGIN",
808b900a41SSimon Glass 	[0x06] = "DISABLE"
818b900a41SSimon Glass };
828b900a41SSimon Glass 
838b900a41SSimon Glass /* Progress Code 1 states */
848b900a41SSimon Glass static const char *const me_progress_bup_values[] = {
858b900a41SSimon Glass 	[0x00] = "Initialization starts",
868b900a41SSimon Glass 	[0x01] = "Disable the host wake event",
878b900a41SSimon Glass 	[0x04] = "Flow determination start process",
888b900a41SSimon Glass 	[0x08] = "Error reading/matching the VSCC table in the descriptor",
898b900a41SSimon Glass 	[0x0a] = "Check to see if straps say ME DISABLED",
908b900a41SSimon Glass 	[0x0b] = "Timeout waiting for PWROK",
918b900a41SSimon Glass 	[0x0d] = "Possibly handle BUP manufacturing override strap",
928b900a41SSimon Glass 	[0x11] = "Bringup in M3",
938b900a41SSimon Glass 	[0x12] = "Bringup in M0",
948b900a41SSimon Glass 	[0x13] = "Flow detection error",
958b900a41SSimon Glass 	[0x15] = "M3 clock switching error",
968b900a41SSimon Glass 	[0x18] = "M3 kernel load",
978b900a41SSimon Glass 	[0x1c] = "T34 missing - cannot program ICC",
988b900a41SSimon Glass 	[0x1f] = "Waiting for DID BIOS message",
998b900a41SSimon Glass 	[0x20] = "Waiting for DID BIOS message failure",
1008b900a41SSimon Glass 	[0x21] = "DID reported an error",
1018b900a41SSimon Glass 	[0x22] = "Enabling UMA",
1028b900a41SSimon Glass 	[0x23] = "Enabling UMA error",
1038b900a41SSimon Glass 	[0x24] = "Sending DID Ack to BIOS",
1048b900a41SSimon Glass 	[0x25] = "Sending DID Ack to BIOS error",
1058b900a41SSimon Glass 	[0x26] = "Switching clocks in M0",
1068b900a41SSimon Glass 	[0x27] = "Switching clocks in M0 error",
1078b900a41SSimon Glass 	[0x28] = "ME in temp disable",
1088b900a41SSimon Glass 	[0x32] = "M0 kernel load",
1098b900a41SSimon Glass };
1108b900a41SSimon Glass 
1118b900a41SSimon Glass /* Progress Code 3 states */
1128b900a41SSimon Glass static const char *const me_progress_policy_values[] = {
1138b900a41SSimon Glass 	[0x00] = "Entery into Policy Module",
1148b900a41SSimon Glass 	[0x03] = "Received S3 entry",
1158b900a41SSimon Glass 	[0x04] = "Received S4 entry",
1168b900a41SSimon Glass 	[0x05] = "Received S5 entry",
1178b900a41SSimon Glass 	[0x06] = "Received UPD entry",
1188b900a41SSimon Glass 	[0x07] = "Received PCR entry",
1198b900a41SSimon Glass 	[0x08] = "Received NPCR entry",
1208b900a41SSimon Glass 	[0x09] = "Received host wake",
1218b900a41SSimon Glass 	[0x0a] = "Received AC<>DC switch",
1228b900a41SSimon Glass 	[0x0b] = "Received DRAM Init Done",
1238b900a41SSimon Glass 	[0x0c] = "VSCC Data not found for flash device",
1248b900a41SSimon Glass 	[0x0d] = "VSCC Table is not valid",
1258b900a41SSimon Glass 	[0x0e] = "Flash Partition Boundary is outside address space",
1268b900a41SSimon Glass 	[0x0f] = "ME cannot access the chipset descriptor region",
1278b900a41SSimon Glass 	[0x10] = "Required VSCC values for flash parts do not match",
1288b900a41SSimon Glass };
1298b900a41SSimon Glass 
1308b900a41SSimon Glass 
1318b900a41SSimon Glass /**
1328b900a41SSimon Glass  * _intel_me_status() - Check Intel Management Engine status
1338b900a41SSimon Glass  *
1348b900a41SSimon Glass  * struct hfs:	Firmware status
1358b900a41SSimon Glass  * struct gmes:	Management engine status
1368b900a41SSimon Glass  */
_intel_me_status(struct me_hfs * hfs,struct me_gmes * gmes)1378b900a41SSimon Glass static void _intel_me_status(struct me_hfs *hfs, struct me_gmes *gmes)
1388b900a41SSimon Glass {
1398b900a41SSimon Glass 	/* Check Current States */
1408b900a41SSimon Glass 	debug("ME: FW Partition Table      : %s\n",
1418b900a41SSimon Glass 	      hfs->fpt_bad ? "BAD" : "OK");
1428b900a41SSimon Glass 	debug("ME: Bringup Loader Failure  : %s\n",
1438b900a41SSimon Glass 	      hfs->ft_bup_ld_flr ? "YES" : "NO");
1448b900a41SSimon Glass 	debug("ME: Firmware Init Complete  : %s\n",
1458b900a41SSimon Glass 	      hfs->fw_init_complete ? "YES" : "NO");
1468b900a41SSimon Glass 	debug("ME: Manufacturing Mode      : %s\n",
1478b900a41SSimon Glass 	      hfs->mfg_mode ? "YES" : "NO");
1488b900a41SSimon Glass 	debug("ME: Boot Options Present    : %s\n",
1498b900a41SSimon Glass 	      hfs->boot_options_present ? "YES" : "NO");
1508b900a41SSimon Glass 	debug("ME: Update In Progress      : %s\n",
1518b900a41SSimon Glass 	      hfs->update_in_progress ? "YES" : "NO");
1528b900a41SSimon Glass 	debug("ME: Current Working State   : %s\n",
1538b900a41SSimon Glass 	      me_cws_values[hfs->working_state]);
1548b900a41SSimon Glass 	debug("ME: Current Operation State : %s\n",
1558b900a41SSimon Glass 	      me_opstate_values[hfs->operation_state]);
1568b900a41SSimon Glass 	debug("ME: Current Operation Mode  : %s\n",
1578b900a41SSimon Glass 	      me_opmode_values[hfs->operation_mode]);
1588b900a41SSimon Glass 	debug("ME: Error Code              : %s\n",
1598b900a41SSimon Glass 	      me_error_values[hfs->error_code]);
1608b900a41SSimon Glass 	debug("ME: Progress Phase          : %s\n",
1618b900a41SSimon Glass 	      me_progress_values[gmes->progress_code]);
1628b900a41SSimon Glass 	debug("ME: Power Management Event  : %s\n",
1638b900a41SSimon Glass 	      me_pmevent_values[gmes->current_pmevent]);
1648b900a41SSimon Glass 
1658b900a41SSimon Glass 	debug("ME: Progress Phase State    : ");
1668b900a41SSimon Glass 	switch (gmes->progress_code) {
1678b900a41SSimon Glass 	case ME_GMES_PHASE_ROM:		/* ROM Phase */
1688b900a41SSimon Glass 		debug("%s", me_progress_rom_values[gmes->current_state]);
1698b900a41SSimon Glass 		break;
1708b900a41SSimon Glass 
1718b900a41SSimon Glass 	case ME_GMES_PHASE_BUP:		/* Bringup Phase */
1728b900a41SSimon Glass 		if (gmes->current_state < ARRAY_SIZE(me_progress_bup_values) &&
1738b900a41SSimon Glass 		    me_progress_bup_values[gmes->current_state])
1748b900a41SSimon Glass 			debug("%s",
1758b900a41SSimon Glass 			      me_progress_bup_values[gmes->current_state]);
1768b900a41SSimon Glass 		else
1778b900a41SSimon Glass 			debug("0x%02x", gmes->current_state);
1788b900a41SSimon Glass 		break;
1798b900a41SSimon Glass 
1808b900a41SSimon Glass 	case ME_GMES_PHASE_POLICY:	/* Policy Module Phase */
1818b900a41SSimon Glass 		if (gmes->current_state <
1828b900a41SSimon Glass 				ARRAY_SIZE(me_progress_policy_values) &&
1838b900a41SSimon Glass 		    me_progress_policy_values[gmes->current_state])
1848b900a41SSimon Glass 			debug("%s",
1858b900a41SSimon Glass 			      me_progress_policy_values[gmes->current_state]);
1868b900a41SSimon Glass 		else
1878b900a41SSimon Glass 			debug("0x%02x", gmes->current_state);
1888b900a41SSimon Glass 		break;
1898b900a41SSimon Glass 
1908b900a41SSimon Glass 	case ME_GMES_PHASE_HOST:	/* Host Communication Phase */
1918b900a41SSimon Glass 		if (!gmes->current_state)
1928b900a41SSimon Glass 			debug("Host communication established");
1938b900a41SSimon Glass 		else
1948b900a41SSimon Glass 			debug("0x%02x", gmes->current_state);
1958b900a41SSimon Glass 		break;
1968b900a41SSimon Glass 
1978b900a41SSimon Glass 	default:
1988b900a41SSimon Glass 		debug("Unknown 0x%02x", gmes->current_state);
1998b900a41SSimon Glass 	}
2008b900a41SSimon Glass 	debug("\n");
2018b900a41SSimon Glass }
2028b900a41SSimon Glass 
intel_me_status(struct udevice * me_dev)2038b900a41SSimon Glass void intel_me_status(struct udevice *me_dev)
2048b900a41SSimon Glass {
2058b900a41SSimon Glass 	struct me_hfs hfs;
2068b900a41SSimon Glass 	struct me_gmes gmes;
2078b900a41SSimon Glass 
2088b900a41SSimon Glass 	pci_read_dword_ptr(me_dev, &hfs, PCI_ME_HFS);
2098b900a41SSimon Glass 	pci_read_dword_ptr(me_dev, &gmes, PCI_ME_GMES);
2108b900a41SSimon Glass 
2118b900a41SSimon Glass 	_intel_me_status(&hfs, &gmes);
2128b900a41SSimon Glass }
213