Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; version 2 of |
| 8 | * the License. |
| 9 | * |
| 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. |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <device/device.h> |
| 17 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 18 | #include <device/pci_ops.h> |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 19 | #include <device/pci_ids.h> |
| 20 | #include "i82801ix.h" |
| 21 | |
| 22 | static void pci_init(struct device *dev) |
| 23 | { |
| 24 | u16 reg16; |
| 25 | u8 reg8; |
| 26 | |
| 27 | /* This device has no interrupt */ |
| 28 | pci_write_config8(dev, PCI_INTERRUPT_LINE, 0xff); |
| 29 | |
| 30 | /* Master Latency Count must be set to 0x04! */ |
| 31 | reg8 = pci_read_config8(dev, D30F0_SMLT); |
| 32 | reg8 &= 0x07; |
| 33 | reg8 |= (0x04 << 3); |
| 34 | pci_write_config8(dev, D30F0_SMLT, reg8); |
| 35 | |
| 36 | /* Clear errors in status registers */ |
| 37 | reg16 = pci_read_config16(dev, PCI_STATUS); |
| 38 | //reg16 |= 0xf900; |
| 39 | pci_write_config16(dev, PCI_STATUS, reg16); |
| 40 | |
| 41 | reg16 = pci_read_config16(dev, PCI_SEC_STATUS); |
| 42 | // reg16 |= 0xf900; |
| 43 | pci_write_config16(dev, PCI_SEC_STATUS, reg16); |
| 44 | } |
| 45 | |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 46 | static struct pci_operations pci_ops = { |
Kyösti Mälkki | dbd3132 | 2019-03-20 17:55:27 +0200 | [diff] [blame] | 47 | .set_subsystem = pci_dev_set_subsystem, |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | static struct device_operations device_ops = { |
| 51 | .read_resources = pci_bus_read_resources, |
| 52 | .set_resources = pci_dev_set_resources, |
| 53 | .enable_resources = pci_bus_enable_resources, |
| 54 | .init = pci_init, |
| 55 | .scan_bus = pci_scan_bridge, |
| 56 | .reset_bus = pci_bus_reset, |
| 57 | .ops_pci = &pci_ops, |
| 58 | }; |
| 59 | |
| 60 | static const unsigned short pci_device_ids[] = { |
| 61 | 0x244e, /* Desktop */ |
| 62 | 0x2448, /* Mobile */ |
| 63 | 0 |
| 64 | }; |
| 65 | |
| 66 | static const struct pci_driver ich9_pci __pci_driver = { |
| 67 | .ops = &device_ops, |
| 68 | .vendor = PCI_VENDOR_ID_INTEL, |
| 69 | .devices = pci_device_ids, |
| 70 | }; |