Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame^] | 4 | * Copyright (C) 2008-2009 coresystems GmbH |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 5 | * |
| 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. |
| 10 | * |
| 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. |
| 15 | * |
| 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 |
| 19 | */ |
| 20 | |
| 21 | #include <console/console.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
| 25 | |
| 26 | static void pci_init(struct device *dev) |
| 27 | { |
| 28 | u16 reg16; |
| 29 | |
| 30 | #if 0 |
| 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); |
| 34 | #endif |
| 35 | |
| 36 | /* disable parity error response */ |
| 37 | reg16 = pci_read_config16(dev, 0x3e); |
| 38 | reg16 &= ~(1 << 0); |
| 39 | pci_write_config16(dev, 0x3e, reg16); |
| 40 | |
| 41 | /* Clear errors in status registers */ |
| 42 | reg16 = pci_read_config16(dev, 0x06); |
| 43 | reg16 |= 0xf900; |
| 44 | pci_write_config16(dev, 0x06, reg16); |
| 45 | |
| 46 | reg16 = pci_read_config16(dev, 0x1e); |
| 47 | reg16 |= 0xf900; |
| 48 | pci_write_config16(dev, 0x1e, reg16); |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame^] | 49 | |
| 50 | /* Will this improve throughput of bus masters? */ |
| 51 | pci_write_config8(dev, PCI_MIN_GNT, 0x06); |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static void ich_pci_dev_enable_resources(struct device *dev) |
| 55 | { |
| 56 | const struct pci_operations *ops; |
| 57 | uint16_t command; |
| 58 | |
| 59 | /* Set the subsystem vendor and device id for mainboard devices */ |
| 60 | ops = ops_pci(dev); |
| 61 | if (dev->on_mainboard && ops && ops->set_subsystem) { |
| 62 | printk_debug("%s subsystem <- %02x/%02x\n", |
| 63 | dev_path(dev), |
| 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); |
| 69 | } |
| 70 | |
| 71 | #if 0 |
| 72 | /* If we write to PCI_COMMAND, on some systems |
| 73 | * this will cause the ROM and APICs not being visible |
| 74 | * anymore. |
| 75 | */ |
| 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); |
| 80 | #endif |
| 81 | } |
| 82 | |
| 83 | static void ich_pci_bus_enable_resources(struct device *dev) |
| 84 | { |
| 85 | uint16_t ctrl; |
| 86 | /* enable IO in command register if there is VGA card |
| 87 | * connected with (even it does not claim IO resource) |
| 88 | */ |
| 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); |
| 96 | |
| 97 | /* This is the reason we need our own pci_bus_enable_resources */ |
| 98 | ich_pci_dev_enable_resources(dev); |
| 99 | |
| 100 | enable_childrens_resources(dev); |
| 101 | } |
| 102 | |
| 103 | static void set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 104 | { |
| 105 | #if 0 |
| 106 | /* Currently disabled because it causes a "BAR 9" memory resource |
| 107 | * conflict: |
| 108 | */ |
| 109 | u32 pci_id; |
| 110 | |
| 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 ); |
| 114 | #endif |
| 115 | } |
| 116 | |
| 117 | static struct pci_operations pci_ops = { |
| 118 | .set_subsystem = set_subsystem, |
| 119 | }; |
| 120 | |
| 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, |
| 125 | .init = pci_init, |
| 126 | .scan_bus = pci_scan_bridge, |
| 127 | .ops_pci = &pci_ops, |
| 128 | }; |
| 129 | |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 130 | /* Desktop */ |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 131 | /* 82801BA/CA/DB/EB/ER/FB/FR/FW/FRW/GB/GR/GDH/HB/IB/6300ESB/i3100 */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 132 | static const struct pci_driver i82801g_pci __pci_driver = { |
| 133 | .ops = &device_ops, |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 134 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 135 | .device = 0x244e, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | /* Mobile / Ultra Mobile */ |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 139 | /* 82801BAM/CAM/DBL/DBM/FBM/GBM/GHM/GU/HBM/HEM */ |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 140 | static const struct pci_driver i82801gmu_pci __pci_driver = { |
| 141 | .ops = &device_ops, |
Uwe Hermann | bddc693 | 2008-10-29 13:51:31 +0000 | [diff] [blame] | 142 | .vendor = PCI_VENDOR_ID_INTEL, |
Uwe Hermann | 5d7a1c8 | 2008-10-31 18:41:09 +0000 | [diff] [blame] | 143 | .device = 0x2448, |
Stefan Reinauer | debb11f | 2008-10-29 04:46:52 +0000 | [diff] [blame] | 144 | }; |