3ef60b893ed73d1c5d96f4a7402077170e1d7a60
[coreboot.git] / src / mainboard / intel / truxton / romstage.c
1 /*
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
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  *
19  */
20
21 #include <stdint.h>
22 #include <stdlib.h>
23 #include <device/pci_def.h>
24 #include <device/pci_ids.h>
25 #include <arch/io.h>
26 #include <device/pnp_def.h>
27 #include <arch/romcc_io.h>
28 #include <cpu/x86/lapic.h>
29 #include <pc80/mc146818rtc.h>
30 #include "pc80/udelay_io.c"
31 #include <console/console.h>
32 #include "lib/ramtest.c"
33 #include "southbridge/intel/i3100/i3100_early_smbus.c"
34 #include "southbridge/intel/i3100/i3100_early_lpc.c"
35 #include "northbridge/intel/i3100/raminit_ep80579.h"
36 #include "superio/intel/i3100/i3100.h"
37 #include "cpu/x86/lapic/boot_cpu.c"
38 #include "cpu/x86/mtrr/earlymtrr.c"
39 #include "superio/intel/i3100/i3100_early_serial.c"
40 #include "cpu/x86/bist.h"
41 #include "spd.h"
42
43 #define DEVPRES_CONFIG  (DEVPRES_D1F0 | DEVPRES_D2F0 | DEVPRES_D3F0 | DEVPRES_D4F0)
44
45 static inline int spd_read_byte(u16 device, u8 address)
46 {
47         return smbus_read_byte(device, address);
48 }
49
50 #include "northbridge/intel/i3100/raminit_ep80579.c"
51 #include "lib/generic_sdram.c"
52 #include "../../intel/jarrell/debug.c"
53 #include "arch/i386/lib/stages.c"
54
55 /* #define TRUXTON_DEBUG */
56
57 static void main(unsigned long bist)
58 {
59         msr_t msr;
60         u16 perf;
61         static const struct mem_controller mch[] = {
62                 {
63                         .node_id = 0,
64                         .f0 = PCI_DEV(0, 0x00, 0),
65                         .channel0 = { (0xa<<3)|2, (0xa<<3)|3 },
66                 }
67         };
68
69         if (bist == 0) {
70                 /* Skip this if there was a built in self test failure */
71                 early_mtrr_init();
72                 if (memory_initialized()) {
73                         skip_romstage();
74                 }
75         }
76
77         /* Set up the console */
78         i3100_enable_superio();
79         i3100_enable_serial(I3100_SUPERIO_CONFIG_PORT, I3100_SP1, CONFIG_TTYS0_BASE);
80         uart_init();
81         console_init();
82
83         /* Prevent the TCO timer from rebooting us */
84         i3100_halt_tco_timer();
85
86         /* Halt if there was a built in self test failure */
87         report_bist_failure(bist);
88
89 #ifdef TRUXTON_DEBUG
90         print_pci_devices();
91 #endif
92         enable_smbus();
93         dump_spd_registers();
94
95         sdram_initialize(ARRAY_SIZE(mch), mch);
96         dump_pci_devices();
97         dump_pci_device(PCI_DEV(0, 0x00, 0));
98 #ifdef TRUXTON_DEBUG
99         dump_bar14(PCI_DEV(0, 0x00, 0));
100 #endif
101
102 #ifdef TRUXTON_DEBUG
103         ram_fill(0x00000000, 0x02000000);
104         ram_verify(0x00000000, 0x02000000);
105 #endif
106 }
107