blob: e324c0532739c0cd1764f2f10f80ad74ccabd6bd [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
16/* Platform has no romstage entry point under mainboard directory,
17 * so this one is named with prefix mainboard.
18 */
19
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010020#include <timestamp.h>
21#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020022#include <device/pci_ops.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010023#include <cbmem.h>
Elyes HAOUAS363b7712019-04-28 18:07:02 +020024#include <cf9_reset.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010025#include <romstage_handoff.h>
26#include <southbridge/intel/i82801gx/i82801gx.h>
Patrick Rudolph425e75a2019-03-24 15:06:17 +010027#include <southbridge/intel/common/pmclib.h>
Kyösti Mälkkicd7a70f2019-08-17 20:51:08 +030028#include <arch/romstage.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010029#include <cpu/x86/lapic.h>
30#include "raminit.h"
31#include "pineview.h"
32
33static void rcba_config(void)
34{
35 /* Set up virtual channel 0 */
36 RCBA32(0x0014) = 0x80000001;
37 RCBA32(0x001c) = 0x03128010;
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010038}
39
40__weak void mb_pirq_setup(void)
41{
42}
43
44#define LPC_DEV PCI_DEV(0x0, 0x1f, 0x0)
45
Kyösti Mälkki157b1892019-08-16 14:02:25 +030046void mainboard_romstage_entry(void)
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010047{
48 u8 spd_addrmap[4] = {};
49 int boot_path, cbmem_was_initted;
50 int s3resume = 0;
51
Kyösti Mälkki157b1892019-08-16 14:02:25 +030052 enable_lapic();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010053
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010054 enable_smbus();
55
56 /* Perform some early chipset initialization required
57 * before RAM initialization can work
58 */
Arthur Heymans399b6c12019-11-11 19:12:57 +010059 i82801gx_early_init();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010060 pineview_early_initialization();
61
62 post_code(0x30);
63
64 s3resume = southbridge_detect_s3_resume();
65
66 if (s3resume) {
67 boot_path = BOOT_PATH_RESUME;
68 } else {
69 if (MCHBAR32(0xf14) & (1 << 8)) /* HOT RESET */
70 boot_path = BOOT_PATH_RESET;
71 else
72 boot_path = BOOT_PATH_NORMAL;
73 }
74
75 get_mb_spd_addrmap(&spd_addrmap[0]);
76
77 printk(BIOS_DEBUG, "Initializing memory\n");
78 timestamp_add_now(TS_BEFORE_INITRAM);
79 sdram_initialize(boot_path, spd_addrmap);
80 timestamp_add_now(TS_AFTER_INITRAM);
81 printk(BIOS_DEBUG, "Memory initialized\n");
82
83 post_code(0x31);
84
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010085 mb_pirq_setup();
86
87 rcba_config();
88
89 cbmem_was_initted = !cbmem_recovery(s3resume);
90
91 if (!cbmem_was_initted && s3resume) {
92 /* Failed S3 resume, reset to come up cleanly */
Elyes HAOUAS363b7712019-04-28 18:07:02 +020093 system_reset();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010094 }
95
96 romstage_handoff_init(s3resume);
97}