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 | |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 3 | #include <device/device.h> |
| 4 | #include <device/pci.h> |
| 5 | #include <device/pciexp.h> |
| 6 | #include <device/pci_ids.h> |
| 7 | #include <assert.h> |
| 8 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 9 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 10 | static const char *pcie_acpi_name(const struct device *dev) |
| 11 | { |
| 12 | assert(dev); |
| 13 | |
| 14 | if (dev->path.type != DEVICE_PATH_PCI) |
| 15 | return NULL; |
| 16 | |
| 17 | assert(dev->bus); |
| 18 | if (dev->bus->secondary == 0) |
| 19 | switch (dev->path.pci.devfn) { |
| 20 | case PCI_DEVFN(1, 0): |
| 21 | return "PEGP"; |
| 22 | case PCI_DEVFN(1, 1): |
| 23 | return "PEG1"; |
| 24 | case PCI_DEVFN(1, 2): |
| 25 | return "PEG2"; |
| 26 | case PCI_DEVFN(6, 0): |
| 27 | return "PEG6"; |
| 28 | }; |
| 29 | |
Elyes HAOUAS | ee8ce8d | 2018-05-22 10:22:30 +0200 | [diff] [blame] | 30 | struct device *const port = dev->bus->dev; |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 31 | assert(port); |
| 32 | assert(port->bus); |
| 33 | |
| 34 | if (dev->path.pci.devfn == PCI_DEVFN(0, 0) && |
| 35 | port->bus->secondary == 0 && |
| 36 | (port->path.pci.devfn == PCI_DEVFN(1, 0) || |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 37 | port->path.pci.devfn == PCI_DEVFN(1, 1) || |
| 38 | port->path.pci.devfn == PCI_DEVFN(1, 2) || |
| 39 | port->path.pci.devfn == PCI_DEVFN(6, 0))) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 40 | return "DEV0"; |
| 41 | |
| 42 | return NULL; |
| 43 | } |
| 44 | #endif |
| 45 | |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 46 | static struct device_operations device_ops = { |
| 47 | .read_resources = pci_bus_read_resources, |
| 48 | .set_resources = pci_dev_set_resources, |
| 49 | .enable_resources = pci_bus_enable_resources, |
| 50 | .scan_bus = pciexp_scan_bridge, |
| 51 | .reset_bus = pci_bus_reset, |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 52 | .init = pci_dev_init, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 53 | .ops_pci = &pci_dev_ops_pci, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 54 | #if CONFIG(HAVE_ACPI_TABLES) |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 55 | .acpi_name = pcie_acpi_name, |
| 56 | #endif |
| 57 | }; |
| 58 | |
Angel Pons | 7c49cb8 | 2020-03-16 23:17:32 +0100 | [diff] [blame] | 59 | static const unsigned short pci_device_ids[] = { |
| 60 | 0x0101, 0x0105, 0x0109, 0x010d, |
| 61 | 0x0151, 0x0155, 0x0159, 0x015d, |
| 62 | 0, |
| 63 | }; |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 64 | |
| 65 | static const struct pci_driver pch_pcie __pci_driver = { |
| 66 | .ops = &device_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 67 | .vendor = PCI_VID_INTEL, |
Patrick Rudolph | 0b643d2 | 2017-07-05 20:07:06 +0200 | [diff] [blame] | 68 | .devices = pci_device_ids, |
| 69 | }; |