fixes for epia, attempts to fix arima
[coreboot.git] / src / mainboard / via / epia / auto.c
1 #define ASSEMBLY 1
2
3 //#define MAXIMUM_CONSOLE_LOGLEVEL 6
4 //#define DEFAULT_CONSOLE_LOGLEVEL 6
5
6 #include <stdint.h>
7 #include <device/pci_def.h>
8 #include <cpu/p6/apic.h>
9 #include <arch/io.h>
10 #include <device/pnp.h>
11 #include <arch/romcc_io.h>
12 #include "pc80/serial.c"
13 #include "arch/i386/lib/console.c"
14 #include "ram/ramtest.c"
15 #include "northbridge/via/vt8601/raminit.h"
16 #include "cpu/p6/earlymtrr.c"
17 /*
18  */
19 void udelay(int usecs) 
20 {
21         int i;
22         for(i = 0; i < usecs; i++)
23                 outb(i&0xff, 0x80);
24 }
25
26 #include "lib/delay.c"
27 #include "cpu/p6/boot_cpu.c"
28 #include "debug.c"
29
30 #include "southbridge/via/vt8231/vt8231_early_smbus.c"
31
32
33 #include "southbridge/via/vt8231/vt8231_early_serial.c"
34 static void memreset_setup(void)
35 {
36 }
37
38 /*
39   static void memreset(int controllers, const struct mem_controller *ctrl)
40   {
41   }
42 */
43 static inline int spd_read_byte(unsigned device, unsigned address)
44 {
45         unsigned char c;
46         c = smbus_read_byte(device, address);
47         return c;
48 }
49
50
51
52 #include "northbridge/via/vt8601/raminit.c"
53 /*
54   #include "sdram/generic_sdram.c"
55 */
56
57 static void enable_mainboard_devices(void) 
58 {
59         device_t dev;
60         /* dev 0 for southbridge */
61   
62         dev = pci_locate_device(PCI_ID(0x1106,0x8231), 0);
63   
64         if (dev == PCI_DEV_INVALID) {
65                 die("Southbridge not found!!!\n");
66         }
67         pci_write_config8(dev, 0x50, 7);
68         pci_write_config8(dev, 0x51, 0xff);
69 #if 0
70         // This early setup switches IDE into compatibility mode before PCI gets 
71         // // a chance to assign I/Os
72         //         movl    $CONFIG_ADDR(0, 0x89, 0x42), %eax
73         //         //      movb    $0x09, %dl
74         //                 movb    $0x00, %dl
75         //                         PCI_WRITE_CONFIG_BYTE
76         //
77 #endif
78         /* we do this here as in V2, we can not yet do raw operations 
79          * to pci!
80          */
81         dev += 0x100; /* ICKY */
82
83         pci_write_config8(dev, 0x42, 0);
84 }
85
86 static void enable_shadow_ram(void) 
87 {
88         device_t dev = 0; /* no need to look up 0:0.0 */
89         unsigned char shadowreg;
90         /* dev 0 for southbridge */
91         shadowreg = pci_read_config8(dev, 0x63);
92         /* 0xf0000-0xfffff */
93         shadowreg |= 0x30;
94         pci_write_config8(dev, 0x63, shadowreg);
95 }
96
97 static void main(void)
98 {
99         unsigned long x;
100         /*      init_timer();*/
101         outb(5, 0x80);
102         
103         enable_vt8231_serial();
104
105         uart_init();
106         console_init();
107         
108         enable_mainboard_devices();
109         enable_smbus();
110         enable_shadow_ram();
111         /*
112           memreset_setup();
113           this is way more generic than we need.
114           sdram_initialize(sizeof(cpu)/sizeof(cpu[0]), cpu);
115         */
116         sdram_set_registers((const struct mem_controller *) 0);
117         sdram_set_spd_registers((const struct mem_controller *) 0);
118         sdram_enable(0, (const struct mem_controller *) 0);
119         
120         /* Check all of memory */
121 #if 0
122         ram_check(0x00000000, msr.lo);
123 #endif
124 #if 0
125         static const struct {
126                 unsigned long lo, hi;
127         } check_addrs[] = {
128                 /* Check 16MB of memory @ 0*/
129                 { 0x00000000, 0x01000000 },
130 #if TOTAL_CPUS > 1
131                 /* Check 16MB of memory @ 2GB */
132                 { 0x80000000, 0x81000000 },
133 #endif
134         };
135         int i;
136         for(i = 0; i < sizeof(check_addrs)/sizeof(check_addrs[0]); i++) {
137                 ram_check(check_addrs[i].lo, check_addrs[i].hi);
138         }
139 #endif
140         early_mtrr_init();
141 }