blob: 2178c9d2ff2ffee46f03abb070bde3762faeed39 [file] [log] [blame]
Angel Pons6e5aabd2020-03-23 23:44:42 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -07003
4#include <console/console.h>
5#include <console/usb.h>
6#include <bootmode.h>
Elyes HAOUASc0567292019-04-28 17:57:47 +02007#include <cf9_reset.h>
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -07008#include <string.h>
Nico Huber47bf4982019-11-17 02:58:00 +01009#include <device/device.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020010#include <device/pci_ops.h>
Patrick Rudolph5709e032019-03-25 10:12:14 +010011#include <arch/cpu.h>
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070012#include <cbmem.h>
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070013#include <cbfs.h>
14#include <ip_checksum.h>
15#include <pc80/mc146818rtc.h>
16#include <device/pci_def.h>
Kyösti Mälkkib697c902019-01-30 08:19:49 +020017#include <lib.h>
Arthur Heymans7539b8c2017-12-24 10:42:57 +010018#include <mrc_cache.h>
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010019#include <timestamp.h>
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070020#include "raminit.h"
21#include "pei_data.h"
22#include "sandybridge.h"
Patrick Rudolph5709e032019-03-25 10:12:14 +010023#include "chip.h"
Philipp Deppenwiesefea24292017-10-17 17:02:29 +020024#include <security/vboot/vboot_common.h>
Patrick Georgi27fbbcf2019-04-23 12:33:23 +020025#include <southbridge/intel/bd82x6x/pch.h>
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070026
27/* Management Engine is in the southbridge */
Elyes HAOUAS21b71ce62018-06-16 18:43:52 +020028#include <southbridge/intel/bd82x6x/me.h>
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070029
30/*
31 * MRC scrambler seed offsets should be reserved in
32 * mainboard cmos.layout and not covered by checksum.
33 */
Julius Wernercd49cce2019-03-05 16:53:33 -080034#if CONFIG(USE_OPTION_TABLE)
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070035#include "option_table.h"
Angel Pons7c49cb82020-03-16 23:17:32 +010036#define CMOS_OFFSET_MRC_SEED (CMOS_VSTART_mrc_scrambler_seed >> 3)
37#define CMOS_OFFSET_MRC_SEED_S3 (CMOS_VSTART_mrc_scrambler_seed_s3 >> 3)
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070038#define CMOS_OFFSET_MRC_SEED_CHK (CMOS_VSTART_mrc_scrambler_seed_chk >> 3)
39#else
40#define CMOS_OFFSET_MRC_SEED 152
41#define CMOS_OFFSET_MRC_SEED_S3 156
42#define CMOS_OFFSET_MRC_SEED_CHK 160
43#endif
44
Arthur Heymans7539b8c2017-12-24 10:42:57 +010045#define MRC_CACHE_VERSION 0
46
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070047void save_mrc_data(struct pei_data *pei_data)
48{
49 u16 c1, c2, checksum;
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070050
51 /* Save the MRC S3 restore data to cbmem */
Angel Pons7c49cb82020-03-16 23:17:32 +010052 mrc_cache_stash_data(MRC_TRAINING_DATA, MRC_CACHE_VERSION, pei_data->mrc_output,
Arthur Heymans7539b8c2017-12-24 10:42:57 +010053 pei_data->mrc_output_len);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070054
55 /* Save the MRC seed values to CMOS */
Kyösti Mälkki28791072020-01-04 12:58:53 +020056 cmos_write32(pei_data->scrambler_seed, CMOS_OFFSET_MRC_SEED);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070057 printk(BIOS_DEBUG, "Save scrambler seed 0x%08x to CMOS 0x%02x\n",
58 pei_data->scrambler_seed, CMOS_OFFSET_MRC_SEED);
59
Kyösti Mälkki28791072020-01-04 12:58:53 +020060 cmos_write32(pei_data->scrambler_seed_s3, CMOS_OFFSET_MRC_SEED_S3);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070061 printk(BIOS_DEBUG, "Save s3 scrambler seed 0x%08x to CMOS 0x%02x\n",
62 pei_data->scrambler_seed_s3, CMOS_OFFSET_MRC_SEED_S3);
63
64 /* Save a simple checksum of the seed values */
Angel Pons7c49cb82020-03-16 23:17:32 +010065 c1 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed, sizeof(u32));
66 c2 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed_s3, sizeof(u32));
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070067 checksum = add_ip_checksums(sizeof(u32), c1, c2);
68
Angel Pons7c49cb82020-03-16 23:17:32 +010069 cmos_write((checksum >> 0) & 0xff, CMOS_OFFSET_MRC_SEED_CHK);
70 cmos_write((checksum >> 8) & 0xff, CMOS_OFFSET_MRC_SEED_CHK + 1);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070071}
72
73static void prepare_mrc_cache(struct pei_data *pei_data)
74{
Arthur Heymans7539b8c2017-12-24 10:42:57 +010075 struct region_device rdev;
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070076 u16 c1, c2, checksum, seed_checksum;
77
Angel Pons7c49cb82020-03-16 23:17:32 +010078 /* Preset just in case there is an error */
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070079 pei_data->mrc_input = NULL;
80 pei_data->mrc_input_len = 0;
81
82 /* Read scrambler seeds from CMOS */
83 pei_data->scrambler_seed = cmos_read32(CMOS_OFFSET_MRC_SEED);
84 printk(BIOS_DEBUG, "Read scrambler seed 0x%08x from CMOS 0x%02x\n",
85 pei_data->scrambler_seed, CMOS_OFFSET_MRC_SEED);
86
87 pei_data->scrambler_seed_s3 = cmos_read32(CMOS_OFFSET_MRC_SEED_S3);
88 printk(BIOS_DEBUG, "Read S3 scrambler seed 0x%08x from CMOS 0x%02x\n",
89 pei_data->scrambler_seed_s3, CMOS_OFFSET_MRC_SEED_S3);
90
91 /* Compute seed checksum and compare */
Angel Pons7c49cb82020-03-16 23:17:32 +010092 c1 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed, sizeof(u32));
93 c2 = compute_ip_checksum((u8 *)&pei_data->scrambler_seed_s3, sizeof(u32));
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070094 checksum = add_ip_checksums(sizeof(u32), c1, c2);
95
Angel Pons7c49cb82020-03-16 23:17:32 +010096 seed_checksum = cmos_read(CMOS_OFFSET_MRC_SEED_CHK);
97 seed_checksum |= cmos_read(CMOS_OFFSET_MRC_SEED_CHK + 1) << 8;
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -070098
99 if (checksum != seed_checksum) {
100 printk(BIOS_ERR, "%s: invalid seed checksum\n", __func__);
101 pei_data->scrambler_seed = 0;
102 pei_data->scrambler_seed_s3 = 0;
103 return;
104 }
105
Angel Pons7c49cb82020-03-16 23:17:32 +0100106 if (mrc_cache_get_current(MRC_TRAINING_DATA, MRC_CACHE_VERSION, &rdev)) {
107 /* Error message printed in find_current_mrc_cache */
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700108 return;
109 }
110
Arthur Heymans7539b8c2017-12-24 10:42:57 +0100111 pei_data->mrc_input = rdev_mmap_full(&rdev);
112 pei_data->mrc_input_len = region_device_sz(&rdev);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700113
Angel Pons7c49cb82020-03-16 23:17:32 +0100114 printk(BIOS_DEBUG, "%s: at %p, size %x\n", __func__, pei_data->mrc_input,
115 pei_data->mrc_input_len);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700116}
117
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700118/**
119 * Find PEI executable in coreboot filesystem and execute it.
120 *
121 * @param pei_data: configuration data for UEFI PEI reference code
122 */
123void sdram_initialize(struct pei_data *pei_data)
124{
125 struct sys_info sysinfo;
Angel Pons7c49cb82020-03-16 23:17:32 +0100126 int (*entry)(struct pei_data *pei_data) __attribute__((regparm(1)));
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700127
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700128 /* Wait for ME to be ready */
129 intel_early_me_init();
130 intel_early_me_uma_size();
131
132 printk(BIOS_DEBUG, "Starting UEFI PEI System Agent\n");
133
134 memset(&sysinfo, 0, sizeof(sysinfo));
135
136 sysinfo.boot_path = pei_data->boot_mode;
137
138 /*
139 * Do not pass MRC data in for recovery mode boot,
140 * Always pass it in for S3 resume.
141 */
Julius Werner29fbfcc2020-03-02 15:54:43 -0800142 if (!(CONFIG(SANDYBRIDGE_VBOOT_IN_BOOTBLOCK) && vboot_recovery_mode_enabled()) ||
143 pei_data->boot_mode == 2)
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700144 prepare_mrc_cache(pei_data);
145
146 /* If MRC data is not found we cannot continue S3 resume. */
147 if (pei_data->boot_mode == 2 && !pei_data->mrc_input) {
Elyes HAOUAS3cd43272020-03-05 22:01:17 +0100148 printk(BIOS_DEBUG, "Giving up in %s: No MRC data\n", __func__);
Elyes HAOUASc0567292019-04-28 17:57:47 +0200149 system_reset();
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700150 }
151
152 /* Pass console handler in pei_data */
153 pei_data->tx_byte = do_putchar;
154
155 /* Locate and call UEFI System Agent binary. */
156 entry = cbfs_boot_map_with_leak("mrc.bin", CBFS_TYPE_MRC, NULL);
157 if (entry) {
158 int rv;
159 rv = entry (pei_data);
160 if (rv) {
161 switch (rv) {
162 case -1:
163 printk(BIOS_ERR, "PEI version mismatch.\n");
164 break;
165 case -2:
166 printk(BIOS_ERR, "Invalid memory frequency.\n");
167 break;
168 default:
169 printk(BIOS_ERR, "MRC returned %x.\n", rv);
170 }
Keith Shortbb41aba2019-05-16 14:07:43 -0600171 die_with_post_code(POST_INVALID_VENDOR_BINARY,
172 "Nonzero MRC return value.\n");
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700173 }
174 } else {
175 die("UEFI PEI System Agent not found.\n");
176 }
177
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700178 /* mrc.bin reconfigures USB, so reinit it to have debug */
Julius Wernercd49cce2019-03-05 16:53:33 -0800179 if (CONFIG(USBDEBUG_IN_PRE_RAM))
Kyösti Mälkki63649d22018-12-29 09:40:40 +0200180 usbdebug_hw_init(true);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700181
Angel Pons7c49cb82020-03-16 23:17:32 +0100182 /* For reference, print the System Agent version after executing the UEFI PEI stage */
Angel Pons88521882020-01-05 20:21:20 +0100183 u32 version = MCHBAR32(MRC_REVISION);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700184 printk(BIOS_DEBUG, "System Agent Version %d.%d.%d Build %d\n",
Angel Pons7c49cb82020-03-16 23:17:32 +0100185 (version >> 24) & 0xff, (version >> 16) & 0xff,
186 (version >> 8) & 0xff, (version >> 0) & 0xff);
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700187
Angel Pons7c49cb82020-03-16 23:17:32 +0100188 /*
189 * Send ME init done for SandyBridge here.
190 * This is done inside the SystemAgent binary on IvyBridge.
191 */
192 if (BASE_REV_SNB == (pci_read_config16(PCI_CPU_DEVICE, PCI_DEVICE_ID) & BASE_REV_MASK))
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700193 intel_early_me_init_done(ME_INIT_STATUS_SUCCESS);
194 else
195 intel_early_me_status();
196
Alexandru Gagniucecf2eb42015-09-28 21:39:12 -0700197 report_memory_config();
198}
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100199
Angel Pons7c49cb82020-03-16 23:17:32 +0100200/*
201 * These are the location and structure of MRC_VAR data in CAR.
202 * The CAR region looks like this:
203 * +------------------+ -> DCACHE_RAM_BASE
204 * | |
205 * | |
206 * | COREBOOT STACK |
207 * | |
208 * | |
209 * +------------------+ -> DCACHE_RAM_BASE + DCACHE_RAM_SIZE
210 * | |
211 * | MRC HEAP |
212 * | size = 0x5000 |
213 * | |
214 * +------------------+
215 * | |
216 * | MRC VAR |
217 * | size = 0x4000 |
218 * | |
219 * +------------------+ -> DACHE_RAM_BASE + DACHE_RAM_SIZE
220 * + DCACHE_RAM_MRC_VAR_SIZE
Arthur Heymans01c83a22019-06-05 13:36:55 +0200221 */
Angel Pons7c49cb82020-03-16 23:17:32 +0100222#define DCACHE_RAM_MRC_VAR_BASE (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE \
223 + CONFIG_DCACHE_RAM_MRC_VAR_SIZE - 0x4000)
Kyösti Mälkkib697c902019-01-30 08:19:49 +0200224
225struct mrc_var_data {
226 u32 acpi_timer_flag;
227 u32 pool_used;
228 u32 pool_base;
229 u32 tx_byte;
230 u32 reserved[4];
231} __packed;
232
Patrick Rudolph5709e032019-03-25 10:12:14 +0100233static void northbridge_fill_pei_data(struct pei_data *pei_data)
234{
Angel Pons7c49cb82020-03-16 23:17:32 +0100235 pei_data->mchbar = (uintptr_t)DEFAULT_MCHBAR;
236 pei_data->dmibar = (uintptr_t)DEFAULT_DMIBAR;
237 pei_data->epbar = DEFAULT_EPBAR;
238 pei_data->pciexbar = CONFIG_MMCONF_BASE_ADDRESS;
Patrick Rudolph5709e032019-03-25 10:12:14 +0100239 pei_data->hpet_address = CONFIG_HPET_ADDRESS;
Angel Pons7c49cb82020-03-16 23:17:32 +0100240 pei_data->thermalbase = 0xfed08000;
241 pei_data->system_type = !(get_platform_type() == PLATFORM_MOBILE);
242 pei_data->tseg_size = CONFIG_SMM_TSEG_SIZE;
Patrick Rudolph5709e032019-03-25 10:12:14 +0100243
244 if ((cpu_get_cpuid() & 0xffff0) == 0x306a0) {
245 const struct device *dev = pcidev_on_root(1, 0);
246 pei_data->pcie_init = dev && dev->enabled;
247 } else {
248 pei_data->pcie_init = 0;
249 }
250}
251
252static void southbridge_fill_pei_data(struct pei_data *pei_data)
253{
254 const struct device *dev = pcidev_on_root(0x19, 0);
255
Angel Pons7c49cb82020-03-16 23:17:32 +0100256 pei_data->smbusbar = SMBUS_IO_BASE;
257 pei_data->wdbbar = 0x04000000;
258 pei_data->wdbsize = 0x1000;
259 pei_data->rcba = (uintptr_t)DEFAULT_RCBABASE;
260 pei_data->pmbase = DEFAULT_PMBASE;
261 pei_data->gpiobase = DEFAULT_GPIOBASE;
Patrick Rudolph5709e032019-03-25 10:12:14 +0100262 pei_data->gbe_enable = dev && dev->enabled;
263}
264
265static void devicetree_fill_pei_data(struct pei_data *pei_data)
266{
267 const struct northbridge_intel_sandybridge_config *cfg;
268
269 const struct device *dev = pcidev_on_root(0, 0);
270 if (!dev || !dev->chip_info)
271 return;
272
273 cfg = dev->chip_info;
274
275 switch (cfg->max_mem_clock_mhz) {
276 /* MRC only supports fixed numbers of frequencies */
277 default:
278 printk(BIOS_WARNING, "RAMINIT: Limiting DDR3 clock to 800 Mhz\n");
279 /* fallthrough */
280 case 400:
281 pei_data->max_ddr3_freq = 800;
282 break;
283 case 533:
284 pei_data->max_ddr3_freq = 1066;
285 break;
286 case 666:
287 pei_data->max_ddr3_freq = 1333;
288 break;
289 case 800:
290 pei_data->max_ddr3_freq = 1600;
291 break;
292
293 }
294
Angel Pons7c49cb82020-03-16 23:17:32 +0100295 memcpy(pei_data->spd_addresses, cfg->spd_addresses, sizeof(pei_data->spd_addresses));
296 memcpy(pei_data->ts_addresses, cfg->ts_addresses, sizeof(pei_data->ts_addresses));
Patrick Rudolph5709e032019-03-25 10:12:14 +0100297
Angel Pons7c49cb82020-03-16 23:17:32 +0100298 pei_data->ec_present = cfg->ec_present;
Patrick Rudolph5709e032019-03-25 10:12:14 +0100299 pei_data->ddr3lv_support = cfg->ddr3lv_support;
300
301 pei_data->nmode = cfg->nmode;
302 pei_data->ddr_refresh_rate_config = cfg->ddr_refresh_rate_config;
303
304 memcpy(pei_data->usb_port_config, cfg->usb_port_config,
305 sizeof(pei_data->usb_port_config));
306
Angel Pons7c49cb82020-03-16 23:17:32 +0100307 pei_data->usb3.mode = cfg->usb3.mode;
Patrick Rudolph5709e032019-03-25 10:12:14 +0100308 pei_data->usb3.hs_port_switch_mask = cfg->usb3.hs_port_switch_mask;
Angel Pons7c49cb82020-03-16 23:17:32 +0100309 pei_data->usb3.preboot_support = cfg->usb3.preboot_support;
310 pei_data->usb3.xhci_streams = cfg->usb3.xhci_streams;
Patrick Rudolph5709e032019-03-25 10:12:14 +0100311}
312
Nico Huber47bf4982019-11-17 02:58:00 +0100313static void disable_p2p(void)
314{
Angel Pons7c49cb82020-03-16 23:17:32 +0100315 /* Disable PCI-to-PCI bridge early to prevent probing by MRC */
Nico Huber47bf4982019-11-17 02:58:00 +0100316 const struct device *const p2p = pcidev_on_root(0x1e, 0);
317 if (p2p && p2p->enabled)
318 return;
319
320 RCBA32(FD) |= PCH_DISABLE_P2P;
321}
322
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100323void perform_raminit(int s3resume)
324{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100325 struct pei_data pei_data;
Kyösti Mälkkib697c902019-01-30 08:19:49 +0200326 struct mrc_var_data *mrc_var;
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100327
328 /* Prepare USB controller early in S3 resume */
329 if (!mainboard_should_reset_usb(s3resume))
330 enable_usb_bar();
331
Patrick Rudolph5709e032019-03-25 10:12:14 +0100332 memset(&pei_data, 0, sizeof(pei_data));
333 pei_data.pei_version = PEI_VERSION,
334
335 northbridge_fill_pei_data(&pei_data);
336 southbridge_fill_pei_data(&pei_data);
337 devicetree_fill_pei_data(&pei_data);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100338 mainboard_fill_pei_data(&pei_data);
339
340 post_code(0x3a);
Patrick Rudolph59b42552019-05-08 12:44:15 +0200341
Patrick Rudolph5709e032019-03-25 10:12:14 +0100342 /* Fill after mainboard_fill_pei_data as it might provide spd_data */
343 pei_data.dimm_channel0_disabled =
344 (!pei_data.spd_addresses[0] && !pei_data.spd_data[0][0]) +
345 (!pei_data.spd_addresses[1] && !pei_data.spd_data[1][0]) * 2;
346
347 pei_data.dimm_channel1_disabled =
348 (!pei_data.spd_addresses[2] && !pei_data.spd_data[2][0]) +
349 (!pei_data.spd_addresses[3] && !pei_data.spd_data[3][0]) * 2;
350
Patrick Rudolph59b42552019-05-08 12:44:15 +0200351 /* Fix spd_data. MRC only uses spd_data[0] and ignores the other */
352 for (size_t i = 1; i < ARRAY_SIZE(pei_data.spd_data); i++) {
353 if (pei_data.spd_data[i][0] && !pei_data.spd_data[0][0]) {
354 memcpy(pei_data.spd_data[0], pei_data.spd_data[i],
355 sizeof(pei_data.spd_data[0]));
Angel Pons7c49cb82020-03-16 23:17:32 +0100356
Patrick Rudolph59b42552019-05-08 12:44:15 +0200357 } else if (pei_data.spd_data[i][0] && pei_data.spd_data[0][0]) {
358 if (memcmp(pei_data.spd_data[i], pei_data.spd_data[0],
359 sizeof(pei_data.spd_data[0])) != 0)
360 die("Onboard SPDs must match each other");
361 }
362 }
363
Nico Huber47bf4982019-11-17 02:58:00 +0100364 disable_p2p();
365
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100366 pei_data.boot_mode = s3resume ? 2 : 0;
367 timestamp_add_now(TS_BEFORE_INITRAM);
368 sdram_initialize(&pei_data);
Kyösti Mälkkib697c902019-01-30 08:19:49 +0200369
Angel Pons7c49cb82020-03-16 23:17:32 +0100370 /* Sanity check mrc_var location by verifying a known field */
Kyösti Mälkkib697c902019-01-30 08:19:49 +0200371 mrc_var = (void *)DCACHE_RAM_MRC_VAR_BASE;
Kyösti Mälkkib697c902019-01-30 08:19:49 +0200372 if (mrc_var->tx_byte == (uintptr_t)pei_data.tx_byte) {
373 printk(BIOS_DEBUG, "MRC_VAR pool occupied [%08x,%08x]\n",
Angel Pons7c49cb82020-03-16 23:17:32 +0100374 mrc_var->pool_base, mrc_var->pool_base + mrc_var->pool_used);
375
Kyösti Mälkkib697c902019-01-30 08:19:49 +0200376 } else {
377 printk(BIOS_ERR, "Could not parse MRC_VAR data\n");
Angel Pons7c49cb82020-03-16 23:17:32 +0100378 hexdump32(BIOS_ERR, mrc_var, sizeof(*mrc_var) / sizeof(u32));
Kyösti Mälkkib697c902019-01-30 08:19:49 +0200379 }
380
Angel Pons7c49cb82020-03-16 23:17:32 +0100381 const int cbmem_was_initted = !cbmem_recovery(s3resume);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100382 if (!s3resume)
383 save_mrc_data(&pei_data);
384
385 if (s3resume && !cbmem_was_initted) {
386 /* Failed S3 resume, reset to come up cleanly */
Elyes HAOUASc0567292019-04-28 17:57:47 +0200387 system_reset();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100388 }
389}