Duncan Laurie has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/44915 )
Change subject: drivers/intel/usb4: Add driver for USB4 PCIe root port ......................................................................
drivers/intel/usb4: Add driver for USB4 PCIe root port
This driver will generate the ACPI _DSD for the USB4 PCIe root port properties instead of using static ASL.
It assigns the USB4 port number and marks the port as external and hotplug capable.
Signed-off-by: Duncan Laurie dlaurie@google.com Change-Id: I7086b06346ce63fab6bef4077fb76ae1d30dc1eb --- A src/drivers/intel/usb4/Kconfig A src/drivers/intel/usb4/Makefile.inc A src/drivers/intel/usb4/pcie/Kconfig A src/drivers/intel/usb4/pcie/Makefile.inc A src/drivers/intel/usb4/pcie/chip.h A src/drivers/intel/usb4/pcie/pcie.c 6 files changed, 99 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/15/44915/1
diff --git a/src/drivers/intel/usb4/Kconfig b/src/drivers/intel/usb4/Kconfig new file mode 100644 index 0000000..93501aa --- /dev/null +++ b/src/drivers/intel/usb4/Kconfig @@ -0,0 +1 @@ +source "src/drivers/intel/usb4/*/Kconfig" diff --git a/src/drivers/intel/usb4/Makefile.inc b/src/drivers/intel/usb4/Makefile.inc new file mode 100644 index 0000000..4c02663 --- /dev/null +++ b/src/drivers/intel/usb4/Makefile.inc @@ -0,0 +1 @@ +subdirs-y += ./* diff --git a/src/drivers/intel/usb4/pcie/Kconfig b/src/drivers/intel/usb4/pcie/Kconfig new file mode 100644 index 0000000..6363939 --- /dev/null +++ b/src/drivers/intel/usb4/pcie/Kconfig @@ -0,0 +1,2 @@ +config DRIVERS_INTEL_USB4_PCIE + bool diff --git a/src/drivers/intel/usb4/pcie/Makefile.inc b/src/drivers/intel/usb4/pcie/Makefile.inc new file mode 100644 index 0000000..b5d3e94 --- /dev/null +++ b/src/drivers/intel/usb4/pcie/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_INTEL_USB4_PCIE) += pcie.c diff --git a/src/drivers/intel/usb4/pcie/chip.h b/src/drivers/intel/usb4/pcie/chip.h new file mode 100644 index 0000000..b821d47 --- /dev/null +++ b/src/drivers/intel/usb4/pcie/chip.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#ifndef __DRIVERS_INTEL_USB4_PCIE_H__ +#define __DRIVERS_INTEL_USB4_PCIE_H__ + +struct drivers_intel_usb4_pcie_config { + const char *desc; + + /* USB port number */ + unsigned int port_id; + + /* Pointer to USB4 device that this PCIe root port is routed to. */ + DEVTREE_CONST struct device *usb4_port; +}; + +#endif /* __DRIVERS_INTEL_USB4_PCIE_H__ */ diff --git a/src/drivers/intel/usb4/pcie/pcie.c b/src/drivers/intel/usb4/pcie/pcie.c new file mode 100644 index 0000000..bba803f --- /dev/null +++ b/src/drivers/intel/usb4/pcie/pcie.c @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <acpi/acpigen.h> +#include <console/console.h> +#include <device/device.h> +#include <device/path.h> +#include <device/pci_def.h> +#include <stdlib.h> +#include <string.h> +#include "chip.h" + +#define PCI_HOTPLUG_IN_D3_UUID "6211E2C0-58A3-4AF3-90E1-927A4E0C55A4" +#define PCI_EXTERNAL_PORT_UUID "EFCC06CC-73AC-4BC3-BFF0-76143807C389" + +static void usb4_pcie_fill_ssdt(const struct device *dev) +{ + struct drivers_intel_usb4_pcie_config *config = dev->chip_info; + struct acpi_dp *dsd, *pkg; + const char *usb4_path; + + if (!dev->enabled) + return; + if (!config->usb4_port) + return; + + /* Get ACPI path to USB4 device. */ + usb4_path = acpi_device_path(config->usb4_port); + if (!usb4_path) + return; + usb4_path = strdup(usb4_path); + + acpigen_write_scope(acpi_device_path(dev)); + + /* Add pointer to USB4 port controller. */ + dsd = acpi_dp_new_table("_DSD"); + acpi_dp_add_reference(dsd, "usb4-host-interface", usb4_path); + acpi_dp_add_integer(dsd, "usb4-port-number", config->port_id); + + /* Indicate that device supports hotplug in D3. */ + pkg = acpi_dp_new_table(PCI_HOTPLUG_IN_D3_UUID); + acpi_dp_add_integer(pkg, "HotPlugSupportInD3", 1); + acpi_dp_add_package(dsd, pkg); + + /* Indicate that port is external. */ + pkg = acpi_dp_new_table(PCI_EXTERNAL_PORT_UUID); + acpi_dp_add_integer(pkg, "ExternalFacingPort", 1); + acpi_dp_add_integer(pkg, "UID", config->port_id); + + acpi_dp_add_package(dsd, pkg); + acpi_dp_write(dsd); + + acpigen_pop_len(); /* Scope */ + + printk(BIOS_INFO, "%s: %s at %s\n", acpi_device_path(dev), config->desc, dev_path(dev)); +} + +static struct device_operations usb4_pcie_dev_ops = { + .read_resources = noop_read_resources, + .set_resources = noop_set_resources, + .acpi_fill_ssdt = usb4_pcie_fill_ssdt, +}; + +static void usb4_pcie_enable(struct device *dev) +{ + struct drivers_intel_usb4_pcie_config *config = dev->chip_info; + + dev->ops = &usb4_pcie_dev_ops; + + if (config->desc) + dev->name = config->desc; + else + config->desc = dev->chip_ops->name; +} + +struct chip_operations drivers_intel_usb4_pcie_ops = { + CHIP_NAME("Intel USB4 PCIe Root Port") + .enable_dev = usb4_pcie_enable +};