blob: bdb685b252692089e42660747847d5d371f8b35c [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
Kyösti Mälkkibdaec072019-03-02 23:18:29 +020020#include <arch/io.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010021#include <timestamp.h>
22#include <console/console.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020023#include <device/pci_ops.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010024#include <cbmem.h>
Elyes HAOUAS363b7712019-04-28 18:07:02 +020025#include <cf9_reset.h>
Elyes HAOUAS74aa99a2019-03-16 08:40:06 +010026#include <halt.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010027#include <romstage_handoff.h>
28#include <southbridge/intel/i82801gx/i82801gx.h>
29#include <southbridge/intel/common/gpio.h>
Patrick Rudolph425e75a2019-03-24 15:06:17 +010030#include <southbridge/intel/common/pmclib.h>
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +010031#include <cpu/intel/romstage.h>
32#include <cpu/x86/bist.h>
33#include <cpu/x86/lapic.h>
34#include "raminit.h"
35#include "pineview.h"
36
37static void rcba_config(void)
38{
39 /* Set up virtual channel 0 */
40 RCBA32(0x0014) = 0x80000001;
41 RCBA32(0x001c) = 0x03128010;
42
43 /* Enable IOAPIC */
44 RCBA8(OIC) = 0x03;
45}
46
47__weak void mb_pirq_setup(void)
48{
49}
50
51#define LPC_DEV PCI_DEV(0x0, 0x1f, 0x0)
52
53void mainboard_romstage_entry(unsigned long bist)
54{
55 u8 spd_addrmap[4] = {};
56 int boot_path, cbmem_was_initted;
57 int s3resume = 0;
58
59 if (bist == 0)
60 enable_lapic();
61
62 /* Disable watchdog timer */
63 RCBA32(GCS) = RCBA32(GCS) | 0x20;
64
65 /* Enable GPIOs */
66 pci_write_config32(LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
67 pci_write_config8(LPC_DEV, GPIO_CNTL, 0x10);
68
69 setup_pch_gpios(&mainboard_gpio_map);
70
71 mb_enable_lpc(); // nm10_enable_lpc
72
73 /* Initialize console device(s) */
74 console_init();
75
76 /* Halt if there was a built in self test failure */
77 report_bist_failure(bist);
78
79 enable_smbus();
80
81 /* Perform some early chipset initialization required
82 * before RAM initialization can work
83 */
84 pineview_early_initialization();
85
86 post_code(0x30);
87
88 s3resume = southbridge_detect_s3_resume();
89
90 if (s3resume) {
91 boot_path = BOOT_PATH_RESUME;
92 } else {
93 if (MCHBAR32(0xf14) & (1 << 8)) /* HOT RESET */
94 boot_path = BOOT_PATH_RESET;
95 else
96 boot_path = BOOT_PATH_NORMAL;
97 }
98
99 get_mb_spd_addrmap(&spd_addrmap[0]);
100
101 printk(BIOS_DEBUG, "Initializing memory\n");
102 timestamp_add_now(TS_BEFORE_INITRAM);
103 sdram_initialize(boot_path, spd_addrmap);
104 timestamp_add_now(TS_AFTER_INITRAM);
105 printk(BIOS_DEBUG, "Memory initialized\n");
106
107 post_code(0x31);
108
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +0100109 mb_pirq_setup();
110
111 rcba_config();
112
113 cbmem_was_initted = !cbmem_recovery(s3resume);
114
115 if (!cbmem_was_initted && s3resume) {
116 /* Failed S3 resume, reset to come up cleanly */
Elyes HAOUAS363b7712019-04-28 18:07:02 +0200117 system_reset();
Arthur Heymansc6ff1ac2019-01-11 16:06:19 +0100118 }
119
120 romstage_handoff_init(s3resume);
121}