1e0cddf727a25ba33d8e81b81b88199fd9a4dc1a
[coreboot.git] / src / mainboard / supermicro / x6dhe_g2 / romstage.c
1 #include <stdint.h>
2 #include <device/pci_def.h>
3 #include <arch/io.h>
4 #include <device/pnp_def.h>
5 #include <arch/romcc_io.h>
6 #include <cpu/x86/lapic.h>
7 #include <stdlib.h>
8 #include "option_table.h"
9 #include "pc80/mc146818rtc_early.c"
10 #include <console/console.h>
11 #include "lib/ramtest.c"
12 #include "southbridge/intel/i82801ex/i82801ex_early_smbus.c"
13 #include "northbridge/intel/e7520/raminit.h"
14 #include "superio/nsc/pc87427/pc87427.h"
15 #include "cpu/x86/lapic/boot_cpu.c"
16 #include "cpu/x86/mtrr/earlymtrr.c"
17 #include "debug.c"
18 #include "watchdog.c"
19 #include "reset.c"
20 #include "x6dhe_g2_fixups.c"
21 #include "superio/nsc/pc87427/pc87427_early_init.c"
22 #include "northbridge/intel/e7520/memory_initialized.c"
23 #include "cpu/x86/bist.h"
24
25 #define SIO_GPIO_BASE 0x680
26 #define SIO_XBUS_BASE 0x4880
27
28 #define CONSOLE_SERIAL_DEV PNP_DEV(0x2e, PC87427_SP1)
29 #define HIDDEN_SERIAL_DEV  PNP_DEV(0x2e, PC87427_SP2)
30
31 #define DEVPRES_CONFIG  ( \
32         DEVPRES_D1F0 | \
33         DEVPRES_D2F0 | \
34         DEVPRES_D3F0 | \
35         DEVPRES_D4F0 | \
36         DEVPRES_D6F0 | \
37         0 )
38 #define DEVPRES1_CONFIG (DEVPRES1_D0F1 | DEVPRES1_D8F0)
39
40 #define RECVENA_CONFIG  0x0708090a
41 #define RECVENB_CONFIG  0x0708090a
42
43 static inline int spd_read_byte(unsigned device, unsigned address)
44 {
45         return smbus_read_byte(device, address);
46 }
47
48 #include "northbridge/intel/e7520/raminit.c"
49 #include "lib/generic_sdram.c"
50 #include "arch/i386/lib/stages.c"
51
52 static void main(unsigned long bist)
53 {
54         /*
55          *
56          *
57          */
58         static const struct mem_controller mch[] = {
59                 {
60                         .node_id = 0,
61                         /*
62                         .f0 = PCI_DEV(0, 0x00, 0),
63                         .f1 = PCI_DEV(0, 0x00, 1),
64                         .f2 = PCI_DEV(0, 0x00, 2),
65                         .f3 = PCI_DEV(0, 0x00, 3),
66                         */
67                         .channel0 = {(0xa<<3)|3, (0xa<<3)|2, (0xa<<3)|1, (0xa<<3)|0, },
68                         .channel1 = {(0xa<<3)|7, (0xa<<3)|6, (0xa<<3)|5, (0xa<<3)|4, },
69
70                 }
71         };
72
73         if (bist == 0) {
74                 /* Skip this if there was a built in self test failure */
75                 early_mtrr_init();
76                 if (memory_initialized()) {
77                         skip_romstage();
78                 }
79         }
80         /* Setup the console */
81         outb(0x87,0x2e);
82         outb(0x87,0x2e);
83         pnp_write_config(CONSOLE_SERIAL_DEV, 0x24, 0x84 | (1 << 6));
84         pc87427_enable_dev(CONSOLE_SERIAL_DEV, CONFIG_TTYS0_BASE);
85         uart_init();
86         console_init();
87
88         /* Halt if there was a built in self test failure */
89 //      report_bist_failure(bist);
90
91         /* MOVE ME TO A BETTER LOCATION !!! */
92         /* config LPC decode for flash memory access */
93         device_t dev;
94         dev = pci_locate_device(PCI_ID(0x8086, 0x25a1), 0);
95         if (dev == PCI_DEV_INVALID) {
96                 die("Missing ich5r?");
97         }
98         pci_write_config32(dev, 0xe8, 0x00000000);
99         pci_write_config8(dev, 0xf0, 0x00);
100
101 #if 0
102         display_cpuid_update_microcode();
103 #endif
104 #if 0
105         print_pci_devices();
106 #endif
107 #if 1
108         enable_smbus();
109 #endif
110 #if 0
111 //      dump_spd_registers(&cpu[0]);
112         int i;
113         for(i = 0; i < 1; i++) {
114                 dump_spd_registers();
115         }
116 #endif
117         disable_watchdogs();
118 //      dump_ipmi_registers();
119 //      mainboard_set_e7520_leds();
120         sdram_initialize(ARRAY_SIZE(mch), mch);
121 #if 0
122         dump_pci_devices();
123 #endif
124 #if 1
125         dump_pci_device(PCI_DEV(0, 0x00, 0));
126         //dump_bar14(PCI_DEV(0, 0x00, 0));
127 #endif
128
129 #if 0 // temporarily disabled
130         /* Check the first 1M */
131 //      ram_check(0x00000000, 0x000100000);
132 //      ram_check(0x00000000, 0x000a0000);
133         ram_check(0x00100000, 0x01000000);
134         /* check the first 1M in the 3rd Gig */
135         ram_check(0x30100000, 0x31000000);
136 #endif
137 #if 0
138         ram_check(0x00000000, 0x02000000);
139 #endif
140
141 #if 0
142         while(1) {
143                 hlt();
144         }
145 #endif
146 }
147