blob: 05f05ecc1d21c0cfe0d1c2bbc5b456d2459e692d [file] [log] [blame]
Patrick Rudolph0b643d22017-07-05 20:07:06 +02001/*
2 * This file is part of the coreboot project.
3 *
Patrick Rudolph0b643d22017-07-05 20:07:06 +02004 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; version 2 of
8 * the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <console/console.h>
17#include <device/device.h>
18#include <device/pci.h>
19#include <device/pciexp.h>
20#include <device/pci_ids.h>
21#include <assert.h>
22
23static void pcie_disable(struct device *dev)
24{
25 printk(BIOS_INFO, "%s: Disabling device\n", dev_path(dev));
26 dev->enabled = 0;
27}
28
Julius Wernercd49cce2019-03-05 16:53:33 -080029#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020030static const char *pcie_acpi_name(const struct device *dev)
31{
32 assert(dev);
33
34 if (dev->path.type != DEVICE_PATH_PCI)
35 return NULL;
36
37 assert(dev->bus);
38 if (dev->bus->secondary == 0)
39 switch (dev->path.pci.devfn) {
40 case PCI_DEVFN(1, 0):
41 return "PEGP";
42 case PCI_DEVFN(1, 1):
43 return "PEG1";
44 case PCI_DEVFN(1, 2):
45 return "PEG2";
46 case PCI_DEVFN(6, 0):
47 return "PEG6";
48 };
49
Elyes HAOUASee8ce8d2018-05-22 10:22:30 +020050 struct device *const port = dev->bus->dev;
Patrick Rudolph0b643d22017-07-05 20:07:06 +020051 assert(port);
52 assert(port->bus);
53
54 if (dev->path.pci.devfn == PCI_DEVFN(0, 0) &&
55 port->bus->secondary == 0 &&
56 (port->path.pci.devfn == PCI_DEVFN(1, 0) ||
Angel Pons7c49cb82020-03-16 23:17:32 +010057 port->path.pci.devfn == PCI_DEVFN(1, 1) ||
58 port->path.pci.devfn == PCI_DEVFN(1, 2) ||
59 port->path.pci.devfn == PCI_DEVFN(6, 0)))
Patrick Rudolph0b643d22017-07-05 20:07:06 +020060 return "DEV0";
61
62 return NULL;
63}
64#endif
65
Patrick Rudolph0b643d22017-07-05 20:07:06 +020066static struct pci_operations pci_ops = {
Subrata Banik15ccbf02019-03-20 15:09:44 +053067 .set_subsystem = pci_dev_set_subsystem,
Patrick Rudolph0b643d22017-07-05 20:07:06 +020068};
69
70static struct device_operations device_ops = {
71 .read_resources = pci_bus_read_resources,
72 .set_resources = pci_dev_set_resources,
73 .enable_resources = pci_bus_enable_resources,
74 .scan_bus = pciexp_scan_bridge,
75 .reset_bus = pci_bus_reset,
76 .disable = pcie_disable,
77 .init = pci_dev_init,
78 .ops_pci = &pci_ops,
Julius Wernercd49cce2019-03-05 16:53:33 -080079#if CONFIG(HAVE_ACPI_TABLES)
Patrick Rudolph0b643d22017-07-05 20:07:06 +020080 .acpi_name = pcie_acpi_name,
81#endif
82};
83
Angel Pons7c49cb82020-03-16 23:17:32 +010084static const unsigned short pci_device_ids[] = {
85 0x0101, 0x0105, 0x0109, 0x010d,
86 0x0151, 0x0155, 0x0159, 0x015d,
87 0,
88};
Patrick Rudolph0b643d22017-07-05 20:07:06 +020089
90static const struct pci_driver pch_pcie __pci_driver = {
91 .ops = &device_ops,
92 .vendor = PCI_VENDOR_ID_INTEL,
93 .devices = pci_device_ids,
94};