blob: 43f5109889458c64b99491ba7540b35251a18455 [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
Kyösti Mälkki157b1892019-08-16 14:02:25 +030036 enable_lapic();
Aaron Durbina2671612013-02-06 21:41:01 -060037
38 wake_from_s3 = early_pch_init(params->gpio_map, params->rcba_config);
39
Aaron Durbina2671612013-02-06 21:41:01 -060040 /* Perform some early chipset initialization required
41 * before RAM initialization can work
42 */
43 haswell_early_initialization(HASWELL_MOBILE);
44 printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n");
45
46 if (wake_from_s3) {
Julius Wernercd49cce2019-03-05 16:53:33 -080047#if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbina2671612013-02-06 21:41:01 -060048 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
Aaron Durbina2671612013-02-06 21:41:01 -060049#else
50 printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n");
Aaron Durbinbf396ff2013-02-11 21:50:35 -060051 wake_from_s3 = 0;
Aaron Durbina2671612013-02-06 21:41:01 -060052#endif
53 }
54
Aaron Durbinbf396ff2013-02-11 21:50:35 -060055 /* There are hard coded assumptions of 2 meaning s3 wake. Normalize
56 * the users of the 2 literal here based off wake_from_s3. */
57 boot_mode = wake_from_s3 ? 2 : 0;
58
Aaron Durbina2671612013-02-06 21:41:01 -060059 /* Prepare USB controller early in S3 resume */
Aaron Durbinbf396ff2013-02-11 21:50:35 -060060 if (wake_from_s3)
Aaron Durbina2671612013-02-06 21:41:01 -060061 enable_usb_bar();
62
63 post_code(0x3a);
64 params->pei_data->boot_mode = boot_mode;
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030065
66 timestamp_add_now(TS_BEFORE_INITRAM);
Aaron Durbina2671612013-02-06 21:41:01 -060067
68 report_platform_info();
69
Aaron Durbinc7633f42013-06-13 17:29:36 -070070 if (params->copy_spd != NULL)
71 params->copy_spd(params->pei_data);
72
Aaron Durbina2671612013-02-06 21:41:01 -060073 sdram_initialize(params->pei_data);
74
Kyösti Mälkki3d45c402013-09-07 20:26:36 +030075 timestamp_add_now(TS_AFTER_INITRAM);
76
Aaron Durbina2671612013-02-06 21:41:01 -060077 post_code(0x3b);
78
79 intel_early_me_status();
80
Aaron Durbinc0cbd6e2013-03-13 13:51:20 -050081 if (!wake_from_s3) {
82 cbmem_initialize_empty();
83 /* Save data returned from MRC on non-S3 resumes. */
Aaron Durbin2ad1dba2013-02-07 00:51:18 -060084 save_mrc_data(params->pei_data);
Aaron Durbin42e68562015-06-09 13:55:51 -050085 } else if (cbmem_initialize()) {
Julius Wernercd49cce2019-03-05 16:53:33 -080086 #if CONFIG(HAVE_ACPI_RESUME)
Aaron Durbin42e68562015-06-09 13:55:51 -050087 /* Failed S3 resume, reset to come up cleanly */
Patrick Rudolph45022ae2018-10-01 19:17:11 +020088 system_reset();
Aaron Durbin42e68562015-06-09 13:55:51 -050089 #endif
Aaron Durbina2671612013-02-06 21:41:01 -060090 }
Aaron Durbinbf396ff2013-02-11 21:50:35 -060091
Tristan Corrick334be322018-12-17 22:10:21 +130092 haswell_unhide_peg();
93
Matt DeVillier5aaa8ce2016-09-02 13:29:17 -050094 setup_sdram_meminfo(params->pei_data);
95
Aaron Durbin77e13992016-11-29 17:43:04 -060096 romstage_handoff_init(wake_from_s3);
Aaron Durbinbf396ff2013-02-11 21:50:35 -060097
Aaron Durbina2671612013-02-06 21:41:01 -060098 post_code(0x3f);
Aaron Durbina2671612013-02-06 21:41:01 -060099}