xref: /OK3568_Linux_fs/u-boot/arch/x86/cpu/intel_common/me_status.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * From Coreboot src/southbridge/intel/bd82x6x/me_status.c
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <common.h>
10*4882a593Smuzhiyun #include <asm/arch/me.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /* HFS1[3:0] Current Working State Values */
13*4882a593Smuzhiyun static const char *const me_cws_values[] = {
14*4882a593Smuzhiyun 	[ME_HFS_CWS_RESET]	= "Reset",
15*4882a593Smuzhiyun 	[ME_HFS_CWS_INIT]	= "Initializing",
16*4882a593Smuzhiyun 	[ME_HFS_CWS_REC]	= "Recovery",
17*4882a593Smuzhiyun 	[ME_HFS_CWS_NORMAL]	= "Normal",
18*4882a593Smuzhiyun 	[ME_HFS_CWS_WAIT]	= "Platform Disable Wait",
19*4882a593Smuzhiyun 	[ME_HFS_CWS_TRANS]	= "OP State Transition",
20*4882a593Smuzhiyun 	[ME_HFS_CWS_INVALID]	= "Invalid CPU Plugged In"
21*4882a593Smuzhiyun };
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /* HFS1[8:6] Current Operation State Values */
24*4882a593Smuzhiyun static const char *const me_opstate_values[] = {
25*4882a593Smuzhiyun 	[ME_HFS_STATE_PREBOOT]	= "Preboot",
26*4882a593Smuzhiyun 	[ME_HFS_STATE_M0_UMA]	= "M0 with UMA",
27*4882a593Smuzhiyun 	[ME_HFS_STATE_M3]	= "M3 without UMA",
28*4882a593Smuzhiyun 	[ME_HFS_STATE_M0]	= "M0 without UMA",
29*4882a593Smuzhiyun 	[ME_HFS_STATE_BRINGUP]	= "Bring up",
30*4882a593Smuzhiyun 	[ME_HFS_STATE_ERROR]	= "M0 without UMA but with error"
31*4882a593Smuzhiyun };
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /* HFS[19:16] Current Operation Mode Values */
34*4882a593Smuzhiyun static const char *const me_opmode_values[] = {
35*4882a593Smuzhiyun 	[ME_HFS_MODE_NORMAL]	= "Normal",
36*4882a593Smuzhiyun 	[ME_HFS_MODE_DEBUG]	= "Debug",
37*4882a593Smuzhiyun 	[ME_HFS_MODE_DIS]	= "Soft Temporary Disable",
38*4882a593Smuzhiyun 	[ME_HFS_MODE_OVER_JMPR]	= "Security Override via Jumper",
39*4882a593Smuzhiyun 	[ME_HFS_MODE_OVER_MEI]	= "Security Override via MEI Message"
40*4882a593Smuzhiyun };
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /* HFS[15:12] Error Code Values */
43*4882a593Smuzhiyun static const char *const me_error_values[] = {
44*4882a593Smuzhiyun 	[ME_HFS_ERROR_NONE]	= "No Error",
45*4882a593Smuzhiyun 	[ME_HFS_ERROR_UNCAT]	= "Uncategorized Failure",
46*4882a593Smuzhiyun 	[ME_HFS_ERROR_IMAGE]	= "Image Failure",
47*4882a593Smuzhiyun 	[ME_HFS_ERROR_DEBUG]	= "Debug Failure"
48*4882a593Smuzhiyun };
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /* GMES[31:28] ME Progress Code */
51*4882a593Smuzhiyun static const char *const me_progress_values[] = {
52*4882a593Smuzhiyun 	[ME_GMES_PHASE_ROM]	= "ROM Phase",
53*4882a593Smuzhiyun 	[ME_GMES_PHASE_BUP]	= "BUP Phase",
54*4882a593Smuzhiyun 	[ME_GMES_PHASE_UKERNEL]	= "uKernel Phase",
55*4882a593Smuzhiyun 	[ME_GMES_PHASE_POLICY]	= "Policy Module",
56*4882a593Smuzhiyun 	[ME_GMES_PHASE_MODULE]	= "Module Loading",
57*4882a593Smuzhiyun 	[ME_GMES_PHASE_UNKNOWN]	= "Unknown",
58*4882a593Smuzhiyun 	[ME_GMES_PHASE_HOST]	= "Host Communication"
59*4882a593Smuzhiyun };
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /* GMES[27:24] Power Management Event */
62*4882a593Smuzhiyun static const char *const me_pmevent_values[] = {
63*4882a593Smuzhiyun 	[0x00] = "Clean Moff->Mx wake",
64*4882a593Smuzhiyun 	[0x01] = "Moff->Mx wake after an error",
65*4882a593Smuzhiyun 	[0x02] = "Clean global reset",
66*4882a593Smuzhiyun 	[0x03] = "Global reset after an error",
67*4882a593Smuzhiyun 	[0x04] = "Clean Intel ME reset",
68*4882a593Smuzhiyun 	[0x05] = "Intel ME reset due to exception",
69*4882a593Smuzhiyun 	[0x06] = "Pseudo-global reset",
70*4882a593Smuzhiyun 	[0x07] = "S0/M0->Sx/M3",
71*4882a593Smuzhiyun 	[0x08] = "Sx/M3->S0/M0",
72*4882a593Smuzhiyun 	[0x09] = "Non-power cycle reset",
73*4882a593Smuzhiyun 	[0x0a] = "Power cycle reset through M3",
74*4882a593Smuzhiyun 	[0x0b] = "Power cycle reset through Moff",
75*4882a593Smuzhiyun 	[0x0c] = "Sx/Mx->Sx/Moff"
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /* Progress Code 0 states */
79*4882a593Smuzhiyun static const char *const me_progress_rom_values[] = {
80*4882a593Smuzhiyun 	[0x00] = "BEGIN",
81*4882a593Smuzhiyun 	[0x06] = "DISABLE"
82*4882a593Smuzhiyun };
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun /* Progress Code 1 states */
85*4882a593Smuzhiyun static const char *const me_progress_bup_values[] = {
86*4882a593Smuzhiyun 	[0x00] = "Initialization starts",
87*4882a593Smuzhiyun 	[0x01] = "Disable the host wake event",
88*4882a593Smuzhiyun 	[0x04] = "Flow determination start process",
89*4882a593Smuzhiyun 	[0x08] = "Error reading/matching the VSCC table in the descriptor",
90*4882a593Smuzhiyun 	[0x0a] = "Check to see if straps say ME DISABLED",
91*4882a593Smuzhiyun 	[0x0b] = "Timeout waiting for PWROK",
92*4882a593Smuzhiyun 	[0x0d] = "Possibly handle BUP manufacturing override strap",
93*4882a593Smuzhiyun 	[0x11] = "Bringup in M3",
94*4882a593Smuzhiyun 	[0x12] = "Bringup in M0",
95*4882a593Smuzhiyun 	[0x13] = "Flow detection error",
96*4882a593Smuzhiyun 	[0x15] = "M3 clock switching error",
97*4882a593Smuzhiyun 	[0x18] = "M3 kernel load",
98*4882a593Smuzhiyun 	[0x1c] = "T34 missing - cannot program ICC",
99*4882a593Smuzhiyun 	[0x1f] = "Waiting for DID BIOS message",
100*4882a593Smuzhiyun 	[0x20] = "Waiting for DID BIOS message failure",
101*4882a593Smuzhiyun 	[0x21] = "DID reported an error",
102*4882a593Smuzhiyun 	[0x22] = "Enabling UMA",
103*4882a593Smuzhiyun 	[0x23] = "Enabling UMA error",
104*4882a593Smuzhiyun 	[0x24] = "Sending DID Ack to BIOS",
105*4882a593Smuzhiyun 	[0x25] = "Sending DID Ack to BIOS error",
106*4882a593Smuzhiyun 	[0x26] = "Switching clocks in M0",
107*4882a593Smuzhiyun 	[0x27] = "Switching clocks in M0 error",
108*4882a593Smuzhiyun 	[0x28] = "ME in temp disable",
109*4882a593Smuzhiyun 	[0x32] = "M0 kernel load",
110*4882a593Smuzhiyun };
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun /* Progress Code 3 states */
113*4882a593Smuzhiyun static const char *const me_progress_policy_values[] = {
114*4882a593Smuzhiyun 	[0x00] = "Entery into Policy Module",
115*4882a593Smuzhiyun 	[0x03] = "Received S3 entry",
116*4882a593Smuzhiyun 	[0x04] = "Received S4 entry",
117*4882a593Smuzhiyun 	[0x05] = "Received S5 entry",
118*4882a593Smuzhiyun 	[0x06] = "Received UPD entry",
119*4882a593Smuzhiyun 	[0x07] = "Received PCR entry",
120*4882a593Smuzhiyun 	[0x08] = "Received NPCR entry",
121*4882a593Smuzhiyun 	[0x09] = "Received host wake",
122*4882a593Smuzhiyun 	[0x0a] = "Received AC<>DC switch",
123*4882a593Smuzhiyun 	[0x0b] = "Received DRAM Init Done",
124*4882a593Smuzhiyun 	[0x0c] = "VSCC Data not found for flash device",
125*4882a593Smuzhiyun 	[0x0d] = "VSCC Table is not valid",
126*4882a593Smuzhiyun 	[0x0e] = "Flash Partition Boundary is outside address space",
127*4882a593Smuzhiyun 	[0x0f] = "ME cannot access the chipset descriptor region",
128*4882a593Smuzhiyun 	[0x10] = "Required VSCC values for flash parts do not match",
129*4882a593Smuzhiyun };
130*4882a593Smuzhiyun 
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun /**
133*4882a593Smuzhiyun  * _intel_me_status() - Check Intel Management Engine status
134*4882a593Smuzhiyun  *
135*4882a593Smuzhiyun  * struct hfs:	Firmware status
136*4882a593Smuzhiyun  * struct gmes:	Management engine status
137*4882a593Smuzhiyun  */
_intel_me_status(struct me_hfs * hfs,struct me_gmes * gmes)138*4882a593Smuzhiyun static void _intel_me_status(struct me_hfs *hfs, struct me_gmes *gmes)
139*4882a593Smuzhiyun {
140*4882a593Smuzhiyun 	/* Check Current States */
141*4882a593Smuzhiyun 	debug("ME: FW Partition Table      : %s\n",
142*4882a593Smuzhiyun 	      hfs->fpt_bad ? "BAD" : "OK");
143*4882a593Smuzhiyun 	debug("ME: Bringup Loader Failure  : %s\n",
144*4882a593Smuzhiyun 	      hfs->ft_bup_ld_flr ? "YES" : "NO");
145*4882a593Smuzhiyun 	debug("ME: Firmware Init Complete  : %s\n",
146*4882a593Smuzhiyun 	      hfs->fw_init_complete ? "YES" : "NO");
147*4882a593Smuzhiyun 	debug("ME: Manufacturing Mode      : %s\n",
148*4882a593Smuzhiyun 	      hfs->mfg_mode ? "YES" : "NO");
149*4882a593Smuzhiyun 	debug("ME: Boot Options Present    : %s\n",
150*4882a593Smuzhiyun 	      hfs->boot_options_present ? "YES" : "NO");
151*4882a593Smuzhiyun 	debug("ME: Update In Progress      : %s\n",
152*4882a593Smuzhiyun 	      hfs->update_in_progress ? "YES" : "NO");
153*4882a593Smuzhiyun 	debug("ME: Current Working State   : %s\n",
154*4882a593Smuzhiyun 	      me_cws_values[hfs->working_state]);
155*4882a593Smuzhiyun 	debug("ME: Current Operation State : %s\n",
156*4882a593Smuzhiyun 	      me_opstate_values[hfs->operation_state]);
157*4882a593Smuzhiyun 	debug("ME: Current Operation Mode  : %s\n",
158*4882a593Smuzhiyun 	      me_opmode_values[hfs->operation_mode]);
159*4882a593Smuzhiyun 	debug("ME: Error Code              : %s\n",
160*4882a593Smuzhiyun 	      me_error_values[hfs->error_code]);
161*4882a593Smuzhiyun 	debug("ME: Progress Phase          : %s\n",
162*4882a593Smuzhiyun 	      me_progress_values[gmes->progress_code]);
163*4882a593Smuzhiyun 	debug("ME: Power Management Event  : %s\n",
164*4882a593Smuzhiyun 	      me_pmevent_values[gmes->current_pmevent]);
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun 	debug("ME: Progress Phase State    : ");
167*4882a593Smuzhiyun 	switch (gmes->progress_code) {
168*4882a593Smuzhiyun 	case ME_GMES_PHASE_ROM:		/* ROM Phase */
169*4882a593Smuzhiyun 		debug("%s", me_progress_rom_values[gmes->current_state]);
170*4882a593Smuzhiyun 		break;
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun 	case ME_GMES_PHASE_BUP:		/* Bringup Phase */
173*4882a593Smuzhiyun 		if (gmes->current_state < ARRAY_SIZE(me_progress_bup_values) &&
174*4882a593Smuzhiyun 		    me_progress_bup_values[gmes->current_state])
175*4882a593Smuzhiyun 			debug("%s",
176*4882a593Smuzhiyun 			      me_progress_bup_values[gmes->current_state]);
177*4882a593Smuzhiyun 		else
178*4882a593Smuzhiyun 			debug("0x%02x", gmes->current_state);
179*4882a593Smuzhiyun 		break;
180*4882a593Smuzhiyun 
181*4882a593Smuzhiyun 	case ME_GMES_PHASE_POLICY:	/* Policy Module Phase */
182*4882a593Smuzhiyun 		if (gmes->current_state <
183*4882a593Smuzhiyun 				ARRAY_SIZE(me_progress_policy_values) &&
184*4882a593Smuzhiyun 		    me_progress_policy_values[gmes->current_state])
185*4882a593Smuzhiyun 			debug("%s",
186*4882a593Smuzhiyun 			      me_progress_policy_values[gmes->current_state]);
187*4882a593Smuzhiyun 		else
188*4882a593Smuzhiyun 			debug("0x%02x", gmes->current_state);
189*4882a593Smuzhiyun 		break;
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun 	case ME_GMES_PHASE_HOST:	/* Host Communication Phase */
192*4882a593Smuzhiyun 		if (!gmes->current_state)
193*4882a593Smuzhiyun 			debug("Host communication established");
194*4882a593Smuzhiyun 		else
195*4882a593Smuzhiyun 			debug("0x%02x", gmes->current_state);
196*4882a593Smuzhiyun 		break;
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun 	default:
199*4882a593Smuzhiyun 		debug("Unknown 0x%02x", gmes->current_state);
200*4882a593Smuzhiyun 	}
201*4882a593Smuzhiyun 	debug("\n");
202*4882a593Smuzhiyun }
203*4882a593Smuzhiyun 
intel_me_status(struct udevice * me_dev)204*4882a593Smuzhiyun void intel_me_status(struct udevice *me_dev)
205*4882a593Smuzhiyun {
206*4882a593Smuzhiyun 	struct me_hfs hfs;
207*4882a593Smuzhiyun 	struct me_gmes gmes;
208*4882a593Smuzhiyun 
209*4882a593Smuzhiyun 	pci_read_dword_ptr(me_dev, &hfs, PCI_ME_HFS);
210*4882a593Smuzhiyun 	pci_read_dword_ptr(me_dev, &gmes, PCI_ME_GMES);
211*4882a593Smuzhiyun 
212*4882a593Smuzhiyun 	_intel_me_status(&hfs, &gmes);
213*4882a593Smuzhiyun }
214