drivers/intel/pmc_mux/conn: Copy ACPI _PLD property from USB port to mux

Copy ACPI _PLD values from USB ports to corresponding USB muxes so that
the kernel can create symlinks between Type C connectors and
corresponding USB muxes. This symlink will be used to let userspace be
able to modify the USB role without knowing ACPI topology for the
device.

BUG=b:121287022 b:329657774
TEST=emerge-${BOARD} coreboot then check ACPI table on DUT

Change-Id: If27042cc995ef188f8a3e31444e994318ff98803
Signed-off-by: Won Chung <wonchung@google.com>
Tested-by: Emilie Roberts <hadrosaur@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/81089
Reviewed-by: Eric Lai <ericllai@google.com>
Reviewed-by: Emilie Roberts <hadrosaur@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Won Chung
2024-02-14 19:28:59 +00:00
committed by Felix Held
parent 7b2b57b0b8
commit ce04bf8c7f

View File

@ -1,9 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* SPDX-License-Identifier: GPL-2.0-or-later */
#include <acpi/acpi_pld.h>
#include <acpi/acpigen.h> #include <acpi/acpigen.h>
#include <boot/coreboot_tables.h> #include <boot/coreboot_tables.h>
#include <cbmem.h> #include <cbmem.h>
#include <console/console.h> #include <console/console.h>
#include <drivers/usb/acpi/chip.h>
#include <intelblocks/acpi.h> #include <intelblocks/acpi.h>
#include "chip.h" #include "chip.h"
@ -94,12 +96,31 @@ static const char *orientation_to_str(enum type_c_orientation ori)
} }
} }
static void get_pld_from_usb_ports(struct acpi_pld *pld,
struct device *usb2_port, struct device *usb3_port)
{
struct drivers_usb_acpi_config *config = NULL;
if (usb3_port)
config = usb3_port->chip_info;
else if (usb2_port)
config = usb2_port->chip_info;
if (config) {
if (config->use_custom_pld)
*pld = config->custom_pld;
else
acpi_pld_fill_usb(pld, config->type, &config->group);
}
}
static void conn_fill_ssdt(const struct device *dev) static void conn_fill_ssdt(const struct device *dev)
{ {
struct drivers_intel_pmc_mux_conn_config *config = dev->chip_info; struct drivers_intel_pmc_mux_conn_config *config = dev->chip_info;
struct acpi_dp *dsd; struct acpi_dp *dsd;
const char *scope; const char *scope;
const char *name; const char *name;
struct acpi_pld pld = {0};
/* Reference the existing scope and write CONx device */ /* Reference the existing scope and write CONx device */
scope = acpi_device_scope(dev); scope = acpi_device_scope(dev);
@ -131,6 +152,10 @@ static void conn_fill_ssdt(const struct device *dev)
acpi_dp_write(dsd); acpi_dp_write(dsd);
/* Copy _PLD from USB ports */
get_pld_from_usb_ports(&pld, config->usb2_port, config->usb3_port);
acpigen_write_pld(&pld);
acpigen_pop_len(); /* CONx Device */ acpigen_pop_len(); /* CONx Device */
acpigen_pop_len(); /* Scope */ acpigen_pop_len(); /* Scope */