Drop \r\n and \n\r as both print_XXX and printk now do this internally.
[coreboot.git] / src / mainboard / via / vt8454c / romstage.c
1 /*
2  * This file is part of the coreboot project.
3  * 
4  * Copyright (C) 2007-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 #include <stdint.h>
23 #include <device/pci_def.h>
24 #include <device/pci_ids.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 "pc80/serial.c"
30 #include "console/console.c"
31 #include "lib/ramtest.c"
32 #include "northbridge/via/cx700/raminit.h"
33 #include "cpu/x86/mtrr/earlymtrr.c"
34 #include "cpu/x86/bist.h"
35
36 #define DEACTIVATE_CAR 1
37 #define DEACTIVATE_CAR_FILE "cpu/via/car/cache_as_ram_post.c"
38 #include "cpu/x86/car/copy_and_run.c"
39 #include "pc80/udelay_io.c"
40 #include "lib/delay.c"
41 #include "cpu/x86/lapic/boot_cpu.c"
42 #include "northbridge/via/cx700/cx700_early_smbus.c"
43 #include "debug.c"
44
45 #include "northbridge/via/cx700/cx700_early_serial.c"
46 #include "northbridge/via/cx700/raminit.c"
47
48 static void enable_mainboard_devices(void)
49 {
50         device_t dev;
51
52         dev = pci_locate_device(PCI_ID(0x1106, 0x8324), 0);
53         if (dev == PCI_DEV_INVALID) {
54                 die("LPC bridge not found!!!\n");
55         }
56         // Disable GP3 
57         pci_write_config8(dev, 0x98, 0x00);
58
59         // Disable mc97
60         pci_write_config8(dev, 0x50, 0x80);
61
62         // Disable internal KBC Configuration
63         pci_write_config8(dev, 0x51, 0x2d);
64         pci_write_config8(dev, 0x58, 0x42);
65         pci_write_config8(dev, 0x59, 0x80);
66         pci_write_config8(dev, 0x5b, 0x01);
67
68         // Enable P2P Bridge Header for External PCI BUS.
69         dev = pci_locate_device(PCI_ID(0x1106, 0x324e), 0);
70         if (dev == PCI_DEV_INVALID) {
71                 die("P2P bridge not found!!!\n");
72         }
73         pci_write_config8(dev, 0x4f, 0x41);
74
75         // Switch SATA to non-RAID mode
76         dev = pci_locate_device(PCI_ID(0x1106, 0x0581), 0);
77         if (dev != PCI_DEV_INVALID) {
78                 pci_write_config16(dev, 0xBA, 0x5324);
79         }
80 }
81
82 static void enable_shadow_ram(const struct mem_controller *ctrl)
83 {
84         u8 shadowreg;
85
86         pci_write_config8(PCI_DEV(0, 0, 3), 0x80, 0x2a);
87
88         /* 0xf0000-0xfffff - ACPI tables */
89         shadowreg = pci_read_config8(PCI_DEV(0, 0, 3), 0x83);
90         shadowreg |= 0x30;
91         pci_write_config8(PCI_DEV(0, 0, 3), 0x83, shadowreg);
92 }
93
94 static void main(unsigned long bist)
95 {
96         /* Set statically so it should work with cx700 as well */
97         static const struct mem_controller cx700[] = {
98                 {
99                         .channel0 = {0x50, 0x51},
100                 },
101         };
102
103         enable_smbus();
104
105         enable_cx700_serial();
106         uart_init();
107         console_init();
108
109         /* Halt if there was a built in self test failure */
110         report_bist_failure(bist);
111
112         enable_mainboard_devices();
113
114         /* Allows access to all northbridge devices */
115         pci_write_config8(PCI_DEV(0, 0, 0), 0x4f, 0x01);
116
117         sdram_set_registers(cx700);
118         enable_shadow_ram(cx700);
119         sdram_enable(cx700);
120
121 #ifdef DEACTIVATE_CAR
122         print_debug("Deactivating CAR");
123 #include DEACTIVATE_CAR_FILE
124         print_debug(" - Done.\n");
125 #endif
126         copy_and_run(0);
127 }
128
129 void amd64_main(unsigned long bist) {
130         main(bist);
131 }
132