blob: 244b0f5a40ac52d3bb006b06dbc113a74151819e [file] [log] [blame]
Angel Pons6e5aabd2020-03-23 23:44:42 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Rudolph0b643d22017-07-05 20:07:06 +02002
Patrick Rudolph0b643d22017-07-05 20:07:06 +02003#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
Patrick Rudolph0b643d22017-07-05 20:07:06 +02009static const char *pcie_acpi_name(const struct device *dev)
10{
11 assert(dev);
12
13 if (dev->path.type != DEVICE_PATH_PCI)
14 return NULL;
15
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020016 assert(dev->upstream);
17 if (dev->upstream->secondary == 0)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020018 switch (dev->path.pci.devfn) {
19 case PCI_DEVFN(1, 0):
20 return "PEGP";
21 case PCI_DEVFN(1, 1):
22 return "PEG1";
23 case PCI_DEVFN(1, 2):
24 return "PEG2";
25 case PCI_DEVFN(6, 0):
26 return "PEG6";
27 };
28
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020029 struct device *const port = dev->upstream->dev;
Patrick Rudolph0b643d22017-07-05 20:07:06 +020030 assert(port);
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020031 assert(port->upstream);
Patrick Rudolph0b643d22017-07-05 20:07:06 +020032
33 if (dev->path.pci.devfn == PCI_DEVFN(0, 0) &&
Arthur Heymans7fcd4d52023-08-24 15:12:19 +020034 port->upstream->secondary == 0 &&
Patrick Rudolph0b643d22017-07-05 20:07:06 +020035 (port->path.pci.devfn == PCI_DEVFN(1, 0) ||
Angel Pons7c49cb82020-03-16 23:17:32 +010036 port->path.pci.devfn == PCI_DEVFN(1, 1) ||
37 port->path.pci.devfn == PCI_DEVFN(1, 2) ||
38 port->path.pci.devfn == PCI_DEVFN(6, 0)))
Patrick Rudolph0b643d22017-07-05 20:07:06 +020039 return "DEV0";
40
41 return NULL;
42}
Patrick Rudolph0b643d22017-07-05 20:07:06 +020043
Patrick Rudolph0b643d22017-07-05 20:07:06 +020044static struct device_operations device_ops = {
45 .read_resources = pci_bus_read_resources,
46 .set_resources = pci_dev_set_resources,
47 .enable_resources = pci_bus_enable_resources,
48 .scan_bus = pciexp_scan_bridge,
49 .reset_bus = pci_bus_reset,
Patrick Rudolph0b643d22017-07-05 20:07:06 +020050 .init = pci_dev_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020051 .ops_pci = &pci_dev_ops_pci,
Patrick Rudolph0b643d22017-07-05 20:07:06 +020052 .acpi_name = pcie_acpi_name,
Patrick Rudolph0b643d22017-07-05 20:07:06 +020053};
54
Angel Pons7c49cb82020-03-16 23:17:32 +010055static const unsigned short pci_device_ids[] = {
56 0x0101, 0x0105, 0x0109, 0x010d,
57 0x0151, 0x0155, 0x0159, 0x015d,
58 0,
59};
Patrick Rudolph0b643d22017-07-05 20:07:06 +020060
61static const struct pci_driver pch_pcie __pci_driver = {
62 .ops = &device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010063 .vendor = PCI_VID_INTEL,
Patrick Rudolph0b643d22017-07-05 20:07:06 +020064 .devices = pci_device_ids,
65};