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-or-later */
2 
3 #include <acpi/acpigen.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/path.h>
7 #include <string.h>
8 #include "chip.h"
9 
10 #define PCI_HOTPLUG_IN_D3_UUID "6211E2C0-58A3-4AF3-90E1-927A4E0C55A4"
11 #define PCI_EXTERNAL_PORT_UUID "EFCC06CC-73AC-4BC3-BFF0-76143807C389"
12 
13 #if CONFIG(HAVE_ACPI_TABLES)
14 static void usb4_pcie_acpi_fill_ssdt(const struct device *dev)
15 {
17  const struct device *parent;
18  struct acpi_dp *dsd, *pkg;
19  const char *usb4_path;
20  int port_id;
21 
22  /* Get parent PCI device */
23  parent = dev->bus->dev;
24  if (!parent) {
25  printk(BIOS_ERR, "%s: Unable to find parent device\n", __func__);
26  return;
27  }
28 
29  if (!parent->enabled)
30  return;
31 
32  config = config_of(dev);
33  if (!config->usb4_port) {
34  printk(BIOS_ERR, "%s: Unable to find reference to usb4_port\n", __func__);
35  return;
36  }
37 
38  /* Get ACPI path to USB4 device. */
39  usb4_path = acpi_device_path(config->usb4_port);
40  if (!usb4_path) {
41  printk(BIOS_ERR, "%s: Unable to find ACPI path for usb4_port %s\n",
42  __func__, dev_path(config->usb4_port));
43  return;
44  }
45 
46  usb4_path = strdup(usb4_path);
47  port_id = dev->path.generic.id;
48 
50 
51  /* Add pointer to USB4 port controller. */
52  dsd = acpi_dp_new_table("_DSD");
53  acpi_dp_add_reference(dsd, "usb4-host-interface", usb4_path);
54  acpi_dp_add_integer(dsd, "usb4-port-number", port_id);
55 
56  /* Indicate that device supports hotplug in D3. */
58  acpi_dp_add_integer(pkg, "HotPlugSupportInD3", 1);
59  acpi_dp_add_package(dsd, pkg);
60 
61  /* Indicate that port is external. */
63  acpi_dp_add_integer(pkg, "ExternalFacingPort", 1);
64 
65  acpi_dp_add_package(dsd, pkg);
66  acpi_dp_write(dsd);
67 
68  acpigen_pop_len(); /* Scope */
69 
70  printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(parent),
71  config->desc ? : dev->chip_ops->name, dev_path(parent));
72 }
73 #endif
74 
77  .set_resources = noop_set_resources,
78 #if CONFIG(HAVE_ACPI_TABLES)
79  .acpi_fill_ssdt = usb4_pcie_acpi_fill_ssdt,
80 #endif
81 };
82 
83 static void usb4_pcie_acpi_enable(struct device *dev)
84 {
86 }
87 
89  CHIP_NAME("Intel USB4 PCIe Root Port")
90  .enable_dev = usb4_pcie_acpi_enable
91 };
struct acpi_dp * acpi_dp_add_package(struct acpi_dp *dp, struct acpi_dp *package)
Definition: device.c:1036
const char * acpi_device_path(const struct device *dev)
Definition: device.c:144
struct acpi_dp * acpi_dp_add_integer(struct acpi_dp *dp, const char *name, uint64_t value)
Definition: device.c:977
struct acpi_dp * acpi_dp_add_reference(struct acpi_dp *dp, const char *name, const char *reference)
Definition: device.c:1005
void acpi_dp_write(struct acpi_dp *table)
Definition: device.c:898
struct acpi_dp * acpi_dp_new_table(const char *name)
Definition: device.c:930
void acpigen_pop_len(void)
Definition: acpigen.c:37
void acpigen_write_scope(const char *name)
Definition: acpigen.c:326
#define printk(level,...)
Definition: stdlib.h:16
const char * dev_path(const struct device *dev)
Definition: device_util.c:149
#define CHIP_NAME(X)
Definition: device.h:32
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
static DEVTREE_CONST void * config_of(const struct device *dev)
Definition: device.h:382
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
enum board_config config
Definition: memory.c:448
struct chip_operations soc_intel_common_block_usb4_ops
Definition: pcie.c:88
#define PCI_HOTPLUG_IN_D3_UUID
Definition: pcie.c:10
static void usb4_pcie_acpi_enable(struct device *dev)
Definition: pcie.c:83
static struct device_operations usb4_pcie_acpi_dev_ops
Definition: pcie.c:75
#define PCI_EXTERNAL_PORT_UUID
Definition: pcie.c:11
char * strdup(const char *s)
Definition: string.c:7
DEVTREE_CONST struct device * dev
Definition: device.h:78
const char * name
Definition: device.h:29
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct generic_path generic
Definition: path.h:125
Definition: device.h:107
struct chip_operations * chip_ops
Definition: device.h:144
struct device_path path
Definition: device.h:115
struct device_operations * ops
Definition: device.h:143
DEVTREE_CONST struct bus * bus
Definition: device.h:108
unsigned int enabled
Definition: device.h:122
unsigned int id
Definition: path.h:96