blob: f75077833cf82838027ffefd86cf12c03651a2c6 [file] [log] [blame]
Ed Swierkb8e53eb2008-10-13 23:18:56 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 Arastra, Inc.
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 version 2 as
8 * published by the Free Software Foundation.
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 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Ed Swierkb8e53eb2008-10-13 23:18:56 +000018 */
19
Ed Swierkb8e53eb2008-10-13 23:18:56 +000020#include <stdint.h>
21#include <stdlib.h>
22#include <device/pci_def.h>
23#include <device/pci_ids.h>
24#include <arch/io.h>
25#include <device/pnp_def.h>
Ed Swierkb8e53eb2008-10-13 23:18:56 +000026#include <cpu/x86/lapic.h>
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000027#include <pc80/mc146818rtc.h>
Stefan Reinauerae5e11d2012-04-27 02:31:28 +020028#include "drivers/pc80/udelay_io.c"
Patrick Georgi12584e22010-05-08 09:14:51 +000029#include <console/console.h>
stepan836ae292010-12-08 05:42:47 +000030#include "southbridge/intel/i3100/early_smbus.c"
31#include "southbridge/intel/i3100/early_lpc.c"
Ed Swierkb8e53eb2008-10-13 23:18:56 +000032#include "northbridge/intel/i3100/raminit_ep80579.h"
Edward O'Callaghan74834e02015-01-04 04:17:35 +110033#include <superio/intel/i3100/i3100.h>
Ed Swierkb8e53eb2008-10-13 23:18:56 +000034#include "cpu/x86/mtrr/earlymtrr.c"
stepan8301d832010-12-08 07:07:33 +000035#include "superio/intel/i3100/early_serial.c"
Edward O'Callaghan633f6e32014-11-02 10:17:10 +110036#include "lib/debug.c" // XXX
Ed Swierkb8e53eb2008-10-13 23:18:56 +000037#include "cpu/x86/bist.h"
Patrick Georgi9bd9a902010-11-20 10:31:00 +000038#include <spd.h>
Ed Swierkb8e53eb2008-10-13 23:18:56 +000039
Ed Swierkb8e53eb2008-10-13 23:18:56 +000040#define DEVPRES_CONFIG (DEVPRES_D1F0 | DEVPRES_D2F0 | DEVPRES_D3F0 | DEVPRES_D4F0)
41
Ed Swierkb8e53eb2008-10-13 23:18:56 +000042static inline int spd_read_byte(u16 device, u8 address)
43{
44 return smbus_read_byte(device, address);
45}
46
47#include "northbridge/intel/i3100/raminit_ep80579.c"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000048#include "lib/generic_sdram.c"
Ed Swierkb8e53eb2008-10-13 23:18:56 +000049
Uwe Hermannd1a1d572010-11-10 18:22:11 +000050#define SERIAL_DEV PNP_DEV(0x4e, I3100_SP1)
51
Aaron Durbina0a37272014-08-14 08:35:11 -050052#include <cpu/intel/romstage.h>
Stefan Reinauer61ed48c2014-12-17 13:23:05 -080053void main(unsigned long bist)
Ed Swierkb8e53eb2008-10-13 23:18:56 +000054{
Ed Swierkb8e53eb2008-10-13 23:18:56 +000055 static const struct mem_controller mch[] = {
56 {
57 .node_id = 0,
58 .f0 = PCI_DEV(0, 0x00, 0),
Uwe Hermann6dc92f02010-11-21 11:36:03 +000059 .channel0 = { DIMM2, DIMM3 },
Ed Swierkb8e53eb2008-10-13 23:18:56 +000060 }
61 };
62
63 if (bist == 0) {
64 /* Skip this if there was a built in self test failure */
Uwe Hermann7b997052010-11-21 22:47:22 +000065 if (memory_initialized())
Stefan Reinauer61ed48c2014-12-17 13:23:05 -080066 return;
Ed Swierkb8e53eb2008-10-13 23:18:56 +000067 }
68
69 /* Set up the console */
70 i3100_enable_superio();
Uwe Hermannd1a1d572010-11-10 18:22:11 +000071 i3100_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
72 i3100_configure_uart_clk(SERIAL_DEV, I3100_UART_CLK_PREDIVIDE_26);
73
Ed Swierkb8e53eb2008-10-13 23:18:56 +000074 console_init();
75
76 /* Prevent the TCO timer from rebooting us */
77 i3100_halt_tco_timer();
78
79 /* Halt if there was a built in self test failure */
80 report_bist_failure(bist);
81
82#ifdef TRUXTON_DEBUG
83 print_pci_devices();
84#endif
85 enable_smbus();
Ed Swierkb8e53eb2008-10-13 23:18:56 +000086
87 sdram_initialize(ARRAY_SIZE(mch), mch);
88 dump_pci_devices();
89 dump_pci_device(PCI_DEV(0, 0x00, 0));
90#ifdef TRUXTON_DEBUG
91 dump_bar14(PCI_DEV(0, 0x00, 0));
92#endif
Ed Swierkb8e53eb2008-10-13 23:18:56 +000093}