blob: 71b8e1278285e0ea001d3f7f84ed2e581f2e6220 [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>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02006#include <cpu/x86/lapic.h>
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +02007#include <romstage_handoff.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02008#include "sandybridge.h"
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +03009#include <arch/romstage.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060010#include <device/pci_def.h>
11#include <device/device.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060012#include <northbridge/intel/sandybridge/chip.h>
Michał Żygowski68ff3372021-11-21 13:47:25 +010013#include <security/intel/txt/txt.h>
14#include <security/intel/txt/txt_platform.h>
15#include <security/intel/txt/txt_register.h>
Elyes HAOUAS21b71ce62018-06-16 18:43:52 +020016#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe2f0a5f2019-03-24 14:47:47 +010017#include <southbridge/intel/common/pmclib.h>
Patrick Rudolph90050712019-03-25 09:53:23 +010018#include <elog.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020019
Arthur Heymansdc2e7c62019-11-12 16:17:26 +010020__weak void mainboard_early_init(int s3_resume)
21{
22}
23
Arthur Heymans9c538342019-11-12 16:42:33 +010024__weak void mainboard_late_rcba_config(void)
25{
26}
27
Michał Żygowski68ff3372021-11-21 13:47:25 +010028static void configure_dpr(void)
29{
30 union dpr_register dpr = txt_get_chipset_dpr();
31
32 /*
33 * Just need to program the size of DPR, enable and lock it.
34 * The dpr.top will always point to TSEG_BASE (updated by hardware).
35 * We do it early because it will be needed later to calculate cbmem_top.
36 */
37 dpr.lock = 1;
38 dpr.epm = 1;
39 dpr.size = CONFIG_INTEL_TXT_DPR_SIZE;
40 pci_write_config32(HOST_BRIDGE, DPR, dpr.raw);
41}
42
Patrick Rudolph45d4b172019-03-24 12:27:31 +010043static void early_pch_reset_pmcon(void)
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060044{
Angel Pons7c49cb82020-03-16 23:17:32 +010045 /* Reset RTC power status */
Angel Pons9733f6a2020-06-07 19:23:03 +020046 pci_and_config8(PCH_LPC_DEV, GEN_PMCON_3, ~(1 << 2));
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060047}
48
Angel Pons7c49cb82020-03-16 23:17:32 +010049/* The romstage entry point for this platform is not mainboard-specific, hence the name */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030050void mainboard_romstage_entry(void)
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020051{
52 int s3resume = 0;
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020053
Angel Pons66780a02021-03-26 13:33:22 +010054 if (mchbar_read16(SSKPD_HI) == 0xcafe)
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020055 system_reset();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020056
Kyösti Mälkki157b1892019-08-16 14:02:25 +030057 enable_lapic();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020058
Patrick Rudolph45d4b172019-03-24 12:27:31 +010059 /* Init LPC, GPIO, BARs, disable watchdog ... */
60 early_pch_init();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020061
Angel Pons7c49cb82020-03-16 23:17:32 +010062 /* When using MRC, USB is initialized by MRC */
Julius Werner5d1f9a02019-03-07 17:07:26 -080063 if (CONFIG(USE_NATIVE_RAMINIT)) {
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010064 early_usb_init(mainboard_usb_ports);
65 }
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020066
Angel Pons7c49cb82020-03-16 23:17:32 +010067 /* Perform some early chipset init needed before RAM initialization can work */
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +010068 systemagent_early_init();
69 printk(BIOS_DEBUG, "Back from systemagent_early_init()\n");
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020070
71 s3resume = southbridge_detect_s3_resume();
72
Kyösti Mälkki7f50afb2019-09-11 17:12:26 +030073 elog_boot_notify(s3resume);
Patrick Rudolph90050712019-03-25 09:53:23 +010074
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020075 post_code(0x38);
Vladimir Serbinenko609bd942016-01-31 14:00:54 +010076
77 mainboard_early_init(s3resume);
78
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020079 post_code(0x39);
80
Michał Żygowski68ff3372021-11-21 13:47:25 +010081 if (CONFIG(INTEL_TXT)) {
82 configure_dpr();
83 intel_txt_romstage_init();
84 }
85
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010086 perform_raminit(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020087
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010088 post_code(0x3b);
89 /* Perform some initialization that must run before stage2 */
Patrick Rudolph45d4b172019-03-24 12:27:31 +010090 early_pch_reset_pmcon();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020091 post_code(0x3c);
92
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020093 southbridge_configure_default_intmap();
Nico Huberff4025c2018-01-14 12:34:43 +010094 southbridge_rcba_config();
Arthur Heymans9c538342019-11-12 16:42:33 +010095 mainboard_late_rcba_config();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010096
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020097 post_code(0x3d);
98
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +020099 northbridge_romstage_finalize();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200100
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200101 post_code(0x3f);
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +0200102
103 romstage_handoff_init(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200104}