blob: ec44ee2c8ad09240b90ce28c748177f1dafcdda5 [file] [log] [blame]
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02001/*
2 * This file is part of the coreboot project.
3 *
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020013 */
14
15#include <stdint.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020016#include <console/console.h>
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020017#include <cf9_reset.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020018#include <device/pci_ops.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020019#include <cpu/x86/lapic.h>
20#include <timestamp.h>
21#include "sandybridge.h"
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +030022#include <arch/romstage.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060023#include <device/pci_def.h>
24#include <device/device.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060025#include <northbridge/intel/sandybridge/chip.h>
Elyes HAOUAS21b71ce62018-06-16 18:43:52 +020026#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe2f0a5f2019-03-24 14:47:47 +010027#include <southbridge/intel/common/pmclib.h>
Patrick Rudolph90050712019-03-25 09:53:23 +010028#include <elog.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020029
Arthur Heymansdc2e7c62019-11-12 16:17:26 +010030__weak void mainboard_early_init(int s3_resume)
31{
32}
33
Arthur Heymans9c538342019-11-12 16:42:33 +010034__weak void mainboard_late_rcba_config(void)
35{
36}
37
Patrick Rudolph45d4b172019-03-24 12:27:31 +010038static void early_pch_reset_pmcon(void)
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060039{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010040 u8 reg8;
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060041
Angel Pons7c49cb82020-03-16 23:17:32 +010042 /* Reset RTC power status */
Patrick Rudolph5c31af82017-05-03 17:47:54 +020043 reg8 = pci_read_config8(PCH_LPC_DEV, GEN_PMCON_3);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010044 reg8 &= ~(1 << 2);
Patrick Rudolph5c31af82017-05-03 17:47:54 +020045 pci_write_config8(PCH_LPC_DEV, GEN_PMCON_3, reg8);
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 Pons7c49cb82020-03-16 23:17:32 +010053 if (MCHBAR16(SSKPD_HI) == 0xCAFE)
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020054 system_reset();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020055
Kyösti Mälkki157b1892019-08-16 14:02:25 +030056 enable_lapic();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020057
Patrick Rudolph45d4b172019-03-24 12:27:31 +010058 /* Init LPC, GPIO, BARs, disable watchdog ... */
59 early_pch_init();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020060
Angel Pons7c49cb82020-03-16 23:17:32 +010061 /* When using MRC, USB is initialized by MRC */
Julius Werner5d1f9a02019-03-07 17:07:26 -080062 if (CONFIG(USE_NATIVE_RAMINIT)) {
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010063 early_usb_init(mainboard_usb_ports);
64 }
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020065
Angel Pons7c49cb82020-03-16 23:17:32 +010066 /* Perform some early chipset init needed before RAM initialization can work */
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +010067 systemagent_early_init();
68 printk(BIOS_DEBUG, "Back from systemagent_early_init()\n");
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020069
70 s3resume = southbridge_detect_s3_resume();
71
Kyösti Mälkki7f50afb2019-09-11 17:12:26 +030072 elog_boot_notify(s3resume);
Patrick Rudolph90050712019-03-25 09:53:23 +010073
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020074 post_code(0x38);
Vladimir Serbinenko609bd942016-01-31 14:00:54 +010075
76 mainboard_early_init(s3resume);
77
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020078 post_code(0x39);
79
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010080 perform_raminit(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020081
82 timestamp_add_now(TS_AFTER_INITRAM);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010083
84 post_code(0x3b);
85 /* Perform some initialization that must run before stage2 */
Patrick Rudolph45d4b172019-03-24 12:27:31 +010086 early_pch_reset_pmcon();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020087 post_code(0x3c);
88
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020089 southbridge_configure_default_intmap();
Nico Huberff4025c2018-01-14 12:34:43 +010090 southbridge_rcba_config();
Arthur Heymans9c538342019-11-12 16:42:33 +010091 mainboard_late_rcba_config();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010092
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020093 post_code(0x3d);
94
95 northbridge_romstage_finalize(s3resume);
96
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020097 post_code(0x3f);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020098}