blob: 9a8f5d50f6707667fc34e47260f86e0c39caa384 [file] [log] [blame]
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Damien Zammit <damien@zamaudio.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010016#include <timestamp.h>
17#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020018#include <device/pci_ops.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010019#include <cbmem.h>
Elyes HAOUAS363b7712019-04-28 18:07:02 +020020#include <cf9_reset.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010021#include <romstage_handoff.h>
22#include <southbridge/intel/i82801gx/i82801gx.h>
Patrick Rudolph425e75a2019-03-24 15:06:17 +010023#include <southbridge/intel/common/pmclib.h>
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +030024#include <arch/romstage.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010025#include <cpu/x86/lapic.h>
26#include "raminit.h"
27#include "pineview.h"
28
29static void rcba_config(void)
30{
Angel Pons39ff7032020-03-09 21:39:44 +010031 /* Set up Virtual Channel 0 */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010032 RCBA32(0x0014) = 0x80000001;
33 RCBA32(0x001c) = 0x03128010;
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010034}
35
36__weak void mb_pirq_setup(void)
37{
38}
39
Angel Pons39ff7032020-03-09 21:39:44 +010040/* The romstage entry point for this platform is not mainboard-specific, hence the name. */
Kyösti Mälkki157b1892019-08-16 14:02:25 +030041void mainboard_romstage_entry(void)
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010042{
43 u8 spd_addrmap[4] = {};
44 int boot_path, cbmem_was_initted;
45 int s3resume = 0;
46
Kyösti Mälkki157b1892019-08-16 14:02:25 +030047 enable_lapic();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010048
Angel Pons39ff7032020-03-09 21:39:44 +010049 /* Do some early chipset init, necessary for RAM init to work */
Arthur Heymans399b6c12019-11-11 19:12:57 +010050 i82801gx_early_init();
Angel Pons39ff7032020-03-09 21:39:44 +010051 pineview_early_init();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010052
53 post_code(0x30);
54
55 s3resume = southbridge_detect_s3_resume();
56
57 if (s3resume) {
58 boot_path = BOOT_PATH_RESUME;
59 } else {
Angel Pons39ff7032020-03-09 21:39:44 +010060 if (MCHBAR32(PMSTS) & (1 << 8)) /* HOT RESET */
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010061 boot_path = BOOT_PATH_RESET;
62 else
63 boot_path = BOOT_PATH_NORMAL;
64 }
65
66 get_mb_spd_addrmap(&spd_addrmap[0]);
67
68 printk(BIOS_DEBUG, "Initializing memory\n");
69 timestamp_add_now(TS_BEFORE_INITRAM);
70 sdram_initialize(boot_path, spd_addrmap);
71 timestamp_add_now(TS_AFTER_INITRAM);
72 printk(BIOS_DEBUG, "Memory initialized\n");
73
74 post_code(0x31);
75
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010076 mb_pirq_setup();
77
78 rcba_config();
79
80 cbmem_was_initted = !cbmem_recovery(s3resume);
81
82 if (!cbmem_was_initted && s3resume) {
83 /* Failed S3 resume, reset to come up cleanly */
Elyes HAOUAS363b7712019-04-28 18:07:02 +020084 system_reset();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010085 }
86
87 romstage_handoff_init(s3resume);
88}