blob: 2cef5f260533fafe32da37ca365f58b984781512 [file] [log] [blame]
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
6 * Copyright (C) 2014 Vladimir Serbinenko
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020016 */
17
18#include <stdint.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020019#include <console/console.h>
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020020#include <cf9_reset.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020022#include <cpu/x86/lapic.h>
23#include <timestamp.h>
24#include "sandybridge.h"
25#include <cpu/x86/bist.h>
26#include <cpu/intel/romstage.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060027#include <device/pci_def.h>
28#include <device/device.h>
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060029#include <northbridge/intel/sandybridge/chip.h>
Elyes HAOUAS21b71ce62018-06-16 18:43:52 +020030#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe2f0a5f2019-03-24 14:47:47 +010031#include <southbridge/intel/common/pmclib.h>
Patrick Rudolph90050712019-03-25 09:53:23 +010032#include <elog.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020033
Patrick Rudolph45d4b172019-03-24 12:27:31 +010034static void early_pch_reset_pmcon(void)
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060035{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010036 u8 reg8;
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060037
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010038 // reset rtc power status
Patrick Rudolph5c31af82017-05-03 17:47:54 +020039 reg8 = pci_read_config8(PCH_LPC_DEV, GEN_PMCON_3);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010040 reg8 &= ~(1 << 2);
Patrick Rudolph5c31af82017-05-03 17:47:54 +020041 pci_write_config8(PCH_LPC_DEV, GEN_PMCON_3, reg8);
Alexandru Gagniuc8b2c8f12015-02-17 04:31:01 -060042}
43
Kyösti Mälkki75d139b2016-06-17 10:00:28 +030044/* Platform has no romstage entry point under mainboard directory,
45 * so this one is named with prefix mainboard.
46 */
47void mainboard_romstage_entry(unsigned long bist)
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020048{
49 int s3resume = 0;
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020050
Elyes HAOUAS1bc7b6e2019-05-05 16:29:41 +020051 if (MCHBAR16(SSKPD) == 0xCAFE)
52 system_reset();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020053
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020054 if (bist == 0)
55 enable_lapic();
56
Patrick Rudolph45d4b172019-03-24 12:27:31 +010057 /* Init LPC, GPIO, BARs, disable watchdog ... */
58 early_pch_init();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020059
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010060 /* Initialize superio */
61 mainboard_config_superio();
62
Martin Roth128c1042016-11-18 09:29:03 -070063 /* USB is initialized in MRC if MRC is used. */
Julius Werner5d1f9a02019-03-07 17:07:26 -080064 if (CONFIG(USE_NATIVE_RAMINIT)) {
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010065 early_usb_init(mainboard_usb_ports);
66 }
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020067
68 /* Initialize console device(s) */
69 console_init();
70
71 /* Halt if there was a built in self test failure */
72 report_bist_failure(bist);
73
74 /* Perform some early chipset initialization required
75 * before RAM initialization can work
76 */
Patrick Rudolph2cdb65d2019-03-24 18:08:43 +010077 systemagent_early_init();
78 printk(BIOS_DEBUG, "Back from systemagent_early_init()\n");
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020079
80 s3resume = southbridge_detect_s3_resume();
81
Patrick Rudolph90050712019-03-25 09:53:23 +010082 if (CONFIG(ELOG_BOOT_COUNT) && !s3resume)
83 boot_count_increment();
84
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020085 post_code(0x38);
Vladimir Serbinenko609bd942016-01-31 14:00:54 +010086
87 mainboard_early_init(s3resume);
88
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020089 /* Enable SPD ROMs and DDR-III DRAM */
90 enable_smbus();
91
92 post_code(0x39);
93
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010094 perform_raminit(s3resume);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020095
96 timestamp_add_now(TS_AFTER_INITRAM);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010097
98 post_code(0x3b);
99 /* Perform some initialization that must run before stage2 */
Patrick Rudolph45d4b172019-03-24 12:27:31 +0100100 early_pch_reset_pmcon();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200101 post_code(0x3c);
102
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +0200103 southbridge_configure_default_intmap();
Nico Huberff4025c2018-01-14 12:34:43 +0100104 southbridge_rcba_config();
105 mainboard_rcba_config();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100106
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200107 post_code(0x3d);
108
109 northbridge_romstage_finalize(s3resume);
110
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200111 post_code(0x3f);
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +0200112}