2 * This file is part of the coreboot project.
4 * Copyright (C) 2008 VIA Technologies, Inc.
5 * (Written by Aaron Lwe <aaron.lwe@gmail.com> for VIA)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <device/pci_def.h>
27 #include <device/pci_ids.h>
29 #include <device/pnp_def.h>
30 #include <arch/romcc_io.h>
32 #include "pc80/serial.c"
33 #include "arch/i386/lib/console.c"
34 #include "lib/ramtest.c"
35 #include "northbridge/via/cn700/raminit.h"
36 #include "cpu/x86/mtrr/earlymtrr.c"
37 #include "cpu/x86/bist.h"
38 #include "pc80/udelay_io.c"
39 #include "lib/delay.c"
40 #include "cpu/x86/lapic/boot_cpu.c"
41 #include "southbridge/via/vt8237r/vt8237r_early_smbus.c"
42 #include "superio/winbond/w83697hf/w83697hf_early_serial.c"
43 #define SERIAL_DEV PNP_DEV(0x2e, W83697HF_SP1)
45 static void memreset_setup(void)
49 static inline int spd_read_byte(unsigned device, unsigned address)
51 return smbus_read_byte(device, address);
54 #include "northbridge/via/cn700/raminit.c"
56 static void enable_mainboard_devices(void)
61 dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
62 if (dev == PCI_DEV_INVALID)
63 die("Southbridge not found!!!\n");
65 /* bit=0 means enable function (per CX700 datasheet)
68 * 3 15.0 SATA and PATA
72 pci_write_config8(dev, 0x50, 0x80);
74 /* bit=1 means enable internal function (per CX700 datasheet)
76 * 2 Internal PS2 Mouse
77 * 1 Internal KBC Configuration
78 * 0 Internal Keyboard Controller
80 pci_write_config8(dev, 0x51, 0x1d);
83 static const struct mem_controller ctrl = {
93 static void main(unsigned long bist)
98 /* Enable multifunction for northbridge. */
99 pci_write_config8(ctrl.d0f0, 0x4f, 0x01);
101 w83697hf_set_clksel_48(SERIAL_DEV);
103 w83697hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
107 print_spew("In romstage.c:main()\r\n");
113 print_debug("doing early_mtrr\r\n");
117 /* Halt if there was a built-in self test failure. */
118 report_bist_failure(bist);
120 print_debug("Enabling mainboard devices\r\n");
121 enable_mainboard_devices();
123 ddr_ram_setup(&ctrl);
125 /* ram_check(0, 640 * 1024); */
127 print_spew("Leaving romstage.c:main()\r\n");