2 * This file is part of the coreboot project.
4 * Copyright (C) 2008 Arastra, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by 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
21 /* This code is based on src/northbridge/intel/e7520/pciexp_porta.c */
23 #include <console/console.h>
24 #include <device/device.h>
25 #include <device/pci.h>
26 #include <device/pci_ids.h>
27 #include <device/pci_ops.h>
28 #include <device/pciexp.h>
31 #include <part/hard_reset.h>
33 typedef struct northbridge_intel_i3100_config config_t;
35 static void pcie_init(struct device *dev)
39 /* Get the chip configuration */
40 config = dev->chip_info;
42 if(config->intrline) {
43 pci_write_config32(dev, 0x3c, config->intrline);
48 static unsigned int pcie_scan_bridge(struct device *dev, unsigned int max)
54 val = pci_read_config16(dev, 0x76);
55 printk_debug("pcie porta 0x76: %02x\n", val);
56 if ((val & (1<<10)) && (!flag)) { /* training error */
57 ctl = pci_read_config16(dev, 0x74);
58 pci_write_config16(dev, 0x74, (ctl | (1<<5)));
59 val = pci_read_config16(dev, 0x76);
60 printk_debug("pcie porta reset 0x76: %02x\n", val);
64 } while (val & (3<<10));
65 return pciexp_scan_bridge(dev, max);
68 static struct device_operations pcie_ops = {
69 .read_resources = pci_bus_read_resources,
70 .set_resources = pci_dev_set_resources,
71 .enable_resources = pci_bus_enable_resources,
73 .scan_bus = pcie_scan_bridge,
74 .reset_bus = pci_bus_reset,
78 static struct pci_driver pci_driver_0 __pci_driver = {
80 .vendor = PCI_VENDOR_ID_INTEL,
81 .device = PCI_DEVICE_ID_INTEL_3100_PCIE_PA,
84 static struct pci_driver pci_driver_1 __pci_driver = {
86 .vendor = PCI_VENDOR_ID_INTEL,
87 .device = PCI_DEVICE_ID_INTEL_3100_PCIE_PA1,