Drop excessive whitespace randomly sprinkled in romstage.c files.
[coreboot.git] / src / mainboard / via / epia / 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 <arch/hlt.h>
7 #include <stdlib.h>
8 #include <console/console.h>
9 #include "lib/ramtest.c"
10 #include "northbridge/via/vt8601/raminit.h"
11 #include "cpu/x86/mtrr/earlymtrr.c"
12 #include "cpu/x86/bist.h"
13 #include "pc80/udelay_io.c"
14 #include "lib/delay.c"
15 #include "lib/debug.c"
16 #include "southbridge/via/vt8231/vt8231_early_smbus.c"
17 #include "southbridge/via/vt8231/vt8231_early_serial.c"
18 #include "southbridge/via/vt8231/vt8231_enable_rom.c"
19
20 static inline int spd_read_byte(unsigned device, unsigned address)
21 {
22         return smbus_read_byte(device, address);
23 }
24
25 #include "northbridge/via/vt8601/raminit.c"
26
27 static void enable_mainboard_devices(void)
28 {
29         device_t dev;
30         /* dev 0 for southbridge */
31
32         dev = pci_locate_device(PCI_ID(0x1106,0x8231), 0);
33
34         if (dev == PCI_DEV_INVALID) {
35                 die("Southbridge not found!!!\n");
36         }
37
38         pci_write_config8(dev, 0x50, 7);
39         pci_write_config8(dev, 0x51, 0xff);
40 #if 0
41         // This early setup switches IDE into compatibility mode before PCI gets
42         // a chance to assign I/Os
43         //   movl    $CONFIG_ADDR(0, 0x89, 0x42), %eax
44         //   movb    $0x09, %dl
45         //   movb    $0x00, %dl
46         //   PCI_WRITE_CONFIG_BYTE
47         //
48 #endif
49         /* we do this here as in V2, we can not yet do raw operations
50          * to pci!
51          */
52         /* changed this to work correctly on later revisions of LB.
53         * The original dev += 0x100; stopped working. It also appears
54         * that if this is not set here, but in ide_init() only, the IDE
55         * does not work at all. I assume it needs to be set before something else,
56         * possibly before enabling the IDE peripheral, or it is a timing issue.
57         * Ben Hewson 29 Apr 2007.
58         */
59
60         dev = pci_locate_device(PCI_ID(0x1106,0x0571), 0);
61         pci_write_config8(dev, 0x42, 0);
62 }
63
64 static void enable_shadow_ram(void)
65 {
66         device_t dev = 0;
67         unsigned char shadowreg;
68
69         shadowreg = pci_read_config8(dev, 0x63);
70         /* 0xf0000-0xfffff */
71         shadowreg |= 0x30;
72         pci_write_config8(dev, 0x63, shadowreg);
73 }
74
75 static void main(unsigned long bist)
76 {
77         if (bist == 0) {
78                 early_mtrr_init();
79         }
80         enable_vt8231_serial();
81         uart_init();
82         console_init();
83
84         /* Halt if there was a built in self test failure */
85         report_bist_failure(bist);
86
87         vt8231_enable_rom();
88         enable_mainboard_devices();
89         enable_smbus();
90         enable_shadow_ram();
91
92         /*
93           this is way more generic than we need.
94           sdram_initialize(ARRAY_SIZE(cpu), cpu);
95         */
96         sdram_set_registers((const struct mem_controller *) 0);
97         sdram_set_spd_registers((const struct mem_controller *) 0);
98         sdram_enable(0, (const struct mem_controller *) 0);
99
100         /* Check all of memory */
101 #if 0
102         ram_check(0x00000000, msr.lo);
103 #endif
104 #if 0
105         static const struct {
106                 unsigned long lo, hi;
107         } check_addrs[] = {
108                 /* Check 16MB of memory @ 0*/
109                 { 0x00000000, 0x01000000 },
110 #if TOTAL_CPUS > 1
111                 /* Check 16MB of memory @ 2GB */
112                 { 0x80000000, 0x81000000 },
113 #endif
114         };
115         int i;
116         for(i = 0; i < ARRAY_SIZE(check_addrs); i++) {
117                 ram_check(check_addrs[i].lo, check_addrs[i].hi);
118         }
119 #endif
120 }