blob: 00f5f4793891d0b726148f59fc126e0fd2e9afee [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 Pons6eea1912020-07-03 14:14:30 +020016/* Copy SPD data for on-board memory */
17void __weak copy_spd(struct pei_data *peid)
18{
19}
20
Angel Pons73fa0352020-07-03 12:29:03 +020021void __weak mb_late_romstage_setup(void)
22{
23}
24
Aaron Durbina2671612013-02-06 21:41:01 -060025void romstage_common(const struct romstage_params *params)
26{
Aaron Durbina2671612013-02-06 21:41:01 -060027 int wake_from_s3;
Aaron Durbina2671612013-02-06 21:41:01 -060028
Kyösti Mälkki157b1892019-08-16 14:02:25 +030029 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060030
Angel Pons03f0e432020-07-03 13:51:15 +020031 wake_from_s3 = early_pch_init();
Aaron Durbina2671612013-02-06 21:41:01 -060032
Aaron Durbina2671612013-02-06 21:41:01 -060033 /* Perform some early chipset initialization required
34 * before RAM initialization can work
35 */
Angel Ponse8168292020-07-03 11:42:22 +020036 haswell_early_initialization();
Aaron Durbina2671612013-02-06 21:41:01 -060037 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
38
39 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080040#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060041 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060042#else
43 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060044 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060045#endif
46 }
47
48 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060049 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060050 enable_usb_bar();
51
52 post_code(0x3a);
Angel Pons284a5472020-07-03 11:46:50 +020053
54 /* MRC has hardcoded assumptions of 2 meaning S3 wake. Normalize it here. */
55 params->pei_data->boot_mode = wake_from_s3 ? 2 : 0;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030056
57 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060058
59 report_platform_info();
60
Angel Pons6eea1912020-07-03 14:14:30 +020061 copy_spd(params->pei_data);
Aaron Durbinc7633f42013-06-13 17:29:36 -070062
Aaron Durbina2671612013-02-06 21:41:01 -060063 sdram_initialize(params->pei_data);
64
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030065 timestamp_add_now(TS_AFTER_INITRAM);
66
Aaron Durbina2671612013-02-06 21:41:01 -060067 post_code(0x3b);
68
69 intel_early_me_status();
70
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050071 if (!wake_from_s3) {
72 cbmem_initialize_empty();
73 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060074 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050075 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080076 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050077 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020078 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050079 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060080 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060081
Tristan Corrick334be322018-12-17 22:10:21 +130082 haswell_unhide_peg();
83
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050084 setup_sdram_meminfo(params->pei_data);
85
Aaron Durbin77e13992016-11-29 17:43:04 -060086 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060087
Angel Pons73fa0352020-07-03 12:29:03 +020088 mb_late_romstage_setup();
89
Aaron Durbina2671612013-02-06 21:41:01 -060090 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060091}