blob: 81883038778d97dd833cfa53165991969355e2e0 [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>
31#include <southbridge/intel/ibexpeak/pch.h>
32#include <southbridge/intel/ibexpeak/me.h>
Arthur Heymanscea4fd92019-10-03 08:54:35 +020033
34/* Platform has no romstage entry point under mainboard directory,
35 * so this one is named with prefix mainboard.
36 */
37void mainboard_romstage_entry(void)
38{
39 u32 reg32;
40 int s3resume = 0;
41 u8 spd_addrmap[4] = {};
42
43 enable_lapic();
44
45 /* TODO, make this configurable */
46 nehalem_early_initialization(NEHALEM_MOBILE);
47
Arthur Heymansb9c9cd72019-10-10 15:06:33 +020048 early_pch_init();
49
Arthur Heymanscea4fd92019-10-03 08:54:35 +020050 /* Read PM1_CNT, DON'T CLEAR IT or raminit will fail! */
51 reg32 = inl(DEFAULT_PMBASE + 0x04);
52 printk(BIOS_DEBUG, "PM1_CNT: %08x\n", reg32);
53 if (((reg32 >> 10) & 7) == 5) {
54 u8 reg8;
55 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2);
56 printk(BIOS_DEBUG, "a2: %02x\n", reg8);
57 if (!(reg8 & 0x20)) {
58 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
59 printk(BIOS_DEBUG, "Bad resume from S3 detected.\n");
60 } else {
61 if (acpi_s3_resume_allowed()) {
62 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
63 s3resume = 1;
64 } else {
65 printk(BIOS_DEBUG,
66 "Resume from S3 detected, but disabled.\n");
67 }
68 }
69 }
70
71 /* Enable SMBUS. */
72 enable_smbus();
73
74 early_thermal_init();
75
76 timestamp_add_now(TS_BEFORE_INITRAM);
77
78 chipset_init(s3resume);
79
80 mainboard_pre_raminit();
81
82 mainboard_get_spd_map(spd_addrmap);
83
84 raminit(s3resume, spd_addrmap);
85
86 timestamp_add_now(TS_AFTER_INITRAM);
87
88 intel_early_me_status();
89
90 if (s3resume) {
91 /* Clear SLP_TYPE. This will break stage2 but
92 * we care for that when we get there.
93 */
94 reg32 = inl(DEFAULT_PMBASE + 0x04);
95 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
96 }
97
98 romstage_handoff_init(s3resume);
99}