Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Chris Morgan | 5e5e789 | 2020-02-07 09:40:42 -0600 | [diff] [blame] | 3 | |
| 4 | #include <console/console.h> |
| 5 | #include <device/device.h> |
| 6 | #include <device/pci.h> |
| 7 | #include <device/pciexp.h> |
| 8 | #include <device/pci_ids.h> |
| 9 | #include <assert.h> |
| 10 | |
| 11 | static void pcie_disable(struct device *dev) |
| 12 | { |
| 13 | printk(BIOS_INFO, "%s: Disabling device\n", dev_path(dev)); |
| 14 | dev->enabled = 0; |
| 15 | } |
| 16 | |
| 17 | #if CONFIG(HAVE_ACPI_TABLES) |
| 18 | static const char *pcie_acpi_name(const struct device *dev) |
| 19 | { |
| 20 | assert(dev); |
| 21 | |
| 22 | if (dev->path.type != DEVICE_PATH_PCI) |
| 23 | return NULL; |
| 24 | |
| 25 | assert(dev->bus); |
| 26 | if (dev->bus->secondary == 0) |
| 27 | switch (dev->path.pci.devfn) { |
| 28 | case PCI_DEVFN(1, 0): |
| 29 | return "PEGP"; |
| 30 | case PCI_DEVFN(1, 1): |
| 31 | return "PEG1"; |
| 32 | case PCI_DEVFN(1, 2): |
| 33 | return "PEG2"; |
| 34 | }; |
| 35 | |
| 36 | struct device *const port = dev->bus->dev; |
| 37 | assert(port); |
| 38 | assert(port->bus); |
| 39 | |
| 40 | if (dev->path.pci.devfn == PCI_DEVFN(0, 0) && |
| 41 | port->bus->secondary == 0 && |
| 42 | (port->path.pci.devfn == PCI_DEVFN(1, 0) || |
| 43 | port->path.pci.devfn == PCI_DEVFN(1, 1) || |
| 44 | port->path.pci.devfn == PCI_DEVFN(1, 2))) |
| 45 | return "DEV0"; |
| 46 | |
| 47 | return NULL; |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | static struct pci_operations pci_ops = { |
| 52 | .set_subsystem = pci_dev_set_subsystem, |
| 53 | }; |
| 54 | |
| 55 | static struct device_operations device_ops = { |
| 56 | .read_resources = pci_bus_read_resources, |
| 57 | .set_resources = pci_dev_set_resources, |
| 58 | .enable_resources = pci_bus_enable_resources, |
| 59 | .scan_bus = pciexp_scan_bridge, |
| 60 | .reset_bus = pci_bus_reset, |
| 61 | .disable = pcie_disable, |
| 62 | .init = pci_dev_init, |
| 63 | .ops_pci = &pci_ops, |
| 64 | #if CONFIG(HAVE_ACPI_TABLES) |
| 65 | .acpi_name = pcie_acpi_name, |
| 66 | #endif |
| 67 | }; |
| 68 | |
| 69 | static const unsigned short pci_device_ids[] = { 0x0c01, 0x0c05, 0x0c09, 0x0c0d, 0 }; |
| 70 | |
| 71 | static const struct pci_driver pch_pcie __pci_driver = { |
| 72 | .ops = &device_ops, |
| 73 | .vendor = PCI_VENDOR_ID_INTEL, |
| 74 | .devices = pci_device_ids, |
| 75 | }; |