blob: eddfc668e9465f3eefda691e029d3b5dfad60534 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01003
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01004#include <timestamp.h>
5#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01007#include <cbmem.h>
Elyes HAOUAS363b7712019-04-28 18:07:02 +02008#include <cf9_reset.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01009#include <romstage_handoff.h>
10#include <southbridge/intel/i82801gx/i82801gx.h>
Patrick Rudolph425e75a2019-03-24 15:06:17 +010011#include <southbridge/intel/common/pmclib.h>
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +030012#include <arch/romstage.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010013#include <cpu/x86/lapic.h>
14#include "raminit.h"
15#include "pineview.h"
16
17static void rcba_config(void)
18{
Angel Pons39ff7032020-03-09 21:39:44 +010019 /* Set up Virtual Channel 0 */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010020 RCBA32(0x0014) = 0x80000001;
21 RCBA32(0x001c) = 0x03128010;
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010022}
23
24__weak void mb_pirq_setup(void)
25{
26}
27
Angel Pons39ff7032020-03-09 21:39:44 +010028/* The romstage entry point for this platform is not mainboard-specific, hence the name. */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030029void mainboard_romstage_entry(void)
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010030{
31 u8 spd_addrmap[4] = {};
32 int boot_path, cbmem_was_initted;
33 int s3resume = 0;
34
Kyösti Mälkki157b1892019-08-16 14:02:25 +030035 enable_lapic();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010036
Angel Pons39ff7032020-03-09 21:39:44 +010037 /* Do some early chipset init, necessary for RAM init to work */
Arthur Heymans399b6c12019-11-11 19:12:57 +010038 i82801gx_early_init();
Angel Pons39ff7032020-03-09 21:39:44 +010039 pineview_early_init();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010040
41 post_code(0x30);
42
43 s3resume = southbridge_detect_s3_resume();
44
45 if (s3resume) {
46 boot_path = BOOT_PATH_RESUME;
47 } else {
Angel Pons39ff7032020-03-09 21:39:44 +010048 if (MCHBAR32(PMSTS) & (1 << 8)) /* HOT RESET */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010049 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 Heymansc6ff1ac2019-01-11 16:06:19 +010064 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 HAOUAS363b7712019-04-28 18:07:02 +020072 system_reset();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010073 }
74
75 romstage_handoff_init(s3resume);
76}