blob: 0d2cc368da5c9fd8f24fd55974b9cdfc0e9ca039 [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
20#include <lib.h>
21#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>
25#include <romstage_handoff.h>
26#include <southbridge/intel/i82801gx/i82801gx.h>
27#include <southbridge/intel/common/gpio.h>
28#include <cpu/intel/romstage.h>
29#include <cpu/x86/bist.h>
30#include <cpu/x86/lapic.h>
31#include "raminit.h"
32#include "pineview.h"
33
34static void rcba_config(void)
35{
36 /* Set up virtual channel 0 */
37 RCBA32(0x0014) = 0x80000001;
38 RCBA32(0x001c) = 0x03128010;
39
40 /* Enable IOAPIC */
41 RCBA8(OIC) = 0x03;
42}
43
44__weak void mb_pirq_setup(void)
45{
46}
47
48#define LPC_DEV PCI_DEV(0x0, 0x1f, 0x0)
49
50void mainboard_romstage_entry(unsigned long bist)
51{
52 u8 spd_addrmap[4] = {};
53 int boot_path, cbmem_was_initted;
54 int s3resume = 0;
55
56 if (bist == 0)
57 enable_lapic();
58
59 /* Disable watchdog timer */
60 RCBA32(GCS) = RCBA32(GCS) | 0x20;
61
62 /* Enable GPIOs */
63 pci_write_config32(LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
64 pci_write_config8(LPC_DEV, GPIO_CNTL, 0x10);
65
66 setup_pch_gpios(&mainboard_gpio_map);
67
68 mb_enable_lpc(); // nm10_enable_lpc
69
70 /* Initialize console device(s) */
71 console_init();
72
73 /* Halt if there was a built in self test failure */
74 report_bist_failure(bist);
75
76 enable_smbus();
77
78 /* Perform some early chipset initialization required
79 * before RAM initialization can work
80 */
81 pineview_early_initialization();
82
83 post_code(0x30);
84
85 s3resume = southbridge_detect_s3_resume();
86
87 if (s3resume) {
88 boot_path = BOOT_PATH_RESUME;
89 } else {
90 if (MCHBAR32(0xf14) & (1 << 8)) /* HOT RESET */
91 boot_path = BOOT_PATH_RESET;
92 else
93 boot_path = BOOT_PATH_NORMAL;
94 }
95
96 get_mb_spd_addrmap(&spd_addrmap[0]);
97
98 printk(BIOS_DEBUG, "Initializing memory\n");
99 timestamp_add_now(TS_BEFORE_INITRAM);
100 sdram_initialize(boot_path, spd_addrmap);
101 timestamp_add_now(TS_AFTER_INITRAM);
102 printk(BIOS_DEBUG, "Memory initialized\n");
103
104 post_code(0x31);
105
106 quick_ram_check();
107
108 mb_pirq_setup();
109
110 rcba_config();
111
112 cbmem_was_initted = !cbmem_recovery(s3resume);
113
114 if (!cbmem_was_initted && s3resume) {
115 /* Failed S3 resume, reset to come up cleanly */
116 outb(0x6, 0xcf9);
117 halt();
118 }
119
120 romstage_handoff_init(s3resume);
121}