blob: b2f8e23b71340174030bc8d66f700583c6846b16 [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
Angel Pons45f448f2020-07-03 14:46:47 +02003#include <arch/romstage.h>
Aaron Durbin3d0071b2013-01-18 14:32:50 -06004#include <console/console.h>
Patrick Rudolph45022ae2018-10-01 19:17:11 +02005#include <cf9_reset.h>
Aaron Durbina2671612013-02-06 21:41:01 -06006#include <timestamp.h>
Aaron Durbina2671612013-02-06 21:41:01 -06007#include <cpu/x86/lapic.h>
Kyösti Mälkki465eff62016-06-15 06:07:55 +03008#include <cbmem.h>
Elyes HAOUASd26844c2019-06-21 07:31:40 +02009#include <commonlib/helpers.h>
Aaron Durbinbf396ff2013-02-11 21:50:35 -060010#include <romstage_handoff.h>
Angel Pons2e25ac62020-07-03 12:06:04 +020011#include <cpu/intel/haswell/haswell.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020012#include <northbridge/intel/haswell/haswell.h>
13#include <northbridge/intel/haswell/raminit.h>
14#include <southbridge/intel/lynxpoint/pch.h>
15#include <southbridge/intel/lynxpoint/me.h>
Aaron Durbina2671612013-02-06 21:41:01 -060016
Angel Pons6eea1912020-07-03 14:14:30 +020017/* Copy SPD data for on-board memory */
18void __weak copy_spd(struct pei_data *peid)
19{
20}
21
Angel Pons73fa0352020-07-03 12:29:03 +020022void __weak mb_late_romstage_setup(void)
23{
24}
25
Angel Pons45f448f2020-07-03 14:46:47 +020026/* The romstage entry point for this platform is not mainboard-specific, hence the name */
27void mainboard_romstage_entry(void)
Aaron Durbina2671612013-02-06 21:41:01 -060028{
Aaron Durbina2671612013-02-06 21:41:01 -060029 int wake_from_s3;
Aaron Durbina2671612013-02-06 21:41:01 -060030
Angel Pons45f448f2020-07-03 14:46:47 +020031 struct pei_data pei_data = {
32 };
33
34 mainboard_fill_pei_data(&pei_data);
35
Kyösti Mälkki157b1892019-08-16 14:02:25 +030036 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060037
Angel Pons03f0e432020-07-03 13:51:15 +020038 wake_from_s3 = early_pch_init();
Aaron Durbina2671612013-02-06 21:41:01 -060039
Aaron Durbina2671612013-02-06 21:41:01 -060040 /* Perform some early chipset initialization required
41 * before RAM initialization can work
42 */
Angel Ponse8168292020-07-03 11:42:22 +020043 haswell_early_initialization();
Aaron Durbina2671612013-02-06 21:41:01 -060044 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
45
46 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080047#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060048 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060049#else
50 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060051 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060052#endif
53 }
54
55 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060056 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060057 enable_usb_bar();
58
59 post_code(0x3a);
Angel Pons284a5472020-07-03 11:46:50 +020060
61 /* MRC has hardcoded assumptions of 2 meaning S3 wake. Normalize it here. */
Angel Pons45f448f2020-07-03 14:46:47 +020062 pei_data.boot_mode = wake_from_s3 ? 2 : 0;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030063
64 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060065
66 report_platform_info();
67
Angel Pons45f448f2020-07-03 14:46:47 +020068 copy_spd(&pei_data);
Aaron Durbinc7633f42013-06-13 17:29:36 -070069
Angel Pons45f448f2020-07-03 14:46:47 +020070 sdram_initialize(&pei_data);
Aaron Durbina2671612013-02-06 21:41:01 -060071
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030072 timestamp_add_now(TS_AFTER_INITRAM);
73
Aaron Durbina2671612013-02-06 21:41:01 -060074 post_code(0x3b);
75
76 intel_early_me_status();
77
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050078 if (!wake_from_s3) {
79 cbmem_initialize_empty();
80 /* Save data returned from MRC on non-S3 resumes. */
Angel Pons45f448f2020-07-03 14:46:47 +020081 save_mrc_data(&pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050082 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080083 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050084 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020085 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050086 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060087 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060088
Tristan Corrick334be322018-12-17 22:10:21 +130089 haswell_unhide_peg();
90
Angel Pons45f448f2020-07-03 14:46:47 +020091 setup_sdram_meminfo(&pei_data);
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050092
Aaron Durbin77e13992016-11-29 17:43:04 -060093 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060094
Angel Pons73fa0352020-07-03 12:29:03 +020095 mb_late_romstage_setup();
96
Aaron Durbina2671612013-02-06 21:41:01 -060097 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060098}