blob: 1a1efbf8f6f6b146bc1440136c8d58fde7f84449 [file] [log] [blame]
Stefan Reinaueraeba92a2009-04-17 08:37:18 +00001/*
2 * This file is part of the coreboot project.
Stefan Reinauer14e22772010-04-27 06:56:47 +00003 *
Stefan Reinaueraeba92a2009-04-17 08:37:18 +00004 * 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
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000022#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"
Stefan Reinauer5a1f5972010-03-31 14:34:40 +000030#include "console/console.c"
Stefan Reinauerc13093b2009-09-23 18:51:03 +000031#include "lib/ramtest.c"
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000032#include "northbridge/via/cx700/raminit.h"
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000033#include "cpu/x86/bist.h"
34
Stefan Reinauer853263b2010-04-09 10:43:49 +000035
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000036#include "pc80/udelay_io.c"
37#include "lib/delay.c"
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000038#include "northbridge/via/cx700/cx700_early_smbus.c"
Stefan Reinauerc65666f2010-04-03 12:41:41 +000039#include "lib/debug.c"
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000040
41#include "northbridge/via/cx700/cx700_early_serial.c"
42#include "northbridge/via/cx700/raminit.c"
43
44static void enable_mainboard_devices(void)
45{
46 device_t dev;
47
48 dev = pci_locate_device(PCI_ID(0x1106, 0x8324), 0);
49 if (dev == PCI_DEV_INVALID) {
50 die("LPC bridge not found!!!\n");
51 }
Stefan Reinauer14e22772010-04-27 06:56:47 +000052 // Disable GP3
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000053 pci_write_config8(dev, 0x98, 0x00);
54
55 // Disable mc97
56 pci_write_config8(dev, 0x50, 0x80);
57
58 // Disable internal KBC Configuration
59 pci_write_config8(dev, 0x51, 0x2d);
60 pci_write_config8(dev, 0x58, 0x42);
61 pci_write_config8(dev, 0x59, 0x80);
62 pci_write_config8(dev, 0x5b, 0x01);
63
64 // Enable P2P Bridge Header for External PCI BUS.
65 dev = pci_locate_device(PCI_ID(0x1106, 0x324e), 0);
66 if (dev == PCI_DEV_INVALID) {
67 die("P2P bridge not found!!!\n");
68 }
69 pci_write_config8(dev, 0x4f, 0x41);
70
71 // Switch SATA to non-RAID mode
72 dev = pci_locate_device(PCI_ID(0x1106, 0x0581), 0);
73 if (dev != PCI_DEV_INVALID) {
74 pci_write_config16(dev, 0xBA, 0x5324);
75 }
76}
77
78static void enable_shadow_ram(const struct mem_controller *ctrl)
79{
80 u8 shadowreg;
81
82 pci_write_config8(PCI_DEV(0, 0, 3), 0x80, 0x2a);
83
84 /* 0xf0000-0xfffff - ACPI tables */
85 shadowreg = pci_read_config8(PCI_DEV(0, 0, 3), 0x83);
86 shadowreg |= 0x30;
87 pci_write_config8(PCI_DEV(0, 0, 3), 0x83, shadowreg);
88}
89
Stefan Reinauer314e5512010-04-09 20:36:29 +000090void main(unsigned long bist)
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000091{
92 /* Set statically so it should work with cx700 as well */
93 static const struct mem_controller cx700[] = {
94 {
95 .channel0 = {0x50, 0x51},
96 },
97 };
98
99 enable_smbus();
100
101 enable_cx700_serial();
102 uart_init();
103 console_init();
104
105 /* Halt if there was a built in self test failure */
106 report_bist_failure(bist);
107
108 enable_mainboard_devices();
109
110 /* Allows access to all northbridge devices */
111 pci_write_config8(PCI_DEV(0, 0, 0), 0x4f, 0x01);
112
113 sdram_set_registers(cx700);
114 enable_shadow_ram(cx700);
115 sdram_enable(cx700);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +0000116}
Stefan Reinauer798ef282010-03-29 22:08:01 +0000117