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