blob: fad8e2f91aab58bc4aea405d0977b29aee68deec [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 <timestamp.h>
9#include "sandybridge.h"
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +030010#include <arch/romstage.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060011#include <device/pci_def.h>
12#include <device/device.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060013#include <northbridge/intel/sandybridge/chip.h>
Elyes HAOUAS21b71ce62018-06-16 18:43:52 +020014#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe2f0a5f2019-03-24 14:47:47 +010015#include <southbridge/intel/common/pmclib.h>
Patrick Rudolph90050712019-03-25 09:53:23 +010016#include <elog.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020017
Arthur Heymansdc2e7c62019-11-12 16:17:26 +010018__weak void mainboard_early_init(int s3_resume)
19{
20}
21
Arthur Heymans9c538342019-11-12 16:42:33 +010022__weak void mainboard_late_rcba_config(void)
23{
24}
25
Patrick Rudolph45d4b172019-03-24 12:27:31 +010026static void early_pch_reset_pmcon(void)
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060027{
Angel Pons7c49cb82020-03-16 23:17:32 +010028 /* Reset RTC power status */
Angel Pons9733f6a2020-06-07 19:23:03 +020029 pci_and_config8(PCH_LPC_DEV, GEN_PMCON_3, ~(1 << 2));
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060030}
31
Angel Pons7c49cb82020-03-16 23:17:32 +010032/* The romstage entry point for this platform is not mainboard-specific, hence the name */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030033void mainboard_romstage_entry(void)
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020034{
35 int s3resume = 0;
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020036
Angel Pons7c49cb82020-03-16 23:17:32 +010037 if (MCHBAR16(SSKPD_HI) == 0xCAFE)
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020038 system_reset();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020039
Kyösti Mälkki157b1892019-08-16 14:02:25 +030040 enable_lapic();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020041
Patrick Rudolph45d4b172019-03-24 12:27:31 +010042 /* Init LPC, GPIO, BARs, disable watchdog ... */
43 early_pch_init();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020044
Angel Pons7c49cb82020-03-16 23:17:32 +010045 /* When using MRC, USB is initialized by MRC */
Julius Werner5d1f9a02019-03-07 17:07:26 -080046 if (CONFIG(USE_NATIVE_RAMINIT)) {
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010047 early_usb_init(mainboard_usb_ports);
48 }
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020049
Angel Pons7c49cb82020-03-16 23:17:32 +010050 /* Perform some early chipset init needed before RAM initialization can work */
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +010051 systemagent_early_init();
52 printk(BIOS_DEBUG, "Back from systemagent_early_init()\n");
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020053
54 s3resume = southbridge_detect_s3_resume();
55
Kyösti Mälkki7f50afb2019-09-11 17:12:26 +030056 elog_boot_notify(s3resume);
Patrick Rudolph90050712019-03-25 09:53:23 +010057
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020058 post_code(0x38);
Vladimir Serbinenko609bd942016-01-31 14:00:54 +010059
60 mainboard_early_init(s3resume);
61
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020062 post_code(0x39);
63
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010064 perform_raminit(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020065
66 timestamp_add_now(TS_AFTER_INITRAM);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010067
68 post_code(0x3b);
69 /* Perform some initialization that must run before stage2 */
Patrick Rudolph45d4b172019-03-24 12:27:31 +010070 early_pch_reset_pmcon();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020071 post_code(0x3c);
72
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020073 southbridge_configure_default_intmap();
Nico Huberff4025c2018-01-14 12:34:43 +010074 southbridge_rcba_config();
Arthur Heymans9c538342019-11-12 16:42:33 +010075 mainboard_late_rcba_config();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010076
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020077 post_code(0x3d);
78
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +020079 northbridge_romstage_finalize();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020080
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020081 post_code(0x3f);
Kyösti Mälkki4ce0a072021-02-17 18:10:49 +020082
83 romstage_handoff_init(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020084}