0004-haswell-lynxpoint-Add-native-early-ME-init.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. From 98142e01fc8ebb3b762974e9e4de75e7f5c073b4 Mon Sep 17 00:00:00 2001
  2. From: Angel Pons <th3fanbus@gmail.com>
  3. Date: Fri, 6 May 2022 22:18:21 +0200
  4. Subject: [PATCH 04/26] haswell/lynxpoint: Add native early ME init
  5. Implement native early ME init for Lynx Point. This is only needed when
  6. MRC.bin is not used.
  7. Change-Id: If416e2078f139f26b4742c564b70e018725bf003
  8. Signed-off-by: Angel Pons <th3fanbus@gmail.com>
  9. ---
  10. .../haswell/native_raminit/raminit_native.c | 17 ++++++++++-
  11. src/southbridge/intel/lynxpoint/early_me.c | 30 ++++++++++++++++++-
  12. src/southbridge/intel/lynxpoint/me.h | 7 +++--
  13. 3 files changed, 50 insertions(+), 4 deletions(-)
  14. diff --git a/src/northbridge/intel/haswell/native_raminit/raminit_native.c b/src/northbridge/intel/haswell/native_raminit/raminit_native.c
  15. index 0938e026e3..6a002548c1 100644
  16. --- a/src/northbridge/intel/haswell/native_raminit/raminit_native.c
  17. +++ b/src/northbridge/intel/haswell/native_raminit/raminit_native.c
  18. @@ -1,18 +1,24 @@
  19. /* SPDX-License-Identifier: GPL-2.0-or-later */
  20. #include <console/console.h>
  21. +#include <delay.h>
  22. #include <northbridge/intel/haswell/haswell.h>
  23. #include <northbridge/intel/haswell/raminit.h>
  24. +#include <southbridge/intel/lynxpoint/me.h>
  25. #include <types.h>
  26. static bool early_init_native(int s3resume)
  27. {
  28. printk(BIOS_DEBUG, "Starting native platform initialisation\n");
  29. + intel_early_me_init();
  30. + /** TODO: CPU replacement check must be skipped in warm boots and S3 resumes **/
  31. + const bool cpu_replaced = !s3resume && intel_early_me_cpu_replacement_check();
  32. +
  33. if (!CONFIG(INTEL_LYNXPOINT_LP))
  34. dmi_early_init();
  35. - return false;
  36. + return cpu_replaced;
  37. }
  38. void perform_raminit(const int s3resume)
  39. @@ -25,6 +31,15 @@ void perform_raminit(const int s3resume)
  40. (void)cpu_replaced;
  41. + /** TODO: Move after raminit */
  42. + if (intel_early_me_uma_size() > 0) {
  43. + /** TODO: Update status once raminit is implemented **/
  44. + uint8_t me_status = ME_INIT_STATUS_ERROR;
  45. + intel_early_me_init_done(me_status);
  46. + }
  47. +
  48. + intel_early_me_status();
  49. +
  50. /** TODO: Implement the required magic **/
  51. die("NATIVE RAMINIT: More Magic (tm) required.\n");
  52. }
  53. diff --git a/src/southbridge/intel/lynxpoint/early_me.c b/src/southbridge/intel/lynxpoint/early_me.c
  54. index 947c570e16..07013c5539 100644
  55. --- a/src/southbridge/intel/lynxpoint/early_me.c
  56. +++ b/src/southbridge/intel/lynxpoint/early_me.c
  57. @@ -1,11 +1,12 @@
  58. /* SPDX-License-Identifier: GPL-2.0-only */
  59. #include <arch/io.h>
  60. +#include <cf9_reset.h>
  61. #include <device/pci_ops.h>
  62. #include <console/console.h>
  63. #include <delay.h>
  64. #include <halt.h>
  65. -
  66. +#include <timer.h>
  67. #include "me.h"
  68. #include "pch.h"
  69. @@ -60,6 +61,33 @@ int intel_early_me_init(void)
  70. return 0;
  71. }
  72. +bool intel_early_me_cpu_replacement_check(void)
  73. +{
  74. + printk(BIOS_DEBUG, "ME: Checking whether CPU was replaced... ");
  75. +
  76. + struct stopwatch timer;
  77. + stopwatch_init_msecs_expire(&timer, 50);
  78. +
  79. + union me_hfs2 hfs2;
  80. + do {
  81. + hfs2.raw = pci_read_config32(PCH_ME_DEV, PCI_ME_HFS2);
  82. + if (stopwatch_expired(&timer)) {
  83. + /* Assume CPU was replaced just in case */
  84. + printk(BIOS_DEBUG, "timed out, assuming CPU was replaced\n");
  85. + return true;
  86. + }
  87. + udelay(ME_DELAY);
  88. + } while (!hfs2.cpu_replaced_valid);
  89. +
  90. + if (hfs2.warm_reset_request) {
  91. + printk(BIOS_DEBUG, "warm reset needed for dynamic fusing\n");
  92. + system_reset();
  93. + }
  94. +
  95. + printk(BIOS_DEBUG, "%sreplaced\n", hfs2.cpu_replaced_sts ? "" : "not ");
  96. + return hfs2.cpu_replaced_sts;
  97. +}
  98. +
  99. int intel_early_me_uma_size(void)
  100. {
  101. union me_uma uma = { .raw = pci_read_config32(PCH_ME_DEV, PCI_ME_UMA) };
  102. diff --git a/src/southbridge/intel/lynxpoint/me.h b/src/southbridge/intel/lynxpoint/me.h
  103. index fe8b0260c4..6990322651 100644
  104. --- a/src/southbridge/intel/lynxpoint/me.h
  105. +++ b/src/southbridge/intel/lynxpoint/me.h
  106. @@ -177,14 +177,16 @@ union me_did {
  107. union me_hfs2 {
  108. struct __packed {
  109. u32 bist_in_progress: 1;
  110. - u32 reserved1: 2;
  111. + u32 icc_prog_sts: 2;
  112. u32 invoke_mebx: 1;
  113. u32 cpu_replaced_sts: 1;
  114. u32 mbp_rdy: 1;
  115. u32 mfs_failure: 1;
  116. u32 warm_reset_request: 1;
  117. u32 cpu_replaced_valid: 1;
  118. - u32 reserved2: 4;
  119. + u32 reserved: 2;
  120. + u32 fw_upd_ipu: 1;
  121. + u32 reserved2: 1;
  122. u32 mbp_cleared: 1;
  123. u32 reserved3: 2;
  124. u32 current_state: 8;
  125. @@ -338,6 +340,7 @@ void intel_me_status(union me_hfs hfs, union me_hfs2 hfs2);
  126. void intel_early_me_status(void);
  127. int intel_early_me_init(void);
  128. +bool intel_early_me_cpu_replacement_check(void);
  129. int intel_early_me_uma_size(void);
  130. int intel_early_me_init_done(u8 status);
  131. --
  132. 2.39.2