Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <cf9_reset.h> |
| 5 | #include <cpu/x86/lapic.h> |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 6 | #include <arch/romstage.h> |
| 7 | #include <northbridge/intel/i945/i945.h> |
| 8 | #include <northbridge/intel/i945/raminit.h> |
| 9 | #include <southbridge/intel/i82801gx/i82801gx.h> |
| 10 | #include <southbridge/intel/common/pmclib.h> |
| 11 | |
| 12 | __weak void mainboard_lpc_decode(void) |
| 13 | { |
| 14 | } |
| 15 | |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 16 | __weak void mainboard_pre_raminit_config(int s3_resume) |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | __weak void mainboard_get_spd_map(u8 spd_map[4]) |
| 21 | { |
| 22 | spd_map[0] = 0x50; |
| 23 | spd_map[1] = 0x51; |
| 24 | spd_map[2] = 0x52; |
| 25 | spd_map[3] = 0x53; |
| 26 | } |
| 27 | |
| 28 | void mainboard_romstage_entry(void) |
| 29 | { |
| 30 | int s3resume = 0; |
| 31 | u8 spd_map[4] = {}; |
| 32 | |
| 33 | enable_lapic(); |
| 34 | |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 35 | mainboard_lpc_decode(); |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 36 | |
| 37 | if (MCHBAR16(SSKPD) == 0xCAFE) { |
| 38 | system_reset(); |
| 39 | } |
| 40 | |
| 41 | /* Perform some early chipset initialization required |
| 42 | * before RAM initialization can work |
| 43 | */ |
| 44 | i82801gx_early_init(); |
| 45 | i945_early_initialization(); |
| 46 | |
| 47 | s3resume = southbridge_detect_s3_resume(); |
| 48 | |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 49 | mainboard_pre_raminit_config(s3resume); |
| 50 | |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 51 | mainboard_get_spd_map(spd_map); |
| 52 | |
Angel Pons | a60b42a | 2021-03-28 14:06:55 +0200 | [diff] [blame] | 53 | if (CONFIG(DEBUG_RAM_SETUP)) |
| 54 | dump_spd_registers(spd_map); |
| 55 | |
Paul Menzel | e0cd2eb | 2020-01-19 00:07:05 +0100 | [diff] [blame] | 56 | sdram_initialize(s3resume ? BOOT_PATH_RESUME : BOOT_PATH_NORMAL, spd_map); |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 57 | |
| 58 | /* This should probably go away. Until now it is required |
| 59 | * and mainboard specific |
| 60 | */ |
| 61 | mainboard_late_rcba_config(); |
| 62 | |
| 63 | /* Chipset Errata! */ |
Elyes HAOUAS | 8273e13 | 2020-03-10 22:17:12 +0100 | [diff] [blame] | 64 | if (CONFIG(NORTHBRIDGE_INTEL_SUBTYPE_I945GM)) |
| 65 | fixup_i945gm_errata(); |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 66 | |
| 67 | /* Initialize the internal PCIe links before we go into stage2 */ |
| 68 | i945_late_initialization(s3resume); |
| 69 | } |