blob: ae9d707d9076e98b8378f8cbf78f91bb6b98acf6 [file] [log] [blame]
Angel Ponsf23ae0b2020-04-02 23:48:12 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin3d0071b2013-01-18 14:32:50 -06002
Aaron Durbin3d0071b2013-01-18 14:32:50 -06003#include <console/console.h>
Patrick Rudolph45022ae2018-10-01 19:17:11 +02004#include <cf9_reset.h>
Aaron Durbina2671612013-02-06 21:41:01 -06005#include <timestamp.h>
Aaron Durbina2671612013-02-06 21:41:01 -06006#include <cpu/x86/lapic.h>
Kyösti Mälkki465eff62016-06-15 06:07:55 +03007#include <cbmem.h>
Elyes HAOUASd26844c2019-06-21 07:31:40 +02008#include <commonlib/helpers.h>
Aaron Durbinbf396ff2013-02-11 21:50:35 -06009#include <romstage_handoff.h>
Angel Pons2e25ac62020-07-03 12:06:04 +020010#include <cpu/intel/haswell/haswell.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020011#include <northbridge/intel/haswell/haswell.h>
12#include <northbridge/intel/haswell/raminit.h>
13#include <southbridge/intel/lynxpoint/pch.h>
14#include <southbridge/intel/lynxpoint/me.h>
Aaron Durbina2671612013-02-06 21:41:01 -060015
Angel Pons73fa0352020-07-03 12:29:03 +020016void __weak mb_late_romstage_setup(void)
17{
18}
19
Aaron Durbina2671612013-02-06 21:41:01 -060020void romstage_common(const struct romstage_params *params)
21{
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
Angel Pons03f0e432020-07-03 13:51:15 +020026 wake_from_s3 = early_pch_init();
Aaron Durbina2671612013-02-06 21:41:01 -060027
Aaron Durbina2671612013-02-06 21:41:01 -060028 /* Perform some early chipset initialization required
29 * before RAM initialization can work
30 */
Angel Ponse8168292020-07-03 11:42:22 +020031 haswell_early_initialization();
Aaron Durbina2671612013-02-06 21:41:01 -060032 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
43 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060044 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060045 enable_usb_bar();
46
47 post_code(0x3a);
Angel Pons284a5472020-07-03 11:46:50 +020048
49 /* MRC has hardcoded assumptions of 2 meaning S3 wake. Normalize it here. */
50 params->pei_data->boot_mode = wake_from_s3 ? 2 : 0;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030051
52 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060053
54 report_platform_info();
55
Aaron Durbinc7633f42013-06-13 17:29:36 -070056 if (params->copy_spd != NULL)
57 params->copy_spd(params->pei_data);
58
Aaron Durbina2671612013-02-06 21:41:01 -060059 sdram_initialize(params->pei_data);
60
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030061 timestamp_add_now(TS_AFTER_INITRAM);
62
Aaron Durbina2671612013-02-06 21:41:01 -060063 post_code(0x3b);
64
65 intel_early_me_status();
66
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050067 if (!wake_from_s3) {
68 cbmem_initialize_empty();
69 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060070 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050071 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080072 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050073 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020074 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050075 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060076 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060077
Tristan Corrick334be322018-12-17 22:10:21 +130078 haswell_unhide_peg();
79
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050080 setup_sdram_meminfo(params->pei_data);
81
Aaron Durbin77e13992016-11-29 17:43:04 -060082 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060083
Angel Pons73fa0352020-07-03 12:29:03 +020084 mb_late_romstage_setup();
85
Aaron Durbina2671612013-02-06 21:41:01 -060086 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060087}