blob: 54766de0e702c0c7802c948c0c10e5fec30baae3 [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 pch_pre_console_init();
Arthur Heymanscea4fd92019-10-03 08:54:35 +020049
50 /* Initialize console device(s) */
51 console_init();
52
Arthur Heymansb9c9cd72019-10-10 15:06:33 +020053 early_pch_init();
54
Arthur Heymanscea4fd92019-10-03 08:54:35 +020055 /* Read PM1_CNT, DON'T CLEAR IT or raminit will fail! */
56 reg32 = inl(DEFAULT_PMBASE + 0x04);
57 printk(BIOS_DEBUG, "PM1_CNT: %08x\n", reg32);
58 if (((reg32 >> 10) & 7) == 5) {
59 u8 reg8;
60 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2);
61 printk(BIOS_DEBUG, "a2: %02x\n", reg8);
62 if (!(reg8 & 0x20)) {
63 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
64 printk(BIOS_DEBUG, "Bad resume from S3 detected.\n");
65 } else {
66 if (acpi_s3_resume_allowed()) {
67 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
68 s3resume = 1;
69 } else {
70 printk(BIOS_DEBUG,
71 "Resume from S3 detected, but disabled.\n");
72 }
73 }
74 }
75
76 /* Enable SMBUS. */
77 enable_smbus();
78
79 early_thermal_init();
80
81 timestamp_add_now(TS_BEFORE_INITRAM);
82
83 chipset_init(s3resume);
84
85 mainboard_pre_raminit();
86
87 mainboard_get_spd_map(spd_addrmap);
88
89 raminit(s3resume, spd_addrmap);
90
91 timestamp_add_now(TS_AFTER_INITRAM);
92
93 intel_early_me_status();
94
95 if (s3resume) {
96 /* Clear SLP_TYPE. This will break stage2 but
97 * we care for that when we get there.
98 */
99 reg32 = inl(DEFAULT_PMBASE + 0x04);
100 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
101 }
102
103 romstage_handoff_init(s3resume);
104}