From beb2af4e3512e2f1c8445417ab2fcc90ef481124 Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Mon, 7 May 2018 14:26:59 -0700 Subject: acpi: Add support for generating ACPI _UPC This commit adds support for writing ACPI _UPC structures that help describe USB ports for the OS. This is a simple structure format which indicates what type of port it is and whether it is connectable. It should be paired with an ACPI _PLD structure to define USB ports for the OS. Change-Id: Ide3768f60f96e9ad7f919ad3fb11d91045dc174a Signed-off-by: Duncan Laurie Reviewed-on: https://review.coreboot.org/26170 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh --- src/arch/x86/acpigen.c | 15 +++++++++++++++ src/arch/x86/include/arch/acpi.h | 24 ++++++++++++++++++++++++ src/arch/x86/include/arch/acpigen.h | 1 + 3 files changed, 40 insertions(+) (limited to 'src') diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c index 10a4e1ee8f..867c809a45 100644 --- a/src/arch/x86/acpigen.c +++ b/src/arch/x86/acpigen.c @@ -1221,6 +1221,21 @@ void acpigen_write_return_string(const char *arg) acpigen_write_string(arg); } +void acpigen_write_upc(enum acpi_upc_type type) +{ + acpigen_write_name("_UPC"); + acpigen_write_package(4); + /* Connectable */ + acpigen_write_byte(type == UPC_TYPE_UNUSED ? 0 : 0xff); + /* Type */ + acpigen_write_byte(type); + /* Reserved0 */ + acpigen_write_zero(); + /* Reserved1 */ + acpigen_write_zero(); + acpigen_pop_len(); +} + void acpigen_write_dsm(const char *uuid, void (**callbacks)(void *), size_t count, void *arg) { diff --git a/src/arch/x86/include/arch/acpi.h b/src/arch/x86/include/arch/acpi.h index 586a0851ad..5480834eb2 100644 --- a/src/arch/x86/include/arch/acpi.h +++ b/src/arch/x86/include/arch/acpi.h @@ -636,6 +636,30 @@ typedef struct acpi_tstate { u32 status; } __packed acpi_tstate_t; +/* Port types for ACPI _UPC object */ +enum acpi_upc_type { + /* These types are defined in ACPI 6.2 section 9.14 */ + UPC_TYPE_A, + UPC_TYPE_MINI_AB, + UPC_TYPE_EXPRESSCARD, + UPC_TYPE_USB3_A, + UPC_TYPE_USB3_B, + UPC_TYPE_USB3_MICRO_B, + UPC_TYPE_USB3_MICRO_AB, + UPC_TYPE_USB3_POWER_B, + UPC_TYPE_C_USB2_ONLY, + UPC_TYPE_C_USB2_SS_SWITCH, + UPC_TYPE_C_USB2_SS, + UPC_TYPE_PROPRIETARY = 0xff, + /* + * The following types are not directly defined in the ACPI + * spec but are used by coreboot to identify a USB device type. + */ + UPC_TYPE_INTERNAL = 0xff, + UPC_TYPE_UNUSED, + UPC_TYPE_HUB +}; + unsigned long fw_cfg_acpi_tables(unsigned long start); /* These are implemented by the target port or north/southbridge. */ diff --git a/src/arch/x86/include/arch/acpigen.h b/src/arch/x86/include/arch/acpigen.h index 216e75fce6..250c0b73c9 100644 --- a/src/arch/x86/include/arch/acpigen.h +++ b/src/arch/x86/include/arch/acpigen.h @@ -255,6 +255,7 @@ void acpigen_write_byte_buffer(uint8_t *arr, size_t size); void acpigen_write_return_byte_buffer(uint8_t *arr, size_t size); void acpigen_write_return_singleton_buffer(uint8_t arg); void acpigen_write_return_byte(uint8_t arg); +void acpigen_write_upc(enum acpi_upc_type type); /* * Generate ACPI AML code for _DSM method. * This function takes as input uuid for the device, set of callbacks and -- cgit v1.2.3