Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 3 | |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 4 | #include <timestamp.h> |
| 5 | #include <console/console.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 6 | #include <device/pci_ops.h> |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 7 | #include <cbmem.h> |
Elyes HAOUAS | 363b771 | 2019-04-28 18:07:02 +0200 | [diff] [blame] | 8 | #include <cf9_reset.h> |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 9 | #include <romstage_handoff.h> |
| 10 | #include <southbridge/intel/i82801gx/i82801gx.h> |
Patrick Rudolph | 425e75a | 2019-03-24 15:06:17 +0100 | [diff] [blame] | 11 | #include <southbridge/intel/common/pmclib.h> |
Kyösti Mälkki | cd7a70f | 2019-08-17 20:51:08 +0300 | [diff] [blame] | 12 | #include <arch/romstage.h> |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 13 | #include <cpu/x86/lapic.h> |
| 14 | #include "raminit.h" |
| 15 | #include "pineview.h" |
| 16 | |
| 17 | static void rcba_config(void) |
| 18 | { |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 19 | /* Set up Virtual Channel 0 */ |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 20 | RCBA32(0x0014) = 0x80000001; |
| 21 | RCBA32(0x001c) = 0x03128010; |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | __weak void mb_pirq_setup(void) |
| 25 | { |
| 26 | } |
| 27 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 28 | /* The romstage entry point for this platform is not mainboard-specific, hence the name. */ |
Kyösti Mälkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 29 | void mainboard_romstage_entry(void) |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 30 | { |
| 31 | u8 spd_addrmap[4] = {}; |
| 32 | int boot_path, cbmem_was_initted; |
| 33 | int s3resume = 0; |
| 34 | |
Kyösti Mälkki | 157b189 | 2019-08-16 14:02:25 +0300 | [diff] [blame] | 35 | enable_lapic(); |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 36 | |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 37 | /* Do some early chipset init, necessary for RAM init to work */ |
Arthur Heymans | 399b6c1 | 2019-11-11 19:12:57 +0100 | [diff] [blame] | 38 | i82801gx_early_init(); |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 39 | pineview_early_init(); |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 40 | |
| 41 | post_code(0x30); |
| 42 | |
| 43 | s3resume = southbridge_detect_s3_resume(); |
| 44 | |
| 45 | if (s3resume) { |
| 46 | boot_path = BOOT_PATH_RESUME; |
| 47 | } else { |
Angel Pons | 39ff703 | 2020-03-09 21:39:44 +0100 | [diff] [blame] | 48 | if (MCHBAR32(PMSTS) & (1 << 8)) /* HOT RESET */ |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 49 | boot_path = BOOT_PATH_RESET; |
| 50 | else |
| 51 | boot_path = BOOT_PATH_NORMAL; |
| 52 | } |
| 53 | |
| 54 | get_mb_spd_addrmap(&spd_addrmap[0]); |
| 55 | |
| 56 | printk(BIOS_DEBUG, "Initializing memory\n"); |
| 57 | timestamp_add_now(TS_BEFORE_INITRAM); |
| 58 | sdram_initialize(boot_path, spd_addrmap); |
| 59 | timestamp_add_now(TS_AFTER_INITRAM); |
| 60 | printk(BIOS_DEBUG, "Memory initialized\n"); |
| 61 | |
| 62 | post_code(0x31); |
| 63 | |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 64 | mb_pirq_setup(); |
| 65 | |
| 66 | rcba_config(); |
| 67 | |
| 68 | cbmem_was_initted = !cbmem_recovery(s3resume); |
| 69 | |
| 70 | if (!cbmem_was_initted && s3resume) { |
| 71 | /* Failed S3 resume, reset to come up cleanly */ |
Elyes HAOUAS | 363b771 | 2019-04-28 18:07:02 +0200 | [diff] [blame] | 72 | system_reset(); |
Arthur Heymans | c6ff1ac | 2019-01-11 16:06:19 +0100 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | romstage_handoff_init(s3resume); |
| 76 | } |