blob: 83848273a09fcc2aada34fcbbd8361bfb8ca7d55 [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>
33#include <southbridge/intel/common/pmclib.h>
34#include <southbridge/intel/common/gpio.h>
35
36/* Platform has no romstage entry point under mainboard directory,
37 * so this one is named with prefix mainboard.
38 */
39void mainboard_romstage_entry(void)
40{
41 u32 reg32;
42 int s3resume = 0;
43 u8 spd_addrmap[4] = {};
44
45 enable_lapic();
46
47 /* TODO, make this configurable */
48 nehalem_early_initialization(NEHALEM_MOBILE);
49
50 /* mainboard_lpc_init */
51 mainboard_lpc_init();
52
53 /* Enable GPIOs */
54 pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
55 pci_write_config8(PCH_LPC_DEV, GPIO_CNTL, 0x10);
56
57 setup_pch_gpios(&mainboard_gpio_map);
58
59 /* TODO, make this configurable */
60 pch_setup_cir(NEHALEM_MOBILE);
61
62 southbridge_configure_default_intmap();
63
64 /* Must set BIT0 (hides performance counters PCI device).
65 coreboot enables the Rate Matching Hub which makes the UHCI PCI
66 devices disappear, so BIT5-12 and BIT28 can be set to hide those. */
67 RCBA32(FD) = (1 << 28) | (0xff << 5) | 1;
68
69 /* Set reserved bit to 1 */
70 RCBA32(FD2) = 1;
71
72 early_usb_init(mainboard_usb_ports);
73
74 /* Initialize console device(s) */
75 console_init();
76
77 /* Read PM1_CNT, DON'T CLEAR IT or raminit will fail! */
78 reg32 = inl(DEFAULT_PMBASE + 0x04);
79 printk(BIOS_DEBUG, "PM1_CNT: %08x\n", reg32);
80 if (((reg32 >> 10) & 7) == 5) {
81 u8 reg8;
82 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2);
83 printk(BIOS_DEBUG, "a2: %02x\n", reg8);
84 if (!(reg8 & 0x20)) {
85 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
86 printk(BIOS_DEBUG, "Bad resume from S3 detected.\n");
87 } else {
88 if (acpi_s3_resume_allowed()) {
89 printk(BIOS_DEBUG, "Resume from S3 detected.\n");
90 s3resume = 1;
91 } else {
92 printk(BIOS_DEBUG,
93 "Resume from S3 detected, but disabled.\n");
94 }
95 }
96 }
97
98 /* Enable SMBUS. */
99 enable_smbus();
100
101 early_thermal_init();
102
103 timestamp_add_now(TS_BEFORE_INITRAM);
104
105 chipset_init(s3resume);
106
107 mainboard_pre_raminit();
108
109 mainboard_get_spd_map(spd_addrmap);
110
111 raminit(s3resume, spd_addrmap);
112
113 timestamp_add_now(TS_AFTER_INITRAM);
114
115 intel_early_me_status();
116
117 if (s3resume) {
118 /* Clear SLP_TYPE. This will break stage2 but
119 * we care for that when we get there.
120 */
121 reg32 = inl(DEFAULT_PMBASE + 0x04);
122 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
123 }
124
125 romstage_handoff_init(s3resume);
126}