blob: 114494bdb5c83799de4c5daf8b4fee50db42c5df [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.
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000015 */
16
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000017#include <stdint.h>
18#include <device/pci_def.h>
19#include <device/pci_ids.h>
20#include <arch/io.h>
21#include <device/pnp_def.h>
Patrick Georgi12584e22010-05-08 09:14:51 +000022#include <console/console.h>
Patrick Georgid0835952010-10-05 09:07:10 +000023#include <lib.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110024#include <northbridge/via/cx700/raminit.h>
25#include <cpu/x86/bist.h>
Kyösti Mälkki52769412016-06-17 07:55:03 +030026#include <cpu/amd/car.h>
Edward O'Callaghanebe3a7a2015-01-05 00:27:54 +110027#include <delay.h>
stepan8301d832010-12-08 07:07:33 +000028#include "northbridge/via/cx700/early_smbus.c"
Stefan Reinauerc65666f2010-04-03 12:41:41 +000029#include "lib/debug.c"
stepan8301d832010-12-08 07:07:33 +000030#include "northbridge/via/cx700/early_serial.c"
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000031#include "northbridge/via/cx700/raminit.c"
Uwe Hermann6dc92f02010-11-21 11:36:03 +000032#include <spd.h>
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000033
34static void enable_mainboard_devices(void)
35{
Antonello Dettori50f1b1a2016-11-08 18:44:46 +010036 pci_devfn_t dev;
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000037
38 dev = pci_locate_device(PCI_ID(0x1106, 0x8324), 0);
39 if (dev == PCI_DEV_INVALID) {
40 die("LPC bridge not found!!!\n");
41 }
Stefan Reinauer14e22772010-04-27 06:56:47 +000042 // Disable GP3
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000043 pci_write_config8(dev, 0x98, 0x00);
44
45 // Disable mc97
46 pci_write_config8(dev, 0x50, 0x80);
47
48 // Disable internal KBC Configuration
49 pci_write_config8(dev, 0x51, 0x2d);
50 pci_write_config8(dev, 0x58, 0x42);
51 pci_write_config8(dev, 0x59, 0x80);
52 pci_write_config8(dev, 0x5b, 0x01);
53
54 // Enable P2P Bridge Header for External PCI BUS.
55 dev = pci_locate_device(PCI_ID(0x1106, 0x324e), 0);
56 if (dev == PCI_DEV_INVALID) {
57 die("P2P bridge not found!!!\n");
58 }
59 pci_write_config8(dev, 0x4f, 0x41);
60
61 // Switch SATA to non-RAID mode
62 dev = pci_locate_device(PCI_ID(0x1106, 0x0581), 0);
63 if (dev != PCI_DEV_INVALID) {
64 pci_write_config16(dev, 0xBA, 0x5324);
65 }
66}
67
68static void enable_shadow_ram(const struct mem_controller *ctrl)
69{
70 u8 shadowreg;
71
72 pci_write_config8(PCI_DEV(0, 0, 3), 0x80, 0x2a);
73
74 /* 0xf0000-0xfffff - ACPI tables */
75 shadowreg = pci_read_config8(PCI_DEV(0, 0, 3), 0x83);
76 shadowreg |= 0x30;
77 pci_write_config8(PCI_DEV(0, 0, 3), 0x83, shadowreg);
78}
79
Stefan Reinauer314e5512010-04-09 20:36:29 +000080void main(unsigned long bist)
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000081{
82 /* Set statically so it should work with cx700 as well */
83 static const struct mem_controller cx700[] = {
84 {
Uwe Hermannd773fd32010-11-20 20:23:08 +000085 .channel0 = {DIMM0, DIMM1},
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000086 },
87 };
88
89 enable_smbus();
90
91 enable_cx700_serial();
Stefan Reinaueraeba92a2009-04-17 08:37:18 +000092 console_init();
93
94 /* Halt if there was a built in self test failure */
95 report_bist_failure(bist);
96
97 enable_mainboard_devices();
98
99 /* Allows access to all northbridge devices */
100 pci_write_config8(PCI_DEV(0, 0, 0), 0x4f, 0x01);
101
102 sdram_set_registers(cx700);
103 enable_shadow_ram(cx700);
104 sdram_enable(cx700);
Stefan Reinaueraeba92a2009-04-17 08:37:18 +0000105}