coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pcie.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #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 
9 #if CONFIG(HAVE_ACPI_TABLES)
10 static 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 
30  struct device *const port = dev->bus->dev;
31  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) ||
37  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)))
40  return "DEV0";
41 
42  return NULL;
43 }
44 #endif
45 
46 static struct device_operations device_ops = {
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,
52  .init = pci_dev_init,
53  .ops_pci = &pci_dev_ops_pci,
54 #if CONFIG(HAVE_ACPI_TABLES)
55  .acpi_name = pcie_acpi_name,
56 #endif
57 };
58 
59 static const unsigned short pci_device_ids[] = {
60  0x0101, 0x0105, 0x0109, 0x010d,
61  0x0151, 0x0155, 0x0159, 0x015d,
62  0,
63 };
64 
65 static const struct pci_driver pch_pcie __pci_driver = {
66  .ops = &device_ops,
67  .vendor = PCI_VID_INTEL,
68  .devices = pci_device_ids,
69 };
#define assert(statement)
Definition: assert.h:74
port
Definition: i915.h:29
static struct device_operations device_ops
Definition: pcie.c:46
static const unsigned short pci_device_ids[]
Definition: pcie.c:59
static const struct pci_driver pch_pcie __pci_driver
Definition: pcie.c:65
@ DEVICE_PATH_PCI
Definition: path.h:9
#define PCI_DEVFN(slot, func)
Definition: pci_def.h:548
void pci_dev_init(struct device *dev)
Default handler: only runs the relevant PCI BIOS.
Definition: pci_device.c:873
void pci_bus_enable_resources(struct device *dev)
Definition: pci_device.c:758
void pci_bus_read_resources(struct device *dev)
Definition: pci_device.c:540
void pci_bus_reset(struct bus *bus)
Definition: pci_device.c:777
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
#define PCI_VID_INTEL
Definition: pci_ids.h:2157
void pciexp_scan_bridge(struct device *dev)
#define NULL
Definition: stddef.h:19
DEVTREE_CONST struct device * dev
Definition: device.h:78
uint16_t secondary
Definition: device.h:84
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct pci_path pci
Definition: path.h:116
enum device_path_type type
Definition: path.h:114
Definition: device.h:107
struct device_path path
Definition: device.h:115
DEVTREE_CONST struct bus * bus
Definition: device.h:108
unsigned int devfn
Definition: path.h:54