Angel Pons | 6e5aabd | 2020-03-23 23:44:42 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 2 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 3 | #include <console/console.h> |
Elyes HAOUAS | 1bc7b6e | 2019-05-05 16:29:41 +0200 | [diff] [blame] | 4 | #include <cf9_reset.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 5 | #include <device/pci_ops.h> |
Kyösti Mälkki | 4ce0a07 | 2021-02-17 18:10:49 +0200 | [diff] [blame] | 6 | #include <romstage_handoff.h> |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 7 | #include "sandybridge.h" |
Kyösti Mälkki | cd7a70f | 2019-08-17 20:51:08 +0300 | [diff] [blame] | 8 | #include <arch/romstage.h> |
Alexandru Gagniuc | 8b2c8f1 | 2015-02-17 04:31:01 -0600 | [diff] [blame] | 9 | #include <device/pci_def.h> |
| 10 | #include <device/device.h> |
Alexandru Gagniuc | 8b2c8f1 | 2015-02-17 04:31:01 -0600 | [diff] [blame] | 11 | #include <northbridge/intel/sandybridge/chip.h> |
Michał Żygowski | 68ff337 | 2021-11-21 13:47:25 +0100 | [diff] [blame] | 12 | #include <security/intel/txt/txt.h> |
| 13 | #include <security/intel/txt/txt_platform.h> |
| 14 | #include <security/intel/txt/txt_register.h> |
Elyes HAOUAS | 21b71ce6 | 2018-06-16 18:43:52 +0200 | [diff] [blame] | 15 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e2f0a5f | 2019-03-24 14:47:47 +0100 | [diff] [blame] | 16 | #include <southbridge/intel/common/pmclib.h> |
Patrick Rudolph | 9005071 | 2019-03-25 09:53:23 +0100 | [diff] [blame] | 17 | #include <elog.h> |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 18 | |
Arthur Heymans | 9c53834 | 2019-11-12 16:42:33 +0100 | [diff] [blame] | 19 | __weak void mainboard_late_rcba_config(void) |
| 20 | { |
| 21 | } |
| 22 | |
Michał Żygowski | 68ff337 | 2021-11-21 13:47:25 +0100 | [diff] [blame] | 23 | static void configure_dpr(void) |
| 24 | { |
| 25 | union dpr_register dpr = txt_get_chipset_dpr(); |
| 26 | |
| 27 | /* |
| 28 | * Just need to program the size of DPR, enable and lock it. |
| 29 | * The dpr.top will always point to TSEG_BASE (updated by hardware). |
| 30 | * We do it early because it will be needed later to calculate cbmem_top. |
| 31 | */ |
| 32 | dpr.lock = 1; |
| 33 | dpr.epm = 1; |
| 34 | dpr.size = CONFIG_INTEL_TXT_DPR_SIZE; |
| 35 | pci_write_config32(HOST_BRIDGE, DPR, dpr.raw); |
| 36 | } |
| 37 | |
Patrick Rudolph | 45d4b17 | 2019-03-24 12:27:31 +0100 | [diff] [blame] | 38 | static void early_pch_reset_pmcon(void) |
Alexandru Gagniuc | 8b2c8f1 | 2015-02-17 04:31:01 -0600 | [diff] [blame] | 39 | { |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 40 | /* Reset RTC power status */ |
Angel Pons | 9733f6a | 2020-06-07 19:23:03 +0200 | [diff] [blame] | 41 | pci_and_config8(PCH_LPC_DEV, GEN_PMCON_3, ~(1 << 2)); |
Alexandru Gagniuc | 8b2c8f1 | 2015-02-17 04:31:01 -0600 | [diff] [blame] | 42 | } |
| 43 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 44 | /* The romstage entry point for this platform is not mainboard-specific, hence the name */ |
Kyösti Mälkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 45 | void mainboard_romstage_entry(void) |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 46 | { |
| 47 | int s3resume = 0; |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 48 | |
Angel Pons | 66780a0 | 2021-03-26 13:33:22 +0100 | [diff] [blame] | 49 | if (mchbar_read16(SSKPD_HI) == 0xcafe) |
Elyes HAOUAS | 1bc7b6e | 2019-05-05 16:29:41 +0200 | [diff] [blame] | 50 | system_reset(); |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 51 | |
Patrick Rudolph | 45d4b17 | 2019-03-24 12:27:31 +0100 | [diff] [blame] | 52 | /* Init LPC, GPIO, BARs, disable watchdog ... */ |
| 53 | early_pch_init(); |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 54 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 55 | /* When using MRC, USB is initialized by MRC */ |
Julius Werner | 5d1f9a0 | 2019-03-07 17:07:26 -0800 | [diff] [blame] | 56 | if (CONFIG(USE_NATIVE_RAMINIT)) { |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 57 | early_usb_init(mainboard_usb_ports); |
| 58 | } |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 59 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 60 | /* Perform some early chipset init needed before RAM initialization can work */ |
Patrick Rudolph | 2cdb65d | 2019-03-24 18:08:43 +0100 | [diff] [blame] | 61 | systemagent_early_init(); |
| 62 | printk(BIOS_DEBUG, "Back from systemagent_early_init()\n"); |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 63 | |
| 64 | s3resume = southbridge_detect_s3_resume(); |
| 65 | |
Kyösti Mälkki | 7f50afb | 2019-09-11 17:12:26 +0300 | [diff] [blame] | 66 | elog_boot_notify(s3resume); |
Patrick Rudolph | 9005071 | 2019-03-25 09:53:23 +0100 | [diff] [blame] | 67 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 68 | post_code(0x38); |
Vladimir Serbinenko | 609bd94 | 2016-01-31 14:00:54 +0100 | [diff] [blame] | 69 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 70 | post_code(0x39); |
| 71 | |
Michał Żygowski | 68ff337 | 2021-11-21 13:47:25 +0100 | [diff] [blame] | 72 | if (CONFIG(INTEL_TXT)) { |
| 73 | configure_dpr(); |
| 74 | intel_txt_romstage_init(); |
| 75 | } |
| 76 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 77 | perform_raminit(s3resume); |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 78 | |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 79 | post_code(0x3b); |
| 80 | /* Perform some initialization that must run before stage2 */ |
Patrick Rudolph | 45d4b17 | 2019-03-24 12:27:31 +0100 | [diff] [blame] | 81 | early_pch_reset_pmcon(); |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 82 | post_code(0x3c); |
| 83 | |
Vladimir Serbinenko | 33b535f | 2014-10-19 10:13:14 +0200 | [diff] [blame] | 84 | southbridge_configure_default_intmap(); |
Nico Huber | ff4025c | 2018-01-14 12:34:43 +0100 | [diff] [blame] | 85 | southbridge_rcba_config(); |
Arthur Heymans | 9c53834 | 2019-11-12 16:42:33 +0100 | [diff] [blame] | 86 | mainboard_late_rcba_config(); |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 87 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 88 | post_code(0x3d); |
| 89 | |
Kyösti Mälkki | 4ce0a07 | 2021-02-17 18:10:49 +0200 | [diff] [blame] | 90 | northbridge_romstage_finalize(); |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 91 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 92 | post_code(0x3f); |
Kyösti Mälkki | 4ce0a07 | 2021-02-17 18:10:49 +0200 | [diff] [blame] | 93 | |
| 94 | romstage_handoff_init(s3resume); |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 95 | } |