me_status.c 6.8 KB

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