2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License v2 as published by
8 * the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <console/console.h>
21 #include <device/device.h>
22 #include <device/pci.h>
23 #include <device/pciexp.h>
24 #include <device/pci_ids.h>
26 static void peg_init(struct device *dev)
30 printk_debug("Configuring PCIe PEG\n");
34 reg = pci_read_config8(dev, 0x50);
35 pci_write_config8(dev, 0x50, reg | 0x10);
37 /* Award has 0xb, VIA recomends 0x4. */
38 pci_write_config8(dev, 0xe1, 0xb);
41 * pci_write_config8(dev, 0xe2, 0x0);
42 * pci_write_config8(dev, 0xe3, 0x92);
44 /* Disable scrambling bit 6 to 1. */
45 pci_write_config8(dev, 0xc0, 0x43);
47 /* Set replay timer limit. */
48 pci_write_config8(dev, 0xb1, 0xf0);
50 /* Bit0 = 1 SDP (Start DLLP) always at Lane0. */
51 reg = pci_read_config8(dev, 0xb8);
52 pci_write_config8(dev, 0xb8, reg | 0x1);
55 * Downstream wait and Upstream Checking Malformed TLP through
56 * "Byte Enable Rule" And "Over 4K Boundary Rule".
58 reg = pci_read_config8(dev, 0xa4);
59 pci_write_config8(dev, 0xa4, reg | 0x30);
62 reg = pci_read_config8(dev, 0x50);
63 pci_write_config8(dev, 0x50, reg & ~0x10);
66 reg = pci_read_config8(dev, 0x50);
67 pci_write_config8(dev, 0x50, reg | 0x20);
69 reg = pci_read_config8(dev, 0x3e);
70 reg |= 0x40; /* Bus reset. */
71 pci_write_config8(dev, 0x3e, reg);
73 reg = pci_read_config8(dev, 0x3e);
74 reg &= ~0x40; /* Clear reset. */
75 pci_write_config8(dev, 0x3e, reg);
80 static void pcie_init(struct device *dev)
84 printk_debug("Configuring PCIe PEXs\n");
88 reg = pci_read_config8(dev, 0x50);
89 pci_write_config8(dev, 0x50, reg | 0x10);
91 /* Award has 0xb, VIA recommends 0x4. */
92 pci_write_config8(dev, 0xe1, 0xb);
93 /* Set replay timer limit. */
94 pci_write_config8(dev, 0xb1, 0xf0);
97 reg = pci_read_config8(dev, 0x50);
98 pci_write_config8(dev, 0x50, reg & ~0x10);
101 reg = pci_read_config8(dev, 0x50);
102 pci_write_config8(dev, 0x50, reg | 0x20);
104 reg = pci_read_config8(dev, 0x3e);
105 reg |= 0x40; /* Bus reset. */
106 pci_write_config8(dev, 0x3e, reg);
108 reg = pci_read_config8(dev, 0x3e);
109 reg &= ~0x40; /* Clear reset. */
110 pci_write_config8(dev, 0x3e, reg);
115 static const struct device_operations peg_ops = {
116 .read_resources = pci_bus_read_resources,
117 .set_resources = pci_dev_set_resources,
118 .enable_resources = pci_bus_enable_resources,
120 .scan_bus = pciexp_scan_bridge,
121 .reset_bus = pci_bus_reset,
125 static const struct device_operations pcie_ops = {
126 .read_resources = pci_bus_read_resources,
127 .set_resources = pci_dev_set_resources,
128 .enable_resources = pci_bus_enable_resources,
130 .scan_bus = pciexp_scan_bridge,
131 .reset_bus = pci_bus_reset,
135 static const struct pci_driver northbridge_driver __pci_driver = {
137 .vendor = PCI_VENDOR_ID_VIA,
138 .device = PCI_DEVICE_ID_VIA_K8T890CE_PEG,
141 static const struct pci_driver pcie_drvd3f0 __pci_driver = {
143 .vendor = PCI_VENDOR_ID_VIA,
144 .device = PCI_DEVICE_ID_VIA_K8T890CE_PEX0,
147 static const struct pci_driver pcie_drvd3f1 __pci_driver = {
149 .vendor = PCI_VENDOR_ID_VIA,
150 .device = PCI_DEVICE_ID_VIA_K8T890CE_PEX1,
153 static const struct pci_driver pcie_drvd3f2 __pci_driver = {
155 .vendor = PCI_VENDOR_ID_VIA,
156 .device = PCI_DEVICE_ID_VIA_K8T890CE_PEX2,
159 static const struct pci_driver pcie_drvd3f3 __pci_driver = {
161 .vendor = PCI_VENDOR_ID_VIA,
162 .device = PCI_DEVICE_ID_VIA_K8T890CE_PEX3,