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