This patch drops arch/i386/lib/console.c and arch/i386/lib/console_print.c and
[coreboot.git] / src / mainboard / via / epia-m / romstage.c
1 #include <stdint.h>
2 #include <device/pci_def.h>
3 #include <device/pci_ids.h>
4 #if 0
5 #include <cpu/x86/lapic.h>
6 #endif
7 #include <arch/io.h>
8 #include <device/pnp_def.h>
9 #include <arch/romcc_io.h>
10 #include <arch/hlt.h>
11 #include <stdlib.h>
12 #include "pc80/serial.c"
13 #include "console/console.c"
14 #include "lib/ramtest.c"
15 #include "northbridge/via/vt8623/raminit.h"
16 #include "cpu/x86/mtrr/earlymtrr.c"
17 #include "cpu/x86/bist.h"
18 #include "pc80/udelay_io.c"
19 #include "lib/delay.c"
20 #include "cpu/x86/lapic/boot_cpu.c"
21 #include "lib/debug.c"
22 #include "southbridge/via/vt8235/vt8235_early_smbus.c"
23 #include "southbridge/via/vt8235/vt8235_early_serial.c"
24
25 static void memreset_setup(void)
26 {
27 }
28
29 static inline int spd_read_byte(unsigned device, unsigned address)
30 {
31         return smbus_read_byte(device, address);
32 }
33
34 #include "northbridge/via/vt8623/raminit.c"
35
36 static void enable_mainboard_devices(void) 
37 {
38         device_t dev;
39   
40         dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
41                                 PCI_DEVICE_ID_VIA_8235), 0);
42   
43         if (dev == PCI_DEV_INVALID) {
44                 die("Southbridge not found!!!\n");
45         }
46         pci_write_config8(dev, 0x50, 0x80);
47         pci_write_config8(dev, 0x51, 0x1f);
48 #if 0
49         // This early setup switches IDE into compatibility mode before PCI gets 
50         // a chance to assign I/Os
51         // movl    $CONFIG_ADDR(0, 0x89, 0x42), %eax
52         // //      movb    $0x09, %dl
53         // movb    $0x00, %dl
54         // PCI_WRITE_CONFIG_BYTE
55 #endif
56         /* we do this here as in V2, we can not yet do raw operations 
57          * to pci!
58          */
59         dev += 0x100; /* ICKY */
60
61         pci_write_config8(dev, 0x04, 7);
62         pci_write_config8(dev, 0x40, 3);
63         pci_write_config8(dev, 0x42, 0);
64         pci_write_config8(dev, 0x3c, 0xe);
65         pci_write_config8(dev, 0x3d, 0);
66 }
67
68 static void enable_shadow_ram(void) 
69 {
70         device_t dev = 0; /* no need to look up 0:0.0 */
71         unsigned char shadowreg;
72         /* dev 0 for southbridge */
73         shadowreg = pci_read_config8(dev, 0x63);
74         /* 0xf0000-0xfffff */
75         shadowreg |= 0x30;
76         pci_write_config8(dev, 0x63, shadowreg);
77 }
78
79 static void main(unsigned long bist)
80 {
81         unsigned long x;
82         device_t dev;
83
84         /*
85          * Enable VGA; 32MB buffer.
86          */
87         pci_write_config8(0, 0xe1, 0xdd);
88
89         /*
90          * Disable the firewire stuff, which apparently steps on IO 0+ on
91          * reset. Doh!
92          */
93         dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA,
94                                 PCI_DEVICE_ID_VIA_6305), 0);
95         if (dev != PCI_DEV_INVALID) {
96                 pci_write_config8(dev, 0x15, 0x1c);
97         }
98
99         enable_vt8235_serial();
100         uart_init();
101         console_init();
102
103         enable_smbus();
104
105         print_spew("In romstage.c:main()\r\n");
106
107         /* Halt if there was a built in self test failure */
108         report_bist_failure(bist);
109
110         // init_timer();
111
112         outb(5, 0x80);  
113
114         print_debug(" Enabling mainboard devices\r\n");
115         enable_mainboard_devices();
116
117         print_debug(" Enabling shadow ram\r\n");
118         enable_shadow_ram();
119
120         ddr_ram_setup((const struct mem_controller *)0);
121         
122         /* Check all of memory */
123 #if 0
124         ram_check(0x00000000, msr.lo);
125 #endif
126 #if 0
127         static const struct {
128                 unsigned long lo, hi;
129         } check_addrs[] = {
130                 /* Check 16MB of memory @ 0*/
131                 { 0x00000000, 0x01000000 },
132 #if TOTAL_CPUS > 1
133                 /* Check 16MB of memory @ 2GB */
134                 { 0x80000000, 0x81000000 },
135 #endif
136         };
137         int i;
138         for(i = 0; i < ARRAY_SIZE(check_addrs); i++) {
139                 ram_check(check_addrs[i].lo, check_addrs[i].hi);
140         }
141 #endif
142
143         if (bist == 0) {
144                 print_debug(" Doing MTRR init.\r\n");
145                 early_mtrr_init();
146         }
147
148         //dump_pci_devices();
149         
150         print_spew("Leaving romstage.c:main()\r\n");
151 }
152