blob: 34fd7b045899a08af093a895c251e373d4a51f53 [file] [log] [blame]
Aaron Durbin3d0071b2013-01-18 14:32:50 -06001/*
2 * This file is part of the coreboot project.
3 *
Aaron Durbin3d0071b2013-01-18 14:32:50 -06004 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
Aaron Durbin3d0071b2013-01-18 14:32:50 -060012 */
13
14#include <stdint.h>
Aaron Durbin3d0071b2013-01-18 14:32:50 -060015#include <console/console.h>
Patrick Rudolph45022ae2018-10-01 19:17:11 +020016#include <cf9_reset.h>
Aaron Durbina2671612013-02-06 21:41:01 -060017#include <cpu/x86/bist.h>
Aaron Durbina2671612013-02-06 21:41:01 -060018#include <timestamp.h>
Aaron Durbina2671612013-02-06 21:41:01 -060019#include <cpu/x86/lapic.h>
Kyösti Mälkki465eff62016-06-15 06:07:55 +030020#include <cbmem.h>
Elyes HAOUASd26844c2019-06-21 07:31:40 +020021#include <commonlib/helpers.h>
Aaron Durbinbf396ff2013-02-11 21:50:35 -060022#include <romstage_handoff.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020023#include <northbridge/intel/haswell/haswell.h>
24#include <northbridge/intel/haswell/raminit.h>
25#include <southbridge/intel/lynxpoint/pch.h>
26#include <southbridge/intel/lynxpoint/me.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020027#include "haswell.h"
Aaron Durbina2671612013-02-06 21:41:01 -060028
Aaron Durbina2671612013-02-06 21:41:01 -060029void romstage_common(const struct romstage_params *params)
30{
Aaron Durbinbf396ff2013-02-11 21:50:35 -060031 int boot_mode;
Aaron Durbina2671612013-02-06 21:41:01 -060032 int wake_from_s3;
Aaron Durbina2671612013-02-06 21:41:01 -060033
Kyösti Mälkki157b1892019-08-16 14:02:25 +030034 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060035
36 wake_from_s3 = early_pch_init(params->gpio_map, params->rcba_config);
37
Aaron Durbina2671612013-02-06 21:41:01 -060038 /* Perform some early chipset initialization required
39 * before RAM initialization can work
40 */
41 haswell_early_initialization(HASWELL_MOBILE);
42 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
43
44 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080045#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060046 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060047#else
48 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060049 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060050#endif
51 }
52
Aaron Durbinbf396ff2013-02-11 21:50:35 -060053 /* There are hard coded assumptions of 2 meaning s3 wake. Normalize
54 * the users of the 2 literal here based off wake_from_s3. */
55 boot_mode = wake_from_s3 ? 2 : 0;
56
Aaron Durbina2671612013-02-06 21:41:01 -060057 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060058 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060059 enable_usb_bar();
60
61 post_code(0x3a);
62 params->pei_data->boot_mode = boot_mode;
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
Aaron Durbinc7633f42013-06-13 17:29:36 -070068 if (params->copy_spd != NULL)
69 params->copy_spd(params->pei_data);
70
Aaron Durbina2671612013-02-06 21:41:01 -060071 sdram_initialize(params->pei_data);
72
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030073 timestamp_add_now(TS_AFTER_INITRAM);
74
Aaron Durbina2671612013-02-06 21:41:01 -060075 post_code(0x3b);
76
77 intel_early_me_status();
78
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050079 if (!wake_from_s3) {
80 cbmem_initialize_empty();
81 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060082 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050083 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080084 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050085 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020086 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050087 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060088 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060089
Tristan Corrick334be322018-12-17 22:10:21 +130090 haswell_unhide_peg();
91
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050092 setup_sdram_meminfo(params->pei_data);
93
Aaron Durbin77e13992016-11-29 17:43:04 -060094 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060095
Aaron Durbina2671612013-02-06 21:41:01 -060096 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060097}