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