blob: 737cd63c32e3e1e1032e0c4509a5799d9fd2020d [file] [log] [blame]
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
6 * Copyright (C) 2014 Vladimir Serbinenko
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <stdint.h>
23#include <string.h>
24#include <console/console.h>
25#include <arch/io.h>
26#include <lib.h>
27#include <cpu/x86/lapic.h>
28#include <timestamp.h>
29#include "sandybridge.h"
30#include <cpu/x86/bist.h>
31#include <cpu/intel/romstage.h>
Patrick Georgibd79c5e2014-11-28 22:35:36 +010032#include <halt.h>
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020033#include "raminit_native.h"
34#include "southbridge/intel/bd82x6x/pch.h"
35#include "southbridge/intel/bd82x6x/gpio.h"
36
37void main(unsigned long bist)
38{
39 int s3resume = 0;
40 spd_raw_data spd[4];
41
42 if (MCHBAR16(SSKPD) == 0xCAFE) {
43 outb(0x6, 0xcf9);
Patrick Georgibd79c5e2014-11-28 22:35:36 +010044 halt ();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020045 }
46
47 timestamp_init(get_initial_timestamp());
48 timestamp_add_now(TS_START_ROMSTAGE);
49
50 if (bist == 0)
51 enable_lapic();
52
53 pch_enable_lpc();
54
55 /* Enable GPIOs */
56 pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE|1);
57 pci_write_config8(PCH_LPC_DEV, GPIO_CNTL, 0x10);
58
59 setup_pch_gpios(&mainboard_gpio_map);
60
61 early_usb_init(mainboard_usb_ports);
62
63 /* Initialize console device(s) */
64 console_init();
65
66 /* Halt if there was a built in self test failure */
67 report_bist_failure(bist);
68
69 /* Perform some early chipset initialization required
70 * before RAM initialization can work
71 */
72 sandybridge_early_initialization(SANDYBRIDGE_MOBILE);
73 printk(BIOS_DEBUG, "Back from sandybridge_early_initialization()\n");
74
75 s3resume = southbridge_detect_s3_resume();
76
77 post_code(0x38);
78 /* Enable SPD ROMs and DDR-III DRAM */
79 enable_smbus();
80
81 post_code(0x39);
82
83 post_code(0x3a);
84
85 memset (spd, 0, sizeof (spd));
86 mainboard_get_spd(spd);
87
88 timestamp_add_now(TS_BEFORE_INITRAM);
89
90 init_dram_ddr3(spd, 1, TCK_800MHZ, s3resume);
91
92 timestamp_add_now(TS_AFTER_INITRAM);
93 post_code(0x3c);
94
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020095 southbridge_configure_default_intmap();
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020096 rcba_config();
97 post_code(0x3d);
98
99 northbridge_romstage_finalize(s3resume);
100
101 post_code(0x3f);
102 timestamp_add_now(TS_END_ROMSTAGE);
103}