blob: 44abf4bc7df4b76605efd8a6e9da9733d07161ae [file] [log] [blame]
Angel Ponsf23ae0b2020-04-02 23:48:12 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbin3d0071b2013-01-18 14:32:50 -06003
4#include <stdint.h>
Aaron Durbin3d0071b2013-01-18 14:32:50 -06005#include <console/console.h>
Patrick Rudolph45022ae2018-10-01 19:17:11 +02006#include <cf9_reset.h>
Aaron Durbina2671612013-02-06 21:41:01 -06007#include <cpu/x86/bist.h>
Aaron Durbina2671612013-02-06 21:41:01 -06008#include <timestamp.h>
Aaron Durbina2671612013-02-06 21:41:01 -06009#include <cpu/x86/lapic.h>
Kyösti Mälkki465eff62016-06-15 06:07:55 +030010#include <cbmem.h>
Elyes HAOUASd26844c2019-06-21 07:31:40 +020011#include <commonlib/helpers.h>
Aaron Durbinbf396ff2013-02-11 21:50:35 -060012#include <romstage_handoff.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020013#include <northbridge/intel/haswell/haswell.h>
14#include <northbridge/intel/haswell/raminit.h>
15#include <southbridge/intel/lynxpoint/pch.h>
16#include <southbridge/intel/lynxpoint/me.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020017#include "haswell.h"
Aaron Durbina2671612013-02-06 21:41:01 -060018
Aaron Durbina2671612013-02-06 21:41:01 -060019void romstage_common(const struct romstage_params *params)
20{
Aaron Durbinbf396ff2013-02-11 21:50:35 -060021 int boot_mode;
Aaron Durbina2671612013-02-06 21:41:01 -060022 int wake_from_s3;
Aaron Durbina2671612013-02-06 21:41:01 -060023
Kyösti Mälkki157b1892019-08-16 14:02:25 +030024 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060025
26 wake_from_s3 = early_pch_init(params->gpio_map, params->rcba_config);
27
Aaron Durbina2671612013-02-06 21:41:01 -060028 /* Perform some early chipset initialization required
29 * before RAM initialization can work
30 */
31 haswell_early_initialization(HASWELL_MOBILE);
32 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
33
34 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080035#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060036 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060037#else
38 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060039 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060040#endif
41 }
42
Aaron Durbinbf396ff2013-02-11 21:50:35 -060043 /* There are hard coded assumptions of 2 meaning s3 wake. Normalize
44 * the users of the 2 literal here based off wake_from_s3. */
45 boot_mode = wake_from_s3 ? 2 : 0;
46
Aaron Durbina2671612013-02-06 21:41:01 -060047 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060048 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060049 enable_usb_bar();
50
51 post_code(0x3a);
52 params->pei_data->boot_mode = boot_mode;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030053
54 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060055
56 report_platform_info();
57
Aaron Durbinc7633f42013-06-13 17:29:36 -070058 if (params->copy_spd != NULL)
59 params->copy_spd(params->pei_data);
60
Aaron Durbina2671612013-02-06 21:41:01 -060061 sdram_initialize(params->pei_data);
62
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030063 timestamp_add_now(TS_AFTER_INITRAM);
64
Aaron Durbina2671612013-02-06 21:41:01 -060065 post_code(0x3b);
66
67 intel_early_me_status();
68
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050069 if (!wake_from_s3) {
70 cbmem_initialize_empty();
71 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060072 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050073 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080074 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050075 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020076 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050077 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060078 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060079
Tristan Corrick334be322018-12-17 22:10:21 +130080 haswell_unhide_peg();
81
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050082 setup_sdram_meminfo(params->pei_data);
83
Aaron Durbin77e13992016-11-29 17:43:04 -060084 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060085
Aaron Durbina2671612013-02-06 21:41:01 -060086 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060087}