Angel Pons | f23ae0b | 2020-04-02 23:48:12 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 3d0071b | 2013-01-18 14:32:50 -0600 | [diff] [blame] | 2 | |
Aaron Durbin | 3d0071b | 2013-01-18 14:32:50 -0600 | [diff] [blame] | 3 | #include <console/console.h> |
Patrick Rudolph | 45022ae | 2018-10-01 19:17:11 +0200 | [diff] [blame] | 4 | #include <cf9_reset.h> |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 5 | #include <timestamp.h> |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 6 | #include <cpu/x86/lapic.h> |
Kyösti Mälkki | 465eff6 | 2016-06-15 06:07:55 +0300 | [diff] [blame] | 7 | #include <cbmem.h> |
Elyes HAOUAS | d26844c | 2019-06-21 07:31:40 +0200 | [diff] [blame] | 8 | #include <commonlib/helpers.h> |
Aaron Durbin | bf396ff | 2013-02-11 21:50:35 -0600 | [diff] [blame] | 9 | #include <romstage_handoff.h> |
Angel Pons | 2e25ac6 | 2020-07-03 12:06:04 +0200 | [diff] [blame] | 10 | #include <cpu/intel/haswell/haswell.h> |
Elyes HAOUAS | 65bb543 | 2018-07-03 14:59:50 +0200 | [diff] [blame] | 11 | #include <northbridge/intel/haswell/haswell.h> |
12 | #include <northbridge/intel/haswell/raminit.h> | ||||
13 | #include <southbridge/intel/lynxpoint/pch.h> | ||||
14 | #include <southbridge/intel/lynxpoint/me.h> | ||||
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 15 | |
Angel Pons | 6eea191 | 2020-07-03 14:14:30 +0200 | [diff] [blame] | 16 | /* Copy SPD data for on-board memory */ |
17 | void __weak copy_spd(struct pei_data *peid) | ||||
18 | { | ||||
19 | } | ||||
20 | |||||
Angel Pons | 73fa035 | 2020-07-03 12:29:03 +0200 | [diff] [blame] | 21 | void __weak mb_late_romstage_setup(void) |
22 | { | ||||
23 | } | ||||
24 | |||||
Angel Pons | 14c4f4f | 2020-07-03 14:22:20 +0200 | [diff] [blame] | 25 | void romstage_common(struct pei_data *pei_data) |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 26 | { |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 27 | int wake_from_s3; |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 28 | |
Kyösti Mälkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 29 | enable_lapic(); |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 30 | |
Angel Pons | 03f0e43 | 2020-07-03 13:51:15 +0200 | [diff] [blame] | 31 | wake_from_s3 = early_pch_init(); |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 32 | |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 33 | /* Perform some early chipset initialization required |
34 | * before RAM initialization can work | ||||
35 | */ | ||||
Angel Pons | e816829 | 2020-07-03 11:42:22 +0200 | [diff] [blame] | 36 | haswell_early_initialization(); |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 37 | printk(BIOS_DEBUG, "Back from haswell_early_initialization()\n"); |
38 | |||||
39 | if (wake_from_s3) { | ||||
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 40 | #if CONFIG(HAVE_ACPI_RESUME) |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 41 | printk(BIOS_DEBUG, "Resume from S3 detected.\n"); |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 42 | #else |
43 | printk(BIOS_DEBUG, "Resume from S3 detected, but disabled.\n"); | ||||
Aaron Durbin | bf396ff | 2013-02-11 21:50:35 -0600 | [diff] [blame] | 44 | wake_from_s3 = 0; |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 45 | #endif |
46 | } | ||||
47 | |||||
48 | /* Prepare USB controller early in S3 resume */ | ||||
Aaron Durbin | bf396ff | 2013-02-11 21:50:35 -0600 | [diff] [blame] | 49 | if (wake_from_s3) |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 50 | enable_usb_bar(); |
51 | |||||
52 | post_code(0x3a); | ||||
Angel Pons | 284a547 | 2020-07-03 11:46:50 +0200 | [diff] [blame] | 53 | |
54 | /* MRC has hardcoded assumptions of 2 meaning S3 wake. Normalize it here. */ | ||||
Angel Pons | 14c4f4f | 2020-07-03 14:22:20 +0200 | [diff] [blame] | 55 | pei_data->boot_mode = wake_from_s3 ? 2 : 0; |
Kyösti Mälkki | 3d45c40 | 2013-09-07 20:26:36 +0300 | [diff] [blame] | 56 | |
57 | timestamp_add_now(TS_BEFORE_INITRAM); | ||||
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 58 | |
59 | report_platform_info(); | ||||
60 | |||||
Angel Pons | 14c4f4f | 2020-07-03 14:22:20 +0200 | [diff] [blame] | 61 | copy_spd(pei_data); |
Aaron Durbin | c7633f4 | 2013-06-13 17:29:36 -0700 | [diff] [blame] | 62 | |
Angel Pons | 14c4f4f | 2020-07-03 14:22:20 +0200 | [diff] [blame] | 63 | sdram_initialize(pei_data); |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 64 | |
Kyösti Mälkki | 3d45c40 | 2013-09-07 20:26:36 +0300 | [diff] [blame] | 65 | timestamp_add_now(TS_AFTER_INITRAM); |
66 | |||||
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 67 | post_code(0x3b); |
68 | |||||
69 | intel_early_me_status(); | ||||
70 | |||||
Aaron Durbin | c0cbd6e | 2013-03-13 13:51:20 -0500 | [diff] [blame] | 71 | if (!wake_from_s3) { |
72 | cbmem_initialize_empty(); | ||||
73 | /* Save data returned from MRC on non-S3 resumes. */ | ||||
Angel Pons | 14c4f4f | 2020-07-03 14:22:20 +0200 | [diff] [blame] | 74 | save_mrc_data(pei_data); |
Aaron Durbin | 42e6856 | 2015-06-09 13:55:51 -0500 | [diff] [blame] | 75 | } else if (cbmem_initialize()) { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 76 | #if CONFIG(HAVE_ACPI_RESUME) |
Aaron Durbin | 42e6856 | 2015-06-09 13:55:51 -0500 | [diff] [blame] | 77 | /* Failed S3 resume, reset to come up cleanly */ |
Patrick Rudolph | 45022ae | 2018-10-01 19:17:11 +0200 | [diff] [blame] | 78 | system_reset(); |
Aaron Durbin | 42e6856 | 2015-06-09 13:55:51 -0500 | [diff] [blame] | 79 | #endif |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 80 | } |
Aaron Durbin | bf396ff | 2013-02-11 21:50:35 -0600 | [diff] [blame] | 81 | |
Tristan Corrick | 334be32 | 2018-12-17 22:10:21 +1300 | [diff] [blame] | 82 | haswell_unhide_peg(); |
83 | |||||
Angel Pons | 14c4f4f | 2020-07-03 14:22:20 +0200 | [diff] [blame] | 84 | setup_sdram_meminfo(pei_data); |
Matt DeVillier | 5aaa8ce | 2016-09-02 13:29:17 -0500 | [diff] [blame] | 85 | |
Aaron Durbin | 77e1399 | 2016-11-29 17:43:04 -0600 | [diff] [blame] | 86 | romstage_handoff_init(wake_from_s3); |
Aaron Durbin | bf396ff | 2013-02-11 21:50:35 -0600 | [diff] [blame] | 87 | |
Angel Pons | 73fa035 | 2020-07-03 12:29:03 +0200 | [diff] [blame] | 88 | mb_late_romstage_setup(); |
89 | |||||
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 90 | post_code(0x3f); |
Aaron Durbin | a267161 | 2013-02-06 21:41:01 -0600 | [diff] [blame] | 91 | } |