2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2009-2010 iWave Systems
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
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
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <device/pci_ids.h>
27 static void pci_init(struct device *dev)
32 printk(BIOS_DEBUG, "Initializing SCH PCIe bridge.\n");
34 /* Enable Bus Master */
35 reg32 = pci_read_config32(dev, PCI_COMMAND);
36 reg32 |= PCI_COMMAND_MASTER;
37 pci_write_config32(dev, PCI_COMMAND, reg32);
39 /* Set Cache Line Size to 0x10 */
40 // This has no effect but the OS might expect it
41 pci_write_config8(dev, 0x0c, 0x10);
42 //pci_write_config32(dev, 0x18, 0x11);
44 //reg16 = pci_read_config16(dev, 0x3e);
45 //reg16 &= ~(1 << 0); /* disable parity error response */
46 // reg16 &= ~(1 << 1); /* disable SERR */
47 //reg16 |= (1 << 2); /* ISA enable */
48 //pci_write_config16(dev, 0x3e, reg16);
50 reg16 = pci_read_config16(dev, 0x42);
52 pci_write_config16(dev, 0x42, reg16);
54 reg16 = pci_read_config16(dev, 0x48);
56 pci_write_config16(dev, 0x48, reg16);
60 static void pcie_set_subsystem(device_t dev, unsigned vendor, unsigned device)
62 /* NOTE: This is not the default position! */
63 if (!vendor || !device) {
64 pci_write_config32(dev, 0x94,
65 pci_read_config32(dev, 0));
67 pci_write_config32(dev, 0x94,
68 ((device & 0xffff) << 16) | (vendor & 0xffff));
72 static struct pci_operations pci_ops = {
73 .set_subsystem = pcie_set_subsystem,
76 static struct device_operations device_ops = {
77 .read_resources = pci_bus_read_resources,
78 .set_resources = pci_dev_set_resources,
79 .enable_resources = pci_bus_enable_resources,
81 .scan_bus = pci_scan_bridge,
86 static const struct pci_driver sch_pcie_port1 __pci_driver = {
88 .vendor = PCI_VENDOR_ID_INTEL,
93 static const struct pci_driver sch_pcie_port2 __pci_driver = {
95 .vendor = PCI_VENDOR_ID_INTEL,