blob: 544a93fd9710434a760e718731943a8368cdcf03 [file] [log] [blame]
Aaron Durbin3d0071b2013-01-18 14:32:50 -06001/*
2 * This file is part of the coreboot project.
3 *
Patrick Georgi5b2a2d02018-09-26 20:46:04 +02004 * Copyright (C) 2012 Google LLC
Aaron Durbin3d0071b2013-01-18 14:32:50 -06005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbin3d0071b2013-01-18 14:32:50 -060014 */
15
16#include <stdint.h>
Aaron Durbin3d0071b2013-01-18 14:32:50 -060017#include <console/console.h>
Patrick Rudolph45022ae2018-10-01 19:17:11 +020018#include <cf9_reset.h>
Aaron Durbina2671612013-02-06 21:41:01 -060019#include <cpu/x86/bist.h>
Aaron Durbina2671612013-02-06 21:41:01 -060020#include <timestamp.h>
Aaron Durbina2671612013-02-06 21:41:01 -060021#include <cpu/x86/lapic.h>
Kyösti Mälkki465eff62016-06-15 06:07:55 +030022#include <cbmem.h>
Elyes HAOUASd26844c2019-06-21 07:31:40 +020023#include <commonlib/helpers.h>
Aaron Durbinbf396ff2013-02-11 21:50:35 -060024#include <romstage_handoff.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020025#include <northbridge/intel/haswell/haswell.h>
26#include <northbridge/intel/haswell/raminit.h>
27#include <southbridge/intel/lynxpoint/pch.h>
28#include <southbridge/intel/lynxpoint/me.h>
Elyes HAOUAS65bb5432018-07-03 14:59:50 +020029#include "haswell.h"
Aaron Durbina2671612013-02-06 21:41:01 -060030
Aaron Durbina2671612013-02-06 21:41:01 -060031void romstage_common(const struct romstage_params *params)
32{
Aaron Durbinbf396ff2013-02-11 21:50:35 -060033 int boot_mode;
Aaron Durbina2671612013-02-06 21:41:01 -060034 int wake_from_s3;
Aaron Durbina2671612013-02-06 21:41:01 -060035
Aaron Durbina2671612013-02-06 21:41:01 -060036 if (params->bist == 0)
37 enable_lapic();
38
39 wake_from_s3 = early_pch_init(params->gpio_map, params->rcba_config);
40
41 /* Halt if there was a built in self test failure */
42 report_bist_failure(params->bist);
43
44 /* Perform some early chipset initialization required
45 * before RAM initialization can work
46 */
47 haswell_early_initialization(HASWELL_MOBILE);
48 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
49
50 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080051#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060052 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060053#else
54 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060055 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060056#endif
57 }
58
Aaron Durbinbf396ff2013-02-11 21:50:35 -060059 /* There are hard coded assumptions of 2 meaning s3 wake. Normalize
60 * the users of the 2 literal here based off wake_from_s3. */
61 boot_mode = wake_from_s3 ? 2 : 0;
62
Aaron Durbina2671612013-02-06 21:41:01 -060063 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060064 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060065 enable_usb_bar();
66
67 post_code(0x3a);
68 params->pei_data->boot_mode = boot_mode;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030069
70 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060071
72 report_platform_info();
73
Aaron Durbinc7633f42013-06-13 17:29:36 -070074 if (params->copy_spd != NULL)
75 params->copy_spd(params->pei_data);
76
Aaron Durbina2671612013-02-06 21:41:01 -060077 sdram_initialize(params->pei_data);
78
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030079 timestamp_add_now(TS_AFTER_INITRAM);
80
Aaron Durbina2671612013-02-06 21:41:01 -060081 post_code(0x3b);
82
83 intel_early_me_status();
84
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050085 if (!wake_from_s3) {
86 cbmem_initialize_empty();
87 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060088 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050089 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080090 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050091 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020092 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050093 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060094 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060095
Tristan Corrick334be322018-12-17 22:10:21 +130096 haswell_unhide_peg();
97
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050098 setup_sdram_meminfo(params->pei_data);
99
Aaron Durbin77e13992016-11-29 17:43:04 -0600100 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -0600101
Aaron Durbina2671612013-02-06 21:41:01 -0600102 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -0600103}