blob: ec737a2651f4b2218193cc289439be3c99d1e0a2 [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
Julius Wernercd49cce2019-03-05 16:53:33 -08009#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020010static 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 HAOUASee8ce8d2018-05-22 10:22:30 +020030 struct device *const port = dev->bus->dev;
Patrick Rudolph0b643d22017-07-05 20:07:06 +020031 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 Pons7c49cb82020-03-16 23:17:32 +010037 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 Rudolph0b643d22017-07-05 20:07:06 +020040 return "DEV0";
41
42 return NULL;
43}
44#endif
45
Patrick Rudolph0b643d22017-07-05 20:07:06 +020046static 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 Rudolph0b643d22017-07-05 20:07:06 +020052 .init = pci_dev_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020053 .ops_pci = &pci_dev_ops_pci,
Julius Wernercd49cce2019-03-05 16:53:33 -080054#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020055 .acpi_name = pcie_acpi_name,
56#endif
57};
58
Angel Pons7c49cb82020-03-16 23:17:32 +010059static const unsigned short pci_device_ids[] = {
60 0x0101, 0x0105, 0x0109, 0x010d,
61 0x0151, 0x0155, 0x0159, 0x015d,
62 0,
63};
Patrick Rudolph0b643d22017-07-05 20:07:06 +020064
65static const struct pci_driver pch_pcie __pci_driver = {
66 .ops = &device_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010067 .vendor = PCI_VID_INTEL,
Patrick Rudolph0b643d22017-07-05 20:07:06 +020068 .devices = pci_device_ids,
69};