blob: 69383e6520ebba1e5f432053e65d0b929a154cfe [file] [log] [blame]
Arthur Heymanscea4fd92019-10-03 08:54:35 +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.
16 */
17
18#include <stdint.h>
19#include <console/console.h>
20#include <cf9_reset.h>
21#include <device/pci_ops.h>
22#include <cpu/x86/lapic.h>
23#include <timestamp.h>
24#include <romstage_handoff.h>
25#include "nehalem.h"
26#include <arch/romstage.h>
27#include <device/pci_def.h>
28#include <device/device.h>
29#include <northbridge/intel/nehalem/chip.h>
30#include <northbridge/intel/nehalem/raminit.h>
Arthur Heymans2878c0b2019-10-14 18:42:00 +020031#include <southbridge/intel/common/pmclib.h>
Arthur Heymanscea4fd92019-10-03 08:54:35 +020032#include <southbridge/intel/ibexpeak/pch.h>
33#include <southbridge/intel/ibexpeak/me.h>
Arthur Heymanscea4fd92019-10-03 08:54:35 +020034
35/* Platform has no romstage entry point under mainboard directory,
36 * so this one is named with prefix mainboard.
37 */
38void mainboard_romstage_entry(void)
39{
40 u32 reg32;
41 int s3resume = 0;
42 u8 spd_addrmap[4] = {};
43
44 enable_lapic();
45
46 /* TODO, make this configurable */
47 nehalem_early_initialization(NEHALEM_MOBILE);
48
Arthur Heymansb9c9cd72019-10-10 15:06:33 +020049 early_pch_init();
50
Arthur Heymans2878c0b2019-10-14 18:42:00 +020051 s3resume = southbridge_detect_s3_resume();
52 if (s3resume) {
53 u8 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2);
Arthur Heymanscea4fd92019-10-03 08:54:35 +020054 if (!(reg8 & 0x20)) {
Arthur Heymans2878c0b2019-10-14 18:42:00 +020055 s3resume = 0;
Arthur Heymanscea4fd92019-10-03 08:54:35 +020056 printk(BIOS_DEBUG, "Bad resume from S3 detected.\n");
Arthur Heymanscea4fd92019-10-03 08:54:35 +020057 }
58 }
59
60 /* Enable SMBUS. */
61 enable_smbus();
62
63 early_thermal_init();
64
65 timestamp_add_now(TS_BEFORE_INITRAM);
66
67 chipset_init(s3resume);
68
69 mainboard_pre_raminit();
70
71 mainboard_get_spd_map(spd_addrmap);
72
73 raminit(s3resume, spd_addrmap);
74
75 timestamp_add_now(TS_AFTER_INITRAM);
76
77 intel_early_me_status();
78
79 if (s3resume) {
80 /* Clear SLP_TYPE. This will break stage2 but
81 * we care for that when we get there.
82 */
83 reg32 = inl(DEFAULT_PMBASE + 0x04);
84 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
85 }
86
87 romstage_handoff_init(s3resume);
88}