2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2009 coresystems GmbH
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
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.
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, MA 02110-1301 USA
21 #include <console/console.h>
22 #include <device/device.h>
23 #include <device/pci.h>
24 #include <device/pci_ids.h>
26 static void pci_init(struct device *dev)
31 /* Commented out for now because it will break on some machines. */
32 /* Set latency timer to 32. */
33 pci_write_config16(dev, 0x1b, 0x20);
36 /* disable parity error response */
37 reg16 = pci_read_config16(dev, 0x3e);
39 pci_write_config16(dev, 0x3e, reg16);
41 /* Clear errors in status registers */
42 reg16 = pci_read_config16(dev, 0x06);
44 pci_write_config16(dev, 0x06, reg16);
46 reg16 = pci_read_config16(dev, 0x1e);
48 pci_write_config16(dev, 0x1e, reg16);
50 /* Will this improve throughput of bus masters? */
51 pci_write_config8(dev, PCI_MIN_GNT, 0x06);
54 static void ich_pci_dev_enable_resources(struct device *dev)
56 const struct pci_operations *ops;
59 /* Set the subsystem vendor and device id for mainboard devices */
61 if (dev->on_mainboard && ops && ops->set_subsystem) {
62 printk_debug("%s subsystem <- %02x/%02x\n",
64 MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
65 MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
66 ops->set_subsystem(dev,
67 MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
68 MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
72 /* If we write to PCI_COMMAND, on some systems
73 * this will cause the ROM and APICs not being visible
76 command = pci_read_config16(dev, PCI_COMMAND);
77 command |= dev->command;
78 printk_debug("%s cmd <- %02x\n", dev_path(dev), command);
79 pci_write_config16(dev, PCI_COMMAND, command);
83 static void ich_pci_bus_enable_resources(struct device *dev)
86 /* enable IO in command register if there is VGA card
87 * connected with (even it does not claim IO resource)
89 if (dev->link[0].bridge_ctrl & PCI_BRIDGE_CTL_VGA)
90 dev->command |= PCI_COMMAND_IO;
91 ctrl = pci_read_config16(dev, PCI_BRIDGE_CONTROL);
92 ctrl |= dev->link[0].bridge_ctrl;
93 ctrl |= (PCI_BRIDGE_CTL_PARITY + PCI_BRIDGE_CTL_SERR); /* error check */
94 printk_debug("%s bridge ctrl <- %04x\n", dev_path(dev), ctrl);
95 pci_write_config16(dev, PCI_BRIDGE_CONTROL, ctrl);
97 /* This is the reason we need our own pci_bus_enable_resources */
98 ich_pci_dev_enable_resources(dev);
100 enable_childrens_resources(dev);
103 static void set_subsystem(device_t dev, unsigned vendor, unsigned device)
106 /* Currently disabled because it causes a "BAR 9" memory resource
111 printk_debug("Setting PCI bridge subsystem ID\n");
112 pci_id = pci_read_config32(dev, 0);
113 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, pci_id );
117 static struct pci_operations pci_ops = {
118 .set_subsystem = set_subsystem,
121 static struct device_operations device_ops = {
122 .read_resources = pci_bus_read_resources,
123 .set_resources = pci_dev_set_resources,
124 .enable_resources = ich_pci_bus_enable_resources,
126 .scan_bus = pci_scan_bridge,
131 /* 82801BA/CA/DB/EB/ER/FB/FR/FW/FRW/GB/GR/GDH/HB/IB/6300ESB/i3100 */
132 static const struct pci_driver i82801g_pci __pci_driver = {
134 .vendor = PCI_VENDOR_ID_INTEL,
138 /* Mobile / Ultra Mobile */
139 /* 82801BAM/CAM/DBL/DBM/FBM/GBM/GHM/GU/HBM/HEM */
140 static const struct pci_driver i82801gmu_pci __pci_driver = {
142 .vendor = PCI_VENDOR_ID_INTEL,