Angel Pons | 6e5aabd | 2020-03-23 23:44:42 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [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 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 16 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 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 | case PCI_DEVFN(6, 0): |
| 34 | return "PEG6"; |
| 35 | }; |
| 36 | |
Elyes HAOUAS | ee8ce8d | 2018-05-22 10:22:30 +0200 | [diff] [blame] | 37 | struct device *const port = dev->bus->dev; |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 38 | assert(port); |
| 39 | assert(port->bus); |
| 40 | |
| 41 | if (dev->path.pci.devfn == PCI_DEVFN(0, 0) && |
| 42 | port->bus->secondary == 0 && |
| 43 | (port->path.pci.devfn == PCI_DEVFN(1, 0) || |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 44 | port->path.pci.devfn == PCI_DEVFN(1, 1) || |
| 45 | port->path.pci.devfn == PCI_DEVFN(1, 2) || |
| 46 | port->path.pci.devfn == PCI_DEVFN(6, 0))) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 47 | return "DEV0"; |
| 48 | |
| 49 | return NULL; |
| 50 | } |
| 51 | #endif |
| 52 | |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 53 | static struct pci_operations pci_ops = { |
Subrata Banik | 15ccbf0 | 2019-03-20 15:09:44 +0530 | [diff] [blame] | 54 | .set_subsystem = pci_dev_set_subsystem, |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | static struct device_operations device_ops = { |
| 58 | .read_resources = pci_bus_read_resources, |
| 59 | .set_resources = pci_dev_set_resources, |
| 60 | .enable_resources = pci_bus_enable_resources, |
| 61 | .scan_bus = pciexp_scan_bridge, |
| 62 | .reset_bus = pci_bus_reset, |
| 63 | .disable = pcie_disable, |
| 64 | .init = pci_dev_init, |
| 65 | .ops_pci = &pci_ops, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 66 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 67 | .acpi_name = pcie_acpi_name, |
| 68 | #endif |
| 69 | }; |
| 70 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 71 | static const unsigned short pci_device_ids[] = { |
| 72 | 0x0101, 0x0105, 0x0109, 0x010d, |
| 73 | 0x0151, 0x0155, 0x0159, 0x015d, |
| 74 | 0, |
| 75 | }; |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 76 | |
| 77 | static const struct pci_driver pch_pcie __pci_driver = { |
| 78 | .ops = &device_ops, |
| 79 | .vendor = PCI_VENDOR_ID_INTEL, |
| 80 | .devices = pci_device_ids, |
| 81 | }; |