Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 4 | * |
| 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älkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 18 | #include <device/pci_ops.h> |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 19 | #include <arch/acpi.h> |
| 20 | #include <cpu/x86/lapic.h> |
Kyösti Mälkki | cd7a70f | 2019-08-17 20:51:08 +0300 | [diff] [blame] | 21 | #include <arch/romstage.h> |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 22 | #include <northbridge/intel/gm45/gm45.h> |
| 23 | #include <southbridge/intel/i82801ix/i82801ix.h> |
| 24 | #include <southbridge/intel/common/gpio.h> |
Patrick Rudolph | ad0b482 | 2019-04-13 16:56:23 +0200 | [diff] [blame] | 25 | #include <southbridge/intel/common/pmclib.h> |
Elyes HAOUAS | a1e22b8 | 2019-03-18 22:49:36 +0100 | [diff] [blame] | 26 | #include <string.h> |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 27 | |
| 28 | #define LPC_DEV PCI_DEV(0, 0x1f, 0) |
| 29 | #define MCH_DEV PCI_DEV(0, 0, 0) |
| 30 | |
| 31 | void __weak mb_setup_superio(void) |
| 32 | { |
| 33 | } |
| 34 | |
| 35 | void __weak mb_pre_raminit_setup(sysinfo_t *sysinfo) |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | void __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älkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 46 | void mainboard_romstage_entry(void) |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 47 | { |
| 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älkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 56 | enable_lapic(); |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 57 | |
| 58 | /* First, run everything needed for console output. */ |
| 59 | i82801ix_early_init(); |
| 60 | setup_pch_gpios(&mainboard_gpio_map); |
| 61 | |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 62 | 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 Rudolph | ad0b482 | 2019-04-13 16:56:23 +0200 | [diff] [blame] | 73 | s3resume = southbridge_detect_s3_resume(); |
Arthur Heymans | 3b0eb60 | 2019-01-31 22:47:09 +0100 | [diff] [blame] | 74 | |
| 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 | } |