24008bcfe632059fd8ee27891949fed2eec98153
[coreboot.git] / src / mainboard / lanner / em8510 / romstage.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Original take from digitallogic/adl855pc
5  *
6  * Copyright (C) 2010 Travelping GmbH <info@travelping.com>
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; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
21  */
22
23 #include <stdint.h>
24 #include <device/pci_def.h>
25 #include <arch/io.h>
26 #include <device/pnp_def.h>
27 #include <arch/romcc_io.h>
28 #include <arch/hlt.h>
29 #include <stdlib.h>
30 #include <lib.h>
31 #include <spd.h>
32 #include "pc80/udelay_io.c"
33 #include <pc80/mc146818rtc.h>
34 #include <console/console.h>
35 #include "southbridge/intel/i82801dx/i82801dx.h"
36 #include "southbridge/intel/i82801dx/i82801dx_early_smbus.c"
37 #include "northbridge/intel/i855/raminit.h"
38 #include "northbridge/intel/i855/debug.c"
39 #include "superio/winbond/w83627thg/w83627thg_early_serial.c"
40 #include "cpu/x86/mtrr/earlymtrr.c"
41 #include "cpu/x86/bist.h"
42
43 #define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1)
44
45 static inline int spd_read_byte(unsigned device, unsigned address)
46 {
47         return smbus_read_byte(device, address);
48 }
49
50 #include "northbridge/intel/i855/raminit.c"
51 #include "northbridge/intel/i855/reset_test.c"
52
53 void main(unsigned long bist)
54 {
55         if (bist == 0) {
56 #if 0
57                 enable_lapic();
58                 init_timer();
59 #endif
60         }
61
62         w83627thg_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
63         uart_init();
64         console_init();
65
66         /* Halt if there was a built in self test failure */
67         report_bist_failure(bist);
68
69 #if 0
70         print_pci_devices();
71 #endif
72
73         if (!bios_reset_detected()) {
74                 enable_smbus();
75 #if 1
76                 dump_spd_registers();
77                 dump_smbus_registers();
78 #endif
79                 sdram_set_registers();
80                 sdram_set_spd_registers();
81                 sdram_enable();
82         }
83
84 #if 0
85         dump_pci_devices();
86         dump_pci_device(PCI_DEV(0, 0, 0));
87
88         // Check all of memory
89         ram_check(0x00000000, msr.lo+(msr.hi<<32));
90         // Check 16MB of memory @ 0
91         ram_check(0x00000000, 0x01000000);
92         // Check 16MB of memory @ 2GB
93         ram_check(0x80000000, 0x81000000);
94 #endif
95 }