Use DIMM0 et al in lots more places instead of hardocding values.
[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 <spd.h>
31 #include "pc80/udelay_io.c"
32 #include <pc80/mc146818rtc.h>
33 #include <console/console.h>
34 #include "southbridge/intel/i82801dx/i82801dx.h"
35 #include "southbridge/intel/i82801dx/i82801dx_early_smbus.c"
36 #include "northbridge/intel/i855/raminit.h"
37 #include "northbridge/intel/i855/debug.c"
38 #include "superio/winbond/w83627thg/w83627thg_early_serial.c"
39 #include "cpu/x86/mtrr/earlymtrr.c"
40 #include "cpu/x86/bist.h"
41
42 #define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1)
43
44 static inline int spd_read_byte(unsigned device, unsigned address)
45 {
46         return smbus_read_byte(device, address);
47 }
48
49 #include "northbridge/intel/i855/raminit.c"
50 #include "northbridge/intel/i855/reset_test.c"
51 #include "lib/generic_sdram.c"
52
53 void main(unsigned long bist)
54 {
55         static const struct mem_controller memctrl[] = {
56                 {
57                         .d0 = PCI_DEV(0, 0, 1),
58                         .channel0 = { DIMM0, 0 },
59                 },
60         };
61
62         if (bist == 0) {
63 #if 0
64                 enable_lapic();
65                 init_timer();
66 #endif
67         }
68
69         w83627thg_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
70         uart_init();
71         console_init();
72
73         /* Halt if there was a built in self test failure */
74         report_bist_failure(bist);
75
76 #if 0
77         print_pci_devices();
78 #endif
79
80         if(!bios_reset_detected()) {
81                 enable_smbus();
82 #if 1
83                 dump_spd_registers(&memctrl[0]);
84                 dump_smbus_registers();
85 #endif
86
87                 sdram_initialize(ARRAY_SIZE(memctrl), memctrl);
88
89         }
90
91 #if 0
92         dump_pci_devices();
93         dump_pci_device(PCI_DEV(0, 0, 0));
94
95         // Check all of memory
96         ram_check(0x00000000, msr.lo+(msr.hi<<32));
97         // Check 16MB of memory @ 0
98         ram_check(0x00000000, 0x01000000);
99         // Check 16MB of memory @ 2GB
100         ram_check(0x80000000, 0x81000000);
101 #endif
102 }
103