blob: e8e5c56ecee565f27b9405ea63a5295ee0f75f3d [file] [log] [blame]
Arthur Heymanscea4fd92019-10-03 08:54:35 +02001/*
2 * This file is part of the coreboot project.
3 *
Arthur Heymanscea4fd92019-10-03 08:54:35 +02004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <stdint.h>
16#include <console/console.h>
17#include <cf9_reset.h>
18#include <device/pci_ops.h>
19#include <cpu/x86/lapic.h>
20#include <timestamp.h>
21#include <romstage_handoff.h>
Angel Pons95de2312020-02-17 13:08:53 +010022#include "ironlake.h"
Arthur Heymanscea4fd92019-10-03 08:54:35 +020023#include <arch/romstage.h>
24#include <device/pci_def.h>
25#include <device/device.h>
Angel Pons95de2312020-02-17 13:08:53 +010026#include <northbridge/intel/ironlake/chip.h>
27#include <northbridge/intel/ironlake/raminit.h>
Arthur Heymans2878c0b2019-10-14 18:42:00 +020028#include <southbridge/intel/common/pmclib.h>
Arthur Heymanscea4fd92019-10-03 08:54:35 +020029#include <southbridge/intel/ibexpeak/pch.h>
30#include <southbridge/intel/ibexpeak/me.h>
Arthur Heymanscea4fd92019-10-03 08:54:35 +020031
32/* Platform has no romstage entry point under mainboard directory,
33 * so this one is named with prefix mainboard.
34 */
35void mainboard_romstage_entry(void)
36{
37 u32 reg32;
38 int s3resume = 0;
39 u8 spd_addrmap[4] = {};
40
41 enable_lapic();
42
43 /* TODO, make this configurable */
Angel Pons95de2312020-02-17 13:08:53 +010044 ironlake_early_initialization(IRONLAKE_MOBILE);
Arthur Heymanscea4fd92019-10-03 08:54:35 +020045
Arthur Heymansb9c9cd72019-10-10 15:06:33 +020046 early_pch_init();
47
Arthur Heymans2878c0b2019-10-14 18:42:00 +020048 s3resume = southbridge_detect_s3_resume();
49 if (s3resume) {
50 u8 reg8 = pci_read_config8(PCI_DEV(0, 0x1f, 0), 0xa2);
Arthur Heymanscea4fd92019-10-03 08:54:35 +020051 if (!(reg8 & 0x20)) {
Arthur Heymans2878c0b2019-10-14 18:42:00 +020052 s3resume = 0;
Arthur Heymanscea4fd92019-10-03 08:54:35 +020053 printk(BIOS_DEBUG, "Bad resume from S3 detected.\n");
Arthur Heymanscea4fd92019-10-03 08:54:35 +020054 }
55 }
56
Arthur Heymanscea4fd92019-10-03 08:54:35 +020057 early_thermal_init();
58
59 timestamp_add_now(TS_BEFORE_INITRAM);
60
61 chipset_init(s3resume);
62
63 mainboard_pre_raminit();
64
65 mainboard_get_spd_map(spd_addrmap);
66
67 raminit(s3resume, spd_addrmap);
68
69 timestamp_add_now(TS_AFTER_INITRAM);
70
71 intel_early_me_status();
72
73 if (s3resume) {
74 /* Clear SLP_TYPE. This will break stage2 but
75 * we care for that when we get there.
76 */
77 reg32 = inl(DEFAULT_PMBASE + 0x04);
78 outl(reg32 & ~(7 << 10), DEFAULT_PMBASE + 0x04);
79 }
80
81 romstage_handoff_init(s3resume);
82}