blob: d9e77a787acff2589355451a49c354b47085d66a [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Chris Morgan5e5e7892020-02-07 09:40:42 -06002
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
16#if CONFIG(HAVE_ACPI_TABLES)
17static 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 };
34
35 struct device *const port = dev->bus->dev;
36 assert(port);
37 assert(port->bus);
38
39 if (dev->path.pci.devfn == PCI_DEVFN(0, 0) &&
40 port->bus->secondary == 0 &&
41 (port->path.pci.devfn == PCI_DEVFN(1, 0) ||
42 port->path.pci.devfn == PCI_DEVFN(1, 1) ||
43 port->path.pci.devfn == PCI_DEVFN(1, 2)))
44 return "DEV0";
45
46 return NULL;
47}
48#endif
49
Chris Morgan5e5e7892020-02-07 09:40:42 -060050static struct device_operations device_ops = {
51 .read_resources = pci_bus_read_resources,
52 .set_resources = pci_dev_set_resources,
53 .enable_resources = pci_bus_enable_resources,
54 .scan_bus = pciexp_scan_bridge,
55 .reset_bus = pci_bus_reset,
56 .disable = pcie_disable,
57 .init = pci_dev_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020058 .ops_pci = &pci_dev_ops_pci,
Chris Morgan5e5e7892020-02-07 09:40:42 -060059#if CONFIG(HAVE_ACPI_TABLES)
60 .acpi_name = pcie_acpi_name,
61#endif
62};
63
Iru Cai12a13e12020-05-22 22:57:03 +080064static const unsigned short pci_device_ids[] = {
65 0x0c01, 0x0c05, 0x0c09, 0x0c0d,
66 0x0d01, 0x0d05, 0x0d09, /* Crystal Well */
67 0 };
Chris Morgan5e5e7892020-02-07 09:40:42 -060068
69static const struct pci_driver pch_pcie __pci_driver = {
70 .ops = &device_ops,
71 .vendor = PCI_VENDOR_ID_INTEL,
72 .devices = pci_device_ids,
73};