blob: 86569c1cb4045f24f98edb63075809c5499d1c0e [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
Angel Pons9d8dac02022-04-09 08:34:29 +020019__weak void mainboard_early_init(int s3resume)
20{
21}
22
Arthur Heymans9c538342019-11-12 16:42:33 +010023__weak void mainboard_late_rcba_config(void)
24{
25}
26
Michał Żygowski68ff3372021-11-21 13:47:25 +010027static void configure_dpr(void)
28{
29 union dpr_register dpr = txt_get_chipset_dpr();
30
31 /*
32 * Just need to program the size of DPR, enable and lock it.
33 * The dpr.top will always point to TSEG_BASE (updated by hardware).
34 * We do it early because it will be needed later to calculate cbmem_top.
35 */
36 dpr.lock = 1;
37 dpr.epm = 1;
38 dpr.size = CONFIG_INTEL_TXT_DPR_SIZE;
39 pci_write_config32(HOST_BRIDGE, DPR, dpr.raw);
40}
41
Patrick Rudolph45d4b172019-03-24 12:27:31 +010042static void early_pch_reset_pmcon(void)
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060043{
Angel Pons7c49cb82020-03-16 23:17:32 +010044 /* Reset RTC power status */
Angel Pons9733f6a2020-06-07 19:23:03 +020045 pci_and_config8(PCH_LPC_DEV, GEN_PMCON_3, ~(1 << 2));
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060046}
47
Angel Pons7c49cb82020-03-16 23:17:32 +010048/* The romstage entry point for this platform is not mainboard-specific, hence the name */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030049void mainboard_romstage_entry(void)
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020050{
51 int s3resume = 0;
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020052
Angel Pons66780a02021-03-26 13:33:22 +010053 if (mchbar_read16(SSKPD_HI) == 0xcafe)
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020054 system_reset();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020055
Patrick Rudolph45d4b172019-03-24 12:27:31 +010056 /* Init LPC, GPIO, BARs, disable watchdog ... */
57 early_pch_init();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020058
Angel Pons7c49cb82020-03-16 23:17:32 +010059 /* When using MRC, USB is initialized by MRC */
Julius Werner5d1f9a02019-03-07 17:07:26 -080060 if (CONFIG(USE_NATIVE_RAMINIT)) {
Keith Huiee126342024-02-05 18:49:46 -050061 early_usb_init();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010062 }
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020063
Angel Pons7c49cb82020-03-16 23:17:32 +010064 /* Perform some early chipset init needed before RAM initialization can work */
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +010065 systemagent_early_init();
66 printk(BIOS_DEBUG, "Back from systemagent_early_init()\n");
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020067
68 s3resume = southbridge_detect_s3_resume();
69
Kyösti Mälkki7f50afb2019-09-11 17:12:26 +030070 elog_boot_notify(s3resume);
Patrick Rudolph90050712019-03-25 09:53:23 +010071
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020072 post_code(0x38);
Vladimir Serbinenko609bd942016-01-31 14:00:54 +010073
Angel Pons9d8dac02022-04-09 08:34:29 +020074 mainboard_early_init(s3resume);
75
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020076 post_code(0x39);
77
Michał Żygowski68ff3372021-11-21 13:47:25 +010078 if (CONFIG(INTEL_TXT)) {
79 configure_dpr();
80 intel_txt_romstage_init();
81 }
82
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010083 perform_raminit(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020084
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010085 post_code(0x3b);
86 /* Perform some initialization that must run before stage2 */
Patrick Rudolph45d4b172019-03-24 12:27:31 +010087 early_pch_reset_pmcon();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020088 post_code(0x3c);
89
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020090 southbridge_configure_default_intmap();
Nico Huberff4025c2018-01-14 12:34:43 +010091 southbridge_rcba_config();
Arthur Heymans9c538342019-11-12 16:42:33 +010092 mainboard_late_rcba_config();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010093
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020094 post_code(0x3d);
95
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +020096 northbridge_romstage_finalize();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020097
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020098 post_code(0x3f);
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +020099
100 romstage_handoff_init(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200101}