blob: 0c3912c0bf96e9d3578a3ea87fc1896b9ef18ac3 [file] [log] [blame]
Angel Pons6e5aabd2020-03-23 23:44:42 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Patrick Rudolph0b643d22017-07-05 20:07:06 +02003
4#include <console/console.h>
5#include <device/device.h>
6#include <device/pci.h>
7#include <device/pciexp.h>
8#include <device/pci_ids.h>
9#include <assert.h>
10
11static void pcie_disable(struct device *dev)
12{
13 printk(BIOS_INFO, "%s: Disabling device\n", dev_path(dev));
14 dev->enabled = 0;
15}
16
Julius Wernercd49cce2019-03-05 16:53:33 -080017#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020018static const char *pcie_acpi_name(const struct device *dev)
19{
20 assert(dev);
21
22 if (dev->path.type != DEVICE_PATH_PCI)
23 return NULL;
24
25 assert(dev->bus);
26 if (dev->bus->secondary == 0)
27 switch (dev->path.pci.devfn) {
28 case PCI_DEVFN(1, 0):
29 return "PEGP";
30 case PCI_DEVFN(1, 1):
31 return "PEG1";
32 case PCI_DEVFN(1, 2):
33 return "PEG2";
34 case PCI_DEVFN(6, 0):
35 return "PEG6";
36 };
37
Elyes HAOUASee8ce8d2018-05-22 10:22:30 +020038 struct device *const port = dev->bus->dev;
Patrick Rudolph0b643d22017-07-05 20:07:06 +020039 assert(port);
40 assert(port->bus);
41
42 if (dev->path.pci.devfn == PCI_DEVFN(0, 0) &&
43 port->bus->secondary == 0 &&
44 (port->path.pci.devfn == PCI_DEVFN(1, 0) ||
Angel Pons7c49cb82020-03-16 23:17:32 +010045 port->path.pci.devfn == PCI_DEVFN(1, 1) ||
46 port->path.pci.devfn == PCI_DEVFN(1, 2) ||
47 port->path.pci.devfn == PCI_DEVFN(6, 0)))
Patrick Rudolph0b643d22017-07-05 20:07:06 +020048 return "DEV0";
49
50 return NULL;
51}
52#endif
53
Patrick Rudolph0b643d22017-07-05 20:07:06 +020054static struct pci_operations pci_ops = {
Subrata Banik15ccbf02019-03-20 15:09:44 +053055 .set_subsystem = pci_dev_set_subsystem,
Patrick Rudolph0b643d22017-07-05 20:07:06 +020056};
57
58static struct device_operations device_ops = {
59 .read_resources = pci_bus_read_resources,
60 .set_resources = pci_dev_set_resources,
61 .enable_resources = pci_bus_enable_resources,
62 .scan_bus = pciexp_scan_bridge,
63 .reset_bus = pci_bus_reset,
64 .disable = pcie_disable,
65 .init = pci_dev_init,
66 .ops_pci = &pci_ops,
Julius Wernercd49cce2019-03-05 16:53:33 -080067#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020068 .acpi_name = pcie_acpi_name,
69#endif
70};
71
Angel Pons7c49cb82020-03-16 23:17:32 +010072static const unsigned short pci_device_ids[] = {
73 0x0101, 0x0105, 0x0109, 0x010d,
74 0x0151, 0x0155, 0x0159, 0x015d,
75 0,
76};
Patrick Rudolph0b643d22017-07-05 20:07:06 +020077
78static const struct pci_driver pch_pcie __pci_driver = {
79 .ops = &device_ops,
80 .vendor = PCI_VENDOR_ID_INTEL,
81 .devices = pci_device_ids,
82};