blob: 38f2d5f68f164ce10c256fbd1e8766d4f2085fd5 [file] [log] [blame]
Arthur Heymans3b0eb602019-01-31 22:47:09 +01001/*
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 <cbmem.h>
19#include <romstage_handoff.h>
20#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020021#include <device/pci_ops.h>
Arthur Heymans3b0eb602019-01-31 22:47:09 +010022#include <arch/acpi.h>
23#include <cpu/x86/lapic.h>
24#include <cpu/x86/bist.h>
25#include <cpu/intel/romstage.h>
26#include <northbridge/intel/gm45/gm45.h>
27#include <southbridge/intel/i82801ix/i82801ix.h>
28#include <southbridge/intel/common/gpio.h>
Patrick Rudolphad0b4822019-04-13 16:56:23 +020029#include <southbridge/intel/common/pmclib.h>
Elyes HAOUASa1e22b82019-03-18 22:49:36 +010030#include <string.h>
Arthur Heymans3b0eb602019-01-31 22:47:09 +010031
32#define LPC_DEV PCI_DEV(0, 0x1f, 0)
33#define MCH_DEV PCI_DEV(0, 0, 0)
34
35void __weak mb_setup_superio(void)
36{
37}
38
39void __weak mb_pre_raminit_setup(sysinfo_t *sysinfo)
40{
41}
42
43void __weak mb_post_raminit_setup(void)
44{
45}
46
47/* Platform has no romstage entry point under mainboard directory,
48 * so this one is named with prefix mainboard.
49 */
50void mainboard_romstage_entry(unsigned long bist)
51{
52 sysinfo_t sysinfo;
53 int s3resume = 0;
54 int cbmem_initted;
55 u16 reg16;
56
57 /* basic northbridge setup, including MMCONF BAR */
58 gm45_early_init();
59
60 if (bist == 0)
61 enable_lapic();
62
63 /* First, run everything needed for console output. */
64 i82801ix_early_init();
65 setup_pch_gpios(&mainboard_gpio_map);
66
67 mb_setup_lpc();
68
69 mb_setup_superio();
70
71 console_init();
72 report_bist_failure(bist);
73
74 reg16 = pci_read_config16(LPC_DEV, D31F0_GEN_PMCON_3);
75 pci_write_config16(LPC_DEV, D31F0_GEN_PMCON_3, reg16);
76 if ((MCHBAR16(SSKPD_MCHBAR) == 0xCAFE) && !(reg16 & (1 << 9))) {
77 printk(BIOS_DEBUG, "soft reset detected, rebooting properly\n");
78 gm45_early_reset();
79 }
80
81 /* ASPM related setting, set early by original BIOS. */
82 DMIBAR16(0x204) &= ~(3 << 10);
83
84 /* Check for S3 resume. */
Patrick Rudolphad0b4822019-04-13 16:56:23 +020085 s3resume = southbridge_detect_s3_resume();
Arthur Heymans3b0eb602019-01-31 22:47:09 +010086
87 /* RAM initialization */
88 enter_raminit_or_reset();
89 memset(&sysinfo, 0, sizeof(sysinfo));
90 get_mb_spd_addrmap(sysinfo.spd_map);
91 const struct device *dev;
92 dev = pcidev_on_root(2, 0);
93 if (dev)
94 sysinfo.enable_igd = dev->enabled;
95 dev = pcidev_on_root(1, 0);
96 if (dev)
97 sysinfo.enable_peg = dev->enabled;
98 get_gmch_info(&sysinfo);
99
100 mb_pre_raminit_setup(&sysinfo);
101
102 raminit(&sysinfo, s3resume);
103
104 mb_post_raminit_setup();
105
106 const u32 deven = pci_read_config32(MCH_DEV, D0F0_DEVEN);
107 /* Disable D4F0 (unknown signal controller). */
108 pci_write_config32(MCH_DEV, D0F0_DEVEN, deven & ~0x4000);
109
110 init_pm(&sysinfo, 0);
111
112 i82801ix_dmi_setup();
113 gm45_late_init(sysinfo.stepping);
114 i82801ix_dmi_poll_vc1();
115
116 MCHBAR16(SSKPD_MCHBAR) = 0xCAFE;
117
118 init_iommu();
119
120 cbmem_initted = !cbmem_recovery(s3resume);
121
122 romstage_handoff_init(cbmem_initted && s3resume);
123
124 printk(BIOS_SPEW, "exit main()\n");
125}