blob: 381d7bfcb571dc7e9a5774e89d40328f2dd1e6db [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>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020010#include <northbridge/intel/haswell/haswell.h>
11#include <northbridge/intel/haswell/raminit.h>
12#include <southbridge/intel/lynxpoint/pch.h>
13#include <southbridge/intel/lynxpoint/me.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020014#include "haswell.h"
Aaron Durbina2671612013-02-06 21:41:01 -060015
Aaron Durbina2671612013-02-06 21:41:01 -060016void romstage_common(const struct romstage_params *params)
17{
Aaron Durbinbf396ff2013-02-11 21:50:35 -060018 int boot_mode;
Aaron Durbina2671612013-02-06 21:41:01 -060019 int wake_from_s3;
Aaron Durbina2671612013-02-06 21:41:01 -060020
Kyösti Mälkki157b1892019-08-16 14:02:25 +030021 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060022
23 wake_from_s3 = early_pch_init(params->gpio_map, params->rcba_config);
24
Aaron Durbina2671612013-02-06 21:41:01 -060025 /* Perform some early chipset initialization required
26 * before RAM initialization can work
27 */
Angel Ponse8168292020-07-03 11:42:22 +020028 haswell_early_initialization();
Aaron Durbina2671612013-02-06 21:41:01 -060029 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
30
31 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080032#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060033 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060034#else
35 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060036 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060037#endif
38 }
39
Aaron Durbinbf396ff2013-02-11 21:50:35 -060040 /* There are hard coded assumptions of 2 meaning s3 wake. Normalize
41 * the users of the 2 literal here based off wake_from_s3. */
42 boot_mode = wake_from_s3 ? 2 : 0;
43
Aaron Durbina2671612013-02-06 21:41:01 -060044 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060045 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060046 enable_usb_bar();
47
48 post_code(0x3a);
49 params->pei_data->boot_mode = boot_mode;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030050
51 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060052
53 report_platform_info();
54
Aaron Durbinc7633f42013-06-13 17:29:36 -070055 if (params->copy_spd != NULL)
56 params->copy_spd(params->pei_data);
57
Aaron Durbina2671612013-02-06 21:41:01 -060058 sdram_initialize(params->pei_data);
59
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030060 timestamp_add_now(TS_AFTER_INITRAM);
61
Aaron Durbina2671612013-02-06 21:41:01 -060062 post_code(0x3b);
63
64 intel_early_me_status();
65
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050066 if (!wake_from_s3) {
67 cbmem_initialize_empty();
68 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060069 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050070 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080071 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050072 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020073 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050074 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060075 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060076
Tristan Corrick334be322018-12-17 22:10:21 +130077 haswell_unhide_peg();
78
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050079 setup_sdram_meminfo(params->pei_data);
80
Aaron Durbin77e13992016-11-29 17:43:04 -060081 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060082
Aaron Durbina2671612013-02-06 21:41:01 -060083 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060084}