blob: ee211beab1b234b0a8610b0832e0651440b359d0 [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 = {
Angel Ponsdd7470c2020-07-03 18:19:29 +020032 .pei_version = PEI_VERSION,
33 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
34 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
35 .epbar = DEFAULT_EPBAR,
36 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
37 .smbusbar = SMBUS_IO_BASE,
38 .hpet_address = HPET_ADDR,
39 .rcba = (uintptr_t)DEFAULT_RCBA,
40 .pmbase = DEFAULT_PMBASE,
41 .gpiobase = DEFAULT_GPIOBASE,
42 .temp_mmio_base = 0xfed08000,
43 .tseg_size = CONFIG_SMM_TSEG_SIZE,
Angel Pons45f448f2020-07-03 14:46:47 +020044 };
45
46 mainboard_fill_pei_data(&pei_data);
47
Kyösti Mälkki157b1892019-08-16 14:02:25 +030048 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060049
Angel Pons03f0e432020-07-03 13:51:15 +020050 wake_from_s3 = early_pch_init();
Aaron Durbina2671612013-02-06 21:41:01 -060051
Aaron Durbina2671612013-02-06 21:41:01 -060052 /* Perform some early chipset initialization required
53 * before RAM initialization can work
54 */
Angel Ponse8168292020-07-03 11:42:22 +020055 haswell_early_initialization();
Aaron Durbina2671612013-02-06 21:41:01 -060056 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
57
58 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080059#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060060 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060061#else
62 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060063 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060064#endif
65 }
66
67 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060068 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060069 enable_usb_bar();
70
71 post_code(0x3a);
Angel Pons284a5472020-07-03 11:46:50 +020072
73 /* MRC has hardcoded assumptions of 2 meaning S3 wake. Normalize it here. */
Angel Pons45f448f2020-07-03 14:46:47 +020074 pei_data.boot_mode = wake_from_s3 ? 2 : 0;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030075
76 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060077
78 report_platform_info();
79
Angel Pons45f448f2020-07-03 14:46:47 +020080 copy_spd(&pei_data);
Aaron Durbinc7633f42013-06-13 17:29:36 -070081
Angel Pons45f448f2020-07-03 14:46:47 +020082 sdram_initialize(&pei_data);
Aaron Durbina2671612013-02-06 21:41:01 -060083
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030084 timestamp_add_now(TS_AFTER_INITRAM);
85
Aaron Durbina2671612013-02-06 21:41:01 -060086 post_code(0x3b);
87
88 intel_early_me_status();
89
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050090 if (!wake_from_s3) {
91 cbmem_initialize_empty();
92 /* Save data returned from MRC on non-S3 resumes. */
Angel Pons45f448f2020-07-03 14:46:47 +020093 save_mrc_data(&pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050094 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080095 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050096 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020097 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050098 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060099 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -0600100
Tristan Corrick334be322018-12-17 22:10:21 +1300101 haswell_unhide_peg();
102
Angel Pons45f448f2020-07-03 14:46:47 +0200103 setup_sdram_meminfo(&pei_data);
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -0500104
Aaron Durbin77e13992016-11-29 17:43:04 -0600105 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -0600106
Angel Pons73fa0352020-07-03 12:29:03 +0200107 mb_late_romstage_setup();
108
Aaron Durbina2671612013-02-06 21:41:01 -0600109 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -0600110}