blob: 1b6e744c5a7833d7802ad46168a8c458f43bf75b [file] [log] [blame]
Angel Pons6e5aabd2020-03-23 23:44:42 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02002
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02003#include <console/console.h>
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +02004#include <cf9_reset.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02005#include <device/pci_ops.h>
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +02006#include <romstage_handoff.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02007#include "sandybridge.h"
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +03008#include <arch/romstage.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -06009#include <device/pci_def.h>
10#include <device/device.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060011#include <northbridge/intel/sandybridge/chip.h>
Michał Żygowski68ff3372021-11-21 13:47:25 +010012#include <security/intel/txt/txt.h>
13#include <security/intel/txt/txt_platform.h>
14#include <security/intel/txt/txt_register.h>
Elyes HAOUAS21b71ce62018-06-16 18:43:52 +020015#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe2f0a5f2019-03-24 14:47:47 +010016#include <southbridge/intel/common/pmclib.h>
Patrick Rudolph90050712019-03-25 09:53:23 +010017#include <elog.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020018
Arthur Heymans9c538342019-11-12 16:42:33 +010019__weak void mainboard_late_rcba_config(void)
20{
21}
22
Michał Żygowski68ff3372021-11-21 13:47:25 +010023static 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 Rudolph45d4b172019-03-24 12:27:31 +010038static void early_pch_reset_pmcon(void)
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060039{
Angel Pons7c49cb82020-03-16 23:17:32 +010040 /* Reset RTC power status */
Angel Pons9733f6a2020-06-07 19:23:03 +020041 pci_and_config8(PCH_LPC_DEV, GEN_PMCON_3, ~(1 << 2));
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060042}
43
Angel Pons7c49cb82020-03-16 23:17:32 +010044/* The romstage entry point for this platform is not mainboard-specific, hence the name */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030045void mainboard_romstage_entry(void)
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020046{
47 int s3resume = 0;
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020048
Angel Pons66780a02021-03-26 13:33:22 +010049 if (mchbar_read16(SSKPD_HI) == 0xcafe)
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020050 system_reset();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020051
Patrick Rudolph45d4b172019-03-24 12:27:31 +010052 /* Init LPC, GPIO, BARs, disable watchdog ... */
53 early_pch_init();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020054
Angel Pons7c49cb82020-03-16 23:17:32 +010055 /* When using MRC, USB is initialized by MRC */
Julius Werner5d1f9a02019-03-07 17:07:26 -080056 if (CONFIG(USE_NATIVE_RAMINIT)) {
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010057 early_usb_init(mainboard_usb_ports);
58 }
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020059
Angel Pons7c49cb82020-03-16 23:17:32 +010060 /* Perform some early chipset init needed before RAM initialization can work */
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +010061 systemagent_early_init();
62 printk(BIOS_DEBUG, "Back from systemagent_early_init()\n");
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020063
64 s3resume = southbridge_detect_s3_resume();
65
Kyösti Mälkki7f50afb2019-09-11 17:12:26 +030066 elog_boot_notify(s3resume);
Patrick Rudolph90050712019-03-25 09:53:23 +010067
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020068 post_code(0x38);
Vladimir Serbinenko609bd942016-01-31 14:00:54 +010069
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020070 post_code(0x39);
71
Michał Żygowski68ff3372021-11-21 13:47:25 +010072 if (CONFIG(INTEL_TXT)) {
73 configure_dpr();
74 intel_txt_romstage_init();
75 }
76
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010077 perform_raminit(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020078
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010079 post_code(0x3b);
80 /* Perform some initialization that must run before stage2 */
Patrick Rudolph45d4b172019-03-24 12:27:31 +010081 early_pch_reset_pmcon();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020082 post_code(0x3c);
83
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020084 southbridge_configure_default_intmap();
Nico Huberff4025c2018-01-14 12:34:43 +010085 southbridge_rcba_config();
Arthur Heymans9c538342019-11-12 16:42:33 +010086 mainboard_late_rcba_config();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010087
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020088 post_code(0x3d);
89
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +020090 northbridge_romstage_finalize();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020091
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020092 post_code(0x3f);
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +020093
94 romstage_handoff_init(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020095}