blob: 03058ec2b538b455ba5dc6253a47e3a558e3e3f3 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01002
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01003#include <timestamp.h>
4#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02005#include <device/pci_ops.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01006#include <cbmem.h>
Elyes HAOUAS363b7712019-04-28 18:07:02 +02007#include <cf9_reset.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01008#include <romstage_handoff.h>
9#include <southbridge/intel/i82801gx/i82801gx.h>
Patrick Rudolph425e75a2019-03-24 15:06:17 +010010#include <southbridge/intel/common/pmclib.h>
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +030011#include <arch/romstage.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010012#include "raminit.h"
13#include "pineview.h"
14
15static void rcba_config(void)
16{
Angel Pons39ff7032020-03-09 21:39:44 +010017 /* Set up Virtual Channel 0 */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010018 RCBA32(0x0014) = 0x80000001;
19 RCBA32(0x001c) = 0x03128010;
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010020}
21
22__weak void mb_pirq_setup(void)
23{
24}
25
Angel Pons39ff7032020-03-09 21:39:44 +010026/* The romstage entry point for this platform is not mainboard-specific, hence the name. */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030027void mainboard_romstage_entry(void)
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010028{
29 u8 spd_addrmap[4] = {};
30 int boot_path, cbmem_was_initted;
31 int s3resume = 0;
32
Angel Pons39ff7032020-03-09 21:39:44 +010033 /* Do some early chipset init, necessary for RAM init to work */
Arthur Heymans399b6c12019-11-11 19:12:57 +010034 i82801gx_early_init();
Angel Pons39ff7032020-03-09 21:39:44 +010035 pineview_early_init();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010036
37 post_code(0x30);
38
39 s3resume = southbridge_detect_s3_resume();
40
41 if (s3resume) {
42 boot_path = BOOT_PATH_RESUME;
43 } else {
Angel Pons0aeaee72021-03-26 17:57:46 +010044 if (mchbar_read32(PMSTS) & (1 << 8)) /* HOT RESET */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010045 boot_path = BOOT_PATH_RESET;
46 else
47 boot_path = BOOT_PATH_NORMAL;
48 }
49
50 get_mb_spd_addrmap(&spd_addrmap[0]);
51
52 printk(BIOS_DEBUG, "Initializing memory\n");
Jakub Czapigaad6157e2022-02-15 11:50:31 +010053 timestamp_add_now(TS_INITRAM_START);
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010054 sdram_initialize(boot_path, spd_addrmap);
Jakub Czapigaad6157e2022-02-15 11:50:31 +010055 timestamp_add_now(TS_INITRAM_END);
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010056 printk(BIOS_DEBUG, "Memory initialized\n");
57
58 post_code(0x31);
59
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010060 mb_pirq_setup();
61
62 rcba_config();
63
64 cbmem_was_initted = !cbmem_recovery(s3resume);
65
66 if (!cbmem_was_initted && s3resume) {
67 /* Failed S3 resume, reset to come up cleanly */
Elyes HAOUAS363b7712019-04-28 18:07:02 +020068 system_reset();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010069 }
70
71 romstage_handoff_init(s3resume);
72}