blob: d0b7fd5820f9c181263c4ff618d407cc8232c7a5 [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
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
10static 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 Wernercd49cce2019-03-05 16:53:33 -080016#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020017static 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 HAOUASee8ce8d2018-05-22 10:22:30 +020037 struct device *const port = dev->bus->dev;
Patrick Rudolph0b643d22017-07-05 20:07:06 +020038 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 Pons7c49cb82020-03-16 23:17:32 +010044 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 Rudolph0b643d22017-07-05 20:07:06 +020047 return "DEV0";
48
49 return NULL;
50}
51#endif
52
Patrick Rudolph0b643d22017-07-05 20:07:06 +020053static struct device_operations device_ops = {
54 .read_resources = pci_bus_read_resources,
55 .set_resources = pci_dev_set_resources,
56 .enable_resources = pci_bus_enable_resources,
57 .scan_bus = pciexp_scan_bridge,
58 .reset_bus = pci_bus_reset,
59 .disable = pcie_disable,
60 .init = pci_dev_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020061 .ops_pci = &pci_dev_ops_pci,
Julius Wernercd49cce2019-03-05 16:53:33 -080062#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020063 .acpi_name = pcie_acpi_name,
64#endif
65};
66
Angel Pons7c49cb82020-03-16 23:17:32 +010067static const unsigned short pci_device_ids[] = {
68 0x0101, 0x0105, 0x0109, 0x010d,
69 0x0151, 0x0155, 0x0159, 0x015d,
70 0,
71};
Patrick Rudolph0b643d22017-07-05 20:07:06 +020072
73static const struct pci_driver pch_pcie __pci_driver = {
74 .ops = &device_ops,
75 .vendor = PCI_VENDOR_ID_INTEL,
76 .devices = pci_device_ids,
77};