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
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
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>
27 static void pci_init(struct device *dev)
32 /* Enable Bus Master */
33 reg16 = pci_read_config16(dev, PCI_COMMAND);
34 reg16 |= PCI_COMMAND_MASTER;
35 pci_write_config16(dev, PCI_COMMAND, reg16);
37 /* This device has no interrupt */
38 pci_write_config8(dev, INTR, 0xff);
40 /* disable parity error response and SERR */
41 reg16 = pci_read_config16(dev, BCTRL);
44 pci_write_config16(dev, BCTRL, reg16);
46 /* Master Latency Count must be set to 0x04! */
47 reg8 = pci_read_config8(dev, SMLT);
50 pci_write_config8(dev, SMLT, reg8);
52 /* Will this improve throughput of bus masters? */
53 pci_write_config8(dev, PCI_MIN_GNT, 0x06);
55 /* Clear errors in status registers */
56 reg16 = pci_read_config16(dev, PSTS);
58 pci_write_config16(dev, PSTS, reg16);
60 reg16 = pci_read_config16(dev, SECSTS);
62 pci_write_config16(dev, SECSTS, reg16);
65 #undef PCI_BRIDGE_UPDATE_COMMAND
66 static void ich_pci_dev_enable_resources(struct device *dev)
68 const struct pci_operations *ops;
71 /* Set the subsystem vendor and device id for mainboard devices */
73 if (dev->on_mainboard && ops && ops->set_subsystem) {
74 printk(BIOS_DEBUG, "%s subsystem <- %02x/%02x\n",
76 CONFIG_MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
77 CONFIG_MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
78 ops->set_subsystem(dev,
79 CONFIG_MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID,
80 CONFIG_MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID);
83 command = pci_read_config16(dev, PCI_COMMAND);
84 command |= dev->command;
85 #ifdef PCI_BRIDGE_UPDATE_COMMAND
86 /* If we write to PCI_COMMAND, on some systems
87 * this will cause the ROM and APICs not being visible
90 printk(BIOS_DEBUG, "%s cmd <- %02x\n", dev_path(dev), command);
91 pci_write_config16(dev, PCI_COMMAND, command);
93 printk(BIOS_DEBUG, "%s cmd <- %02x (NOT WRITTEN!)\n", dev_path(dev), command);
97 static void ich_pci_bus_enable_resources(struct device *dev)
100 /* enable IO in command register if there is VGA card
101 * connected with (even it does not claim IO resource)
103 if (dev->link_list->bridge_ctrl & PCI_BRIDGE_CTL_VGA)
104 dev->command |= PCI_COMMAND_IO;
105 ctrl = pci_read_config16(dev, PCI_BRIDGE_CONTROL);
106 ctrl |= dev->link_list->bridge_ctrl;
107 ctrl |= (PCI_BRIDGE_CTL_PARITY + PCI_BRIDGE_CTL_SERR); /* error check */
108 printk(BIOS_DEBUG, "%s bridge ctrl <- %04x\n", dev_path(dev), ctrl);
109 pci_write_config16(dev, PCI_BRIDGE_CONTROL, ctrl);
111 /* This is the reason we need our own pci_bus_enable_resources */
112 ich_pci_dev_enable_resources(dev);
115 static void set_subsystem(device_t dev, unsigned vendor, unsigned device)
117 /* NOTE: This is not the default position! */
118 if (!vendor || !device) {
119 pci_write_config32(dev, 0x54,
120 pci_read_config32(dev, PCI_VENDOR_ID));
122 pci_write_config32(dev, 0x54,
123 ((device & 0xffff) << 16) | (vendor & 0xffff));
127 static struct pci_operations pci_ops = {
128 .set_subsystem = set_subsystem,
131 static struct device_operations device_ops = {
132 .read_resources = pci_bus_read_resources,
133 .set_resources = pci_dev_set_resources,
134 .enable_resources = ich_pci_bus_enable_resources,
136 .scan_bus = pci_scan_bridge,
141 /* 82801BA/CA/DB/EB/ER/FB/FR/FW/FRW/GB/GR/GDH/HB/IB/6300ESB/i3100 */
142 static const struct pci_driver i82801g_pci __pci_driver = {
144 .vendor = PCI_VENDOR_ID_INTEL,
148 /* Mobile / Ultra Mobile */
149 /* 82801BAM/CAM/DBL/DBM/FBM/GBM/GHM/GU/HBM/HEM */
150 static const struct pci_driver i82801gmu_pci __pci_driver = {
152 .vendor = PCI_VENDOR_ID_INTEL,