blob: 7886de07ed665943d3508534a48ee56223b6fcc7 [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 Durbina2671612013-02-06 21:41:01 -060018 int wake_from_s3;
Aaron Durbina2671612013-02-06 21:41:01 -060019
Kyösti Mälkki157b1892019-08-16 14:02:25 +030020 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060021
22 wake_from_s3 = early_pch_init(params->gpio_map, params->rcba_config);
23
Aaron Durbina2671612013-02-06 21:41:01 -060024 /* Perform some early chipset initialization required
25 * before RAM initialization can work
26 */
Angel Ponse8168292020-07-03 11:42:22 +020027 haswell_early_initialization();
Aaron Durbina2671612013-02-06 21:41:01 -060028 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
29
30 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080031#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060032 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060033#else
34 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060035 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060036#endif
37 }
38
39 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060040 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060041 enable_usb_bar();
42
43 post_code(0x3a);
Angel Pons284a5472020-07-03 11:46:50 +020044
45 /* MRC has hardcoded assumptions of 2 meaning S3 wake. Normalize it here. */
46 params->pei_data->boot_mode = wake_from_s3 ? 2 : 0;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030047
48 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060049
50 report_platform_info();
51
Aaron Durbinc7633f42013-06-13 17:29:36 -070052 if (params->copy_spd != NULL)
53 params->copy_spd(params->pei_data);
54
Aaron Durbina2671612013-02-06 21:41:01 -060055 sdram_initialize(params->pei_data);
56
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030057 timestamp_add_now(TS_AFTER_INITRAM);
58
Aaron Durbina2671612013-02-06 21:41:01 -060059 post_code(0x3b);
60
61 intel_early_me_status();
62
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050063 if (!wake_from_s3) {
64 cbmem_initialize_empty();
65 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060066 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050067 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080068 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050069 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020070 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050071 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060072 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060073
Tristan Corrick334be322018-12-17 22:10:21 +130074 haswell_unhide_peg();
75
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050076 setup_sdram_meminfo(params->pei_data);
77
Aaron Durbin77e13992016-11-29 17:43:04 -060078 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060079
Aaron Durbina2671612013-02-06 21:41:01 -060080 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060081}